STM32F479xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f4xx_hal_sd.h 00004 * @author MCD Application Team 00005 * @brief Header file of SD HAL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * <h2><center>© Copyright (c) 2017 STMicroelectronics. 00010 * All rights reserved.</center></h2> 00011 * 00012 * This software component is licensed by ST under BSD 3-Clause license, 00013 * the "License"; You may not use this file except in compliance with the 00014 * License. You may obtain a copy of the License at: 00015 * opensource.org/licenses/BSD-3-Clause 00016 * 00017 ****************************************************************************** 00018 */ 00019 00020 /* Define to prevent recursive inclusion -------------------------------------*/ 00021 #ifndef STM32F4xx_HAL_SD_H 00022 #define STM32F4xx_HAL_SD_H 00023 00024 #ifdef __cplusplus 00025 extern "C" { 00026 #endif 00027 00028 #if defined(SDIO) 00029 00030 /* Includes ------------------------------------------------------------------*/ 00031 #include "stm32f4xx_ll_sdmmc.h" 00032 00033 /** @addtogroup STM32F4xx_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 = 0x00000000U, /*!< SD not yet initialized or disabled */ 00053 HAL_SD_STATE_READY = 0x00000001U, /*!< SD initialized and ready for use */ 00054 HAL_SD_STATE_TIMEOUT = 0x00000002U, /*!< SD Timeout state */ 00055 HAL_SD_STATE_BUSY = 0x00000003U, /*!< SD process ongoing */ 00056 HAL_SD_STATE_PROGRAMMING = 0x00000004U, /*!< SD Programming State */ 00057 HAL_SD_STATE_RECEIVING = 0x00000005U, /*!< SD Receiving State */ 00058 HAL_SD_STATE_TRANSFER = 0x00000006U, /*!< SD Transfer State */ 00059 HAL_SD_STATE_ERROR = 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 SDIO_InitTypeDef 00087 #define SD_TypeDef SDIO_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 }HAL_SD_CardInfoTypeDef; 00111 00112 /** 00113 * @brief SD handle Structure definition 00114 */ 00115 #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) 00116 typedef struct __SD_HandleTypeDef 00117 #else 00118 typedef struct 00119 #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ 00120 { 00121 SD_TypeDef *Instance; /*!< SD registers base address */ 00122 00123 SD_InitTypeDef Init; /*!< SD required parameters */ 00124 00125 HAL_LockTypeDef Lock; /*!< SD locking object */ 00126 00127 uint8_t *pTxBuffPtr; /*!< Pointer to SD Tx transfer Buffer */ 00128 00129 uint32_t TxXferSize; /*!< SD Tx Transfer size */ 00130 00131 uint8_t *pRxBuffPtr; /*!< Pointer to SD Rx transfer Buffer */ 00132 00133 uint32_t RxXferSize; /*!< SD Rx Transfer size */ 00134 00135 __IO uint32_t Context; /*!< SD transfer context */ 00136 00137 __IO HAL_SD_StateTypeDef State; /*!< SD card State */ 00138 00139 __IO uint32_t ErrorCode; /*!< SD Card Error codes */ 00140 00141 DMA_HandleTypeDef *hdmatx; /*!< SD Tx DMA handle parameters */ 00142 00143 DMA_HandleTypeDef *hdmarx; /*!< SD Rx DMA handle parameters */ 00144 00145 HAL_SD_CardInfoTypeDef SdCard; /*!< SD Card information */ 00146 00147 uint32_t CSD[4]; /*!< SD card specific data table */ 00148 00149 uint32_t CID[4]; /*!< SD card identification number table */ 00150 00151 #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) 00152 void (* TxCpltCallback) (struct __SD_HandleTypeDef *hsd); 00153 void (* RxCpltCallback) (struct __SD_HandleTypeDef *hsd); 00154 void (* ErrorCallback) (struct __SD_HandleTypeDef *hsd); 00155 void (* AbortCpltCallback) (struct __SD_HandleTypeDef *hsd); 00156 00157 void (* MspInitCallback) (struct __SD_HandleTypeDef *hsd); 00158 void (* MspDeInitCallback) (struct __SD_HandleTypeDef *hsd); 00159 #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ 00160 }SD_HandleTypeDef; 00161 00162 /** 00163 * @} 00164 */ 00165 00166 /** @defgroup SD_Exported_Types_Group4 Card Specific Data: CSD Register 00167 * @{ 00168 */ 00169 typedef struct 00170 { 00171 __IO uint8_t CSDStruct; /*!< CSD structure */ 00172 __IO uint8_t SysSpecVersion; /*!< System specification version */ 00173 __IO uint8_t Reserved1; /*!< Reserved */ 00174 __IO uint8_t TAAC; /*!< Data read access time 1 */ 00175 __IO uint8_t NSAC; /*!< Data read access time 2 in CLK cycles */ 00176 __IO uint8_t MaxBusClkFrec; /*!< Max. bus clock frequency */ 00177 __IO uint16_t CardComdClasses; /*!< Card command classes */ 00178 __IO uint8_t RdBlockLen; /*!< Max. read data block length */ 00179 __IO uint8_t PartBlockRead; /*!< Partial blocks for read allowed */ 00180 __IO uint8_t WrBlockMisalign; /*!< Write block misalignment */ 00181 __IO uint8_t RdBlockMisalign; /*!< Read block misalignment */ 00182 __IO uint8_t DSRImpl; /*!< DSR implemented */ 00183 __IO uint8_t Reserved2; /*!< Reserved */ 00184 __IO uint32_t DeviceSize; /*!< Device Size */ 00185 __IO uint8_t MaxRdCurrentVDDMin; /*!< Max. read current @ VDD min */ 00186 __IO uint8_t MaxRdCurrentVDDMax; /*!< Max. read current @ VDD max */ 00187 __IO uint8_t MaxWrCurrentVDDMin; /*!< Max. write current @ VDD min */ 00188 __IO uint8_t MaxWrCurrentVDDMax; /*!< Max. write current @ VDD max */ 00189 __IO uint8_t DeviceSizeMul; /*!< Device size multiplier */ 00190 __IO uint8_t EraseGrSize; /*!< Erase group size */ 00191 __IO uint8_t EraseGrMul; /*!< Erase group size multiplier */ 00192 __IO uint8_t WrProtectGrSize; /*!< Write protect group size */ 00193 __IO uint8_t WrProtectGrEnable; /*!< Write protect group enable */ 00194 __IO uint8_t ManDeflECC; /*!< Manufacturer default ECC */ 00195 __IO uint8_t WrSpeedFact; /*!< Write speed factor */ 00196 __IO uint8_t MaxWrBlockLen; /*!< Max. write data block length */ 00197 __IO uint8_t WriteBlockPaPartial; /*!< Partial blocks for write allowed */ 00198 __IO uint8_t Reserved3; /*!< Reserved */ 00199 __IO uint8_t ContentProtectAppli; /*!< Content protection application */ 00200 __IO uint8_t FileFormatGroup; /*!< File format group */ 00201 __IO uint8_t CopyFlag; /*!< Copy flag (OTP) */ 00202 __IO uint8_t PermWrProtect; /*!< Permanent write protection */ 00203 __IO uint8_t TempWrProtect; /*!< Temporary write protection */ 00204 __IO uint8_t FileFormat; /*!< File format */ 00205 __IO uint8_t ECC; /*!< ECC code */ 00206 __IO uint8_t CSD_CRC; /*!< CSD CRC */ 00207 __IO uint8_t Reserved4; /*!< Always 1 */ 00208 }HAL_SD_CardCSDTypeDef; 00209 /** 00210 * @} 00211 */ 00212 00213 /** @defgroup SD_Exported_Types_Group5 Card Identification Data: CID Register 00214 * @{ 00215 */ 00216 typedef struct 00217 { 00218 __IO uint8_t ManufacturerID; /*!< Manufacturer ID */ 00219 __IO uint16_t OEM_AppliID; /*!< OEM/Application ID */ 00220 __IO uint32_t ProdName1; /*!< Product Name part1 */ 00221 __IO uint8_t ProdName2; /*!< Product Name part2 */ 00222 __IO uint8_t ProdRev; /*!< Product Revision */ 00223 __IO uint32_t ProdSN; /*!< Product Serial Number */ 00224 __IO uint8_t Reserved1; /*!< Reserved1 */ 00225 __IO uint16_t ManufactDate; /*!< Manufacturing Date */ 00226 __IO uint8_t CID_CRC; /*!< CID CRC */ 00227 __IO uint8_t Reserved2; /*!< Always 1 */ 00228 00229 }HAL_SD_CardCIDTypeDef; 00230 /** 00231 * @} 00232 */ 00233 00234 /** @defgroup SD_Exported_Types_Group6 SD Card Status returned by ACMD13 00235 * @{ 00236 */ 00237 typedef struct 00238 { 00239 __IO uint8_t DataBusWidth; /*!< Shows the currently defined data bus width */ 00240 __IO uint8_t SecuredMode; /*!< Card is in secured mode of operation */ 00241 __IO uint16_t CardType; /*!< Carries information about card type */ 00242 __IO uint32_t ProtectedAreaSize; /*!< Carries information about the capacity of protected area */ 00243 __IO uint8_t SpeedClass; /*!< Carries information about the speed class of the card */ 00244 __IO uint8_t PerformanceMove; /*!< Carries information about the card's performance move */ 00245 __IO uint8_t AllocationUnitSize; /*!< Carries information about the card's allocation unit size */ 00246 __IO uint16_t EraseSize; /*!< Determines the number of AUs to be erased in one operation */ 00247 __IO uint8_t EraseTimeout; /*!< Determines the timeout for any number of AU erase */ 00248 __IO uint8_t EraseOffset; /*!< Carries information about the erase offset */ 00249 00250 }HAL_SD_CardStatusTypeDef; 00251 /** 00252 * @} 00253 */ 00254 00255 #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) 00256 /** @defgroup SD_Exported_Types_Group7 SD Callback ID enumeration definition 00257 * @{ 00258 */ 00259 typedef enum 00260 { 00261 HAL_SD_TX_CPLT_CB_ID = 0x00U, /*!< SD Tx Complete Callback ID */ 00262 HAL_SD_RX_CPLT_CB_ID = 0x01U, /*!< SD Rx Complete Callback ID */ 00263 HAL_SD_ERROR_CB_ID = 0x02U, /*!< SD Error Callback ID */ 00264 HAL_SD_ABORT_CB_ID = 0x03U, /*!< SD Abort Callback ID */ 00265 00266 HAL_SD_MSP_INIT_CB_ID = 0x10U, /*!< SD MspInit Callback ID */ 00267 HAL_SD_MSP_DEINIT_CB_ID = 0x11U /*!< SD MspDeInit Callback ID */ 00268 }HAL_SD_CallbackIDTypeDef; 00269 /** 00270 * @} 00271 */ 00272 00273 /** @defgroup SD_Exported_Types_Group8 SD Callback pointer definition 00274 * @{ 00275 */ 00276 typedef void (*pSD_CallbackTypeDef) (SD_HandleTypeDef *hsd); 00277 /** 00278 * @} 00279 */ 00280 #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ 00281 /** 00282 * @} 00283 */ 00284 00285 /* Exported constants --------------------------------------------------------*/ 00286 /** @defgroup SD_Exported_Constants Exported Constants 00287 * @{ 00288 */ 00289 00290 #define BLOCKSIZE 512U /*!< Block size is 512 bytes */ 00291 00292 /** @defgroup SD_Exported_Constansts_Group1 SD Error status enumeration Structure definition 00293 * @{ 00294 */ 00295 #define HAL_SD_ERROR_NONE SDMMC_ERROR_NONE /*!< No error */ 00296 #define HAL_SD_ERROR_CMD_CRC_FAIL SDMMC_ERROR_CMD_CRC_FAIL /*!< Command response received (but CRC check failed) */ 00297 #define HAL_SD_ERROR_DATA_CRC_FAIL SDMMC_ERROR_DATA_CRC_FAIL /*!< Data block sent/received (CRC check failed) */ 00298 #define HAL_SD_ERROR_CMD_RSP_TIMEOUT SDMMC_ERROR_CMD_RSP_TIMEOUT /*!< Command response timeout */ 00299 #define HAL_SD_ERROR_DATA_TIMEOUT SDMMC_ERROR_DATA_TIMEOUT /*!< Data timeout */ 00300 #define HAL_SD_ERROR_TX_UNDERRUN SDMMC_ERROR_TX_UNDERRUN /*!< Transmit FIFO underrun */ 00301 #define HAL_SD_ERROR_RX_OVERRUN SDMMC_ERROR_RX_OVERRUN /*!< Receive FIFO overrun */ 00302 #define HAL_SD_ERROR_ADDR_MISALIGNED SDMMC_ERROR_ADDR_MISALIGNED /*!< Misaligned address */ 00303 #define HAL_SD_ERROR_BLOCK_LEN_ERR SDMMC_ERROR_BLOCK_LEN_ERR /*!< Transferred block length is not allowed for the card or the 00304 number of transferred bytes does not match the block length */ 00305 #define HAL_SD_ERROR_ERASE_SEQ_ERR SDMMC_ERROR_ERASE_SEQ_ERR /*!< An error in the sequence of erase command occurs */ 00306 #define HAL_SD_ERROR_BAD_ERASE_PARAM SDMMC_ERROR_BAD_ERASE_PARAM /*!< An invalid selection for erase groups */ 00307 #define HAL_SD_ERROR_WRITE_PROT_VIOLATION SDMMC_ERROR_WRITE_PROT_VIOLATION /*!< Attempt to program a write protect block */ 00308 #define HAL_SD_ERROR_LOCK_UNLOCK_FAILED SDMMC_ERROR_LOCK_UNLOCK_FAILED /*!< Sequence or password error has been detected in unlock 00309 command or if there was an attempt to access a locked card */ 00310 #define HAL_SD_ERROR_COM_CRC_FAILED SDMMC_ERROR_COM_CRC_FAILED /*!< CRC check of the previous command failed */ 00311 #define HAL_SD_ERROR_ILLEGAL_CMD SDMMC_ERROR_ILLEGAL_CMD /*!< Command is not legal for the card state */ 00312 #define HAL_SD_ERROR_CARD_ECC_FAILED SDMMC_ERROR_CARD_ECC_FAILED /*!< Card internal ECC was applied but failed to correct the data */ 00313 #define HAL_SD_ERROR_CC_ERR SDMMC_ERROR_CC_ERR /*!< Internal card controller error */ 00314 #define HAL_SD_ERROR_GENERAL_UNKNOWN_ERR SDMMC_ERROR_GENERAL_UNKNOWN_ERR /*!< General or unknown error */ 00315 #define HAL_SD_ERROR_STREAM_READ_UNDERRUN SDMMC_ERROR_STREAM_READ_UNDERRUN /*!< The card could not sustain data reading in stream rmode */ 00316 #define HAL_SD_ERROR_STREAM_WRITE_OVERRUN SDMMC_ERROR_STREAM_WRITE_OVERRUN /*!< The card could not sustain data programming in stream mode */ 00317 #define HAL_SD_ERROR_CID_CSD_OVERWRITE SDMMC_ERROR_CID_CSD_OVERWRITE /*!< CID/CSD overwrite error */ 00318 #define HAL_SD_ERROR_WP_ERASE_SKIP SDMMC_ERROR_WP_ERASE_SKIP /*!< Only partial address space was erased */ 00319 #define HAL_SD_ERROR_CARD_ECC_DISABLED SDMMC_ERROR_CARD_ECC_DISABLED /*!< Command has been executed without using internal ECC */ 00320 #define HAL_SD_ERROR_ERASE_RESET SDMMC_ERROR_ERASE_RESET /*!< Erase sequence was cleared before executing because an out 00321 of erase sequence command was received */ 00322 #define HAL_SD_ERROR_AKE_SEQ_ERR SDMMC_ERROR_AKE_SEQ_ERR /*!< Error in sequence of authentication */ 00323 #define HAL_SD_ERROR_INVALID_VOLTRANGE SDMMC_ERROR_INVALID_VOLTRANGE /*!< Error in case of invalid voltage range */ 00324 #define HAL_SD_ERROR_ADDR_OUT_OF_RANGE SDMMC_ERROR_ADDR_OUT_OF_RANGE /*!< Error when addressed block is out of range */ 00325 #define HAL_SD_ERROR_REQUEST_NOT_APPLICABLE SDMMC_ERROR_REQUEST_NOT_APPLICABLE /*!< Error when command request is not applicable */ 00326 #define HAL_SD_ERROR_PARAM SDMMC_ERROR_INVALID_PARAMETER /*!< the used parameter is not valid */ 00327 #define HAL_SD_ERROR_UNSUPPORTED_FEATURE SDMMC_ERROR_UNSUPPORTED_FEATURE /*!< Error when feature is not insupported */ 00328 #define HAL_SD_ERROR_BUSY SDMMC_ERROR_BUSY /*!< Error when transfer process is busy */ 00329 #define HAL_SD_ERROR_DMA SDMMC_ERROR_DMA /*!< Error while DMA transfer */ 00330 #define HAL_SD_ERROR_TIMEOUT SDMMC_ERROR_TIMEOUT /*!< Timeout error */ 00331 00332 #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) 00333 #define HAL_SD_ERROR_INVALID_CALLBACK SDMMC_ERROR_INVALID_PARAMETER /*!< Invalid callback error */ 00334 #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ 00335 /** 00336 * @} 00337 */ 00338 00339 /** @defgroup SD_Exported_Constansts_Group2 SD context enumeration 00340 * @{ 00341 */ 00342 #define SD_CONTEXT_NONE 0x00000000U /*!< None */ 00343 #define SD_CONTEXT_READ_SINGLE_BLOCK 0x00000001U /*!< Read single block operation */ 00344 #define SD_CONTEXT_READ_MULTIPLE_BLOCK 0x00000002U /*!< Read multiple blocks operation */ 00345 #define SD_CONTEXT_WRITE_SINGLE_BLOCK 0x00000010U /*!< Write single block operation */ 00346 #define SD_CONTEXT_WRITE_MULTIPLE_BLOCK 0x00000020U /*!< Write multiple blocks operation */ 00347 #define SD_CONTEXT_IT 0x00000008U /*!< Process in Interrupt mode */ 00348 #define SD_CONTEXT_DMA 0x00000080U /*!< Process in DMA mode */ 00349 00350 /** 00351 * @} 00352 */ 00353 00354 /** @defgroup SD_Exported_Constansts_Group3 SD Supported Memory Cards 00355 * @{ 00356 */ 00357 #define CARD_SDSC 0x00000000U /*!< SD Standard Capacity <2Go */ 00358 #define CARD_SDHC_SDXC 0x00000001U /*!< SD High Capacity <32Go, SD Extended Capacity <2To */ 00359 #define CARD_SECURED 0x00000003U 00360 00361 /** 00362 * @} 00363 */ 00364 00365 /** @defgroup SD_Exported_Constansts_Group4 SD Supported Version 00366 * @{ 00367 */ 00368 #define CARD_V1_X 0x00000000U 00369 #define CARD_V2_X 0x00000001U 00370 /** 00371 * @} 00372 */ 00373 00374 /** 00375 * @} 00376 */ 00377 00378 /* Exported macro ------------------------------------------------------------*/ 00379 /** @defgroup SD_Exported_macros SD Exported Macros 00380 * @brief macros to handle interrupts and specific clock configurations 00381 * @{ 00382 */ 00383 /** @brief Reset SD handle state. 00384 * @param __HANDLE__ : SD handle. 00385 * @retval None 00386 */ 00387 #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) 00388 #define __HAL_SD_RESET_HANDLE_STATE(__HANDLE__) do { \ 00389 (__HANDLE__)->State = HAL_SD_STATE_RESET; \ 00390 (__HANDLE__)->MspInitCallback = NULL; \ 00391 (__HANDLE__)->MspDeInitCallback = NULL; \ 00392 } while(0) 00393 #else 00394 #define __HAL_SD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SD_STATE_RESET) 00395 #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ 00396 00397 /** 00398 * @brief Enable the SD device. 00399 * @retval None 00400 */ 00401 #define __HAL_SD_ENABLE(__HANDLE__) __SDIO_ENABLE((__HANDLE__)->Instance) 00402 00403 /** 00404 * @brief Disable the SD device. 00405 * @retval None 00406 */ 00407 #define __HAL_SD_DISABLE(__HANDLE__) __SDIO_DISABLE((__HANDLE__)->Instance) 00408 00409 /** 00410 * @brief Enable the SDMMC DMA transfer. 00411 * @retval None 00412 */ 00413 #define __HAL_SD_DMA_ENABLE(__HANDLE__) __SDIO_DMA_ENABLE((__HANDLE__)->Instance) 00414 00415 /** 00416 * @brief Disable the SDMMC DMA transfer. 00417 * @retval None 00418 */ 00419 #define __HAL_SD_DMA_DISABLE(__HANDLE__) __SDIO_DMA_DISABLE((__HANDLE__)->Instance) 00420 00421 /** 00422 * @brief Enable the SD device interrupt. 00423 * @param __HANDLE__: SD Handle 00424 * @param __INTERRUPT__: specifies the SDMMC interrupt sources to be enabled. 00425 * This parameter can be one or a combination of the following values: 00426 * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt 00427 * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt 00428 * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt 00429 * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt 00430 * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt 00431 * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt 00432 * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt 00433 * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt 00434 * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt 00435 * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt 00436 * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt 00437 * @arg SDIO_IT_TXACT: Data transmit in progress interrupt 00438 * @arg SDIO_IT_RXACT: Data receive in progress interrupt 00439 * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt 00440 * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt 00441 * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt 00442 * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt 00443 * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt 00444 * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt 00445 * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt 00446 * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt 00447 * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt 00448 * @retval None 00449 */ 00450 #define __HAL_SD_ENABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_ENABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__)) 00451 00452 /** 00453 * @brief Disable the SD device interrupt. 00454 * @param __HANDLE__: SD Handle 00455 * @param __INTERRUPT__: specifies the SDMMC interrupt sources to be disabled. 00456 * This parameter can be one or a combination of the following values: 00457 * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt 00458 * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt 00459 * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt 00460 * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt 00461 * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt 00462 * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt 00463 * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt 00464 * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt 00465 * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt 00466 * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt 00467 * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt 00468 * @arg SDIO_IT_TXACT: Data transmit in progress interrupt 00469 * @arg SDIO_IT_RXACT: Data receive in progress interrupt 00470 * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt 00471 * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt 00472 * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt 00473 * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt 00474 * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt 00475 * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt 00476 * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt 00477 * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt 00478 * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt 00479 * @retval None 00480 */ 00481 #define __HAL_SD_DISABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_DISABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__)) 00482 00483 /** 00484 * @brief Check whether the specified SD flag is set or not. 00485 * @param __HANDLE__: SD Handle 00486 * @param __FLAG__: specifies the flag to check. 00487 * This parameter can be one of the following values: 00488 * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) 00489 * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) 00490 * @arg SDIO_FLAG_CTIMEOUT: Command response timeout 00491 * @arg SDIO_FLAG_DTIMEOUT: Data timeout 00492 * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error 00493 * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error 00494 * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) 00495 * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) 00496 * @arg SDIO_FLAG_DATAEND: Data end (data counter, DATACOUNT, is zero) 00497 * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) 00498 * @arg SDIO_FLAG_CMDACT: Command transfer in progress 00499 * @arg SDIO_FLAG_TXACT: Data transmit in progress 00500 * @arg SDIO_FLAG_RXACT: Data receive in progress 00501 * @arg SDIO_FLAG_TXFIFOHE: Transmit FIFO Half Empty 00502 * @arg SDIO_FLAG_RXFIFOHF: Receive FIFO Half Full 00503 * @arg SDIO_FLAG_TXFIFOF: Transmit FIFO full 00504 * @arg SDIO_FLAG_RXFIFOF: Receive FIFO full 00505 * @arg SDIO_FLAG_TXFIFOE: Transmit FIFO empty 00506 * @arg SDIO_FLAG_RXFIFOE: Receive FIFO empty 00507 * @arg SDIO_FLAG_TXDAVL: Data available in transmit FIFO 00508 * @arg SDIO_FLAG_RXDAVL: Data available in receive FIFO 00509 * @arg SDIO_FLAG_SDIOIT: SDIO interrupt received 00510 * @retval The new state of SD FLAG (SET or RESET). 00511 */ 00512 #define __HAL_SD_GET_FLAG(__HANDLE__, __FLAG__) __SDIO_GET_FLAG((__HANDLE__)->Instance, (__FLAG__)) 00513 00514 /** 00515 * @brief Clear the SD's pending flags. 00516 * @param __HANDLE__: SD Handle 00517 * @param __FLAG__: specifies the flag to clear. 00518 * This parameter can be one or a combination of the following values: 00519 * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) 00520 * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) 00521 * @arg SDIO_FLAG_CTIMEOUT: Command response timeout 00522 * @arg SDIO_FLAG_DTIMEOUT: Data timeout 00523 * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error 00524 * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error 00525 * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) 00526 * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) 00527 * @arg SDIO_FLAG_DATAEND: Data end (data counter, DATACOUNT, is zero) 00528 * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) 00529 * @arg SDIO_FLAG_SDIOIT: SDIO interrupt received 00530 * @retval None 00531 */ 00532 #define __HAL_SD_CLEAR_FLAG(__HANDLE__, __FLAG__) __SDIO_CLEAR_FLAG((__HANDLE__)->Instance, (__FLAG__)) 00533 00534 /** 00535 * @brief Check whether the specified SD interrupt has occurred or not. 00536 * @param __HANDLE__: SD Handle 00537 * @param __INTERRUPT__: specifies the SDMMC interrupt source to check. 00538 * This parameter can be one of the following values: 00539 * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt 00540 * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt 00541 * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt 00542 * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt 00543 * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt 00544 * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt 00545 * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt 00546 * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt 00547 * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt 00548 * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt 00549 * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt 00550 * @arg SDIO_IT_TXACT: Data transmit in progress interrupt 00551 * @arg SDIO_IT_RXACT: Data receive in progress interrupt 00552 * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt 00553 * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt 00554 * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt 00555 * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt 00556 * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt 00557 * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt 00558 * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt 00559 * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt 00560 * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt 00561 * @retval The new state of SD IT (SET or RESET). 00562 */ 00563 #define __HAL_SD_GET_IT(__HANDLE__, __INTERRUPT__) __SDIO_GET_IT((__HANDLE__)->Instance, (__INTERRUPT__)) 00564 00565 /** 00566 * @brief Clear the SD's interrupt pending bits. 00567 * @param __HANDLE__: SD Handle 00568 * @param __INTERRUPT__: specifies the interrupt pending bit to clear. 00569 * This parameter can be one or a combination of the following values: 00570 * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt 00571 * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt 00572 * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt 00573 * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt 00574 * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt 00575 * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt 00576 * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt 00577 * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt 00578 * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt 00579 * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt 00580 * @retval None 00581 */ 00582 #define __HAL_SD_CLEAR_IT(__HANDLE__, __INTERRUPT__) __SDIO_CLEAR_IT((__HANDLE__)->Instance, (__INTERRUPT__)) 00583 00584 /** 00585 * @} 00586 */ 00587 00588 /* Exported functions --------------------------------------------------------*/ 00589 /** @defgroup SD_Exported_Functions SD Exported Functions 00590 * @{ 00591 */ 00592 00593 /** @defgroup SD_Exported_Functions_Group1 Initialization and de-initialization functions 00594 * @{ 00595 */ 00596 HAL_StatusTypeDef HAL_SD_Init(SD_HandleTypeDef *hsd); 00597 HAL_StatusTypeDef HAL_SD_InitCard(SD_HandleTypeDef *hsd); 00598 HAL_StatusTypeDef HAL_SD_DeInit (SD_HandleTypeDef *hsd); 00599 void HAL_SD_MspInit(SD_HandleTypeDef *hsd); 00600 void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd); 00601 /** 00602 * @} 00603 */ 00604 00605 /** @defgroup SD_Exported_Functions_Group2 Input and Output operation functions 00606 * @{ 00607 */ 00608 /* Blocking mode: Polling */ 00609 HAL_StatusTypeDef HAL_SD_ReadBlocks(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout); 00610 HAL_StatusTypeDef HAL_SD_WriteBlocks(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout); 00611 HAL_StatusTypeDef HAL_SD_Erase(SD_HandleTypeDef *hsd, uint32_t BlockStartAdd, uint32_t BlockEndAdd); 00612 /* Non-Blocking mode: IT */ 00613 HAL_StatusTypeDef HAL_SD_ReadBlocks_IT(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); 00614 HAL_StatusTypeDef HAL_SD_WriteBlocks_IT(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); 00615 /* Non-Blocking mode: DMA */ 00616 HAL_StatusTypeDef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); 00617 HAL_StatusTypeDef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); 00618 00619 void HAL_SD_IRQHandler(SD_HandleTypeDef *hsd); 00620 00621 /* Callback in non blocking modes (DMA) */ 00622 void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd); 00623 void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd); 00624 void HAL_SD_ErrorCallback(SD_HandleTypeDef *hsd); 00625 void HAL_SD_AbortCallback(SD_HandleTypeDef *hsd); 00626 00627 #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) 00628 /* SD callback registering/unregistering */ 00629 HAL_StatusTypeDef HAL_SD_RegisterCallback (SD_HandleTypeDef *hsd, HAL_SD_CallbackIDTypeDef CallbackId, pSD_CallbackTypeDef pCallback); 00630 HAL_StatusTypeDef HAL_SD_UnRegisterCallback(SD_HandleTypeDef *hsd, HAL_SD_CallbackIDTypeDef CallbackId); 00631 #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ 00632 00633 /** 00634 * @} 00635 */ 00636 00637 /** @defgroup SD_Exported_Functions_Group3 Peripheral Control functions 00638 * @{ 00639 */ 00640 HAL_StatusTypeDef HAL_SD_ConfigWideBusOperation(SD_HandleTypeDef *hsd, uint32_t WideMode); 00641 /** 00642 * @} 00643 */ 00644 00645 /** @defgroup SD_Exported_Functions_Group4 SD card related functions 00646 * @{ 00647 */ 00648 HAL_StatusTypeDef HAL_SD_SendSDStatus(SD_HandleTypeDef *hsd, uint32_t *pSDstatus); 00649 HAL_SD_CardStateTypeDef HAL_SD_GetCardState(SD_HandleTypeDef *hsd); 00650 HAL_StatusTypeDef HAL_SD_GetCardCID(SD_HandleTypeDef *hsd, HAL_SD_CardCIDTypeDef *pCID); 00651 HAL_StatusTypeDef HAL_SD_GetCardCSD(SD_HandleTypeDef *hsd, HAL_SD_CardCSDTypeDef *pCSD); 00652 HAL_StatusTypeDef HAL_SD_GetCardStatus(SD_HandleTypeDef *hsd, HAL_SD_CardStatusTypeDef *pStatus); 00653 HAL_StatusTypeDef HAL_SD_GetCardInfo(SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypeDef *pCardInfo); 00654 /** 00655 * @} 00656 */ 00657 00658 /** @defgroup SD_Exported_Functions_Group5 Peripheral State and Errors functions 00659 * @{ 00660 */ 00661 HAL_SD_StateTypeDef HAL_SD_GetState(SD_HandleTypeDef *hsd); 00662 uint32_t HAL_SD_GetError(SD_HandleTypeDef *hsd); 00663 /** 00664 * @} 00665 */ 00666 00667 /** @defgroup SD_Exported_Functions_Group6 Perioheral Abort management 00668 * @{ 00669 */ 00670 HAL_StatusTypeDef HAL_SD_Abort(SD_HandleTypeDef *hsd); 00671 HAL_StatusTypeDef HAL_SD_Abort_IT(SD_HandleTypeDef *hsd); 00672 /** 00673 * @} 00674 */ 00675 00676 /* Private types -------------------------------------------------------------*/ 00677 /** @defgroup SD_Private_Types SD Private Types 00678 * @{ 00679 */ 00680 00681 /** 00682 * @} 00683 */ 00684 00685 /* Private defines -----------------------------------------------------------*/ 00686 /** @defgroup SD_Private_Defines SD Private Defines 00687 * @{ 00688 */ 00689 00690 /** 00691 * @} 00692 */ 00693 00694 /* Private variables ---------------------------------------------------------*/ 00695 /** @defgroup SD_Private_Variables SD Private Variables 00696 * @{ 00697 */ 00698 00699 /** 00700 * @} 00701 */ 00702 00703 /* Private constants ---------------------------------------------------------*/ 00704 /** @defgroup SD_Private_Constants SD Private Constants 00705 * @{ 00706 */ 00707 00708 /** 00709 * @} 00710 */ 00711 00712 /* Private macros ------------------------------------------------------------*/ 00713 /** @defgroup SD_Private_Macros SD Private Macros 00714 * @{ 00715 */ 00716 00717 /** 00718 * @} 00719 */ 00720 00721 /* Private functions prototypes ----------------------------------------------*/ 00722 /** @defgroup SD_Private_Functions_Prototypes SD Private Functions Prototypes 00723 * @{ 00724 */ 00725 00726 /** 00727 * @} 00728 */ 00729 00730 /* Private functions ---------------------------------------------------------*/ 00731 /** @defgroup SD_Private_Functions SD Private Functions 00732 * @{ 00733 */ 00734 00735 /** 00736 * @} 00737 */ 00738 00739 00740 /** 00741 * @} 00742 */ 00743 00744 /** 00745 * @} 00746 */ 00747 00748 /** 00749 * @} 00750 */ 00751 00752 #endif /* SDIO */ 00753 00754 #ifdef __cplusplus 00755 } 00756 #endif 00757 00758 00759 #endif /* STM32F4xx_HAL_SD_H */ 00760 00761 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/