21 #ifndef STM32H7xx_HAL_MMC_H
22 #define STM32H7xx_HAL_MMC_H
29 #include "stm32h7xx_ll_sdmmc.h"
67 #define HAL_MMC_CARD_READY 0x00000001U
68 #define HAL_MMC_CARD_IDENTIFICATION 0x00000002U
69 #define HAL_MMC_CARD_STANDBY 0x00000003U
70 #define HAL_MMC_CARD_TRANSFER 0x00000004U
71 #define HAL_MMC_CARD_SENDING 0x00000005U
72 #define HAL_MMC_CARD_RECEIVING 0x00000006U
73 #define HAL_MMC_CARD_PROGRAMMING 0x00000007U
74 #define HAL_MMC_CARD_DISCONNECTED 0x00000008U
75 #define HAL_MMC_CARD_ERROR 0x000000FFU
83 #define MMC_InitTypeDef SDMMC_InitTypeDef
84 #define MMC_TypeDef SDMMC_TypeDef
110 #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U)
111 typedef struct __MMC_HandleTypeDef
142 uint32_t Ext_CSD[128];
144 #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U)
145 void (* TxCpltCallback) (
struct __MMC_HandleTypeDef *hmmc);
146 void (* RxCpltCallback) (
struct __MMC_HandleTypeDef *hmmc);
147 void (* ErrorCallback) (
struct __MMC_HandleTypeDef *hmmc);
148 void (* AbortCpltCallback) (
struct __MMC_HandleTypeDef *hmmc);
149 void (* Read_DMADblBuf0CpltCallback) (
struct __MMC_HandleTypeDef *hmmc);
150 void (* Read_DMADblBuf1CpltCallback) (
struct __MMC_HandleTypeDef *hmmc);
151 void (* Write_DMADblBuf0CpltCallback) (
struct __MMC_HandleTypeDef *hmmc);
152 void (* Write_DMADblBuf1CpltCallback) (
struct __MMC_HandleTypeDef *hmmc);
154 void (* MspInitCallback) (
struct __MMC_HandleTypeDef *hmmc);
155 void (* MspDeInitCallback) (
struct __MMC_HandleTypeDef *hmmc);
233 #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U)
239 HAL_MMC_TX_CPLT_CB_ID = 0x00U,
240 HAL_MMC_RX_CPLT_CB_ID = 0x01U,
241 HAL_MMC_ERROR_CB_ID = 0x02U,
242 HAL_MMC_ABORT_CB_ID = 0x03U,
243 HAL_MMC_READ_DMA_DBL_BUF0_CPLT_CB_ID = 0x04U,
244 HAL_MMC_READ_DMA_DBL_BUF1_CPLT_CB_ID = 0x05U,
245 HAL_MMC_WRITE_DMA_DBL_BUF0_CPLT_CB_ID = 0x06U,
246 HAL_MMC_WRITE_DMA_DBL_BUF1_CPLT_CB_ID = 0x07U,
248 HAL_MMC_MSP_INIT_CB_ID = 0x10U,
249 HAL_MMC_MSP_DEINIT_CB_ID = 0x11U
250 }HAL_MMC_CallbackIDTypeDef;
272 #define MMC_BLOCKSIZE ((uint32_t)512U)
277 #define HAL_MMC_ERROR_NONE SDMMC_ERROR_NONE
278 #define HAL_MMC_ERROR_CMD_CRC_FAIL SDMMC_ERROR_CMD_CRC_FAIL
279 #define HAL_MMC_ERROR_DATA_CRC_FAIL SDMMC_ERROR_DATA_CRC_FAIL
280 #define HAL_MMC_ERROR_CMD_RSP_TIMEOUT SDMMC_ERROR_CMD_RSP_TIMEOUT
281 #define HAL_MMC_ERROR_DATA_TIMEOUT SDMMC_ERROR_DATA_TIMEOUT
282 #define HAL_MMC_ERROR_TX_UNDERRUN SDMMC_ERROR_TX_UNDERRUN
283 #define HAL_MMC_ERROR_RX_OVERRUN SDMMC_ERROR_RX_OVERRUN
284 #define HAL_MMC_ERROR_ADDR_MISALIGNED SDMMC_ERROR_ADDR_MISALIGNED
285 #define HAL_MMC_ERROR_BLOCK_LEN_ERR SDMMC_ERROR_BLOCK_LEN_ERR
287 #define HAL_MMC_ERROR_ERASE_SEQ_ERR SDMMC_ERROR_ERASE_SEQ_ERR
288 #define HAL_MMC_ERROR_BAD_ERASE_PARAM SDMMC_ERROR_BAD_ERASE_PARAM
289 #define HAL_MMC_ERROR_WRITE_PROT_VIOLATION SDMMC_ERROR_WRITE_PROT_VIOLATION
290 #define HAL_MMC_ERROR_LOCK_UNLOCK_FAILED SDMMC_ERROR_LOCK_UNLOCK_FAILED
292 #define HAL_MMC_ERROR_COM_CRC_FAILED SDMMC_ERROR_COM_CRC_FAILED
293 #define HAL_MMC_ERROR_ILLEGAL_CMD SDMMC_ERROR_ILLEGAL_CMD
294 #define HAL_MMC_ERROR_CARD_ECC_FAILED SDMMC_ERROR_CARD_ECC_FAILED
295 #define HAL_MMC_ERROR_CC_ERR SDMMC_ERROR_CC_ERR
296 #define HAL_MMC_ERROR_GENERAL_UNKNOWN_ERR SDMMC_ERROR_GENERAL_UNKNOWN_ERR
297 #define HAL_MMC_ERROR_STREAM_READ_UNDERRUN SDMMC_ERROR_STREAM_READ_UNDERRUN
298 #define HAL_MMC_ERROR_STREAM_WRITE_OVERRUN SDMMC_ERROR_STREAM_WRITE_OVERRUN
299 #define HAL_MMC_ERROR_CID_CSD_OVERWRITE SDMMC_ERROR_CID_CSD_OVERWRITE
300 #define HAL_MMC_ERROR_WP_ERASE_SKIP SDMMC_ERROR_WP_ERASE_SKIP
301 #define HAL_MMC_ERROR_CARD_ECC_DISABLED SDMMC_ERROR_CARD_ECC_DISABLED
302 #define HAL_MMC_ERROR_ERASE_RESET SDMMC_ERROR_ERASE_RESET
304 #define HAL_MMC_ERROR_AKE_SEQ_ERR SDMMC_ERROR_AKE_SEQ_ERR
305 #define HAL_MMC_ERROR_INVALID_VOLTRANGE SDMMC_ERROR_INVALID_VOLTRANGE
306 #define HAL_MMC_ERROR_ADDR_OUT_OF_RANGE SDMMC_ERROR_ADDR_OUT_OF_RANGE
307 #define HAL_MMC_ERROR_REQUEST_NOT_APPLICABLE SDMMC_ERROR_REQUEST_NOT_APPLICABLE
308 #define HAL_MMC_ERROR_PARAM SDMMC_ERROR_INVALID_PARAMETER
309 #define HAL_MMC_ERROR_UNSUPPORTED_FEATURE SDMMC_ERROR_UNSUPPORTED_FEATURE
310 #define HAL_MMC_ERROR_BUSY SDMMC_ERROR_BUSY
311 #define HAL_MMC_ERROR_DMA SDMMC_ERROR_DMA
312 #define HAL_MMC_ERROR_TIMEOUT SDMMC_ERROR_TIMEOUT
314 #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U)
315 #define HAL_MMC_ERROR_INVALID_CALLBACK SDMMC_ERROR_INVALID_PARAMETER
324 #define MMC_CONTEXT_NONE ((uint32_t)0x00000000U)
325 #define MMC_CONTEXT_READ_SINGLE_BLOCK ((uint32_t)0x00000001U)
326 #define MMC_CONTEXT_READ_MULTIPLE_BLOCK ((uint32_t)0x00000002U)
327 #define MMC_CONTEXT_WRITE_SINGLE_BLOCK ((uint32_t)0x00000010U)
328 #define MMC_CONTEXT_WRITE_MULTIPLE_BLOCK ((uint32_t)0x00000020U)
329 #define MMC_CONTEXT_IT ((uint32_t)0x00000008U)
330 #define MMC_CONTEXT_DMA ((uint32_t)0x00000080U)
342 #define MMC_HIGH_VOLTAGE_RANGE 0x80FF8000U
343 #define MMC_DUAL_VOLTAGE_RANGE 0x80FF8080U
344 #define eMMC_HIGH_VOLTAGE_RANGE 0xC0FF8000U
345 #define eMMC_DUAL_VOLTAGE_RANGE 0xC0FF8080U
346 #define MMC_INVALID_VOLTAGE_RANGE 0x0001FF01U
354 #define MMC_LOW_CAPACITY_CARD ((uint32_t)0x00000000U)
355 #define MMC_HIGH_CAPACITY_CARD ((uint32_t)0x00000001U)
364 #define HAL_MMC_ERASE 0x00000000U
365 #define HAL_MMC_TRIM 0x00000001U
366 #define HAL_MMC_DISCARD 0x00000003U
367 #define HAL_MMC_SECURE_ERASE 0x80000000U
368 #define HAL_MMC_SECURE_TRIM_STEP1 0x80000001U
369 #define HAL_MMC_SECURE_TRIM_STEP2 0x80008000U
371 #define IS_MMC_ERASE_TYPE(TYPE) (((TYPE) == HAL_MMC_ERASE) || \
372 ((TYPE) == HAL_MMC_TRIM) || \
373 ((TYPE) == HAL_MMC_DISCARD) || \
374 ((TYPE) == HAL_MMC_SECURE_ERASE) || \
375 ((TYPE) == HAL_MMC_SECURE_TRIM_STEP1) || \
376 ((TYPE) == HAL_MMC_SECURE_TRIM_STEP2))
384 #define HAL_MMC_SRT_ERASE 0x00000001U
385 #define HAL_MMC_SRT_WRITE_CHAR_ERASE 0x00000002U
386 #define HAL_MMC_SRT_WRITE_CHAR_COMPL_RANDOM 0x00000004U
387 #define HAL_MMC_SRT_VENDOR_DEFINED 0x00000008U
390 #define IS_MMC_SRT_TYPE(TYPE) (((TYPE) == HAL_MMC_SRT_ERASE) || \
391 ((TYPE) == HAL_MMC_SRT_WRITE_CHAR_ERASE) || \
392 ((TYPE) == HAL_MMC_SRT_WRITE_CHAR_COMPL_RANDOM) || \
393 ((TYPE) == HAL_MMC_SRT_VENDOR_DEFINED))
411 #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U)
412 #define __HAL_MMC_RESET_HANDLE_STATE(__HANDLE__) do { \
413 (__HANDLE__)->State = HAL_MMC_STATE_RESET; \
414 (__HANDLE__)->MspInitCallback = NULL; \
415 (__HANDLE__)->MspDeInitCallback = NULL; \
418 #define __HAL_MMC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_MMC_STATE_RESET)
451 #define __HAL_MMC_ENABLE_IT(__HANDLE__, __INTERRUPT__) __SDMMC_ENABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__))
483 #define __HAL_MMC_DISABLE_IT(__HANDLE__, __INTERRUPT__) __SDMMC_DISABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__))
521 #define __HAL_MMC_GET_FLAG(__HANDLE__, __FLAG__) __SDMMC_GET_FLAG((__HANDLE__)->Instance, (__FLAG__))
550 #define __HAL_MMC_CLEAR_FLAG(__HANDLE__, __FLAG__) __SDMMC_CLEAR_FLAG((__HANDLE__)->Instance, (__FLAG__))
582 #define __HAL_MMC_GET_IT(__HANDLE__, __INTERRUPT__) __SDMMC_GET_IT((__HANDLE__)->Instance, (__INTERRUPT__))
614 #define __HAL_MMC_CLEAR_IT(__HANDLE__, __INTERRUPT__) __SDMMC_CLEAR_IT((__HANDLE__)->Instance, (__INTERRUPT__))
663 #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U)