21 #ifndef STM32L4xx_HAL_SD_H 22 #define STM32L4xx_HAL_SD_H 52 HAL_SD_STATE_RESET = ((uint32_t)0x00000000U),
53 HAL_SD_STATE_READY = ((uint32_t)0x00000001U),
54 HAL_SD_STATE_TIMEOUT = ((uint32_t)0x00000002U),
55 HAL_SD_STATE_BUSY = ((uint32_t)0x00000003U),
56 HAL_SD_STATE_PROGRAMMING = ((uint32_t)0x00000004U),
57 HAL_SD_STATE_RECEIVING = ((uint32_t)0x00000005U),
58 HAL_SD_STATE_TRANSFER = ((uint32_t)0x00000006U),
59 HAL_SD_STATE_ERROR = ((uint32_t)0x0000000FU)
70 #define HAL_SD_CARD_READY 0x00000001U 71 #define HAL_SD_CARD_IDENTIFICATION 0x00000002U 72 #define HAL_SD_CARD_STANDBY 0x00000003U 73 #define HAL_SD_CARD_TRANSFER 0x00000004U 74 #define HAL_SD_CARD_SENDING 0x00000005U 75 #define HAL_SD_CARD_RECEIVING 0x00000006U 76 #define HAL_SD_CARD_PROGRAMMING 0x00000007U 77 #define HAL_SD_CARD_DISCONNECTED 0x00000008U 78 #define HAL_SD_CARD_ERROR 0x000000FFU 86 #define SD_InitTypeDef SDMMC_InitTypeDef 87 #define SD_TypeDef SDMMC_TypeDef 110 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 120 #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) 121 typedef struct __SD_HandleTypeDef
140 __IO uint32_t Context;
144 __IO uint32_t ErrorCode;
146 #if !defined(STM32L4R5xx) && !defined(STM32L4R7xx) && !defined(STM32L4R9xx) && !defined(STM32L4S5xx) && !defined(STM32L4S7xx) && !defined(STM32L4S9xx) 159 #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) 160 void (* TxCpltCallback) (
struct __SD_HandleTypeDef *hsd);
161 void (* RxCpltCallback) (
struct __SD_HandleTypeDef *hsd);
162 void (* ErrorCallback) (
struct __SD_HandleTypeDef *hsd);
163 void (* AbortCpltCallback) (
struct __SD_HandleTypeDef *hsd);
164 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 165 void (* Read_DMADblBuf0CpltCallback) (
struct __SD_HandleTypeDef *hsd);
166 void (* Read_DMADblBuf1CpltCallback) (
struct __SD_HandleTypeDef *hsd);
167 void (* Write_DMADblBuf0CpltCallback) (
struct __SD_HandleTypeDef *hsd);
168 void (* Write_DMADblBuf1CpltCallback) (
struct __SD_HandleTypeDef *hsd);
170 void (* DriveTransceiver_1_8V_Callback) (FlagStatus status);
173 void (* MspInitCallback) (
struct __SD_HandleTypeDef *hsd);
174 void (* MspDeInitCallback) (
struct __SD_HandleTypeDef *hsd);
265 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 275 #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) 285 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 303 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 319 #define BLOCKSIZE ((uint32_t)512U) 324 #define HAL_SD_ERROR_NONE SDMMC_ERROR_NONE 325 #define HAL_SD_ERROR_CMD_CRC_FAIL SDMMC_ERROR_CMD_CRC_FAIL 326 #define HAL_SD_ERROR_DATA_CRC_FAIL SDMMC_ERROR_DATA_CRC_FAIL 327 #define HAL_SD_ERROR_CMD_RSP_TIMEOUT SDMMC_ERROR_CMD_RSP_TIMEOUT 328 #define HAL_SD_ERROR_DATA_TIMEOUT SDMMC_ERROR_DATA_TIMEOUT 329 #define HAL_SD_ERROR_TX_UNDERRUN SDMMC_ERROR_TX_UNDERRUN 330 #define HAL_SD_ERROR_RX_OVERRUN SDMMC_ERROR_RX_OVERRUN 331 #define HAL_SD_ERROR_ADDR_MISALIGNED SDMMC_ERROR_ADDR_MISALIGNED 332 #define HAL_SD_ERROR_BLOCK_LEN_ERR SDMMC_ERROR_BLOCK_LEN_ERR 334 #define HAL_SD_ERROR_ERASE_SEQ_ERR SDMMC_ERROR_ERASE_SEQ_ERR 335 #define HAL_SD_ERROR_BAD_ERASE_PARAM SDMMC_ERROR_BAD_ERASE_PARAM 336 #define HAL_SD_ERROR_WRITE_PROT_VIOLATION SDMMC_ERROR_WRITE_PROT_VIOLATION 337 #define HAL_SD_ERROR_LOCK_UNLOCK_FAILED SDMMC_ERROR_LOCK_UNLOCK_FAILED 339 #define HAL_SD_ERROR_COM_CRC_FAILED SDMMC_ERROR_COM_CRC_FAILED 340 #define HAL_SD_ERROR_ILLEGAL_CMD SDMMC_ERROR_ILLEGAL_CMD 341 #define HAL_SD_ERROR_CARD_ECC_FAILED SDMMC_ERROR_CARD_ECC_FAILED 342 #define HAL_SD_ERROR_CC_ERR SDMMC_ERROR_CC_ERR 343 #define HAL_SD_ERROR_GENERAL_UNKNOWN_ERR SDMMC_ERROR_GENERAL_UNKNOWN_ERR 344 #define HAL_SD_ERROR_STREAM_READ_UNDERRUN SDMMC_ERROR_STREAM_READ_UNDERRUN 345 #define HAL_SD_ERROR_STREAM_WRITE_OVERRUN SDMMC_ERROR_STREAM_WRITE_OVERRUN 346 #define HAL_SD_ERROR_CID_CSD_OVERWRITE SDMMC_ERROR_CID_CSD_OVERWRITE 347 #define HAL_SD_ERROR_WP_ERASE_SKIP SDMMC_ERROR_WP_ERASE_SKIP 348 #define HAL_SD_ERROR_CARD_ECC_DISABLED SDMMC_ERROR_CARD_ECC_DISABLED 349 #define HAL_SD_ERROR_ERASE_RESET SDMMC_ERROR_ERASE_RESET 351 #define HAL_SD_ERROR_AKE_SEQ_ERR SDMMC_ERROR_AKE_SEQ_ERR 352 #define HAL_SD_ERROR_INVALID_VOLTRANGE SDMMC_ERROR_INVALID_VOLTRANGE 353 #define HAL_SD_ERROR_ADDR_OUT_OF_RANGE SDMMC_ERROR_ADDR_OUT_OF_RANGE 354 #define HAL_SD_ERROR_REQUEST_NOT_APPLICABLE SDMMC_ERROR_REQUEST_NOT_APPLICABLE 355 #define HAL_SD_ERROR_PARAM SDMMC_ERROR_INVALID_PARAMETER 356 #define HAL_SD_ERROR_UNSUPPORTED_FEATURE SDMMC_ERROR_UNSUPPORTED_FEATURE 357 #define HAL_SD_ERROR_BUSY SDMMC_ERROR_BUSY 358 #define HAL_SD_ERROR_DMA SDMMC_ERROR_DMA 359 #define HAL_SD_ERROR_TIMEOUT SDMMC_ERROR_TIMEOUT 361 #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) 362 #define HAL_SD_ERROR_INVALID_CALLBACK SDMMC_ERROR_INVALID_PARAMETER 371 #define SD_CONTEXT_NONE ((uint32_t)0x00000000U) 372 #define SD_CONTEXT_READ_SINGLE_BLOCK ((uint32_t)0x00000001U) 373 #define SD_CONTEXT_READ_MULTIPLE_BLOCK ((uint32_t)0x00000002U) 374 #define SD_CONTEXT_WRITE_SINGLE_BLOCK ((uint32_t)0x00000010U) 375 #define SD_CONTEXT_WRITE_MULTIPLE_BLOCK ((uint32_t)0x00000020U) 376 #define SD_CONTEXT_IT ((uint32_t)0x00000008U) 377 #define SD_CONTEXT_DMA ((uint32_t)0x00000080U) 386 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 387 #define CARD_NORMAL_SPEED ((uint32_t)0x00000000U) 388 #define CARD_HIGH_SPEED ((uint32_t)0x00000100U) 389 #define CARD_ULTRA_HIGH_SPEED ((uint32_t)0x00000200U) 393 #define CARD_SDSC ((uint32_t)0x00000000U) 394 #define CARD_SDHC_SDXC ((uint32_t)0x00000001U) 395 #define CARD_SECURED ((uint32_t)0x00000003U) 404 #define CARD_V1_X ((uint32_t)0x00000000U) 405 #define CARD_V2_X ((uint32_t)0x00000001U) 423 #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) 424 #define __HAL_SD_RESET_HANDLE_STATE(__HANDLE__) do { \ 425 (__HANDLE__)->State = HAL_SD_STATE_RESET; \ 426 (__HANDLE__)->MspInitCallback = NULL; \ 427 (__HANDLE__)->MspDeInitCallback = NULL; \ 430 #define __HAL_SD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SD_STATE_RESET) 433 #if !defined(STM32L4R5xx) && !defined(STM32L4R7xx) && !defined(STM32L4R9xx) && !defined(STM32L4S5xx) && !defined(STM32L4S7xx) && !defined(STM32L4S9xx) 438 #define __HAL_SD_ENABLE(__HANDLE__) __SDMMC_ENABLE((__HANDLE__)->Instance) 444 #define __HAL_SD_DISABLE(__HANDLE__) __SDMMC_DISABLE((__HANDLE__)->Instance) 450 #define __HAL_SD_DMA_ENABLE(__HANDLE__) __SDMMC_DMA_ENABLE((__HANDLE__)->Instance) 456 #define __HAL_SD_DMA_DISABLE(__HANDLE__) __SDMMC_DMA_DISABLE((__HANDLE__)->Instance) 496 #define __HAL_SD_ENABLE_IT(__HANDLE__, __INTERRUPT__) __SDMMC_ENABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__)) 535 #define __HAL_SD_DISABLE_IT(__HANDLE__, __INTERRUPT__) __SDMMC_DISABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__)) 578 #define __HAL_SD_GET_FLAG(__HANDLE__, __FLAG__) __SDMMC_GET_FLAG((__HANDLE__)->Instance, (__FLAG__)) 607 #define __HAL_SD_CLEAR_FLAG(__HANDLE__, __FLAG__) __SDMMC_CLEAR_FLAG((__HANDLE__)->Instance, (__FLAG__)) 646 #define __HAL_SD_GET_IT(__HANDLE__, __INTERRUPT__) __SDMMC_GET_IT((__HANDLE__)->Instance, (__INTERRUPT__)) 674 #define __HAL_SD_CLEAR_IT(__HANDLE__, __INTERRUPT__) __SDMMC_CLEAR_IT((__HANDLE__)->Instance, (__INTERRUPT__)) 680 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 724 #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) 729 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) __IO uint8_t AllocationUnitSize
__IO uint32_t ProtectedAreaSize
__IO uint16_t CardComdClasses
__IO uint8_t PartBlockRead
HAL_StatusTypeDef HAL_SD_GetCardStatus(SD_HandleTypeDef *hsd, HAL_SD_CardStatusTypeDef *pStatus)
Gets the SD status info.
void(* pSD_TransceiverCallbackTypeDef)(FlagStatus status)
HAL_SD_StateTypeDef HAL_SD_GetState(SD_HandleTypeDef *hsd)
return the SD state
HAL_StatusTypeDef HAL_SD_UnRegisterTransceiverCallback(SD_HandleTypeDef *hsd)
Unregister a User SD Transceiver Callback SD Callback is redirected to the weak (surcharged) predefin...
void HAL_SD_MspInit(SD_HandleTypeDef *hsd)
Initializes the SD MSP.
__IO uint8_t MaxRdCurrentVDDMax
DMA handle Structure definition.
__IO uint8_t EraseTimeout
HAL_StatusTypeDef HAL_SD_Erase(SD_HandleTypeDef *hsd, uint32_t BlockStartAdd, uint32_t BlockEndAdd)
Erases the specified memory area of the given SD card.
__IO uint8_t VideoSpeedClass
void HAL_SD_ErrorCallback(SD_HandleTypeDef *hsd)
SD error callbacks.
HAL_StatusTypeDef HAL_SD_Abort(SD_HandleTypeDef *hsd)
Abort the current transfer and disable the SD.
Header file of SD HAL extended module.
HAL_StatusTypeDef HAL_SD_DeInit(SD_HandleTypeDef *hsd)
De-Initializes the SD card.
Header file of SDMMC HAL module.
__IO uint8_t PermWrProtect
uint32_t HAL_SD_GetError(SD_HandleTypeDef *hsd)
Return the SD error code.
__IO uint8_t ContentProtectAppli
__IO uint8_t MaxWrCurrentVDDMax
struct __SD_HandleTypeDef else typedef struct endif SD_HandleTypeDef
SD handle Structure definition.
__IO uint8_t DeviceSizeMul
__IO uint8_t WriteBlockPaPartial
HAL_StatusTypeDef HAL_SD_ConfigWideBusOperation(SD_HandleTypeDef *hsd, uint32_t WideMode)
Enables wide bus operation for the requested card if supported by card.
HAL_SD_CardStateTypeDef HAL_SD_GetCardState(SD_HandleTypeDef *hsd)
Gets the current sd card data state.
HAL_StatusTypeDef HAL_SD_ConfigSpeedBusOperation(SD_HandleTypeDef *hsd, uint32_t SpeedMode)
Configure the speed bus mode.
HAL_StatusTypeDef HAL_SD_InitCard(SD_HandleTypeDef *hsd)
Initializes the SD Card.
HAL_StatusTypeDef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks)
Reads block(s) from a specified address in a card. The Data transfer is managed by DMA mode...
__IO uint8_t MaxBusClkFrec
void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd)
Rx Transfer completed callbacks.
__IO uint8_t DataBusWidth
HAL_StatusTypeDef HAL_SD_Init(SD_HandleTypeDef *hsd)
Initializes the SD according to the specified parameters in the SD_HandleTypeDef and create the assoc...
__IO uint8_t UhsAllocationUnitSize
HAL_StatusTypeDef HAL_SD_WriteBlocks_IT(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks)
Writes block(s) to a specified address in a card. The Data transfer is managed in interrupt mode...
__IO uint8_t SysSpecVersion
void(* pSD_CallbackTypeDef)(SD_HandleTypeDef *hsd)
__IO uint8_t WrProtectGrSize
SD Card Information Structure definition.
__IO uint8_t MaxRdCurrentVDDMin
__IO uint16_t ManufactDate
__IO uint8_t MaxWrCurrentVDDMin
HAL_StatusTypeDef HAL_SD_ReadBlocks_IT(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks)
Reads block(s) from a specified address in a card. The Data transfer is managed in interrupt mode...
HAL_StatusTypeDef HAL_SD_Abort_IT(SD_HandleTypeDef *hsd)
Abort the current transfer and disable the SD (IT mode).
HAL_StatusTypeDef HAL_SD_WriteBlocks(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout)
Allows to write block(s) to a specified address in a card. The Data transfer is managed by polling mo...
__IO uint8_t UhsSpeedGrade
HAL_SD_CardInfoTypeDef SdCard
HAL_StatusTypeDef HAL_SD_UnRegisterCallback(SD_HandleTypeDef *hsd, HAL_SD_CallbackIDTypeDef CallbackID)
Unregister a User SD Callback SD Callback is redirected to the weak (surcharged) predefined callback...
HAL_StatusTypeDef HAL_SD_RegisterCallback(SD_HandleTypeDef *hsd, HAL_SD_CallbackIDTypeDef CallbackID, pSD_CallbackTypeDef pCallback)
Register a User SD Callback To be used instead of the weak (surcharged) predefined callback...
__IO uint8_t FileFormatGroup
uint32_t HAL_SD_CardStateTypeDef
HAL_LockTypeDef
HAL Lock structures definition.
__IO uint8_t RdBlockMisalign
void HAL_SD_AbortCallback(SD_HandleTypeDef *hsd)
SD Abort callbacks.
HAL_StatusTypeDef HAL_SD_GetCardCID(SD_HandleTypeDef *hsd, HAL_SD_CardCIDTypeDef *pCID)
Returns information the information of the card which are stored on the CID register.
__IO uint8_t ManufacturerID
__IO uint8_t MaxWrBlockLen
HAL_StatusTypeDef HAL_SD_GetCardCSD(SD_HandleTypeDef *hsd, HAL_SD_CardCSDTypeDef *pCSD)
Returns information the information of the card which are stored on the CSD register.
void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd)
Tx Transfer completed callbacks.
__IO uint8_t TempWrProtect
ADC handle Structure definition.
HAL_StatusTypeDef HAL_SD_GetCardInfo(SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypeDef *pCardInfo)
Gets the SD card info.
HAL_StatusTypeDef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks)
Writes block(s) to a specified address in a card. The Data transfer is managed by DMA mode...
__IO HAL_SD_StateTypeDef State
__IO uint8_t WrBlockMisalign
HAL_StatusTypeDef HAL_SD_ReadBlocks(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout)
Reads block(s) from a specified address in a card. The Data transfer is managed by polling mode...
__IO uint16_t OEM_AppliID
HAL_StatusTypeDef HAL_SD_RegisterTransceiverCallback(SD_HandleTypeDef *hsd, pSD_TransceiverCallbackTypeDef pCallback)
Register a User SD Transceiver Callback To be used instead of the weak (surcharged) predefined callba...
void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd)
De-Initialize SD MSP.
HAL_StatusTypeDef HAL_SD_SendSDStatus(SD_HandleTypeDef *hsd, uint32_t *pSDstatus)
void HAL_SD_IRQHandler(SD_HandleTypeDef *hsd)
This function handles SD card interrupt request.
__IO uint8_t WrProtectGrEnable
__IO uint8_t PerformanceMove