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