20#ifndef STM32H7xx_HAL_SD_H
21#define STM32H7xx_HAL_SD_H
29#if defined (DLYB_SDMMC1) || defined (DLYB_SDMMC2) || defined (DLYB_SDMMC3)
72typedef uint32_t HAL_SD_CardStateTypeDef;
74#define HAL_SD_CARD_READY 0x00000001U
75#define HAL_SD_CARD_IDENTIFICATION 0x00000002U
76#define HAL_SD_CARD_STANDBY 0x00000003U
77#define HAL_SD_CARD_TRANSFER 0x00000004U
78#define HAL_SD_CARD_SENDING 0x00000005U
79#define HAL_SD_CARD_RECEIVING 0x00000006U
80#define HAL_SD_CARD_PROGRAMMING 0x00000007U
81#define HAL_SD_CARD_DISCONNECTED 0x00000008U
82#define HAL_SD_CARD_ERROR 0x000000FFU
91#define SD_InitTypeDef SDMMC_InitTypeDef
92#define SD_TypeDef SDMMC_TypeDef
122#if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U)
123typedef struct __SD_HandleTypeDef
154#if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U)
155 void (* TxCpltCallback)(
struct __SD_HandleTypeDef *hsd);
156 void (* RxCpltCallback)(
struct __SD_HandleTypeDef *hsd);
157 void (* ErrorCallback)(
struct __SD_HandleTypeDef *hsd);
158 void (* AbortCpltCallback)(
struct __SD_HandleTypeDef *hsd);
159 void (* Read_DMADblBuf0CpltCallback)(
struct __SD_HandleTypeDef *hsd);
160 void (* Read_DMADblBuf1CpltCallback)(
struct __SD_HandleTypeDef *hsd);
161 void (* Write_DMADblBuf0CpltCallback)(
struct __SD_HandleTypeDef *hsd);
162 void (* Write_DMADblBuf1CpltCallback)(
struct __SD_HandleTypeDef *hsd);
163#if (USE_SD_TRANSCEIVER != 0U)
164 void (* DriveTransceiver_1_8V_Callback)(FlagStatus status);
167 void (* MspInitCallback)(
struct __SD_HandleTypeDef *hsd);
168 void (* MspDeInitCallback)(
struct __SD_HandleTypeDef *hsd);
270#if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U)
277 HAL_SD_TX_CPLT_CB_ID = 0x00U,
278 HAL_SD_RX_CPLT_CB_ID = 0x01U,
279 HAL_SD_ERROR_CB_ID = 0x02U,
280 HAL_SD_ABORT_CB_ID = 0x03U,
281 HAL_SD_READ_DMA_DBL_BUF0_CPLT_CB_ID = 0x04U,
282 HAL_SD_READ_DMA_DBL_BUF1_CPLT_CB_ID = 0x05U,
283 HAL_SD_WRITE_DMA_DBL_BUF0_CPLT_CB_ID = 0x06U,
284 HAL_SD_WRITE_DMA_DBL_BUF1_CPLT_CB_ID = 0x07U,
286 HAL_SD_MSP_INIT_CB_ID = 0x10U,
287 HAL_SD_MSP_DEINIT_CB_ID = 0x11U
288} HAL_SD_CallbackIDTypeDef;
298#if (USE_SD_TRANSCEIVER != 0U)
299typedef void (*pSD_TransceiverCallbackTypeDef)(FlagStatus status);
315#define BLOCKSIZE ((uint32_t)512U)
321#define HAL_SD_ERROR_NONE SDMMC_ERROR_NONE
322#define HAL_SD_ERROR_CMD_CRC_FAIL SDMMC_ERROR_CMD_CRC_FAIL
323#define HAL_SD_ERROR_DATA_CRC_FAIL SDMMC_ERROR_DATA_CRC_FAIL
324#define HAL_SD_ERROR_CMD_RSP_TIMEOUT SDMMC_ERROR_CMD_RSP_TIMEOUT
325#define HAL_SD_ERROR_DATA_TIMEOUT SDMMC_ERROR_DATA_TIMEOUT
326#define HAL_SD_ERROR_TX_UNDERRUN SDMMC_ERROR_TX_UNDERRUN
327#define HAL_SD_ERROR_RX_OVERRUN SDMMC_ERROR_RX_OVERRUN
328#define HAL_SD_ERROR_ADDR_MISALIGNED SDMMC_ERROR_ADDR_MISALIGNED
329#define HAL_SD_ERROR_BLOCK_LEN_ERR SDMMC_ERROR_BLOCK_LEN_ERR
331#define HAL_SD_ERROR_ERASE_SEQ_ERR SDMMC_ERROR_ERASE_SEQ_ERR
332#define HAL_SD_ERROR_BAD_ERASE_PARAM SDMMC_ERROR_BAD_ERASE_PARAM
333#define HAL_SD_ERROR_WRITE_PROT_VIOLATION SDMMC_ERROR_WRITE_PROT_VIOLATION
334#define HAL_SD_ERROR_LOCK_UNLOCK_FAILED SDMMC_ERROR_LOCK_UNLOCK_FAILED
336#define HAL_SD_ERROR_COM_CRC_FAILED SDMMC_ERROR_COM_CRC_FAILED
337#define HAL_SD_ERROR_ILLEGAL_CMD SDMMC_ERROR_ILLEGAL_CMD
338#define HAL_SD_ERROR_CARD_ECC_FAILED SDMMC_ERROR_CARD_ECC_FAILED
339#define HAL_SD_ERROR_CC_ERR SDMMC_ERROR_CC_ERR
340#define HAL_SD_ERROR_GENERAL_UNKNOWN_ERR SDMMC_ERROR_GENERAL_UNKNOWN_ERR
341#define HAL_SD_ERROR_STREAM_READ_UNDERRUN SDMMC_ERROR_STREAM_READ_UNDERRUN
342#define HAL_SD_ERROR_STREAM_WRITE_OVERRUN SDMMC_ERROR_STREAM_WRITE_OVERRUN
343#define HAL_SD_ERROR_CID_CSD_OVERWRITE SDMMC_ERROR_CID_CSD_OVERWRITE
344#define HAL_SD_ERROR_WP_ERASE_SKIP SDMMC_ERROR_WP_ERASE_SKIP
345#define HAL_SD_ERROR_CARD_ECC_DISABLED SDMMC_ERROR_CARD_ECC_DISABLED
346#define HAL_SD_ERROR_ERASE_RESET SDMMC_ERROR_ERASE_RESET
348#define HAL_SD_ERROR_AKE_SEQ_ERR SDMMC_ERROR_AKE_SEQ_ERR
349#define HAL_SD_ERROR_INVALID_VOLTRANGE SDMMC_ERROR_INVALID_VOLTRANGE
350#define HAL_SD_ERROR_ADDR_OUT_OF_RANGE SDMMC_ERROR_ADDR_OUT_OF_RANGE
351#define HAL_SD_ERROR_REQUEST_NOT_APPLICABLE SDMMC_ERROR_REQUEST_NOT_APPLICABLE
352#define HAL_SD_ERROR_PARAM SDMMC_ERROR_INVALID_PARAMETER
353#define HAL_SD_ERROR_UNSUPPORTED_FEATURE SDMMC_ERROR_UNSUPPORTED_FEATURE
354#define HAL_SD_ERROR_BUSY SDMMC_ERROR_BUSY
355#define HAL_SD_ERROR_DMA SDMMC_ERROR_DMA
356#define HAL_SD_ERROR_TIMEOUT SDMMC_ERROR_TIMEOUT
358#if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U)
359#define HAL_SD_ERROR_INVALID_CALLBACK SDMMC_ERROR_INVALID_PARAMETER
369#define SD_CONTEXT_NONE ((uint32_t)0x00000000U)
370#define SD_CONTEXT_READ_SINGLE_BLOCK ((uint32_t)0x00000001U)
371#define SD_CONTEXT_READ_MULTIPLE_BLOCK ((uint32_t)0x00000002U)
372#define SD_CONTEXT_WRITE_SINGLE_BLOCK ((uint32_t)0x00000010U)
373#define SD_CONTEXT_WRITE_MULTIPLE_BLOCK ((uint32_t)0x00000020U)
374#define SD_CONTEXT_IT ((uint32_t)0x00000008U)
375#define SD_CONTEXT_DMA ((uint32_t)0x00000080U)
385#define CARD_NORMAL_SPEED ((uint32_t)0x00000000U)
386#define CARD_HIGH_SPEED ((uint32_t)0x00000100U)
387#define CARD_ULTRA_HIGH_SPEED ((uint32_t)0x00000200U)
390#define CARD_SDSC ((uint32_t)0x00000000U)
391#define CARD_SDHC_SDXC ((uint32_t)0x00000001U)
392#define CARD_SECURED ((uint32_t)0x00000003U)
402#define CARD_V1_X ((uint32_t)0x00000000U)
403#define CARD_V2_X ((uint32_t)0x00000001U)
422#if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U)
423#define __HAL_SD_RESET_HANDLE_STATE(__HANDLE__) do { \
424 (__HANDLE__)->State = HAL_SD_STATE_RESET; \
425 (__HANDLE__)->MspInitCallback = NULL; \
426 (__HANDLE__)->MspDeInitCallback = NULL; \
429#define __HAL_SD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SD_STATE_RESET)
462#define __HAL_SD_ENABLE_IT(__HANDLE__, __INTERRUPT__) __SDMMC_ENABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__))
494#define __HAL_SD_DISABLE_IT(__HANDLE__, __INTERRUPT__) __SDMMC_DISABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__))
532#define __HAL_SD_GET_FLAG(__HANDLE__, __FLAG__) __SDMMC_GET_FLAG((__HANDLE__)->Instance, (__FLAG__))
561#define __HAL_SD_CLEAR_FLAG(__HANDLE__, __FLAG__) __SDMMC_CLEAR_FLAG((__HANDLE__)->Instance, (__FLAG__))
593#define __HAL_SD_GET_IT(__HANDLE__, __INTERRUPT__) __SDMMC_GET_IT((__HANDLE__)->Instance, (__INTERRUPT__))
621#define __HAL_SD_CLEAR_IT(__HANDLE__, __INTERRUPT__) __SDMMC_CLEAR_IT((__HANDLE__)->Instance, (__INTERRUPT__))
657 uint32_t NumberOfBlocks, uint32_t Timeout);
661 uint32_t NumberOfBlocks);
663 uint32_t NumberOfBlocks);
666 uint32_t NumberOfBlocks);
668 uint32_t NumberOfBlocks);
678#if (USE_SD_TRANSCEIVER != 0U)
680void HAL_SD_DriveTransceiver_1_8V_Callback(FlagStatus status);
683#if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U)
686 pSD_CallbackTypeDef pCallback);
689#if (USE_SD_TRANSCEIVER != 0U)
#define __IO
Definition: core_cm4.h:239
HAL_SD_StateTypeDef
Definition: stm32h7xx_hal_sd.h:54
@ HAL_SD_STATE_ERROR
Definition: stm32h7xx_hal_sd.h:62
@ HAL_SD_STATE_RECEIVING
Definition: stm32h7xx_hal_sd.h:60
@ HAL_SD_STATE_PROGRAMMING
Definition: stm32h7xx_hal_sd.h:59
@ HAL_SD_STATE_READY
Definition: stm32h7xx_hal_sd.h:56
@ HAL_SD_STATE_TIMEOUT
Definition: stm32h7xx_hal_sd.h:57
@ HAL_SD_STATE_TRANSFER
Definition: stm32h7xx_hal_sd.h:61
@ HAL_SD_STATE_RESET
Definition: stm32h7xx_hal_sd.h:55
@ HAL_SD_STATE_BUSY
Definition: stm32h7xx_hal_sd.h:58
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32h7xx_hal_def.h:47
HAL_LockTypeDef
HAL Lock structures definition.
Definition: stm32h7xx_hal_def.h:58
Header file of SD HAL extended module.
Header file of Delay Block module.
Header file of SDMMC HAL module.
Definition: stm32h7xx_hal_sd.h:229
__IO uint8_t Reserved1
Definition: stm32h7xx_hal_sd.h:236
__IO uint16_t OEM_AppliID
Definition: stm32h7xx_hal_sd.h:231
__IO uint8_t ManufacturerID
Definition: stm32h7xx_hal_sd.h:230
__IO uint8_t ProdRev
Definition: stm32h7xx_hal_sd.h:234
__IO uint8_t CID_CRC
Definition: stm32h7xx_hal_sd.h:238
__IO uint8_t Reserved2
Definition: stm32h7xx_hal_sd.h:239
__IO uint32_t ProdName1
Definition: stm32h7xx_hal_sd.h:232
__IO uint16_t ManufactDate
Definition: stm32h7xx_hal_sd.h:237
__IO uint32_t ProdSN
Definition: stm32h7xx_hal_sd.h:235
__IO uint8_t ProdName2
Definition: stm32h7xx_hal_sd.h:233
Definition: stm32h7xx_hal_sd.h:181
__IO uint8_t WriteBlockPaPartial
Definition: stm32h7xx_hal_sd.h:208
__IO uint8_t DSRImpl
Definition: stm32h7xx_hal_sd.h:193
__IO uint8_t MaxRdCurrentVDDMax
Definition: stm32h7xx_hal_sd.h:197
__IO uint8_t CSDStruct
Definition: stm32h7xx_hal_sd.h:182
__IO uint8_t PartBlockRead
Definition: stm32h7xx_hal_sd.h:190
__IO uint8_t Reserved1
Definition: stm32h7xx_hal_sd.h:184
__IO uint8_t WrBlockMisalign
Definition: stm32h7xx_hal_sd.h:191
__IO uint8_t WrProtectGrSize
Definition: stm32h7xx_hal_sd.h:203
__IO uint8_t MaxWrBlockLen
Definition: stm32h7xx_hal_sd.h:207
__IO uint8_t Reserved2
Definition: stm32h7xx_hal_sd.h:194
__IO uint8_t WrProtectGrEnable
Definition: stm32h7xx_hal_sd.h:204
__IO uint8_t ContentProtectAppli
Definition: stm32h7xx_hal_sd.h:210
__IO uint32_t DeviceSize
Definition: stm32h7xx_hal_sd.h:195
__IO uint8_t MaxWrCurrentVDDMax
Definition: stm32h7xx_hal_sd.h:199
__IO uint8_t MaxWrCurrentVDDMin
Definition: stm32h7xx_hal_sd.h:198
__IO uint8_t TempWrProtect
Definition: stm32h7xx_hal_sd.h:214
__IO uint8_t EraseGrMul
Definition: stm32h7xx_hal_sd.h:202
__IO uint16_t CardComdClasses
Definition: stm32h7xx_hal_sd.h:188
__IO uint8_t CopyFlag
Definition: stm32h7xx_hal_sd.h:212
__IO uint8_t WrSpeedFact
Definition: stm32h7xx_hal_sd.h:206
__IO uint8_t ECC
Definition: stm32h7xx_hal_sd.h:216
__IO uint8_t RdBlockMisalign
Definition: stm32h7xx_hal_sd.h:192
__IO uint8_t FileFormat
Definition: stm32h7xx_hal_sd.h:215
__IO uint8_t MaxRdCurrentVDDMin
Definition: stm32h7xx_hal_sd.h:196
__IO uint8_t ManDeflECC
Definition: stm32h7xx_hal_sd.h:205
__IO uint8_t CSD_CRC
Definition: stm32h7xx_hal_sd.h:217
__IO uint8_t SysSpecVersion
Definition: stm32h7xx_hal_sd.h:183
__IO uint8_t EraseGrSize
Definition: stm32h7xx_hal_sd.h:201
__IO uint8_t Reserved4
Definition: stm32h7xx_hal_sd.h:218
__IO uint8_t NSAC
Definition: stm32h7xx_hal_sd.h:186
__IO uint8_t MaxBusClkFrec
Definition: stm32h7xx_hal_sd.h:187
__IO uint8_t PermWrProtect
Definition: stm32h7xx_hal_sd.h:213
__IO uint8_t FileFormatGroup
Definition: stm32h7xx_hal_sd.h:211
__IO uint8_t RdBlockLen
Definition: stm32h7xx_hal_sd.h:189
__IO uint8_t TAAC
Definition: stm32h7xx_hal_sd.h:185
__IO uint8_t Reserved3
Definition: stm32h7xx_hal_sd.h:209
__IO uint8_t DeviceSizeMul
Definition: stm32h7xx_hal_sd.h:200
SD Card Information Structure definition.
Definition: stm32h7xx_hal_sd.h:98
uint32_t BlockNbr
Definition: stm32h7xx_hal_sd.h:107
uint32_t LogBlockNbr
Definition: stm32h7xx_hal_sd.h:111
uint32_t CardSpeed
Definition: stm32h7xx_hal_sd.h:115
uint32_t CardVersion
Definition: stm32h7xx_hal_sd.h:101
uint32_t LogBlockSize
Definition: stm32h7xx_hal_sd.h:113
uint32_t BlockSize
Definition: stm32h7xx_hal_sd.h:109
uint32_t CardType
Definition: stm32h7xx_hal_sd.h:99
uint32_t Class
Definition: stm32h7xx_hal_sd.h:103
uint32_t RelCardAdd
Definition: stm32h7xx_hal_sd.h:105
Definition: stm32h7xx_hal_sd.h:251
__IO uint8_t SpeedClass
Definition: stm32h7xx_hal_sd.h:256
__IO uint16_t CardType
Definition: stm32h7xx_hal_sd.h:254
__IO uint8_t PerformanceMove
Definition: stm32h7xx_hal_sd.h:257
__IO uint8_t UhsAllocationUnitSize
Definition: stm32h7xx_hal_sd.h:263
__IO uint8_t VideoSpeedClass
Definition: stm32h7xx_hal_sd.h:264
__IO uint8_t EraseTimeout
Definition: stm32h7xx_hal_sd.h:260
__IO uint8_t UhsSpeedGrade
Definition: stm32h7xx_hal_sd.h:262
__IO uint8_t DataBusWidth
Definition: stm32h7xx_hal_sd.h:252
__IO uint8_t EraseOffset
Definition: stm32h7xx_hal_sd.h:261
__IO uint8_t SecuredMode
Definition: stm32h7xx_hal_sd.h:253
__IO uint32_t ProtectedAreaSize
Definition: stm32h7xx_hal_sd.h:255
__IO uint16_t EraseSize
Definition: stm32h7xx_hal_sd.h:259
__IO uint8_t AllocationUnitSize
Definition: stm32h7xx_hal_sd.h:258
SD handle Structure definition.
Definition: stm32h7xx_hal_sd.h:127
SD_TypeDef * Instance
Definition: stm32h7xx_hal_sd.h:128
SD_InitTypeDef Init
Definition: stm32h7xx_hal_sd.h:130
uint8_t * pRxBuffPtr
Definition: stm32h7xx_hal_sd.h:138
uint32_t TxXferSize
Definition: stm32h7xx_hal_sd.h:136
HAL_SD_CardInfoTypeDef SdCard
Definition: stm32h7xx_hal_sd.h:148
uint32_t RxXferSize
Definition: stm32h7xx_hal_sd.h:140
__IO HAL_SD_StateTypeDef State
Definition: stm32h7xx_hal_sd.h:144
__IO uint32_t Context
Definition: stm32h7xx_hal_sd.h:142
__IO uint32_t ErrorCode
Definition: stm32h7xx_hal_sd.h:146
const uint8_t * pTxBuffPtr
Definition: stm32h7xx_hal_sd.h:134
HAL_LockTypeDef Lock
Definition: stm32h7xx_hal_sd.h:132