STM32L486xx HAL User Manual
stm32l4xx_hal_sd.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32l4xx_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 STM32L4xx_HAL_SD_H
00038 #define STM32L4xx_HAL_SD_H
00039 
00040 #ifdef __cplusplus
00041  extern "C" {
00042 #endif
00043 
00044 #if defined(SDMMC1)
00045 
00046 /* Includes ------------------------------------------------------------------*/
00047 #include "stm32l4xx_ll_sdmmc.h"
00048 
00049 /** @addtogroup STM32L4xx_HAL_Driver
00050   * @{
00051   */
00052 
00053 /** @addtogroup SD
00054   * @{
00055   */
00056 
00057 /* Exported types ------------------------------------------------------------*/ 
00058 /** @defgroup SD_Exported_Types SD Exported Types
00059   * @{
00060   */
00061 
00062 /** @defgroup SD_Exported_Types_Group1 SD State enumeration structure
00063   * @{
00064   */   
00065 typedef enum
00066 {
00067   HAL_SD_STATE_RESET                  = ((uint32_t)0x00000000U),  /*!< SD not yet initialized or disabled  */
00068   HAL_SD_STATE_READY                  = ((uint32_t)0x00000001U),  /*!< SD initialized and ready for use    */
00069   HAL_SD_STATE_TIMEOUT                = ((uint32_t)0x00000002U),  /*!< SD Timeout state                    */
00070   HAL_SD_STATE_BUSY                   = ((uint32_t)0x00000003U),  /*!< SD process ongoing                  */
00071   HAL_SD_STATE_PROGRAMMING            = ((uint32_t)0x00000004U),  /*!< SD Programming State                */
00072   HAL_SD_STATE_RECEIVING              = ((uint32_t)0x00000005U),  /*!< SD Receiving State                  */
00073   HAL_SD_STATE_TRANSFER               = ((uint32_t)0x00000006U),  /*!< SD Transfert State                  */
00074   HAL_SD_STATE_ERROR                  = ((uint32_t)0x0000000FU)   /*!< SD is in error state                */
00075 }HAL_SD_StateTypeDef;
00076 /** 
00077   * @}
00078   */
00079 
00080 /** @defgroup SD_Exported_Types_Group2 SD Card State enumeration structure
00081   * @{
00082   */   
00083 typedef enum
00084 {
00085   HAL_SD_CARD_READY                  = ((uint32_t)0x00000001U),  /*!< Card state is ready                     */
00086   HAL_SD_CARD_IDENTIFICATION         = ((uint32_t)0x00000002U),  /*!< Card is in identification state         */
00087   HAL_SD_CARD_STANDBY                = ((uint32_t)0x00000003U),  /*!< Card is in standby state                */
00088   HAL_SD_CARD_TRANSFER               = ((uint32_t)0x00000004U),  /*!< Card is in transfer state               */  
00089   HAL_SD_CARD_SENDING                = ((uint32_t)0x00000005U),  /*!< Card is sending an operation            */
00090   HAL_SD_CARD_RECEIVING              = ((uint32_t)0x00000006U),  /*!< Card is receiving operation information */
00091   HAL_SD_CARD_PROGRAMMING            = ((uint32_t)0x00000007U),  /*!< Card is in programming state            */
00092   HAL_SD_CARD_DISCONNECTED           = ((uint32_t)0x00000008U),  /*!< Card is disconnected                    */
00093   HAL_SD_CARD_ERROR                  = ((uint32_t)0x000000FFU)   /*!< Card response Error                     */
00094 }HAL_SD_CardStateTypedef;
00095 /** 
00096   * @}
00097   */
00098 
00099 /** @defgroup SD_Exported_Types_Group3 SD Handle Structure definition   
00100   * @{
00101   */
00102 #define SD_InitTypeDef      SDMMC_InitTypeDef 
00103 #define SD_TypeDef          SDMMC_TypeDef
00104 
00105 /** 
00106   * @brief  SD Card Information Structure definition
00107   */ 
00108 typedef struct
00109 {
00110   uint32_t CardType;                     /*!< Specifies the card Type                         */
00111   
00112   uint32_t CardVersion;                  /*!< Specifies the card version                      */
00113 
00114   uint32_t Class;                        /*!< Specifies the class of the card class           */
00115 
00116   uint32_t RelCardAdd;                   /*!< Specifies the Relative Card Address             */
00117   
00118   uint32_t BlockNbr;                     /*!< Specifies the Card Capacity in blocks           */
00119 
00120   uint32_t BlockSize;                    /*!< Specifies one block size in bytes               */
00121   
00122   uint32_t LogBlockNbr;                  /*!< Specifies the Card logical Capacity in blocks   */
00123 
00124   uint32_t LogBlockSize;                 /*!< Specifies logical block size in bytes           */
00125 
00126 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
00127   
00128   uint32_t CardSpeed;                    /*!< Specifies the card Speed                        */
00129 
00130 #endif /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
00131 }HAL_SD_CardInfoTypeDef;
00132 
00133 /** 
00134   * @brief  SD handle Structure definition
00135   */ 
00136 typedef struct __SD_HandleTypeDef
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   uint8_t                      *pTxBuffPtr;      /*!< Pointer to SD Tx transfer Buffer    */
00145   
00146   uint32_t                     TxXferSize;       /*!< SD Tx Transfer size                 */
00147   
00148   uint8_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 #if !defined(STM32L4R5xx) && !defined(STM32L4R7xx) && !defined(STM32L4R9xx) && !defined(STM32L4S5xx) && !defined(STM32L4S7xx) && !defined(STM32L4S9xx)
00159   
00160   DMA_HandleTypeDef            *hdmatx;          /*!< SD Tx DMA handle parameters         */
00161   
00162   DMA_HandleTypeDef            *hdmarx;          /*!< SD Rx DMA handle parameters         */
00163   
00164 #endif /* !STM32L4R5xx && !STM32L4R7xx && !STM32L4R9xx && !STM32L4S5xx && !STM32L4S7xx && !STM32L4S9xx */
00165   HAL_SD_CardInfoTypeDef       SdCard;           /*!< SD Card information                 */
00166   
00167   uint32_t                     CSD[4];           /*!< SD card specific data table         */
00168   
00169   uint32_t                     CID[4];           /*!< SD card identification number table */
00170 
00171 #if (USE_HAL_SD_REGISTER_CALLBACKS == 1)
00172   void (* TxCpltCallback)                 (struct __SD_HandleTypeDef *hsd);
00173   void (* RxCpltCallback)                 (struct __SD_HandleTypeDef *hsd);
00174   void (* ErrorCallback)                  (struct __SD_HandleTypeDef *hsd);
00175   void (* AbortCpltCallback)              (struct __SD_HandleTypeDef *hsd);
00176 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
00177   void (* Read_DMADblBuf0CpltCallback)    (struct __SD_HandleTypeDef *hsd);
00178   void (* Read_DMADblBuf1CpltCallback)    (struct __SD_HandleTypeDef *hsd);
00179   void (* Write_DMADblBuf0CpltCallback)   (struct __SD_HandleTypeDef *hsd);
00180   void (* Write_DMADblBuf1CpltCallback)   (struct __SD_HandleTypeDef *hsd);
00181 
00182   void (* DriveTransceiver_1_8V_Callback) (FlagStatus status);
00183 #endif
00184 
00185   void (* MspInitCallback)                (struct __SD_HandleTypeDef *hsd);
00186   void (* MspDeInitCallback)              (struct __SD_HandleTypeDef *hsd);
00187 #endif  
00188 }SD_HandleTypeDef;
00189 
00190 /** 
00191   * @}
00192   */
00193 
00194 /** @defgroup SD_Exported_Types_Group4 Card Specific Data: CSD Register 
00195   * @{
00196   */ 
00197 typedef struct
00198 {
00199   __IO uint8_t  CSDStruct;            /*!< CSD structure                         */
00200   __IO uint8_t  SysSpecVersion;       /*!< System specification version          */
00201   __IO uint8_t  Reserved1;            /*!< Reserved                              */
00202   __IO uint8_t  TAAC;                 /*!< Data read access time 1               */
00203   __IO uint8_t  NSAC;                 /*!< Data read access time 2 in CLK cycles */
00204   __IO uint8_t  MaxBusClkFrec;        /*!< Max. bus clock frequency              */
00205   __IO uint16_t CardComdClasses;      /*!< Card command classes                  */
00206   __IO uint8_t  RdBlockLen;           /*!< Max. read data block length           */
00207   __IO uint8_t  PartBlockRead;        /*!< Partial blocks for read allowed       */
00208   __IO uint8_t  WrBlockMisalign;      /*!< Write block misalignment              */
00209   __IO uint8_t  RdBlockMisalign;      /*!< Read block misalignment               */
00210   __IO uint8_t  DSRImpl;              /*!< DSR implemented                       */
00211   __IO uint8_t  Reserved2;            /*!< Reserved                              */
00212   __IO uint32_t DeviceSize;           /*!< Device Size                           */
00213   __IO uint8_t  MaxRdCurrentVDDMin;   /*!< Max. read current @ VDD min           */
00214   __IO uint8_t  MaxRdCurrentVDDMax;   /*!< Max. read current @ VDD max           */
00215   __IO uint8_t  MaxWrCurrentVDDMin;   /*!< Max. write current @ VDD min          */
00216   __IO uint8_t  MaxWrCurrentVDDMax;   /*!< Max. write current @ VDD max          */
00217   __IO uint8_t  DeviceSizeMul;        /*!< Device size multiplier                */
00218   __IO uint8_t  EraseGrSize;          /*!< Erase group size                      */
00219   __IO uint8_t  EraseGrMul;           /*!< Erase group size multiplier           */
00220   __IO uint8_t  WrProtectGrSize;      /*!< Write protect group size              */
00221   __IO uint8_t  WrProtectGrEnable;    /*!< Write protect group enable            */
00222   __IO uint8_t  ManDeflECC;           /*!< Manufacturer default ECC              */
00223   __IO uint8_t  WrSpeedFact;          /*!< Write speed factor                    */
00224   __IO uint8_t  MaxWrBlockLen;        /*!< Max. write data block length          */
00225   __IO uint8_t  WriteBlockPaPartial;  /*!< Partial blocks for write allowed      */
00226   __IO uint8_t  Reserved3;            /*!< Reserved                              */
00227   __IO uint8_t  ContentProtectAppli;  /*!< Content protection application        */
00228   __IO uint8_t  FileFormatGroup;      /*!< File format group                     */
00229   __IO uint8_t  CopyFlag;             /*!< Copy flag (OTP)                       */
00230   __IO uint8_t  PermWrProtect;        /*!< Permanent write protection            */
00231   __IO uint8_t  TempWrProtect;        /*!< Temporary write protection            */
00232   __IO uint8_t  FileFormat;           /*!< File format                           */
00233   __IO uint8_t  ECC;                  /*!< ECC code                              */
00234   __IO uint8_t  CSD_CRC;              /*!< CSD CRC                               */
00235   __IO uint8_t  Reserved4;            /*!< Always 1                              */
00236 
00237 }HAL_SD_CardCSDTypedef;
00238 /** 
00239   * @}
00240   */
00241 
00242 /** @defgroup SD_Exported_Types_Group5 Card Identification Data: CID Register
00243   * @{
00244   */
00245 typedef struct
00246 {
00247   __IO uint8_t  ManufacturerID;  /*!< Manufacturer ID       */
00248   __IO uint16_t OEM_AppliID;     /*!< OEM/Application ID    */
00249   __IO uint32_t ProdName1;       /*!< Product Name part1    */
00250   __IO uint8_t  ProdName2;       /*!< Product Name part2    */
00251   __IO uint8_t  ProdRev;         /*!< Product Revision      */
00252   __IO uint32_t ProdSN;          /*!< Product Serial Number */
00253   __IO uint8_t  Reserved1;       /*!< Reserved1             */
00254   __IO uint16_t ManufactDate;    /*!< Manufacturing Date    */
00255   __IO uint8_t  CID_CRC;         /*!< CID CRC               */
00256   __IO uint8_t  Reserved2;       /*!< Always 1              */
00257 
00258 }HAL_SD_CardCIDTypedef;
00259 /** 
00260   * @}
00261   */
00262 
00263 /** @defgroup SD_Exported_Types_Group6 SD Card Status returned by ACMD13 
00264   * @{
00265   */
00266 typedef struct
00267 {
00268   __IO uint8_t  DataBusWidth;           /*!< Shows the currently defined data bus width                 */
00269   __IO uint8_t  SecuredMode;            /*!< Card is in secured mode of operation                       */
00270   __IO uint16_t CardType;               /*!< Carries information about card type                        */
00271   __IO uint32_t ProtectedAreaSize;      /*!< Carries information about the capacity of protected area   */
00272   __IO uint8_t  SpeedClass;             /*!< Carries information about the speed class of the card      */
00273   __IO uint8_t  PerformanceMove;        /*!< Carries information about the card's performance move      */
00274   __IO uint8_t  AllocationUnitSize;     /*!< Carries information about the card's allocation unit size  */
00275   __IO uint16_t EraseSize;              /*!< Determines the number of AUs to be erased in one operation */
00276   __IO uint8_t  EraseTimeout;           /*!< Determines the timeout for any number of AU erase          */
00277   __IO uint8_t  EraseOffset;            /*!< Carries information about the erase offset                 */
00278 
00279 }HAL_SD_CardStatusTypedef;
00280 /** 
00281   * @}
00282   */
00283 
00284 #if (USE_HAL_SD_REGISTER_CALLBACKS == 1)
00285 /** @defgroup SD_Exported_Types_Group7 SD Callback ID enumeration definition 
00286   * @{
00287   */
00288 typedef enum
00289 {
00290   HAL_SD_TX_CPLT_CB_ID                 = 0x00U,  /*!< SD Tx Complete Callback ID                     */
00291   HAL_SD_RX_CPLT_CB_ID                 = 0x01U,  /*!< SD Rx Complete Callback ID                     */
00292   HAL_SD_ERROR_CB_ID                   = 0x02U,  /*!< SD Error Callback ID                           */
00293   HAL_SD_ABORT_CB_ID                   = 0x03U,  /*!< SD Abort Callback ID                           */
00294 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
00295   HAL_SD_READ_DMA_DBL_BUF0_CPLT_CB_ID  = 0x04U,  /*!< SD Rx DMA Double Buffer 0 Complete Callback ID */
00296   HAL_SD_READ_DMA_DBL_BUF1_CPLT_CB_ID  = 0x05U,  /*!< SD Rx DMA Double Buffer 1 Complete Callback ID */
00297   HAL_SD_WRITE_DMA_DBL_BUF0_CPLT_CB_ID = 0x06U,  /*!< SD Tx DMA Double Buffer 0 Complete Callback ID */
00298   HAL_SD_WRITE_DMA_DBL_BUF1_CPLT_CB_ID = 0x07U,  /*!< SD Tx DMA Double Buffer 1 Complete Callback ID */
00299 #endif  
00300 
00301   HAL_SD_MSP_INIT_CB_ID                = 0x10U,  /*!< SD MspInit Callback ID                         */
00302   HAL_SD_MSP_DEINIT_CB_ID              = 0x11U   /*!< SD MspDeInit Callback ID                       */
00303 }HAL_SD_CallbackIDTypeDef;
00304 /** 
00305   * @}
00306   */
00307 
00308 /** @defgroup SD_Exported_Types_Group8 SD Callback pointer definition 
00309   * @{
00310   */
00311 typedef void (*pSD_CallbackTypeDef)           (SD_HandleTypeDef *hsd);
00312 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
00313 typedef void (*pSD_TransceiverCallbackTypeDef)(FlagStatus status);
00314 #endif
00315 /** 
00316   * @}
00317   */
00318 #endif
00319 /** 
00320   * @}
00321   */
00322 
00323 /* Exported constants --------------------------------------------------------*/
00324 /** @defgroup SD_Exported_Constants  Exported Constants
00325   * @{
00326   */
00327 
00328 #define BLOCKSIZE   ((uint32_t)512U) /*!< Block size is 512 bytes */
00329 
00330 /** @defgroup SD_Exported_Constansts_Group1 SD Error status enumeration Structure definition 
00331   * @{
00332   */  
00333 #define HAL_SD_ERROR_NONE                     SDMMC_ERROR_NONE                    /*!< No error                                                      */
00334 #define HAL_SD_ERROR_CMD_CRC_FAIL             SDMMC_ERROR_CMD_CRC_FAIL            /*!< Command response received (but CRC check failed)              */
00335 #define HAL_SD_ERROR_DATA_CRC_FAIL            SDMMC_ERROR_DATA_CRC_FAIL           /*!< Data block sent/received (CRC check failed)                   */
00336 #define HAL_SD_ERROR_CMD_RSP_TIMEOUT          SDMMC_ERROR_CMD_RSP_TIMEOUT         /*!< Command response timeout                                      */
00337 #define HAL_SD_ERROR_DATA_TIMEOUT             SDMMC_ERROR_DATA_TIMEOUT            /*!< Data timeout                                                  */
00338 #define HAL_SD_ERROR_TX_UNDERRUN              SDMMC_ERROR_TX_UNDERRUN             /*!< Transmit FIFO underrun                                        */
00339 #define HAL_SD_ERROR_RX_OVERRUN               SDMMC_ERROR_RX_OVERRUN              /*!< Receive FIFO overrun                                          */
00340 #define HAL_SD_ERROR_ADDR_MISALIGNED          SDMMC_ERROR_ADDR_MISALIGNED         /*!< Misaligned address                                            */
00341 #define HAL_SD_ERROR_BLOCK_LEN_ERR            SDMMC_ERROR_BLOCK_LEN_ERR           /*!< Transferred block length is not allowed for the card or the 
00342                                                                                        number of transferred bytes does not match the block length   */
00343 #define HAL_SD_ERROR_ERASE_SEQ_ERR            SDMMC_ERROR_ERASE_SEQ_ERR           /*!< An error in the sequence of erase command occurs              */
00344 #define HAL_SD_ERROR_BAD_ERASE_PARAM          SDMMC_ERROR_BAD_ERASE_PARAM         /*!< An invalid selection for erase groups                         */
00345 #define HAL_SD_ERROR_WRITE_PROT_VIOLATION     SDMMC_ERROR_WRITE_PROT_VIOLATION    /*!< Attempt to program a write protect block                      */
00346 #define HAL_SD_ERROR_LOCK_UNLOCK_FAILED       SDMMC_ERROR_LOCK_UNLOCK_FAILED      /*!< Sequence or password error has been detected in unlock 
00347                                                                                        command or if there was an attempt to access a locked card    */
00348 #define HAL_SD_ERROR_COM_CRC_FAILED           SDMMC_ERROR_COM_CRC_FAILED          /*!< CRC check of the previous command failed                      */
00349 #define HAL_SD_ERROR_ILLEGAL_CMD              SDMMC_ERROR_ILLEGAL_CMD             /*!< Command is not legal for the card state                       */
00350 #define HAL_SD_ERROR_CARD_ECC_FAILED          SDMMC_ERROR_CARD_ECC_FAILED         /*!< Card internal ECC was applied but failed to correct the data  */
00351 #define HAL_SD_ERROR_CC_ERR                   SDMMC_ERROR_CC_ERR                  /*!< Internal card controller error                                */
00352 #define HAL_SD_ERROR_GENERAL_UNKNOWN_ERR      SDMMC_ERROR_GENERAL_UNKNOWN_ERR     /*!< General or unknown error                                      */
00353 #define HAL_SD_ERROR_STREAM_READ_UNDERRUN     SDMMC_ERROR_STREAM_READ_UNDERRUN    /*!< The card could not sustain data reading in stream rmode       */
00354 #define HAL_SD_ERROR_STREAM_WRITE_OVERRUN     SDMMC_ERROR_STREAM_WRITE_OVERRUN    /*!< The card could not sustain data programming in stream mode    */
00355 #define HAL_SD_ERROR_CID_CSD_OVERWRITE        SDMMC_ERROR_CID_CSD_OVERWRITE       /*!< CID/CSD overwrite error                                       */
00356 #define HAL_SD_ERROR_WP_ERASE_SKIP            SDMMC_ERROR_WP_ERASE_SKIP           /*!< Only partial address space was erased                         */
00357 #define HAL_SD_ERROR_CARD_ECC_DISABLED        SDMMC_ERROR_CARD_ECC_DISABLED       /*!< Command has been executed without using internal ECC          */
00358 #define HAL_SD_ERROR_ERASE_RESET              SDMMC_ERROR_ERASE_RESET             /*!< Erase sequence was cleared before executing because an out 
00359                                                                                        of erase sequence command was received                        */
00360 #define HAL_SD_ERROR_AKE_SEQ_ERR              SDMMC_ERROR_AKE_SEQ_ERR             /*!< Error in sequence of authentication                           */
00361 #define HAL_SD_ERROR_INVALID_VOLTRANGE        SDMMC_ERROR_INVALID_VOLTRANGE       /*!< Error in case of invalid voltage range                        */        
00362 #define HAL_SD_ERROR_ADDR_OUT_OF_RANGE        SDMMC_ERROR_ADDR_OUT_OF_RANGE       /*!< Error when addressed block is out of range                    */        
00363 #define HAL_SD_ERROR_REQUEST_NOT_APPLICABLE   SDMMC_ERROR_REQUEST_NOT_APPLICABLE  /*!< Error when command request is not applicable                  */  
00364 #define HAL_SD_ERROR_PARAM                    SDMMC_ERROR_INVALID_PARAMETER       /*!< the used parameter is not valid                               */  
00365 #define HAL_SD_ERROR_UNSUPPORTED_FEATURE      SDMMC_ERROR_UNSUPPORTED_FEATURE     /*!< Error when feature is not insupported                         */
00366 #define HAL_SD_ERROR_BUSY                     SDMMC_ERROR_BUSY                    /*!< Error when transfer process is busy                           */ 
00367 #define HAL_SD_ERROR_DMA                      SDMMC_ERROR_DMA                     /*!< Error while DMA transfer                                      */
00368 #define HAL_SD_ERROR_TIMEOUT                  SDMMC_ERROR_TIMEOUT                 /*!< Timeout error                                                 */
00369 
00370 #if (USE_HAL_SD_REGISTER_CALLBACKS == 1)
00371 #define HAL_SD_ERROR_INVALID_CALLBACK         SDMMC_ERROR_INVALID_PARAMETER       /*!< Invalid callback error                                        */
00372 #endif
00373                                                 
00374 /** 
00375   * @}
00376   */
00377 
00378 /** @defgroup SD_Exported_Constansts_Group2 SD context enumeration
00379   * @{
00380   */ 
00381 #define SD_CONTEXT_NONE                 ((uint32_t)0x00000000U)  /*!< None                             */
00382 #define SD_CONTEXT_READ_SINGLE_BLOCK    ((uint32_t)0x00000001U)  /*!< Read single block operation      */
00383 #define SD_CONTEXT_READ_MULTIPLE_BLOCK  ((uint32_t)0x00000002U)  /*!< Read multiple blocks operation   */
00384 #define SD_CONTEXT_WRITE_SINGLE_BLOCK   ((uint32_t)0x00000010U)  /*!< Write single block operation     */
00385 #define SD_CONTEXT_WRITE_MULTIPLE_BLOCK ((uint32_t)0x00000020U)  /*!< Write multiple blocks operation  */
00386 #define SD_CONTEXT_IT                   ((uint32_t)0x00000008U)  /*!< Process in Interrupt mode        */
00387 #define SD_CONTEXT_DMA                  ((uint32_t)0x00000080U)  /*!< Process in DMA mode              */  
00388 
00389 /**
00390   * @}
00391   */
00392 
00393 /** @defgroup SD_Exported_Constansts_Group3 SD Supported Memory Cards
00394   * @{
00395   */
00396 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
00397 #define CARD_NORMAL_SPEED          ((uint32_t)0x00000000U)    /*!< Normal Speed Card <12.5Mo/s , Spec Version 1.01    */
00398 #define CARD_HIGH_SPEED            ((uint32_t)0x00000100U)    /*!< High Speed Card <25Mo/s , Spec version 2.00        */
00399 #define CARD_ULTRA_HIGH_SPEED      ((uint32_t)0x00000200U)    /*!< UHS-I SD Card <50Mo/s for SDR50, DDR5 Cards
00400                                                                   and <104Mo/s for SDR104, Spec version 3.01          */
00401 #endif /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
00402 
00403 #define CARD_SDSC                  ((uint32_t)0x00000000U)
00404 #define CARD_SDHC_SDXC             ((uint32_t)0x00000001U)
00405 #define CARD_SECURED               ((uint32_t)0x00000003U)
00406     
00407 /**
00408   * @}
00409   */
00410 
00411 /** @defgroup SD_Exported_Constansts_Group4 SD Supported Version
00412   * @{
00413   */
00414 #define CARD_V1_X                  ((uint32_t)0x00000000U)
00415 #define CARD_V2_X                  ((uint32_t)0x00000001U)
00416 /**
00417   * @}
00418   */
00419 
00420 /**
00421   * @}
00422   */
00423   
00424 /* Exported macro ------------------------------------------------------------*/
00425 /** @defgroup SD_Exported_macros SD Exported Macros
00426  *  @brief macros to handle interrupts and specific clock configurations
00427  * @{
00428  */
00429 /** @brief Reset SD handle state.
00430   * @param  __HANDLE__ : SD handle.
00431   * @retval None
00432   */
00433 #if (USE_HAL_SD_REGISTER_CALLBACKS == 1)
00434 #define __HAL_SD_RESET_HANDLE_STATE(__HANDLE__)           do {                                              \
00435                                                                (__HANDLE__)->State = HAL_SD_STATE_RESET; \
00436                                                                (__HANDLE__)->MspInitCallback = NULL;       \
00437                                                                (__HANDLE__)->MspDeInitCallback = NULL;     \
00438                                                              } while(0)
00439 #else
00440 #define __HAL_SD_RESET_HANDLE_STATE(__HANDLE__)           ((__HANDLE__)->State = HAL_SD_STATE_RESET)
00441 #endif
00442  
00443 #if !defined(STM32L4R5xx) && !defined(STM32L4R7xx) && !defined(STM32L4R9xx) && !defined(STM32L4S5xx) && !defined(STM32L4S7xx) && !defined(STM32L4S9xx)
00444 /**
00445   * @brief  Enable the SD device.
00446   * @retval None
00447   */ 
00448 #define __HAL_SD_ENABLE(__HANDLE__) __SDMMC_ENABLE((__HANDLE__)->Instance)
00449 
00450 /**
00451   * @brief  Disable the SD device.
00452   * @retval None
00453   */
00454 #define __HAL_SD_DISABLE(__HANDLE__) __SDMMC_DISABLE((__HANDLE__)->Instance)
00455 
00456 /**
00457   * @brief  Enable the SDMMC DMA transfer.
00458   * @retval None
00459   */ 
00460 #define __HAL_SD_DMA_ENABLE(__HANDLE__) __SDMMC_DMA_ENABLE((__HANDLE__)->Instance)
00461 
00462 /**
00463   * @brief  Disable the SDMMC DMA transfer.
00464   * @retval None
00465   */
00466 #define __HAL_SD_DMA_DISABLE(__HANDLE__)  __SDMMC_DMA_DISABLE((__HANDLE__)->Instance)
00467 #endif /* !STM32L4R5xx && !STM32L4R7xx && !STM32L4R9xx && !STM32L4S5xx && !STM32L4S7xx && !STM32L4S9xx */
00468  
00469 /**
00470   * @brief  Enable the SD device interrupt.
00471   * @param  __HANDLE__: SD Handle  
00472   * @param  __INTERRUPT__: specifies the SDMMC interrupt sources to be enabled.
00473   *         This parameter can be one or a combination of the following values:
00474   *            @arg SDMMC_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
00475   *            @arg SDMMC_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
00476   *            @arg SDMMC_IT_CTIMEOUT: Command response timeout interrupt
00477   *            @arg SDMMC_IT_DTIMEOUT: Data timeout interrupt
00478   *            @arg SDMMC_IT_TXUNDERR: Transmit FIFO underrun error interrupt
00479   *            @arg SDMMC_IT_RXOVERR:  Received FIFO overrun error interrupt
00480   *            @arg SDMMC_IT_CMDREND:  Command response received (CRC check passed) interrupt
00481   *            @arg SDMMC_IT_CMDSENT:  Command sent (no response required) interrupt
00482   *            @arg SDMMC_IT_DBCKEND:  Data block sent/received (CRC check passed) interrupt
00483   *            @arg SDMMC_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
00484   *            @arg SDMMC_IT_RXFIFOHF: Receive FIFO Half Full interrupt
00485   *            @arg SDMMC_IT_TXFIFOF:  Transmit FIFO full interrupt
00486   *            @arg SDMMC_IT_RXFIFOF:  Receive FIFO full interrupt
00487   *            @arg SDMMC_IT_TXFIFOE:  Transmit FIFO empty interrupt
00488   *            @arg SDMMC_IT_RXFIFOE:  Receive FIFO empty interrupt
00489   *            @arg SDMMC_IT_SDIOIT:   SD I/O interrupt received interrupt
00490   *            @arg SDMMC_IT_DATAEND:    Data end (data counter, DATACOUNT, is zero) interrupt
00491   *            @arg SDMMC_IT_DHOLD:      Data transfer Hold interrupt
00492   *            @arg SDMMC_IT_DABORT:     Data transfer aborted by CMD12 interrupt
00493   *            @arg SDMMC_IT_BUSYD0END:  End of SDMMC_D0 Busy following a CMD response detected interrupt
00494   *            @arg SDMMC_IT_ACKFAIL:    Boot Acknowledgment received interrupt
00495   *            @arg SDMMC_IT_ACKTIMEOUT: Boot Acknowledgment timeout interrupt
00496   *            @arg SDMMC_IT_VSWEND:     Voltage switch critical timing section completion interrupt
00497   *            @arg SDMMC_IT_CKSTOP:     SDMMC_CK stopped in Voltage switch procedure interrupt
00498   *            @arg SDMMC_IT_IDMABTC:    IDMA buffer transfer complete interrupt
00499   *            @arg SDMMC_IT_DATAEND:  Data end (data counter, SDIDCOUNT, is zero) interrupt
00500   *            @arg SDMMC_IT_CMDACT:   Command transfer in progress interrupt
00501   *            @arg SDMMC_IT_TXACT:    Data transmit in progress interrupt
00502   *            @arg SDMMC_IT_RXACT:    Data receive in progress interrupt
00503   *            @arg SDMMC_IT_TXDAVL:   Data available in transmit FIFO interrupt
00504   *            @arg SDMMC_IT_RXDAVL:   Data available in receive FIFO interrupt
00505   * @retval None
00506   */
00507 #define __HAL_SD_ENABLE_IT(__HANDLE__, __INTERRUPT__) __SDMMC_ENABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__))
00508 
00509 /**
00510   * @brief  Disable the SD device interrupt.
00511   * @param  __HANDLE__: SD Handle   
00512   * @param  __INTERRUPT__: specifies the SDMMC interrupt sources to be disabled.
00513   *          This parameter can be one or a combination of the following values:
00514   *            @arg SDMMC_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
00515   *            @arg SDMMC_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
00516   *            @arg SDMMC_IT_CTIMEOUT: Command response timeout interrupt
00517   *            @arg SDMMC_IT_DTIMEOUT: Data timeout interrupt
00518   *            @arg SDMMC_IT_TXUNDERR: Transmit FIFO underrun error interrupt
00519   *            @arg SDMMC_IT_RXOVERR:  Received FIFO overrun error interrupt
00520   *            @arg SDMMC_IT_CMDREND:  Command response received (CRC check passed) interrupt
00521   *            @arg SDMMC_IT_CMDSENT:  Command sent (no response required) interrupt
00522   *            @arg SDMMC_IT_DBCKEND:  Data block sent/received (CRC check passed) interrupt
00523   *            @arg SDMMC_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
00524   *            @arg SDMMC_IT_RXFIFOHF: Receive FIFO Half Full interrupt
00525   *            @arg SDMMC_IT_TXFIFOF:  Transmit FIFO full interrupt
00526   *            @arg SDMMC_IT_RXFIFOF:  Receive FIFO full interrupt
00527   *            @arg SDMMC_IT_TXFIFOE:  Transmit FIFO empty interrupt
00528   *            @arg SDMMC_IT_RXFIFOE:  Receive FIFO empty interrupt
00529   *            @arg SDMMC_IT_SDIOIT:   SD I/O interrupt received interrupt
00530   *            @arg SDMMC_IT_DATAEND:    Data end (data counter, DATACOUNT, is zero) interrupt
00531   *            @arg SDMMC_IT_DHOLD:      Data transfer Hold interrupt
00532   *            @arg SDMMC_IT_DABORT:     Data transfer aborted by CMD12 interrupt
00533   *            @arg SDMMC_IT_BUSYD0END:  End of SDMMC_D0 Busy following a CMD response detected interrupt
00534   *            @arg SDMMC_IT_ACKFAIL:    Boot Acknowledgment received interrupt
00535   *            @arg SDMMC_IT_ACKTIMEOUT: Boot Acknowledgment timeout interrupt
00536   *            @arg SDMMC_IT_VSWEND:     Voltage switch critical timing section completion interrupt
00537   *            @arg SDMMC_IT_CKSTOP:     SDMMC_CK stopped in Voltage switch procedure interrupt
00538   *            @arg SDMMC_IT_IDMABTC:    IDMA buffer transfer complete interrupt
00539   *            @arg SDMMC_IT_DATAEND:  Data end (data counter, SDIDCOUNT, is zero) interrupt
00540   *            @arg SDMMC_IT_CMDACT:   Command transfer in progress interrupt
00541   *            @arg SDMMC_IT_TXACT:    Data transmit in progress interrupt
00542   *            @arg SDMMC_IT_RXACT:    Data receive in progress interrupt
00543   *            @arg SDMMC_IT_TXDAVL:   Data available in transmit FIFO interrupt
00544   *            @arg SDMMC_IT_RXDAVL:   Data available in receive FIFO interrupt
00545   * @retval None
00546   */
00547 #define __HAL_SD_DISABLE_IT(__HANDLE__, __INTERRUPT__) __SDMMC_DISABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__))
00548 
00549 /**
00550   * @brief  Check whether the specified SD flag is set or not. 
00551   * @param  __HANDLE__: SD Handle   
00552   * @param  __FLAG__: specifies the flag to check. 
00553   *          This parameter can be one of the following values:
00554   *            @arg SDMMC_FLAG_CCRCFAIL: Command response received (CRC check failed)
00555   *            @arg SDMMC_FLAG_DCRCFAIL: Data block sent/received (CRC check failed)
00556   *            @arg SDMMC_FLAG_CTIMEOUT: Command response timeout
00557   *            @arg SDMMC_FLAG_DTIMEOUT: Data timeout
00558   *            @arg SDMMC_FLAG_TXUNDERR: Transmit FIFO underrun error
00559   *            @arg SDMMC_FLAG_RXOVERR:  Received FIFO overrun error
00560   *            @arg SDMMC_FLAG_CMDREND:  Command response received (CRC check passed)
00561   *            @arg SDMMC_FLAG_CMDSENT:  Command sent (no response required)
00562   *            @arg SDMMC_FLAG_DBCKEND:  Data block sent/received (CRC check passed)
00563   *            @arg SDMMC_FLAG_CMDACT:   Command transfer in progress
00564   *            @arg SDMMC_FLAG_TXFIFOHE: Transmit FIFO Half Empty
00565   *            @arg SDMMC_FLAG_RXFIFOHF: Receive FIFO Half Full
00566   *            @arg SDMMC_FLAG_TXFIFOF:  Transmit FIFO full
00567   *            @arg SDMMC_FLAG_RXFIFOF:  Receive FIFO full
00568   *            @arg SDMMC_FLAG_TXFIFOE:  Transmit FIFO empty
00569   *            @arg SDMMC_FLAG_RXFIFOE:  Receive FIFO empty
00570   *            @arg SDMMC_FLAG_SDIOIT:   SD I/O interrupt received
00571   *            @arg SDMMC_FLAG_DATAEND:    Data end (data counter, DATACOUNT, is zero)
00572   *            @arg SDMMC_FLAG_DHOLD:      Data transfer Hold
00573   *            @arg SDMMC_FLAG_DABORT:     Data transfer aborted by CMD12
00574   *            @arg SDMMC_FLAG_CPSMACT:    Command path state machine active
00575   *            @arg SDMMC_FLAG_DPSMACT:    Data path state machine active
00576   *            @arg SDMMC_FLAG_BUSYD0:     Inverted value of SDMMC_D0 line (Busy)
00577   *            @arg SDMMC_FLAG_BUSYD0END:  End of SDMMC_D0 Busy following a CMD response detected
00578   *            @arg SDMMC_FLAG_ACKFAIL:    Boot Acknowledgment received
00579   *            @arg SDMMC_FLAG_ACKTIMEOUT: Boot Acknowledgment timeout
00580   *            @arg SDMMC_FLAG_VSWEND:     Voltage switch critical timing section completion
00581   *            @arg SDMMC_FLAG_CKSTOP:     SDMMC_CK stopped in Voltage switch procedure
00582   *            @arg SDMMC_FLAG_IDMATE:     IDMA transfer error
00583   *            @arg SDMMC_FLAG_IDMABTC:    IDMA buffer transfer complete
00584   *            @arg SDMMC_FLAG_DATAEND:  Data end (data counter, SDIDCOUNT, is zero)
00585   *            @arg SDMMC_FLAG_TXACT:    Data transmit in progress
00586   *            @arg SDMMC_FLAG_RXACT:    Data receive in progress
00587   *            @arg SDMMC_FLAG_TXDAVL:   Data available in transmit FIFO
00588   *            @arg SDMMC_FLAG_RXDAVL:   Data available in receive FIFO
00589   * @retval The new state of SD FLAG (SET or RESET).
00590   */
00591 #define __HAL_SD_GET_FLAG(__HANDLE__, __FLAG__) __SDMMC_GET_FLAG((__HANDLE__)->Instance, (__FLAG__))
00592 
00593 /**
00594   * @brief  Clear the SD's pending flags.
00595   * @param  __HANDLE__: SD Handle  
00596   * @param  __FLAG__: specifies the flag to clear.  
00597   *          This parameter can be one or a combination of the following values:
00598   *            @arg SDMMC_FLAG_CCRCFAIL: Command response received (CRC check failed)
00599   *            @arg SDMMC_FLAG_DCRCFAIL: Data block sent/received (CRC check failed)
00600   *            @arg SDMMC_FLAG_CTIMEOUT: Command response timeout
00601   *            @arg SDMMC_FLAG_DTIMEOUT: Data timeout
00602   *            @arg SDMMC_FLAG_TXUNDERR: Transmit FIFO underrun error
00603   *            @arg SDMMC_FLAG_RXOVERR:  Received FIFO overrun error
00604   *            @arg SDMMC_FLAG_CMDREND:  Command response received (CRC check passed)
00605   *            @arg SDMMC_FLAG_CMDSENT:  Command sent (no response required)
00606   *            @arg SDMMC_FLAG_DBCKEND:  Data block sent/received (CRC check passed)
00607   *            @arg SDMMC_FLAG_SDIOIT:   SD I/O interrupt received
00608   *            @arg SDMMC_FLAG_DATAEND:    Data end (data counter, DATACOUNT, is zero)
00609   *            @arg SDMMC_FLAG_DHOLD:      Data transfer Hold
00610   *            @arg SDMMC_FLAG_DABORT:     Data transfer aborted by CMD12
00611   *            @arg SDMMC_FLAG_BUSYD0END:  End of SDMMC_D0 Busy following a CMD response detected
00612   *            @arg SDMMC_FLAG_ACKFAIL:    Boot Acknowledgment received
00613   *            @arg SDMMC_FLAG_ACKTIMEOUT: Boot Acknowledgment timeout
00614   *            @arg SDMMC_FLAG_VSWEND:     Voltage switch critical timing section completion
00615   *            @arg SDMMC_FLAG_CKSTOP:     SDMMC_CK stopped in Voltage switch procedure
00616   *            @arg SDMMC_FLAG_IDMATE:     IDMA transfer error
00617   *            @arg SDMMC_FLAG_IDMABTC:    IDMA buffer transfer complete
00618   *            @arg SDMMC_FLAG_DATAEND:  Data end (data counter, SDIDCOUNT, is zero)
00619   * @retval None
00620   */
00621 #define __HAL_SD_CLEAR_FLAG(__HANDLE__, __FLAG__) __SDMMC_CLEAR_FLAG((__HANDLE__)->Instance, (__FLAG__))
00622 
00623 /**
00624   * @brief  Check whether the specified SD interrupt has occurred or not.
00625   * @param  __HANDLE__: SD Handle   
00626   * @param  __INTERRUPT__: specifies the SDMMC interrupt source to check. 
00627   *          This parameter can be one of the following values:
00628   *            @arg SDMMC_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
00629   *            @arg SDMMC_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
00630   *            @arg SDMMC_IT_CTIMEOUT: Command response timeout interrupt
00631   *            @arg SDMMC_IT_DTIMEOUT: Data timeout interrupt
00632   *            @arg SDMMC_IT_TXUNDERR: Transmit FIFO underrun error interrupt
00633   *            @arg SDMMC_IT_RXOVERR:  Received FIFO overrun error interrupt
00634   *            @arg SDMMC_IT_CMDREND:  Command response received (CRC check passed) interrupt
00635   *            @arg SDMMC_IT_CMDSENT:  Command sent (no response required) interrupt
00636   *            @arg SDMMC_IT_DBCKEND:  Data block sent/received (CRC check passed) interrupt
00637   *            @arg SDMMC_IT_CMDACT:   Command transfer in progress interrupt
00638   *            @arg SDMMC_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
00639   *            @arg SDMMC_IT_RXFIFOHF: Receive FIFO Half Full interrupt
00640   *            @arg SDMMC_IT_TXFIFOF:  Transmit FIFO full interrupt
00641   *            @arg SDMMC_IT_RXFIFOF:  Receive FIFO full interrupt
00642   *            @arg SDMMC_IT_TXFIFOE:  Transmit FIFO empty interrupt
00643   *            @arg SDMMC_IT_RXFIFOE:  Receive FIFO empty interrupt
00644   *            @arg SDMMC_IT_SDIOIT:   SD I/O interrupt received interrupt
00645   *            @arg SDMMC_IT_DATAEND:    Data end (data counter, DATACOUNT, is zero) interrupt
00646   *            @arg SDMMC_IT_DHOLD:      Data transfer Hold interrupt
00647   *            @arg SDMMC_IT_DABORT:     Data transfer aborted by CMD12 interrupt
00648   *            @arg SDMMC_IT_DPSMACT:    Data path state machine active interrupt
00649   *            @arg SDMMC_IT_CPSMACT:    Command path state machine active interrupt
00650   *            @arg SDMMC_IT_BUSYD0:     Inverted value of SDMMC_D0 line (Busy)
00651   *            @arg SDMMC_IT_BUSYD0END:  End of SDMMC_D0 Busy following a CMD response detected interrupt
00652   *            @arg SDMMC_IT_ACKFAIL:    Boot Acknowledgment received interrupt
00653   *            @arg SDMMC_IT_ACKTIMEOUT: Boot Acknowledgment timeout interrupt
00654   *            @arg SDMMC_IT_VSWEND:     Voltage switch critical timing section completion interrupt
00655   *            @arg SDMMC_IT_CKSTOP:     SDMMC_CK stopped in Voltage switch procedure interrupt
00656   *            @arg SDMMC_IT_IDMATE:     IDMA transfer error interrupt
00657   *            @arg SDMMC_IT_IDMABTC:    IDMA buffer transfer complete interrupt
00658   *            @arg SDMMC_IT_DATAEND:  Data end (data counter, SDIDCOUNT, is zero) interrupt
00659   *            @arg SDMMC_IT_TXACT:    Data transmit in progress interrupt
00660   *            @arg SDMMC_IT_RXACT:    Data receive in progress interrupt
00661   *            @arg SDMMC_IT_TXDAVL:   Data available in transmit FIFO interrupt
00662   *            @arg SDMMC_IT_RXDAVL:   Data available in receive FIFO interrupt
00663   * @retval The new state of SD IT (SET or RESET).
00664   */
00665 #define __HAL_SD_GET_IT(__HANDLE__, __INTERRUPT__) __SDMMC_GET_IT((__HANDLE__)->Instance, (__INTERRUPT__))
00666 
00667 /**
00668   * @brief  Clear the SD's interrupt pending bits.
00669   * @param  __HANDLE__: SD Handle
00670   * @param  __INTERRUPT__: specifies the interrupt pending bit to clear. 
00671   *          This parameter can be one or a combination of the following values:
00672   *            @arg SDMMC_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
00673   *            @arg SDMMC_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
00674   *            @arg SDMMC_IT_CTIMEOUT: Command response timeout interrupt
00675   *            @arg SDMMC_IT_DTIMEOUT: Data timeout interrupt
00676   *            @arg SDMMC_IT_TXUNDERR: Transmit FIFO underrun error interrupt
00677   *            @arg SDMMC_IT_RXOVERR:  Received FIFO overrun error interrupt
00678   *            @arg SDMMC_IT_CMDREND:  Command response received (CRC check passed) interrupt
00679   *            @arg SDMMC_IT_CMDSENT:  Command sent (no response required) interrupt
00680   *            @arg SDMMC_IT_SDIOIT:   SD I/O interrupt received interrupt
00681   *            @arg SDMMC_IT_DATAEND:    Data end (data counter, DATACOUNT, is zero) interrupt
00682   *            @arg SDMMC_IT_DHOLD:      Data transfer Hold interrupt
00683   *            @arg SDMMC_IT_DBCKEND:    Data block sent/received (CRC check passed) interrupt
00684   *            @arg SDMMC_IT_DABORT:     Data transfer aborted by CMD12 interrupt
00685   *            @arg SDMMC_IT_BUSYD0END:  End of SDMMC_D0 Busy following a CMD response detected interrupt
00686   *            @arg SDMMC_IT_ACKFAIL:    Boot Acknowledgment received interrupt
00687   *            @arg SDMMC_IT_ACKTIMEOUT: Boot Acknowledgment timeout interrupt
00688   *            @arg SDMMC_IT_VSWEND:     Voltage switch critical timing section completion interrupt
00689   *            @arg SDMMC_IT_CKSTOP:     SDMMC_CK stopped in Voltage switch procedure interrupt
00690   *            @arg SDMMC_IT_IDMATE:     IDMA transfer error interrupt
00691   *            @arg SDMMC_IT_IDMABTC:    IDMA buffer transfer complete interrupt
00692   *            @arg SDMMC_IT_DATAEND:  Data end (data counter, SDMMC_DCOUNT, is zero) interrupt
00693   * @retval None
00694   */
00695 #define __HAL_SD_CLEAR_IT(__HANDLE__, __INTERRUPT__) __SDMMC_CLEAR_IT((__HANDLE__)->Instance, (__INTERRUPT__))
00696 
00697 /**
00698   * @}
00699   */
00700   
00701 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
00702 /* Include SD HAL Extension module */
00703 #include "stm32l4xx_hal_sd_ex.h"
00704 #endif /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
00705 /* Exported functions --------------------------------------------------------*/
00706 /** @defgroup SD_Exported_Functions SD Exported Functions
00707   * @{
00708   */
00709   
00710 /** @defgroup SD_Exported_Functions_Group1 Initialization and de-initialization functions
00711   * @{
00712   */
00713 HAL_StatusTypeDef HAL_SD_Init     (SD_HandleTypeDef *hsd);
00714 HAL_StatusTypeDef HAL_SD_InitCard (SD_HandleTypeDef *hsd);
00715 HAL_StatusTypeDef HAL_SD_DeInit   (SD_HandleTypeDef *hsd);
00716 void              HAL_SD_MspInit  (SD_HandleTypeDef *hsd);
00717 void              HAL_SD_MspDeInit(SD_HandleTypeDef *hsd);
00718 /**
00719   * @}
00720   */
00721   
00722 /** @defgroup SD_Exported_Functions_Group2 Input and Output operation functions
00723   * @{
00724   */
00725 /* Blocking mode: Polling */
00726 HAL_StatusTypeDef HAL_SD_ReadBlocks     (SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout);
00727 HAL_StatusTypeDef HAL_SD_WriteBlocks    (SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout);
00728 HAL_StatusTypeDef HAL_SD_Erase          (SD_HandleTypeDef *hsd, uint32_t BlockStartAdd, uint32_t BlockEndAdd);
00729 /* Non-Blocking mode: IT */
00730 HAL_StatusTypeDef HAL_SD_ReadBlocks_IT  (SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks);
00731 HAL_StatusTypeDef HAL_SD_WriteBlocks_IT (SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks);
00732 /* Non-Blocking mode: DMA */
00733 HAL_StatusTypeDef HAL_SD_ReadBlocks_DMA (SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks);
00734 HAL_StatusTypeDef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks);
00735 
00736 void              HAL_SD_IRQHandler     (SD_HandleTypeDef *hsd);
00737 
00738 /* Callback in non blocking modes (DMA) */
00739 void              HAL_SD_TxCpltCallback (SD_HandleTypeDef *hsd);
00740 void              HAL_SD_RxCpltCallback (SD_HandleTypeDef *hsd);
00741 void              HAL_SD_ErrorCallback  (SD_HandleTypeDef *hsd);
00742 void              HAL_SD_AbortCallback  (SD_HandleTypeDef *hsd);
00743 
00744 #if (USE_HAL_SD_REGISTER_CALLBACKS == 1)
00745 /* SD callback registering/unregistering */
00746 HAL_StatusTypeDef HAL_SD_RegisterCallback  (SD_HandleTypeDef *hsd, HAL_SD_CallbackIDTypeDef CallbackID, pSD_CallbackTypeDef pCallback);
00747 HAL_StatusTypeDef HAL_SD_UnRegisterCallback(SD_HandleTypeDef *hsd, HAL_SD_CallbackIDTypeDef CallbackID);
00748 
00749 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
00750 HAL_StatusTypeDef HAL_SD_RegisterTransceiverCallback  (SD_HandleTypeDef *hsd, pSD_TransceiverCallbackTypeDef pCallback);
00751 HAL_StatusTypeDef HAL_SD_UnRegisterTransceiverCallback(SD_HandleTypeDef *hsd);
00752 #endif
00753 #endif
00754 
00755 /**
00756   * @}
00757   */
00758   
00759 /** @defgroup SD_Exported_Functions_Group3 Peripheral Control functions
00760   * @{
00761   */
00762 HAL_StatusTypeDef HAL_SD_ConfigWideBusOperation(SD_HandleTypeDef *hsd, uint32_t WideMode);
00763 /**
00764   * @}
00765   */
00766   
00767 /** @defgroup SD_Exported_Functions_Group4 SD card related functions
00768   * @{
00769   */
00770 HAL_StatusTypeDef       HAL_SD_SendSDStatus (SD_HandleTypeDef *hsd, uint32_t *pSDstatus);
00771 HAL_SD_CardStateTypedef HAL_SD_GetCardState (SD_HandleTypeDef *hsd);
00772 HAL_StatusTypeDef       HAL_SD_GetCardCID   (SD_HandleTypeDef *hsd, HAL_SD_CardCIDTypedef *pCID);
00773 HAL_StatusTypeDef       HAL_SD_GetCardCSD   (SD_HandleTypeDef *hsd, HAL_SD_CardCSDTypedef *pCSD);
00774 HAL_StatusTypeDef       HAL_SD_GetCardStatus(SD_HandleTypeDef *hsd, HAL_SD_CardStatusTypedef *pStatus);
00775 HAL_StatusTypeDef       HAL_SD_GetCardInfo  (SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypeDef *pCardInfo);
00776 /**
00777   * @}
00778   */
00779 
00780 /** @defgroup SD_Exported_Functions_Group5 Peripheral State and Errors functions
00781   * @{
00782   */
00783 HAL_SD_StateTypeDef HAL_SD_GetState(SD_HandleTypeDef *hsd);
00784 uint32_t            HAL_SD_GetError(SD_HandleTypeDef *hsd);
00785 /**
00786   * @}
00787   */
00788   
00789 /** @defgroup SD_Exported_Functions_Group6 Perioheral Abort management
00790   * @{
00791   */
00792 HAL_StatusTypeDef HAL_SD_Abort   (SD_HandleTypeDef *hsd);
00793 HAL_StatusTypeDef HAL_SD_Abort_IT(SD_HandleTypeDef *hsd);
00794 /**
00795   * @}
00796   */
00797     
00798 /* Private types -------------------------------------------------------------*/
00799 /** @defgroup SD_Private_Types SD Private Types
00800   * @{
00801   */
00802 
00803 /**
00804   * @}
00805   */ 
00806 
00807 /* Private defines -----------------------------------------------------------*/
00808 /** @defgroup SD_Private_Defines SD Private Defines
00809   * @{
00810   */
00811 
00812 /**
00813   * @}
00814   */ 
00815           
00816 /* Private variables ---------------------------------------------------------*/
00817 /** @defgroup SD_Private_Variables SD Private Variables
00818   * @{
00819   */
00820 
00821 /**
00822   * @}
00823   */ 
00824 
00825 /* Private constants ---------------------------------------------------------*/
00826 /** @defgroup SD_Private_Constants SD Private Constants
00827   * @{
00828   */
00829 
00830 /**
00831   * @}
00832   */ 
00833 
00834 /* Private macros ------------------------------------------------------------*/
00835 /** @defgroup SD_Private_Macros SD Private Macros
00836   * @{
00837   */
00838 
00839 /**
00840   * @}
00841   */
00842 
00843 /* Private functions prototypes ----------------------------------------------*/
00844 /** @defgroup SD_Private_Functions_Prototypes SD Private Functions Prototypes
00845   * @{
00846   */
00847 
00848 /**
00849   * @}
00850   */
00851 
00852 /* Private functions ---------------------------------------------------------*/
00853 /** @defgroup SD_Private_Functions SD Private Functions
00854   * @{
00855   */
00856 
00857 /**
00858   * @}
00859   */
00860 
00861 
00862 /**
00863   * @}
00864   */ 
00865 
00866 /**
00867   * @}
00868   */ 
00869 
00870 /**
00871   * @}
00872   */
00873 
00874 #endif /* SDMMC1 */
00875 
00876 #ifdef __cplusplus
00877 }
00878 #endif
00879 
00880 
00881 #endif /* STM32L4xx_HAL_SD_H */ 
00882 
00883 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/