STM32F439xx HAL User Manual
stm32f4xx_hal_sd.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4xx_hal_sd.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of SD HAL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
00010   *
00011   * Redistribution and use in source and binary forms, with or without modification,
00012   * are permitted provided that the following conditions are met:
00013   *   1. Redistributions of source code must retain the above copyright notice,
00014   *      this list of conditions and the following disclaimer.
00015   *   2. Redistributions in binary form must reproduce the above copyright notice,
00016   *      this list of conditions and the following disclaimer in the documentation
00017   *      and/or other materials provided with the distribution.
00018   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00019   *      may be used to endorse or promote products derived from this software
00020   *      without specific prior written permission.
00021   *
00022   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00023   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00025   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00026   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00028   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00030   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00031   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032   *
00033   ******************************************************************************
00034   */ 
00035 
00036 /* Define to prevent recursive inclusion -------------------------------------*/
00037 #ifndef __STM32F4xx_HAL_SD_H
00038 #define __STM32F4xx_HAL_SD_H
00039 
00040 #ifdef __cplusplus
00041  extern "C" {
00042 #endif
00043 
00044 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
00045     defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
00046     defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || \
00047     defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
00048     defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
00049 
00050 /* Includes ------------------------------------------------------------------*/
00051 #include "stm32f4xx_ll_sdmmc.h"
00052 
00053 /** @addtogroup STM32F4xx_HAL_Driver
00054   * @{
00055   */
00056 
00057 /** @defgroup SD SD
00058   * @brief SD HAL module driver
00059   * @{
00060   */ 
00061 
00062 /* Exported types ------------------------------------------------------------*/ 
00063 /** @defgroup SD_Exported_Types SD Exported Types
00064   * @{
00065   */
00066 
00067 /** @defgroup SD_Exported_Types_Group1 SD State enumeration structure
00068   * @{
00069   */   
00070 typedef enum
00071 {
00072   HAL_SD_STATE_RESET                  = 0x00000000U,  /*!< SD not yet initialized or disabled  */
00073   HAL_SD_STATE_READY                  = 0x00000001U,  /*!< SD initialized and ready for use    */
00074   HAL_SD_STATE_TIMEOUT                = 0x00000002U,  /*!< SD Timeout state                    */
00075   HAL_SD_STATE_BUSY                   = 0x00000003U,  /*!< SD process ongoing                  */
00076   HAL_SD_STATE_PROGRAMMING            = 0x00000004U,  /*!< SD Programming State                */
00077   HAL_SD_STATE_RECEIVING              = 0x00000005U,  /*!< SD Receinving State                 */
00078   HAL_SD_STATE_TRANSFER               = 0x00000006U,  /*!< SD Transfert State                  */
00079   HAL_SD_STATE_ERROR                  = 0x0000000FU   /*!< SD is in error state                */
00080 }HAL_SD_StateTypeDef;
00081 /** 
00082   * @}
00083   */
00084 
00085 /** @defgroup SD_Exported_Types_Group2 SD Card State enumeration structure
00086   * @{
00087   */   
00088 typedef enum
00089 {
00090   HAL_SD_CARD_READY                  = 0x00000001U,  /*!< Card state is ready                     */
00091   HAL_SD_CARD_IDENTIFICATION         = 0x00000002U,  /*!< Card is in identification state         */
00092   HAL_SD_CARD_STANDBY                = 0x00000003U,  /*!< Card is in standby state                */
00093   HAL_SD_CARD_TRANSFER               = 0x00000004U,  /*!< Card is in transfer state               */  
00094   HAL_SD_CARD_SENDING                = 0x00000005U,  /*!< Card is sending an operation            */
00095   HAL_SD_CARD_RECEIVING              = 0x00000006U,  /*!< Card is receiving operation information */
00096   HAL_SD_CARD_PROGRAMMING            = 0x00000007U,  /*!< Card is in programming state            */
00097   HAL_SD_CARD_DISCONNECTED           = 0x00000008U,  /*!< Card is disconnected                    */
00098   HAL_SD_CARD_ERROR                  = 0x000000FFU   /*!< Card response Error                     */
00099 }HAL_SD_CardStateTypeDef;
00100 /** 
00101   * @}
00102   */
00103 
00104 /** @defgroup SD_Exported_Types_Group3 SD Handle Structure definition   
00105   * @{
00106   */
00107 #define SD_InitTypeDef      SDIO_InitTypeDef 
00108 #define SD_TypeDef          SDIO_TypeDef
00109 
00110 /** 
00111   * @brief  SD Card Information Structure definition
00112   */ 
00113 typedef struct
00114 {
00115   uint32_t CardType;                     /*!< Specifies the card Type                         */
00116   
00117   uint32_t CardVersion;                  /*!< Specifies the card version                      */
00118 
00119   uint32_t Class;                        /*!< Specifies the class of the card class           */
00120 
00121   uint32_t RelCardAdd;                   /*!< Specifies the Relative Card Address             */
00122   
00123   uint32_t BlockNbr;                     /*!< Specifies the Card Capacity in blocks           */
00124 
00125   uint32_t BlockSize;                    /*!< Specifies one block size in bytes               */
00126   
00127   uint32_t LogBlockNbr;                  /*!< Specifies the Card logical Capacity in blocks   */
00128 
00129   uint32_t LogBlockSize;                 /*!< Specifies logical block size in bytes           */
00130 
00131 }HAL_SD_CardInfoTypeDef;
00132 
00133 /** 
00134   * @brief  SD handle Structure definition
00135   */ 
00136 typedef struct
00137 {
00138   SD_TypeDef                   *Instance;        /*!< SD registers base address           */
00139   
00140   SD_InitTypeDef               Init;             /*!< SD required parameters              */
00141   
00142   HAL_LockTypeDef              Lock;             /*!< SD locking object                   */
00143   
00144   uint32_t                     *pTxBuffPtr;      /*!< Pointer to SD Tx transfer Buffer    */
00145 
00146   uint32_t                     TxXferSize;       /*!< SD Tx Transfer size                 */
00147 
00148   uint32_t                     *pRxBuffPtr;      /*!< Pointer to SD Rx transfer Buffer    */
00149 
00150   uint32_t                     RxXferSize;       /*!< SD Rx Transfer size                 */
00151   
00152   __IO uint32_t                Context;          /*!< SD transfer context                 */
00153  
00154   __IO HAL_SD_StateTypeDef     State;            /*!< SD card State                       */
00155   
00156   __IO uint32_t                ErrorCode;        /*!< SD Card Error codes                 */  
00157  
00158   DMA_HandleTypeDef            *hdmarx;          /*!< SD Rx DMA handle parameters         */
00159   
00160   DMA_HandleTypeDef            *hdmatx;          /*!< SD Tx DMA handle parameters         */
00161   
00162   HAL_SD_CardInfoTypeDef       SdCard;           /*!< SD Card information                 */
00163   
00164   uint32_t                     CSD[4];           /*!< SD card specific data table         */
00165   
00166   uint32_t                     CID[4];           /*!< SD card identification number table */
00167   
00168 }SD_HandleTypeDef;
00169 
00170 /** 
00171   * @}
00172   */
00173 
00174 /** @defgroup SD_Exported_Types_Group4 Card Specific Data: CSD Register 
00175   * @{
00176   */
00177 typedef struct
00178 {
00179   __IO uint8_t  CSDStruct;            /*!< CSD structure                         */
00180   __IO uint8_t  SysSpecVersion;       /*!< System specification version          */
00181   __IO uint8_t  Reserved1;            /*!< Reserved                              */
00182   __IO uint8_t  TAAC;                 /*!< Data read access time 1               */
00183   __IO uint8_t  NSAC;                 /*!< Data read access time 2 in CLK cycles */
00184   __IO uint8_t  MaxBusClkFrec;        /*!< Max. bus clock frequency              */
00185   __IO uint16_t CardComdClasses;      /*!< Card command classes                  */
00186   __IO uint8_t  RdBlockLen;           /*!< Max. read data block length           */
00187   __IO uint8_t  PartBlockRead;        /*!< Partial blocks for read allowed       */
00188   __IO uint8_t  WrBlockMisalign;      /*!< Write block misalignment              */
00189   __IO uint8_t  RdBlockMisalign;      /*!< Read block misalignment               */
00190   __IO uint8_t  DSRImpl;              /*!< DSR implemented                       */
00191   __IO uint8_t  Reserved2;            /*!< Reserved                              */
00192   __IO uint32_t DeviceSize;           /*!< Device Size                           */
00193   __IO uint8_t  MaxRdCurrentVDDMin;   /*!< Max. read current @ VDD min           */
00194   __IO uint8_t  MaxRdCurrentVDDMax;   /*!< Max. read current @ VDD max           */
00195   __IO uint8_t  MaxWrCurrentVDDMin;   /*!< Max. write current @ VDD min          */
00196   __IO uint8_t  MaxWrCurrentVDDMax;   /*!< Max. write current @ VDD max          */
00197   __IO uint8_t  DeviceSizeMul;        /*!< Device size multiplier                */
00198   __IO uint8_t  EraseGrSize;          /*!< Erase group size                      */
00199   __IO uint8_t  EraseGrMul;           /*!< Erase group size multiplier           */
00200   __IO uint8_t  WrProtectGrSize;      /*!< Write protect group size              */
00201   __IO uint8_t  WrProtectGrEnable;    /*!< Write protect group enable            */
00202   __IO uint8_t  ManDeflECC;           /*!< Manufacturer default ECC              */
00203   __IO uint8_t  WrSpeedFact;          /*!< Write speed factor                    */
00204   __IO uint8_t  MaxWrBlockLen;        /*!< Max. write data block length          */
00205   __IO uint8_t  WriteBlockPaPartial;  /*!< Partial blocks for write allowed      */
00206   __IO uint8_t  Reserved3;            /*!< Reserved                              */
00207   __IO uint8_t  ContentProtectAppli;  /*!< Content protection application        */
00208   __IO uint8_t  FileFormatGrouop;     /*!< File format group                     */
00209   __IO uint8_t  CopyFlag;             /*!< Copy flag (OTP)                       */
00210   __IO uint8_t  PermWrProtect;        /*!< Permanent write protection            */
00211   __IO uint8_t  TempWrProtect;        /*!< Temporary write protection            */
00212   __IO uint8_t  FileFormat;           /*!< File format                           */
00213   __IO uint8_t  ECC;                  /*!< ECC code                              */
00214   __IO uint8_t  CSD_CRC;              /*!< CSD CRC                               */
00215   __IO uint8_t  Reserved4;            /*!< Always 1                              */
00216   
00217 }HAL_SD_CardCSDTypeDef;
00218 /** 
00219   * @}
00220   */
00221 
00222 /** @defgroup SD_Exported_Types_Group5 Card Identification Data: CID Register
00223   * @{
00224   */
00225 typedef struct
00226 {
00227   __IO uint8_t  ManufacturerID;  /*!< Manufacturer ID       */
00228   __IO uint16_t OEM_AppliID;     /*!< OEM/Application ID    */
00229   __IO uint32_t ProdName1;       /*!< Product Name part1    */
00230   __IO uint8_t  ProdName2;       /*!< Product Name part2    */
00231   __IO uint8_t  ProdRev;         /*!< Product Revision      */
00232   __IO uint32_t ProdSN;          /*!< Product Serial Number */
00233   __IO uint8_t  Reserved1;       /*!< Reserved1             */
00234   __IO uint16_t ManufactDate;    /*!< Manufacturing Date    */
00235   __IO uint8_t  CID_CRC;         /*!< CID CRC               */
00236   __IO uint8_t  Reserved2;       /*!< Always 1              */
00237 
00238 }HAL_SD_CardCIDTypeDef;
00239 /** 
00240   * @}
00241   */
00242 
00243 /** @defgroup SD_Exported_Types_Group6 SD Card Status returned by ACMD13 
00244   * @{
00245   */
00246 typedef struct
00247 {
00248   __IO uint8_t  DataBusWidth;           /*!< Shows the currently defined data bus width                 */
00249   __IO uint8_t  SecuredMode;            /*!< Card is in secured mode of operation                       */
00250   __IO uint16_t CardType;               /*!< Carries information about card type                        */
00251   __IO uint32_t ProtectedAreaSize;      /*!< Carries information about the capacity of protected area   */
00252   __IO uint8_t  SpeedClass;             /*!< Carries information about the speed class of the card      */
00253   __IO uint8_t  PerformanceMove;        /*!< Carries information about the card's performance move      */
00254   __IO uint8_t  AllocationUnitSize;     /*!< Carries information about the card's allocation unit size  */
00255   __IO uint16_t EraseSize;              /*!< Determines the number of AUs to be erased in one operation */
00256   __IO uint8_t  EraseTimeout;           /*!< Determines the timeout for any number of AU erase          */
00257   __IO uint8_t  EraseOffset;            /*!< Carries information about the erase offset                 */
00258 
00259 }HAL_SD_CardStatusTypeDef;
00260 /** 
00261   * @}
00262   */
00263 
00264 /** 
00265   * @}
00266   */
00267 
00268 /* Exported constants --------------------------------------------------------*/
00269 /** @defgroup SD_Exported_Constants Exported Constants
00270   * @{
00271   */
00272 
00273 #define BLOCKSIZE   512U /*!< Block size is 512 bytes */
00274 
00275 /** @defgroup SD_Exported_Constansts_Group1 SD Error status enumeration Structure definition 
00276   * @{
00277   */  
00278 #define HAL_SD_ERROR_NONE                     SDMMC_ERROR_NONE                    /*!< No error                                                      */
00279 #define HAL_SD_ERROR_CMD_CRC_FAIL             SDMMC_ERROR_CMD_CRC_FAIL            /*!< Command response received (but CRC check failed)              */
00280 #define HAL_SD_ERROR_DATA_CRC_FAIL            SDMMC_ERROR_DATA_CRC_FAIL           /*!< Data block sent/received (CRC check failed)                   */
00281 #define HAL_SD_ERROR_CMD_RSP_TIMEOUT          SDMMC_ERROR_CMD_RSP_TIMEOUT         /*!< Command response timeout                                      */
00282 #define HAL_SD_ERROR_DATA_TIMEOUT             SDMMC_ERROR_DATA_TIMEOUT            /*!< Data timeout                                                  */
00283 #define HAL_SD_ERROR_TX_UNDERRUN              SDMMC_ERROR_TX_UNDERRUN             /*!< Transmit FIFO underrun                                        */
00284 #define HAL_SD_ERROR_RX_OVERRUN               SDMMC_ERROR_RX_OVERRUN              /*!< Receive FIFO overrun                                          */
00285 #define HAL_SD_ERROR_ADDR_MISALIGNED          SDMMC_ERROR_ADDR_MISALIGNED         /*!< Misaligned address                                            */
00286 #define HAL_SD_ERROR_BLOCK_LEN_ERR            SDMMC_ERROR_BLOCK_LEN_ERR           /*!< Transferred block length is not allowed for the card or the 
00287                                                                                        number of transferred bytes does not match the block length   */
00288 #define HAL_SD_ERROR_ERASE_SEQ_ERR            SDMMC_ERROR_ERASE_SEQ_ERR           /*!< An error in the sequence of erase command occurs              */
00289 #define HAL_SD_ERROR_BAD_ERASE_PARAM          SDMMC_ERROR_BAD_ERASE_PARAM         /*!< An invalid selection for erase groups                         */
00290 #define HAL_SD_ERROR_WRITE_PROT_VIOLATION     SDMMC_ERROR_WRITE_PROT_VIOLATION    /*!< Attempt to program a write protect block                      */
00291 #define HAL_SD_ERROR_LOCK_UNLOCK_FAILED       SDMMC_ERROR_LOCK_UNLOCK_FAILED      /*!< Sequence or password error has been detected in unlock 
00292                                                                                        command or if there was an attempt to access a locked card    */
00293 #define HAL_SD_ERROR_COM_CRC_FAILED           SDMMC_ERROR_COM_CRC_FAILED          /*!< CRC check of the previous command failed                      */
00294 #define HAL_SD_ERROR_ILLEGAL_CMD              SDMMC_ERROR_ILLEGAL_CMD             /*!< Command is not legal for the card state                       */
00295 #define HAL_SD_ERROR_CARD_ECC_FAILED          SDMMC_ERROR_CARD_ECC_FAILED         /*!< Card internal ECC was applied but failed to correct the data  */
00296 #define HAL_SD_ERROR_CC_ERR                   SDMMC_ERROR_CC_ERR                  /*!< Internal card controller error                                */
00297 #define HAL_SD_ERROR_GENERAL_UNKNOWN_ERR      SDMMC_ERROR_GENERAL_UNKNOWN_ERR     /*!< General or unknown error                                      */
00298 #define HAL_SD_ERROR_STREAM_READ_UNDERRUN     SDMMC_ERROR_STREAM_READ_UNDERRUN    /*!< The card could not sustain data reading in stream rmode       */
00299 #define HAL_SD_ERROR_STREAM_WRITE_OVERRUN     SDMMC_ERROR_STREAM_WRITE_OVERRUN    /*!< The card could not sustain data programming in stream mode    */
00300 #define HAL_SD_ERROR_CID_CSD_OVERWRITE        SDMMC_ERROR_CID_CSD_OVERWRITE       /*!< CID/CSD overwrite error                                       */
00301 #define HAL_SD_ERROR_WP_ERASE_SKIP            SDMMC_ERROR_WP_ERASE_SKIP           /*!< Only partial address space was erased                         */
00302 #define HAL_SD_ERROR_CARD_ECC_DISABLED        SDMMC_ERROR_CARD_ECC_DISABLED       /*!< Command has been executed without using internal ECC          */
00303 #define HAL_SD_ERROR_ERASE_RESET              SDMMC_ERROR_ERASE_RESET             /*!< Erase sequence was cleared before executing because an out 
00304                                                                                        of erase sequence command was received                        */
00305 #define HAL_SD_ERROR_AKE_SEQ_ERR              SDMMC_ERROR_AKE_SEQ_ERR             /*!< Error in sequence of authentication                           */
00306 #define HAL_SD_ERROR_INVALID_VOLTRANGE        SDMMC_ERROR_INVALID_VOLTRANGE       /*!< Error in case of invalid voltage range                        */        
00307 #define HAL_SD_ERROR_ADDR_OUT_OF_RANGE        SDMMC_ERROR_ADDR_OUT_OF_RANGE       /*!< Error when addressed block is out of range                    */        
00308 #define HAL_SD_ERROR_REQUEST_NOT_APPLICABLE   SDMMC_ERROR_REQUEST_NOT_APPLICABLE  /*!< Error when command request is not applicable                  */  
00309 #define HAL_SD_ERROR_PARAM                    SDMMC_ERROR_INVALID_PARAMETER       /*!< the used parameter is not valid                               */  
00310 #define HAL_SD_ERROR_UNSUPPORTED_FEATURE      SDMMC_ERROR_UNSUPPORTED_FEATURE     /*!< Error when feature is not insupported                         */
00311 #define HAL_SD_ERROR_BUSY                     SDMMC_ERROR_BUSY                    /*!< Error when transfer process is busy                           */ 
00312 #define HAL_SD_ERROR_DMA                      SDMMC_ERROR_DMA                     /*!< Error while DMA transfer                                      */
00313 #define HAL_SD_ERROR_TIMEOUT                  SDMMC_ERROR_TIMEOUT                 /*!< Timeout error                                                 */
00314                                                 
00315 /** 
00316   * @}
00317   */
00318  
00319 /** @defgroup SD_Exported_Constansts_Group2 SD context enumeration
00320   * @{
00321   */ 
00322 #define   SD_CONTEXT_NONE                 0x00000000U  /*!< None                             */
00323 #define   SD_CONTEXT_READ_SINGLE_BLOCK    0x00000001U  /*!< Read single block operation      */
00324 #define   SD_CONTEXT_READ_MULTIPLE_BLOCK  0x00000002U  /*!< Read multiple blocks operation   */
00325 #define   SD_CONTEXT_WRITE_SINGLE_BLOCK   0x00000010U  /*!< Write single block operation     */
00326 #define   SD_CONTEXT_WRITE_MULTIPLE_BLOCK 0x00000020U  /*!< Write multiple blocks operation  */
00327 #define   SD_CONTEXT_IT                   0x00000008U  /*!< Process in Interrupt mode        */
00328 #define   SD_CONTEXT_DMA                  0x00000080U  /*!< Process in DMA mode              */  
00329 
00330 /**
00331   * @}
00332   */
00333 
00334 /** @defgroup SD_Exported_Constansts_Group3 SD Supported Memory Cards
00335   * @{
00336   */
00337 #define CARD_SDSC                  0x00000000U
00338 #define CARD_SDHC_SDXC             0x00000001U
00339 #define CARD_SECURED               0x00000003U
00340     
00341 /**
00342   * @}
00343   */
00344 
00345 /** @defgroup SD_Exported_Constansts_Group4 SD Supported Version
00346   * @{
00347   */
00348 #define CARD_V1_X                  0x00000000U
00349 #define CARD_V2_X                  0x00000001U
00350 /**
00351   * @}
00352   */
00353       
00354 /**
00355   * @}
00356   */
00357   
00358 /* Exported macro ------------------------------------------------------------*/
00359 /** @defgroup SD_Exported_macros SD Exported Macros
00360  *  @brief macros to handle interrupts and specific clock configurations
00361  * @{
00362  */
00363  
00364 /**
00365   * @brief  Enable the SD device.
00366   * @retval None
00367   */ 
00368 #define __HAL_SD_ENABLE(__HANDLE__) __SDIO_ENABLE((__HANDLE__)->Instance)
00369 
00370 /**
00371   * @brief  Disable the SD device.
00372   * @retval None
00373   */
00374 #define __HAL_SD_DISABLE(__HANDLE__) __SDIO_DISABLE((__HANDLE__)->Instance)
00375 
00376 /**
00377   * @brief  Enable the SDMMC DMA transfer.
00378   * @retval None
00379   */ 
00380 #define __HAL_SD_DMA_ENABLE(__HANDLE__) __SDIO_DMA_ENABLE((__HANDLE__)->Instance)
00381 
00382 /**
00383   * @brief  Disable the SDMMC DMA transfer.
00384   * @retval None
00385   */
00386 #define __HAL_SD_DMA_DISABLE(__HANDLE__)  __SDIO_DMA_DISABLE((__HANDLE__)->Instance)
00387  
00388 /**
00389   * @brief  Enable the SD device interrupt.
00390   * @param  __HANDLE__ SD Handle  
00391   * @param  __INTERRUPT__ specifies the SDMMC interrupt sources to be enabled.
00392   *         This parameter can be one or a combination of the following values:
00393   *            @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
00394   *            @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
00395   *            @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt
00396   *            @arg SDIO_IT_DTIMEOUT: Data timeout interrupt
00397   *            @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
00398   *            @arg SDIO_IT_RXOVERR:  Received FIFO overrun error interrupt
00399   *            @arg SDIO_IT_CMDREND:  Command response received (CRC check passed) interrupt
00400   *            @arg SDIO_IT_CMDSENT:  Command sent (no response required) interrupt
00401   *            @arg SDIO_IT_DATAEND:  Data end (data counter, SDIDCOUNT, is zero) interrupt
00402   *            @arg SDIO_IT_DBCKEND:  Data block sent/received (CRC check passed) interrupt
00403   *            @arg SDIO_IT_CMDACT:   Command transfer in progress interrupt
00404   *            @arg SDIO_IT_TXACT:    Data transmit in progress interrupt
00405   *            @arg SDIO_IT_RXACT:    Data receive in progress interrupt
00406   *            @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
00407   *            @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt
00408   *            @arg SDIO_IT_TXFIFOF:  Transmit FIFO full interrupt
00409   *            @arg SDIO_IT_RXFIFOF:  Receive FIFO full interrupt
00410   *            @arg SDIO_IT_TXFIFOE:  Transmit FIFO empty interrupt
00411   *            @arg SDIO_IT_RXFIFOE:  Receive FIFO empty interrupt
00412   *            @arg SDIO_IT_TXDAVL:   Data available in transmit FIFO interrupt
00413   *            @arg SDIO_IT_RXDAVL:   Data available in receive FIFO interrupt
00414   *            @arg SDIO_IT_SDIOIT:   SD I/O interrupt received interrupt
00415   * @retval None
00416   */
00417 #define __HAL_SD_ENABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_ENABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__))
00418 
00419 /**
00420   * @brief  Disable the SD device interrupt.
00421   * @param  __HANDLE__ SD Handle   
00422   * @param  __INTERRUPT__ specifies the SDMMC interrupt sources to be disabled.
00423   *          This parameter can be one or a combination of the following values:
00424   *            @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
00425   *            @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
00426   *            @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt
00427   *            @arg SDIO_IT_DTIMEOUT: Data timeout interrupt
00428   *            @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
00429   *            @arg SDIO_IT_RXOVERR:  Received FIFO overrun error interrupt
00430   *            @arg SDIO_IT_CMDREND:  Command response received (CRC check passed) interrupt
00431   *            @arg SDIO_IT_CMDSENT:  Command sent (no response required) interrupt
00432   *            @arg SDIO_IT_DATAEND:  Data end (data counter, SDIDCOUNT, is zero) interrupt
00433   *            @arg SDIO_IT_DBCKEND:  Data block sent/received (CRC check passed) interrupt
00434   *            @arg SDIO_IT_CMDACT:   Command transfer in progress interrupt
00435   *            @arg SDIO_IT_TXACT:    Data transmit in progress interrupt
00436   *            @arg SDIO_IT_RXACT:    Data receive in progress interrupt
00437   *            @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
00438   *            @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt
00439   *            @arg SDIO_IT_TXFIFOF:  Transmit FIFO full interrupt
00440   *            @arg SDIO_IT_RXFIFOF:  Receive FIFO full interrupt
00441   *            @arg SDIO_IT_TXFIFOE:  Transmit FIFO empty interrupt
00442   *            @arg SDIO_IT_RXFIFOE:  Receive FIFO empty interrupt
00443   *            @arg SDIO_IT_TXDAVL:   Data available in transmit FIFO interrupt
00444   *            @arg SDIO_IT_RXDAVL:   Data available in receive FIFO interrupt
00445   *            @arg SDIO_IT_SDIOIT:   SD I/O interrupt received interrupt   
00446   * @retval None
00447   */
00448 #define __HAL_SD_DISABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_DISABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__))
00449 
00450 /**
00451   * @brief  Check whether the specified SD flag is set or not. 
00452   * @param  __HANDLE__ SD Handle   
00453   * @param  __FLAG__ specifies the flag to check. 
00454   *          This parameter can be one of the following values:
00455   *            @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed)
00456   *            @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed)
00457   *            @arg SDIO_FLAG_CTIMEOUT: Command response timeout
00458   *            @arg SDIO_FLAG_DTIMEOUT: Data timeout
00459   *            @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error
00460   *            @arg SDIO_FLAG_RXOVERR:  Received FIFO overrun error
00461   *            @arg SDIO_FLAG_CMDREND:  Command response received (CRC check passed)
00462   *            @arg SDIO_FLAG_CMDSENT:  Command sent (no response required)
00463   *            @arg SDIO_FLAG_DATAEND:  Data end (data counter, SDIDCOUNT, is zero)
00464   *            @arg SDIO_FLAG_DBCKEND:  Data block sent/received (CRC check passed)
00465   *            @arg SDIO_FLAG_CMDACT:   Command transfer in progress
00466   *            @arg SDIO_FLAG_TXACT:    Data transmit in progress
00467   *            @arg SDIO_FLAG_RXACT:    Data receive in progress
00468   *            @arg SDIO_FLAG_TXFIFOHE: Transmit FIFO Half Empty
00469   *            @arg SDIO_FLAG_RXFIFOHF: Receive FIFO Half Full
00470   *            @arg SDIO_FLAG_TXFIFOF:  Transmit FIFO full
00471   *            @arg SDIO_FLAG_RXFIFOF:  Receive FIFO full
00472   *            @arg SDIO_FLAG_TXFIFOE:  Transmit FIFO empty
00473   *            @arg SDIO_FLAG_RXFIFOE:  Receive FIFO empty
00474   *            @arg SDIO_FLAG_TXDAVL:   Data available in transmit FIFO
00475   *            @arg SDIO_FLAG_RXDAVL:   Data available in receive FIFO
00476   *            @arg SDIO_FLAG_SDIOIT:   SD I/O interrupt received
00477   * @retval The new state of SD FLAG (SET or RESET).
00478   */
00479 #define __HAL_SD_GET_FLAG(__HANDLE__, __FLAG__) __SDIO_GET_FLAG((__HANDLE__)->Instance, (__FLAG__))
00480 
00481 /**
00482   * @brief  Clear the SD's pending flags.
00483   * @param  __HANDLE__ SD Handle  
00484   * @param  __FLAG__ specifies the flag to clear.  
00485   *          This parameter can be one or a combination of the following values:
00486   *            @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed)
00487   *            @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed)
00488   *            @arg SDIO_FLAG_CTIMEOUT: Command response timeout
00489   *            @arg SDIO_FLAG_DTIMEOUT: Data timeout
00490   *            @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error
00491   *            @arg SDIO_FLAG_RXOVERR:  Received FIFO overrun error
00492   *            @arg SDIO_FLAG_CMDREND:  Command response received (CRC check passed)
00493   *            @arg SDIO_FLAG_CMDSENT:  Command sent (no response required)
00494   *            @arg SDIO_FLAG_DATAEND:  Data end (data counter, SDIDCOUNT, is zero)
00495   *            @arg SDIO_FLAG_DBCKEND:  Data block sent/received (CRC check passed)
00496   *            @arg SDIO_FLAG_SDIOIT:   SD I/O interrupt received
00497   * @retval None
00498   */
00499 #define __HAL_SD_CLEAR_FLAG(__HANDLE__, __FLAG__) __SDIO_CLEAR_FLAG((__HANDLE__)->Instance, (__FLAG__))
00500 
00501 /**
00502   * @brief  Check whether the specified SD interrupt has occurred or not.
00503   * @param  __HANDLE__ SD Handle   
00504   * @param  __INTERRUPT__ specifies the SDMMC interrupt source to check. 
00505   *          This parameter can be one of the following values:
00506   *            @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
00507   *            @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
00508   *            @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt
00509   *            @arg SDIO_IT_DTIMEOUT: Data timeout interrupt
00510   *            @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
00511   *            @arg SDIO_IT_RXOVERR:  Received FIFO overrun error interrupt
00512   *            @arg SDIO_IT_CMDREND:  Command response received (CRC check passed) interrupt
00513   *            @arg SDIO_IT_CMDSENT:  Command sent (no response required) interrupt
00514   *            @arg SDIO_IT_DATAEND:  Data end (data counter, SDIDCOUNT, is zero) interrupt
00515   *            @arg SDIO_IT_DBCKEND:  Data block sent/received (CRC check passed) interrupt
00516   *            @arg SDIO_IT_CMDACT:   Command transfer in progress interrupt
00517   *            @arg SDIO_IT_TXACT:    Data transmit in progress interrupt
00518   *            @arg SDIO_IT_RXACT:    Data receive in progress interrupt
00519   *            @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
00520   *            @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt
00521   *            @arg SDIO_IT_TXFIFOF:  Transmit FIFO full interrupt
00522   *            @arg SDIO_IT_RXFIFOF:  Receive FIFO full interrupt
00523   *            @arg SDIO_IT_TXFIFOE:  Transmit FIFO empty interrupt
00524   *            @arg SDIO_IT_RXFIFOE:  Receive FIFO empty interrupt
00525   *            @arg SDIO_IT_TXDAVL:   Data available in transmit FIFO interrupt
00526   *            @arg SDIO_IT_RXDAVL:   Data available in receive FIFO interrupt
00527   *            @arg SDIO_IT_SDIOIT:   SD I/O interrupt received interrupt
00528   * @retval The new state of SD IT (SET or RESET).
00529   */
00530 #define __HAL_SD_GET_IT(__HANDLE__, __INTERRUPT__) __SDIO_GET_IT((__HANDLE__)->Instance, (__INTERRUPT__))
00531 
00532 /**
00533   * @brief  Clear the SD's interrupt pending bits.
00534   * @param  __HANDLE__ SD Handle
00535   * @param  __INTERRUPT__ specifies the interrupt pending bit to clear. 
00536   *          This parameter can be one or a combination of the following values:
00537   *            @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
00538   *            @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
00539   *            @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt
00540   *            @arg SDIO_IT_DTIMEOUT: Data timeout interrupt
00541   *            @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
00542   *            @arg SDIO_IT_RXOVERR:  Received FIFO overrun error interrupt
00543   *            @arg SDIO_IT_CMDREND:  Command response received (CRC check passed) interrupt
00544   *            @arg SDIO_IT_CMDSENT:  Command sent (no response required) interrupt
00545   *            @arg SDIO_IT_DATAEND:  Data end (data counter, SDMMC_DCOUNT, is zero) interrupt
00546   *            @arg SDIO_IT_SDIOIT:   SD I/O interrupt received interrupt
00547   * @retval None
00548   */
00549 #define __HAL_SD_CLEAR_IT(__HANDLE__, __INTERRUPT__) __SDIO_CLEAR_IT((__HANDLE__)->Instance, (__INTERRUPT__))
00550 
00551 /**
00552   * @}
00553   */
00554   
00555 /* Exported functions --------------------------------------------------------*/
00556 /** @defgroup SD_Exported_Functions SD Exported Functions
00557   * @{
00558   */
00559   
00560 /** @defgroup SD_Exported_Functions_Group1 Initialization and de-initialization functions
00561   * @{
00562   */
00563 HAL_StatusTypeDef HAL_SD_Init(SD_HandleTypeDef *hsd);
00564 HAL_StatusTypeDef HAL_SD_InitCard(SD_HandleTypeDef *hsd);
00565 HAL_StatusTypeDef HAL_SD_DeInit (SD_HandleTypeDef *hsd);
00566 void HAL_SD_MspInit(SD_HandleTypeDef *hsd);
00567 void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd);
00568 /**
00569   * @}
00570   */
00571   
00572 /** @defgroup SD_Exported_Functions_Group2 Input and Output operation functions
00573   * @{
00574   */
00575 /* Blocking mode: Polling */
00576 HAL_StatusTypeDef HAL_SD_ReadBlocks(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout);
00577 HAL_StatusTypeDef HAL_SD_WriteBlocks(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout);
00578 HAL_StatusTypeDef HAL_SD_Erase(SD_HandleTypeDef *hsd, uint32_t BlockStartAdd, uint32_t BlockEndAdd);
00579 /* Non-Blocking mode: IT */
00580 HAL_StatusTypeDef HAL_SD_ReadBlocks_IT(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks);
00581 HAL_StatusTypeDef HAL_SD_WriteBlocks_IT(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks);
00582 /* Non-Blocking mode: DMA */
00583 HAL_StatusTypeDef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks);
00584 HAL_StatusTypeDef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks);
00585 
00586 void HAL_SD_IRQHandler(SD_HandleTypeDef *hsd);
00587 
00588 /* Callback in non blocking modes (DMA) */
00589 void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd);
00590 void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd);
00591 void HAL_SD_ErrorCallback(SD_HandleTypeDef *hsd);
00592 void HAL_SD_AbortCallback(SD_HandleTypeDef *hsd);
00593 /**
00594   * @}
00595   */
00596   
00597 /** @defgroup SD_Exported_Functions_Group3 Peripheral Control functions
00598   * @{
00599   */
00600 HAL_StatusTypeDef HAL_SD_ConfigWideBusOperation(SD_HandleTypeDef *hsd, uint32_t WideMode);
00601 /**
00602   * @}
00603   */
00604 
00605 /** @defgroup SD_Exported_Functions_Group4 SD card related functions
00606   * @{
00607   */
00608 HAL_StatusTypeDef       HAL_SD_SendSDStatus(SD_HandleTypeDef *hsd, uint32_t *pSDstatus);
00609 HAL_SD_CardStateTypeDef HAL_SD_GetCardState(SD_HandleTypeDef *hsd);
00610 HAL_StatusTypeDef       HAL_SD_GetCardCID(SD_HandleTypeDef *hsd, HAL_SD_CardCIDTypeDef *pCID);
00611 HAL_StatusTypeDef       HAL_SD_GetCardCSD(SD_HandleTypeDef *hsd, HAL_SD_CardCSDTypeDef *pCSD);
00612 HAL_StatusTypeDef       HAL_SD_GetCardStatus(SD_HandleTypeDef *hsd, HAL_SD_CardStatusTypeDef *pStatus);
00613 HAL_StatusTypeDef       HAL_SD_GetCardInfo(SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypeDef *pCardInfo);
00614 /**
00615   * @}
00616   */
00617 
00618 /** @defgroup SD_Exported_Functions_Group5 Peripheral State and Errors functions
00619   * @{
00620   */
00621 HAL_SD_StateTypeDef HAL_SD_GetState(SD_HandleTypeDef *hsd);
00622 uint32_t HAL_SD_GetError(SD_HandleTypeDef *hsd);
00623 /**
00624   * @}
00625   */
00626 
00627 /** @defgroup SD_Exported_Functions_Group6 Perioheral Abort management
00628   * @{
00629   */
00630 HAL_StatusTypeDef HAL_SD_Abort(SD_HandleTypeDef *hsd);
00631 HAL_StatusTypeDef HAL_SD_Abort_IT(SD_HandleTypeDef *hsd);
00632 /**
00633   * @}
00634   */
00635     
00636 /* Private types -------------------------------------------------------------*/
00637 /** @defgroup SD_Private_Types SD Private Types
00638   * @{
00639   */
00640 
00641 /**
00642   * @}
00643   */ 
00644 
00645 /* Private defines -----------------------------------------------------------*/
00646 /** @defgroup SD_Private_Defines SD Private Defines
00647   * @{
00648   */
00649 
00650 /**
00651   * @}
00652   */ 
00653           
00654 /* Private variables ---------------------------------------------------------*/
00655 /** @defgroup SD_Private_Variables SD Private Variables
00656   * @{
00657   */
00658 
00659 /**
00660   * @}
00661   */ 
00662 
00663 /* Private constants ---------------------------------------------------------*/
00664 /** @defgroup SD_Private_Constants SD Private Constants
00665   * @{
00666   */
00667 
00668 /**
00669   * @}
00670   */ 
00671 
00672 /* Private macros ------------------------------------------------------------*/
00673 /** @defgroup SD_Private_Macros SD Private Macros
00674   * @{
00675   */
00676 
00677 /**
00678   * @}
00679   */
00680 
00681 /* Private functions prototypes ----------------------------------------------*/
00682 /** @defgroup SD_Private_Functions_Prototypes SD Private Functions Prototypes
00683   * @{
00684   */
00685 
00686 /**
00687   * @}
00688   */
00689 
00690 /* Private functions ---------------------------------------------------------*/
00691 /** @defgroup SD_Private_Functions SD Private Functions
00692   * @{
00693   */
00694 
00695 /**
00696   * @}
00697   */
00698 
00699 
00700 /**
00701   * @}
00702   */ 
00703 
00704 /**
00705   * @}
00706   */
00707 
00708 /**
00709   * @}
00710   */
00711 
00712 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
00713           STM32F401xC || STM32F401xE || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx ||
00714           STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
00715 
00716 #ifdef __cplusplus
00717 }
00718 #endif
00719 
00720 
00721 #endif /* __STM32F4xx_HAL_SD_H */ 
00722 
00723 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/