stm32l4xx_hal_mmc.h 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_hal_mmc.h
  4. * @author MCD Application Team
  5. * @brief Header file of MMC HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32L4xx_HAL_MMC_H
  20. #define STM32L4xx_HAL_MMC_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32l4xx_hal_def.h"
  26. #include "stm32l4xx_ll_sdmmc.h"
  27. /** @addtogroup STM32L4xx_HAL_Driver
  28. * @{
  29. */
  30. #if defined(SDMMC1)
  31. /** @addtogroup MMC
  32. * @brief MMC HAL module driver
  33. * @{
  34. */
  35. /* Exported types ------------------------------------------------------------*/
  36. /** @defgroup MMC_Exported_Types MMC Exported Types
  37. * @{
  38. */
  39. /** @defgroup MMC_Exported_Types_Group1 MMC State enumeration structure
  40. * @{
  41. */
  42. typedef enum
  43. {
  44. HAL_MMC_STATE_RESET = ((uint32_t)0x00000000U), /*!< MMC not yet initialized or disabled */
  45. HAL_MMC_STATE_READY = ((uint32_t)0x00000001U), /*!< MMC initialized and ready for use */
  46. HAL_MMC_STATE_TIMEOUT = ((uint32_t)0x00000002U), /*!< MMC Timeout state */
  47. HAL_MMC_STATE_BUSY = ((uint32_t)0x00000003U), /*!< MMC process ongoing */
  48. HAL_MMC_STATE_PROGRAMMING = ((uint32_t)0x00000004U), /*!< MMC Programming State */
  49. HAL_MMC_STATE_RECEIVING = ((uint32_t)0x00000005U), /*!< MMC Receinving State */
  50. HAL_MMC_STATE_TRANSFER = ((uint32_t)0x00000006U), /*!< MMC Transfer State */
  51. HAL_MMC_STATE_ERROR = ((uint32_t)0x0000000FU) /*!< MMC is in error state */
  52. }HAL_MMC_StateTypeDef;
  53. /**
  54. * @}
  55. */
  56. /** @defgroup MMC_Exported_Types_Group2 MMC Card State enumeration structure
  57. * @{
  58. */
  59. typedef uint32_t HAL_MMC_CardStateTypeDef;
  60. #define HAL_MMC_CARD_IDLE 0x00000000U /*!< Card is in idle state (can't be checked by CMD13) */
  61. #define HAL_MMC_CARD_READY 0x00000001U /*!< Card is in ready state (can't be checked by CMD13) */
  62. #define HAL_MMC_CARD_IDENTIFICATION 0x00000002U /*!< Card is in identification state (can't be checked by CMD13) */
  63. #define HAL_MMC_CARD_STANDBY 0x00000003U /*!< Card is in standby state */
  64. #define HAL_MMC_CARD_TRANSFER 0x00000004U /*!< Card is in transfer state */
  65. #define HAL_MMC_CARD_SENDING 0x00000005U /*!< Card is sending an operation */
  66. #define HAL_MMC_CARD_RECEIVING 0x00000006U /*!< Card is receiving operation information */
  67. #define HAL_MMC_CARD_PROGRAMMING 0x00000007U /*!< Card is in programming state */
  68. #define HAL_MMC_CARD_DISCONNECTED 0x00000008U /*!< Card is disconnected */
  69. #define HAL_MMC_CARD_BUSTEST 0x00000009U /*!< Card is in bus test state */
  70. #define HAL_MMC_CARD_SLEEP 0x0000000AU /*!< Card is in sleep state (can't be checked by CMD13) */
  71. #define HAL_MMC_CARD_ERROR 0x000000FFU /*!< Card response Error (can't be checked by CMD13) */
  72. /**
  73. * @}
  74. */
  75. /** @defgroup MMC_Exported_Types_Group3 MMC Handle Structure definition
  76. * @{
  77. */
  78. #define MMC_InitTypeDef SDMMC_InitTypeDef
  79. #define MMC_TypeDef SDMMC_TypeDef
  80. /**
  81. * @brief MMC Card Information Structure definition
  82. */
  83. typedef struct
  84. {
  85. uint32_t CardType; /*!< Specifies the card Type */
  86. uint32_t Class; /*!< Specifies the class of the card class */
  87. uint32_t RelCardAdd; /*!< Specifies the Relative Card Address */
  88. uint32_t BlockNbr; /*!< Specifies the Card Capacity in blocks */
  89. uint32_t BlockSize; /*!< Specifies one block size in bytes */
  90. uint32_t LogBlockNbr; /*!< Specifies the Card logical Capacity in blocks */
  91. uint32_t LogBlockSize; /*!< Specifies logical block size in bytes */
  92. }HAL_MMC_CardInfoTypeDef;
  93. /**
  94. * @brief MMC handle Structure definition
  95. */
  96. #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U)
  97. typedef struct __MMC_HandleTypeDef
  98. #else
  99. typedef struct
  100. #endif /* USE_HAL_MMC_REGISTER_CALLBACKS */
  101. {
  102. MMC_TypeDef *Instance; /*!< MMC registers base address */
  103. MMC_InitTypeDef Init; /*!< MMC required parameters */
  104. HAL_LockTypeDef Lock; /*!< MMC locking object */
  105. uint8_t *pTxBuffPtr; /*!< Pointer to MMC Tx transfer Buffer */
  106. uint32_t TxXferSize; /*!< MMC Tx Transfer size */
  107. uint8_t *pRxBuffPtr; /*!< Pointer to MMC Rx transfer Buffer */
  108. uint32_t RxXferSize; /*!< MMC Rx Transfer size */
  109. __IO uint32_t Context; /*!< MMC transfer context */
  110. __IO HAL_MMC_StateTypeDef State; /*!< MMC card State */
  111. __IO uint32_t ErrorCode; /*!< MMC Card Error codes */
  112. #if !defined(STM32L4P5xx) && !defined(STM32L4Q5xx) && !defined(STM32L4R5xx) && !defined(STM32L4R7xx) && !defined(STM32L4R9xx) && !defined(STM32L4S5xx) && !defined(STM32L4S7xx) && !defined(STM32L4S9xx)
  113. DMA_HandleTypeDef *hdmarx; /*!< MMC Rx DMA handle parameters */
  114. DMA_HandleTypeDef *hdmatx; /*!< MMC Tx DMA handle parameters */
  115. #endif /* !STM32L4P5xx && !STM32L4Q5xx && !STM32L4R5xx && !STM32L4R7xx && !STM32L4R9xx && !STM32L4S5xx && !STM32L4S7xx && !STM32L4S9xx */
  116. HAL_MMC_CardInfoTypeDef MmcCard; /*!< MMC Card information */
  117. uint32_t CSD[4U]; /*!< MMC card specific data table */
  118. uint32_t CID[4U]; /*!< MMC card identification number table */
  119. uint32_t Ext_CSD[128];
  120. #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U)
  121. void (* TxCpltCallback) (struct __MMC_HandleTypeDef *hmmc);
  122. void (* RxCpltCallback) (struct __MMC_HandleTypeDef *hmmc);
  123. void (* ErrorCallback) (struct __MMC_HandleTypeDef *hmmc);
  124. void (* AbortCpltCallback) (struct __MMC_HandleTypeDef *hmmc);
  125. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  126. void (* Read_DMADblBuf0CpltCallback) (struct __MMC_HandleTypeDef *hmmc);
  127. void (* Read_DMADblBuf1CpltCallback) (struct __MMC_HandleTypeDef *hmmc);
  128. void (* Write_DMADblBuf0CpltCallback) (struct __MMC_HandleTypeDef *hmmc);
  129. void (* Write_DMADblBuf1CpltCallback) (struct __MMC_HandleTypeDef *hmmc);
  130. #endif
  131. void (* MspInitCallback) (struct __MMC_HandleTypeDef *hmmc);
  132. void (* MspDeInitCallback) (struct __MMC_HandleTypeDef *hmmc);
  133. #endif
  134. }MMC_HandleTypeDef;
  135. /**
  136. * @}
  137. */
  138. /** @defgroup MMC_Exported_Types_Group4 Card Specific Data: CSD Register
  139. * @{
  140. */
  141. typedef struct
  142. {
  143. __IO uint8_t CSDStruct; /*!< CSD structure */
  144. __IO uint8_t SysSpecVersion; /*!< System specification version */
  145. __IO uint8_t Reserved1; /*!< Reserved */
  146. __IO uint8_t TAAC; /*!< Data read access time 1 */
  147. __IO uint8_t NSAC; /*!< Data read access time 2 in CLK cycles */
  148. __IO uint8_t MaxBusClkFrec; /*!< Max. bus clock frequency */
  149. __IO uint16_t CardComdClasses; /*!< Card command classes */
  150. __IO uint8_t RdBlockLen; /*!< Max. read data block length */
  151. __IO uint8_t PartBlockRead; /*!< Partial blocks for read allowed */
  152. __IO uint8_t WrBlockMisalign; /*!< Write block misalignment */
  153. __IO uint8_t RdBlockMisalign; /*!< Read block misalignment */
  154. __IO uint8_t DSRImpl; /*!< DSR implemented */
  155. __IO uint8_t Reserved2; /*!< Reserved */
  156. __IO uint32_t DeviceSize; /*!< Device Size */
  157. __IO uint8_t MaxRdCurrentVDDMin; /*!< Max. read current @ VDD min */
  158. __IO uint8_t MaxRdCurrentVDDMax; /*!< Max. read current @ VDD max */
  159. __IO uint8_t MaxWrCurrentVDDMin; /*!< Max. write current @ VDD min */
  160. __IO uint8_t MaxWrCurrentVDDMax; /*!< Max. write current @ VDD max */
  161. __IO uint8_t DeviceSizeMul; /*!< Device size multiplier */
  162. __IO uint8_t EraseGrSize; /*!< Erase group size */
  163. __IO uint8_t EraseGrMul; /*!< Erase group size multiplier */
  164. __IO uint8_t WrProtectGrSize; /*!< Write protect group size */
  165. __IO uint8_t WrProtectGrEnable; /*!< Write protect group enable */
  166. __IO uint8_t ManDeflECC; /*!< Manufacturer default ECC */
  167. __IO uint8_t WrSpeedFact; /*!< Write speed factor */
  168. __IO uint8_t MaxWrBlockLen; /*!< Max. write data block length */
  169. __IO uint8_t WriteBlockPaPartial; /*!< Partial blocks for write allowed */
  170. __IO uint8_t Reserved3; /*!< Reserved */
  171. __IO uint8_t ContentProtectAppli; /*!< Content protection application */
  172. __IO uint8_t FileFormatGroup; /*!< File format group */
  173. __IO uint8_t CopyFlag; /*!< Copy flag (OTP) */
  174. __IO uint8_t PermWrProtect; /*!< Permanent write protection */
  175. __IO uint8_t TempWrProtect; /*!< Temporary write protection */
  176. __IO uint8_t FileFormat; /*!< File format */
  177. __IO uint8_t ECC; /*!< ECC code */
  178. __IO uint8_t CSD_CRC; /*!< CSD CRC */
  179. __IO uint8_t Reserved4; /*!< Always 1 */
  180. }HAL_MMC_CardCSDTypeDef;
  181. /**
  182. * @}
  183. */
  184. /** @defgroup MMC_Exported_Types_Group5 Card Identification Data: CID Register
  185. * @{
  186. */
  187. typedef struct
  188. {
  189. __IO uint8_t ManufacturerID; /*!< Manufacturer ID */
  190. __IO uint16_t OEM_AppliID; /*!< OEM/Application ID */
  191. __IO uint32_t ProdName1; /*!< Product Name part1 */
  192. __IO uint8_t ProdName2; /*!< Product Name part2 */
  193. __IO uint8_t ProdRev; /*!< Product Revision */
  194. __IO uint32_t ProdSN; /*!< Product Serial Number */
  195. __IO uint8_t Reserved1; /*!< Reserved1 */
  196. __IO uint16_t ManufactDate; /*!< Manufacturing Date */
  197. __IO uint8_t CID_CRC; /*!< CID CRC */
  198. __IO uint8_t Reserved2; /*!< Always 1 */
  199. }HAL_MMC_CardCIDTypeDef;
  200. /**
  201. * @}
  202. */
  203. #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U)
  204. /** @defgroup MMC_Exported_Types_Group6 MMC Callback ID enumeration definition
  205. * @{
  206. */
  207. typedef enum
  208. {
  209. HAL_MMC_TX_CPLT_CB_ID = 0x00U, /*!< MMC Tx Complete Callback ID */
  210. HAL_MMC_RX_CPLT_CB_ID = 0x01U, /*!< MMC Rx Complete Callback ID */
  211. HAL_MMC_ERROR_CB_ID = 0x02U, /*!< MMC Error Callback ID */
  212. HAL_MMC_ABORT_CB_ID = 0x03U, /*!< MMC Abort Callback ID */
  213. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  214. HAL_MMC_READ_DMA_DBL_BUF0_CPLT_CB_ID = 0x04U, /*!< MMC Rx DMA Double Buffer 0 Complete Callback ID */
  215. HAL_MMC_READ_DMA_DBL_BUF1_CPLT_CB_ID = 0x05U, /*!< MMC Rx DMA Double Buffer 1 Complete Callback ID */
  216. HAL_MMC_WRITE_DMA_DBL_BUF0_CPLT_CB_ID = 0x06U, /*!< MMC Tx DMA Double Buffer 0 Complete Callback ID */
  217. HAL_MMC_WRITE_DMA_DBL_BUF1_CPLT_CB_ID = 0x07U, /*!< MMC Tx DMA Double Buffer 1 Complete Callback ID */
  218. #endif
  219. HAL_MMC_MSP_INIT_CB_ID = 0x10U, /*!< MMC MspInit Callback ID */
  220. HAL_MMC_MSP_DEINIT_CB_ID = 0x11U /*!< MMC MspDeInit Callback ID */
  221. }HAL_MMC_CallbackIDTypeDef;
  222. /**
  223. * @}
  224. */
  225. /** @defgroup MMC_Exported_Types_Group7 MMC Callback pointer definition
  226. * @{
  227. */
  228. typedef void (*pMMC_CallbackTypeDef) (MMC_HandleTypeDef *hmmc);
  229. /**
  230. * @}
  231. */
  232. #endif
  233. /**
  234. * @}
  235. */
  236. /* Exported constants --------------------------------------------------------*/
  237. /** @defgroup MMC_Exported_Constants Exported Constants
  238. * @{
  239. */
  240. #define MMC_BLOCKSIZE ((uint32_t)512U) /*!< Block size is 512 bytes */
  241. /** @defgroup MMC_Exported_Constansts_Group1 MMC Error status enumeration Structure definition
  242. * @{
  243. */
  244. #define HAL_MMC_ERROR_NONE SDMMC_ERROR_NONE /*!< No error */
  245. #define HAL_MMC_ERROR_CMD_CRC_FAIL SDMMC_ERROR_CMD_CRC_FAIL /*!< Command response received (but CRC check failed) */
  246. #define HAL_MMC_ERROR_DATA_CRC_FAIL SDMMC_ERROR_DATA_CRC_FAIL /*!< Data block sent/received (CRC check failed) */
  247. #define HAL_MMC_ERROR_CMD_RSP_TIMEOUT SDMMC_ERROR_CMD_RSP_TIMEOUT /*!< Command response timeout */
  248. #define HAL_MMC_ERROR_DATA_TIMEOUT SDMMC_ERROR_DATA_TIMEOUT /*!< Data timeout */
  249. #define HAL_MMC_ERROR_TX_UNDERRUN SDMMC_ERROR_TX_UNDERRUN /*!< Transmit FIFO underrun */
  250. #define HAL_MMC_ERROR_RX_OVERRUN SDMMC_ERROR_RX_OVERRUN /*!< Receive FIFO overrun */
  251. #define HAL_MMC_ERROR_ADDR_MISALIGNED SDMMC_ERROR_ADDR_MISALIGNED /*!< Misaligned address */
  252. #define HAL_MMC_ERROR_BLOCK_LEN_ERR SDMMC_ERROR_BLOCK_LEN_ERR /*!< Transferred block length is not allowed for the card or the
  253. number of transferred bytes does not match the block length */
  254. #define HAL_MMC_ERROR_ERASE_SEQ_ERR SDMMC_ERROR_ERASE_SEQ_ERR /*!< An error in the sequence of erase command occurs */
  255. #define HAL_MMC_ERROR_BAD_ERASE_PARAM SDMMC_ERROR_BAD_ERASE_PARAM /*!< An invalid selection for erase groups */
  256. #define HAL_MMC_ERROR_WRITE_PROT_VIOLATION SDMMC_ERROR_WRITE_PROT_VIOLATION /*!< Attempt to program a write protect block */
  257. #define HAL_MMC_ERROR_LOCK_UNLOCK_FAILED SDMMC_ERROR_LOCK_UNLOCK_FAILED /*!< Sequence or password error has been detected in unlock
  258. command or if there was an attempt to access a locked card */
  259. #define HAL_MMC_ERROR_COM_CRC_FAILED SDMMC_ERROR_COM_CRC_FAILED /*!< CRC check of the previous command failed */
  260. #define HAL_MMC_ERROR_ILLEGAL_CMD SDMMC_ERROR_ILLEGAL_CMD /*!< Command is not legal for the card state */
  261. #define HAL_MMC_ERROR_CARD_ECC_FAILED SDMMC_ERROR_CARD_ECC_FAILED /*!< Card internal ECC was applied but failed to correct the data */
  262. #define HAL_MMC_ERROR_CC_ERR SDMMC_ERROR_CC_ERR /*!< Internal card controller error */
  263. #define HAL_MMC_ERROR_GENERAL_UNKNOWN_ERR SDMMC_ERROR_GENERAL_UNKNOWN_ERR /*!< General or unknown error */
  264. #define HAL_MMC_ERROR_STREAM_READ_UNDERRUN SDMMC_ERROR_STREAM_READ_UNDERRUN /*!< The card could not sustain data reading in stream rmode */
  265. #define HAL_MMC_ERROR_STREAM_WRITE_OVERRUN SDMMC_ERROR_STREAM_WRITE_OVERRUN /*!< The card could not sustain data programming in stream mode */
  266. #define HAL_MMC_ERROR_CID_CSD_OVERWRITE SDMMC_ERROR_CID_CSD_OVERWRITE /*!< CID/CSD overwrite error */
  267. #define HAL_MMC_ERROR_WP_ERASE_SKIP SDMMC_ERROR_WP_ERASE_SKIP /*!< Only partial address space was erased */
  268. #define HAL_MMC_ERROR_CARD_ECC_DISABLED SDMMC_ERROR_CARD_ECC_DISABLED /*!< Command has been executed without using internal ECC */
  269. #define HAL_MMC_ERROR_ERASE_RESET SDMMC_ERROR_ERASE_RESET /*!< Erase sequence was cleared before executing because an out
  270. of erase sequence command was received */
  271. #define HAL_MMC_ERROR_AKE_SEQ_ERR SDMMC_ERROR_AKE_SEQ_ERR /*!< Error in sequence of authentication */
  272. #define HAL_MMC_ERROR_INVALID_VOLTRANGE SDMMC_ERROR_INVALID_VOLTRANGE /*!< Error in case of invalid voltage range */
  273. #define HAL_MMC_ERROR_ADDR_OUT_OF_RANGE SDMMC_ERROR_ADDR_OUT_OF_RANGE /*!< Error when addressed block is out of range */
  274. #define HAL_MMC_ERROR_REQUEST_NOT_APPLICABLE SDMMC_ERROR_REQUEST_NOT_APPLICABLE /*!< Error when command request is not applicable */
  275. #define HAL_MMC_ERROR_PARAM SDMMC_ERROR_INVALID_PARAMETER /*!< the used parameter is not valid */
  276. #define HAL_MMC_ERROR_UNSUPPORTED_FEATURE SDMMC_ERROR_UNSUPPORTED_FEATURE /*!< Error when feature is not insupported */
  277. #define HAL_MMC_ERROR_BUSY SDMMC_ERROR_BUSY /*!< Error when transfer process is busy */
  278. #define HAL_MMC_ERROR_DMA SDMMC_ERROR_DMA /*!< Error while DMA transfer */
  279. #define HAL_MMC_ERROR_TIMEOUT SDMMC_ERROR_TIMEOUT /*!< Timeout error */
  280. #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U)
  281. #define HAL_MMC_ERROR_INVALID_CALLBACK SDMMC_ERROR_INVALID_PARAMETER /*!< Invalid callback error */
  282. #endif
  283. /**
  284. * @}
  285. */
  286. /** @defgroup MMC_Exported_Constansts_Group2 MMC context enumeration
  287. * @{
  288. */
  289. #define MMC_CONTEXT_NONE ((uint32_t)0x00000000U) /*!< None */
  290. #define MMC_CONTEXT_READ_SINGLE_BLOCK ((uint32_t)0x00000001U) /*!< Read single block operation */
  291. #define MMC_CONTEXT_READ_MULTIPLE_BLOCK ((uint32_t)0x00000002U) /*!< Read multiple blocks operation */
  292. #define MMC_CONTEXT_WRITE_SINGLE_BLOCK ((uint32_t)0x00000010U) /*!< Write single block operation */
  293. #define MMC_CONTEXT_WRITE_MULTIPLE_BLOCK ((uint32_t)0x00000020U) /*!< Write multiple blocks operation */
  294. #define MMC_CONTEXT_IT ((uint32_t)0x00000008U) /*!< Process in Interrupt mode */
  295. #define MMC_CONTEXT_DMA ((uint32_t)0x00000080U) /*!< Process in DMA mode */
  296. /**
  297. * @}
  298. */
  299. /** @defgroup MMC_Exported_Constansts_Group3 MMC Voltage mode
  300. * @{
  301. */
  302. /**
  303. * @brief
  304. */
  305. #define MMC_HIGH_VOLTAGE_RANGE 0x80FF8000U /*!< High voltage in byte mode */
  306. #define MMC_DUAL_VOLTAGE_RANGE 0x80FF8080U /*!< Dual voltage in byte mode */
  307. #define MMC_LOW_VOLTAGE_RANGE 0x80000080U /*!< Low voltage in byte mode */
  308. #define EMMC_HIGH_VOLTAGE_RANGE 0xC0FF8000U /*!< High voltage in sector mode */
  309. #define EMMC_DUAL_VOLTAGE_RANGE 0xC0FF8080U /*!< Dual voltage in sector mode */
  310. #define EMMC_LOW_VOLTAGE_RANGE 0xC0000080U /*!< Low voltage in sector mode */
  311. #define MMC_INVALID_VOLTAGE_RANGE 0x0001FF01U
  312. /**
  313. * @}
  314. */
  315. /** @defgroup MMC_Exported_Constansts_Group4 MMC Memory Cards
  316. * @{
  317. */
  318. #define MMC_LOW_CAPACITY_CARD ((uint32_t)0x00000000U) /*!< MMC Card Capacity <=2Gbytes */
  319. #define MMC_HIGH_CAPACITY_CARD ((uint32_t)0x00000001U) /*!< MMC Card Capacity >2Gbytes and <2Tbytes */
  320. /**
  321. * @}
  322. */
  323. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  324. /** @defgroup MMC_Exported_Constansts_Group5 MMC Erase Type
  325. * @{
  326. */
  327. #define HAL_MMC_ERASE 0x00000000U /*!< Erase the erase groups identified by CMD35 & 36 */
  328. #define HAL_MMC_TRIM 0x00000001U /*!< Erase the write blocks identified by CMD35 & 36 */
  329. #define HAL_MMC_DISCARD 0x00000003U /*!< Discard the write blocks identified by CMD35 & 36 */
  330. #define HAL_MMC_SECURE_ERASE 0x80000000U /*!< Perform a secure purge according SRT on the erase groups identified by CMD35 & 36 */
  331. #define HAL_MMC_SECURE_TRIM_STEP1 0x80000001U /*!< Mark the write blocks identified by CMD35 & 36 for secure erase */
  332. #define HAL_MMC_SECURE_TRIM_STEP2 0x80008000U /*!< Perform a secure purge according SRT on the write blocks previously identified */
  333. #define IS_MMC_ERASE_TYPE(TYPE) (((TYPE) == HAL_MMC_ERASE) || \
  334. ((TYPE) == HAL_MMC_TRIM) || \
  335. ((TYPE) == HAL_MMC_DISCARD) || \
  336. ((TYPE) == HAL_MMC_SECURE_ERASE) || \
  337. ((TYPE) == HAL_MMC_SECURE_TRIM_STEP1) || \
  338. ((TYPE) == HAL_MMC_SECURE_TRIM_STEP2))
  339. /**
  340. * @}
  341. */
  342. /** @defgroup MMC_Exported_Constansts_Group6 MMC Secure Removal Type
  343. * @{
  344. */
  345. #define HAL_MMC_SRT_ERASE 0x00000001U /*!< Information removed by an erase */
  346. #define HAL_MMC_SRT_WRITE_CHAR_ERASE 0x00000002U /*!< Information removed by an overwriting with a character followed by an erase */
  347. #define HAL_MMC_SRT_WRITE_CHAR_COMPL_RANDOM 0x00000004U /*!< Information removed by an overwriting with a character, its complement then a random character */
  348. #define HAL_MMC_SRT_VENDOR_DEFINED 0x00000008U /*!< Information removed using a vendor defined */
  349. #define IS_MMC_SRT_TYPE(TYPE) (((TYPE) == HAL_MMC_SRT_ERASE) || \
  350. ((TYPE) == HAL_MMC_SRT_WRITE_CHAR_ERASE) || \
  351. ((TYPE) == HAL_MMC_SRT_WRITE_CHAR_COMPL_RANDOM) || \
  352. ((TYPE) == HAL_MMC_SRT_VENDOR_DEFINED))
  353. /**
  354. * @}
  355. */
  356. #endif /* defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) */
  357. /**
  358. * @}
  359. */
  360. /* Exported macro ------------------------------------------------------------*/
  361. /** @defgroup MMC_Exported_macros MMC Exported Macros
  362. * @brief macros to handle interrupts and specific clock configurations
  363. * @{
  364. */
  365. /** @brief Reset MMC handle state.
  366. * @param __HANDLE__ : MMC handle.
  367. * @retval None
  368. */
  369. #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U)
  370. #define __HAL_MMC_RESET_HANDLE_STATE(__HANDLE__) do { \
  371. (__HANDLE__)->State = HAL_MMC_STATE_RESET; \
  372. (__HANDLE__)->MspInitCallback = NULL; \
  373. (__HANDLE__)->MspDeInitCallback = NULL; \
  374. } while(0)
  375. #else
  376. #define __HAL_MMC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_MMC_STATE_RESET)
  377. #endif
  378. #if !defined(STM32L4P5xx) && !defined(STM32L4Q5xx) && !defined(STM32L4R5xx) && !defined(STM32L4R7xx) && !defined(STM32L4R9xx) && !defined(STM32L4S5xx) && !defined(STM32L4S7xx) && !defined(STM32L4S9xx)
  379. /**
  380. * @brief Enable the MMC device.
  381. * @retval None
  382. */
  383. #define __HAL_MMC_ENABLE(__HANDLE__) __SDMMC_ENABLE((__HANDLE__)->Instance)
  384. /**
  385. * @brief Disable the MMC device.
  386. * @retval None
  387. */
  388. #define __HAL_MMC_DISABLE(__HANDLE__) __SDMMC_DISABLE((__HANDLE__)->Instance)
  389. /**
  390. * @brief Enable the SDMMC DMA transfer.
  391. * @retval None
  392. */
  393. #define __HAL_MMC_DMA_ENABLE(__HANDLE__) __SDMMC_DMA_ENABLE((__HANDLE__)->Instance)
  394. /**
  395. * @brief Disable the SDMMC DMA transfer.
  396. * @retval None
  397. */
  398. #define __HAL_MMC_DMA_DISABLE(__HANDLE__) __SDMMC_DMA_DISABLE((__HANDLE__)->Instance)
  399. #endif
  400. /**
  401. * @brief Enable the MMC device interrupt.
  402. * @param __HANDLE__ MMC Handle
  403. * @param __INTERRUPT__ specifies the SDMMC interrupt sources to be enabled.
  404. * This parameter can be one or a combination of the following values:
  405. * @arg SDMMC_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
  406. * @arg SDMMC_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
  407. * @arg SDMMC_IT_CTIMEOUT: Command response timeout interrupt
  408. * @arg SDMMC_IT_DTIMEOUT: Data timeout interrupt
  409. * @arg SDMMC_IT_TXUNDERR: Transmit FIFO underrun error interrupt
  410. * @arg SDMMC_IT_RXOVERR: Received FIFO overrun error interrupt
  411. * @arg SDMMC_IT_CMDREND: Command response received (CRC check passed) interrupt
  412. * @arg SDMMC_IT_CMDSENT: Command sent (no response required) interrupt
  413. * @arg SDMMC_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt
  414. * @arg SDMMC_IT_DHOLD: Data transfer Hold interrupt
  415. * @arg SDMMC_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt
  416. * @arg SDMMC_IT_DABORT: Data transfer aborted by CMD12 interrupt
  417. * @arg SDMMC_IT_CMDACT: Command transfer in progress interrupt
  418. * @arg SDMMC_IT_TXACT: Data transmit in progress interrupt
  419. * @arg SDMMC_IT_RXACT: Data receive in progress interrupt
  420. * @arg SDMMC_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
  421. * @arg SDMMC_IT_RXFIFOHF: Receive FIFO Half Full interrupt
  422. * @arg SDMMC_IT_TXFIFOF: Transmit FIFO full interrupt
  423. * @arg SDMMC_IT_RXFIFOF: Receive FIFO full interrupt
  424. * @arg SDMMC_IT_TXFIFOE: Transmit FIFO empty interrupt
  425. * @arg SDMMC_IT_RXFIFOE: Receive FIFO empty interrupt
  426. * @arg SDMMC_IT_TXDAVL: Data available in transmit FIFO interrupt
  427. * @arg SDMMC_IT_RXDAVL: Data available in receive FIFO interrupt
  428. * @arg SDMMC_IT_BUSYD0END: End of SDMMC_D0 Busy following a CMD response detected interrupt
  429. * @arg SDMMC_IT_SDIOIT: SD I/O interrupt received interrupt
  430. * @arg SDMMC_IT_ACKFAIL: Boot Acknowledgment received interrupt
  431. * @arg SDMMC_IT_ACKTIMEOUT: Boot Acknowledgment timeout interrupt
  432. * @arg SDMMC_IT_VSWEND: Voltage switch critical timing section completion interrupt
  433. * @arg SDMMC_IT_CKSTOP: SDMMC_CK stopped in Voltage switch procedure interrupt
  434. * @arg SDMMC_IT_IDMABTC: IDMA buffer transfer complete interrupt
  435. * @retval None
  436. */
  437. #define __HAL_MMC_ENABLE_IT(__HANDLE__, __INTERRUPT__) __SDMMC_ENABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__))
  438. /**
  439. * @brief Disable the MMC device interrupt.
  440. * @param __HANDLE__ MMC Handle
  441. * @param __INTERRUPT__ specifies the SDMMC interrupt sources to be disabled.
  442. * This parameter can be one or a combination of the following values:
  443. * @arg SDMMC_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
  444. * @arg SDMMC_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
  445. * @arg SDMMC_IT_CTIMEOUT: Command response timeout interrupt
  446. * @arg SDMMC_IT_DTIMEOUT: Data timeout interrupt
  447. * @arg SDMMC_IT_TXUNDERR: Transmit FIFO underrun error interrupt
  448. * @arg SDMMC_IT_RXOVERR: Received FIFO overrun error interrupt
  449. * @arg SDMMC_IT_CMDREND: Command response received (CRC check passed) interrupt
  450. * @arg SDMMC_IT_CMDSENT: Command sent (no response required) interrupt
  451. * @arg SDMMC_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt
  452. * @arg SDMMC_IT_DHOLD: Data transfer Hold interrupt
  453. * @arg SDMMC_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt
  454. * @arg SDMMC_IT_DABORT: Data transfer aborted by CMD12 interrupt
  455. * @arg SDMMC_IT_CMDACT: Command transfer in progress interrupt
  456. * @arg SDMMC_IT_TXACT: Data transmit in progress interrupt
  457. * @arg SDMMC_IT_RXACT: Data receive in progress interrupt
  458. * @arg SDMMC_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
  459. * @arg SDMMC_IT_RXFIFOHF: Receive FIFO Half Full interrupt
  460. * @arg SDMMC_IT_TXFIFOF: Transmit FIFO full interrupt
  461. * @arg SDMMC_IT_RXFIFOF: Receive FIFO full interrupt
  462. * @arg SDMMC_IT_TXFIFOE: Transmit FIFO empty interrupt
  463. * @arg SDMMC_IT_RXFIFOE: Receive FIFO empty interrupt
  464. * @arg SDMMC_IT_TXDAVL: Data available in transmit FIFO interrupt
  465. * @arg SDMMC_IT_RXDAVL: Data available in receive FIFO interrupt
  466. * @arg SDMMC_IT_BUSYD0END: End of SDMMC_D0 Busy following a CMD response detected interrupt
  467. * @arg SDMMC_IT_SDIOIT: SD I/O interrupt received interrupt
  468. * @arg SDMMC_IT_ACKFAIL: Boot Acknowledgment received interrupt
  469. * @arg SDMMC_IT_ACKTIMEOUT: Boot Acknowledgment timeout interrupt
  470. * @arg SDMMC_IT_VSWEND: Voltage switch critical timing section completion interrupt
  471. * @arg SDMMC_IT_CKSTOP: SDMMC_CK stopped in Voltage switch procedure interrupt
  472. * @arg SDMMC_IT_IDMABTC: IDMA buffer transfer complete interrupt
  473. * @retval None
  474. */
  475. #define __HAL_MMC_DISABLE_IT(__HANDLE__, __INTERRUPT__) __SDMMC_DISABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__))
  476. /**
  477. * @brief Check whether the specified MMC flag is set or not.
  478. * @param __HANDLE__ MMC Handle
  479. * @param __FLAG__ specifies the flag to check.
  480. * This parameter can be one of the following values:
  481. * @arg SDMMC_FLAG_CCRCFAIL: Command response received (CRC check failed)
  482. * @arg SDMMC_FLAG_DCRCFAIL: Data block sent/received (CRC check failed)
  483. * @arg SDMMC_FLAG_CTIMEOUT: Command response timeout
  484. * @arg SDMMC_FLAG_DTIMEOUT: Data timeout
  485. * @arg SDMMC_FLAG_TXUNDERR: Transmit FIFO underrun error
  486. * @arg SDMMC_FLAG_RXOVERR: Received FIFO overrun error
  487. * @arg SDMMC_FLAG_CMDREND: Command response received (CRC check passed)
  488. * @arg SDMMC_FLAG_CMDSENT: Command sent (no response required)
  489. * @arg SDMMC_FLAG_DATAEND: Data end (data counter, DATACOUNT, is zero)
  490. * @arg SDMMC_FLAG_DHOLD: Data transfer Hold
  491. * @arg SDMMC_FLAG_DBCKEND: Data block sent/received (CRC check passed)
  492. * @arg SDMMC_FLAG_DABORT: Data transfer aborted by CMD12
  493. * @arg SDMMC_FLAG_DPSMACT: Data path state machine active
  494. * @arg SDMMC_FLAG_CPSMACT: Command path state machine active
  495. * @arg SDMMC_FLAG_CMDACT: Command transfer in progress
  496. * @arg SDMMC_FLAG_TXACT: Data transmit in progress
  497. * @arg SDMMC_FLAG_RXACT: Data receive in progress
  498. * @arg SDMMC_FLAG_TXFIFOHE: Transmit FIFO Half Empty
  499. * @arg SDMMC_FLAG_RXFIFOHF: Receive FIFO Half Full
  500. * @arg SDMMC_FLAG_TXFIFOF: Transmit FIFO full
  501. * @arg SDMMC_FLAG_RXFIFOF: Receive FIFO full
  502. * @arg SDMMC_FLAG_TXFIFOE: Transmit FIFO empty
  503. * @arg SDMMC_FLAG_RXFIFOE: Receive FIFO empty
  504. * @arg SDMMC_FLAG_BUSYD0: Inverted value of SDMMC_D0 line (Busy)
  505. * @arg SDMMC_FLAG_BUSYD0END: End of SDMMC_D0 Busy following a CMD response detected
  506. * @arg SDMMC_FLAG_TXDAVL: Data available in transmit FIFO
  507. * @arg SDMMC_FLAG_RXDAVL: Data available in receive FIFO
  508. * @arg SDMMC_FLAG_SDIOIT: SD I/O interrupt received
  509. * @arg SDMMC_FLAG_ACKFAIL: Boot Acknowledgment received
  510. * @arg SDMMC_FLAG_ACKTIMEOUT: Boot Acknowledgment timeout
  511. * @arg SDMMC_FLAG_VSWEND: Voltage switch critical timing section completion
  512. * @arg SDMMC_FLAG_CKSTOP: SDMMC_CK stopped in Voltage switch procedure
  513. * @arg SDMMC_FLAG_IDMATE: IDMA transfer error
  514. * @arg SDMMC_FLAG_IDMABTC: IDMA buffer transfer complete
  515. * @retval The new state of MMC FLAG (SET or RESET).
  516. */
  517. #define __HAL_MMC_GET_FLAG(__HANDLE__, __FLAG__) __SDMMC_GET_FLAG((__HANDLE__)->Instance, (__FLAG__))
  518. /**
  519. * @brief Clear the MMC's pending flags.
  520. * @param __HANDLE__ MMC Handle
  521. * @param __FLAG__ specifies the flag to clear.
  522. * This parameter can be one or a combination of the following values:
  523. * @arg SDMMC_FLAG_CCRCFAIL: Command response received (CRC check failed)
  524. * @arg SDMMC_FLAG_DCRCFAIL: Data block sent/received (CRC check failed)
  525. * @arg SDMMC_FLAG_CTIMEOUT: Command response timeout
  526. * @arg SDMMC_FLAG_DTIMEOUT: Data timeout
  527. * @arg SDMMC_FLAG_TXUNDERR: Transmit FIFO underrun error
  528. * @arg SDMMC_FLAG_RXOVERR: Received FIFO overrun error
  529. * @arg SDMMC_FLAG_CMDREND: Command response received (CRC check passed)
  530. * @arg SDMMC_FLAG_CMDSENT: Command sent (no response required)
  531. * @arg SDMMC_FLAG_DATAEND: Data end (data counter, DATACOUNT, is zero)
  532. * @arg SDMMC_FLAG_DHOLD: Data transfer Hold
  533. * @arg SDMMC_FLAG_DBCKEND: Data block sent/received (CRC check passed)
  534. * @arg SDMMC_FLAG_DABORT: Data transfer aborted by CMD12
  535. * @arg SDMMC_FLAG_BUSYD0END: End of SDMMC_D0 Busy following a CMD response detected
  536. * @arg SDMMC_FLAG_SDIOIT: SD I/O interrupt received
  537. * @arg SDMMC_FLAG_ACKFAIL: Boot Acknowledgment received
  538. * @arg SDMMC_FLAG_ACKTIMEOUT: Boot Acknowledgment timeout
  539. * @arg SDMMC_FLAG_VSWEND: Voltage switch critical timing section completion
  540. * @arg SDMMC_FLAG_CKSTOP: SDMMC_CK stopped in Voltage switch procedure
  541. * @arg SDMMC_FLAG_IDMATE: IDMA transfer error
  542. * @arg SDMMC_FLAG_IDMABTC: IDMA buffer transfer complete
  543. * @retval None
  544. */
  545. #define __HAL_MMC_CLEAR_FLAG(__HANDLE__, __FLAG__) __SDMMC_CLEAR_FLAG((__HANDLE__)->Instance, (__FLAG__))
  546. /**
  547. * @brief Check whether the specified MMC interrupt has occurred or not.
  548. * @param __HANDLE__ MMC Handle
  549. * @param __INTERRUPT__ specifies the SDMMC interrupt source to check.
  550. * This parameter can be one of the following values:
  551. * @arg SDMMC_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
  552. * @arg SDMMC_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
  553. * @arg SDMMC_IT_CTIMEOUT: Command response timeout interrupt
  554. * @arg SDMMC_IT_DTIMEOUT: Data timeout interrupt
  555. * @arg SDMMC_IT_TXUNDERR: Transmit FIFO underrun error interrupt
  556. * @arg SDMMC_IT_RXOVERR: Received FIFO overrun error interrupt
  557. * @arg SDMMC_IT_CMDREND: Command response received (CRC check passed) interrupt
  558. * @arg SDMMC_IT_CMDSENT: Command sent (no response required) interrupt
  559. * @arg SDMMC_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt
  560. * @arg SDMMC_IT_DHOLD: Data transfer Hold interrupt
  561. * @arg SDMMC_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt
  562. * @arg SDMMC_IT_DABORT: Data transfer aborted by CMD12 interrupt
  563. * @arg SDMMC_IT_CMDACT: Command transfer in progress interrupt
  564. * @arg SDMMC_IT_TXACT: Data transmit in progress interrupt
  565. * @arg SDMMC_IT_RXACT: Data receive in progress interrupt
  566. * @arg SDMMC_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
  567. * @arg SDMMC_IT_RXFIFOHF: Receive FIFO Half Full interrupt
  568. * @arg SDMMC_IT_TXFIFOF: Transmit FIFO full interrupt
  569. * @arg SDMMC_IT_RXFIFOF: Receive FIFO full interrupt
  570. * @arg SDMMC_IT_TXFIFOE: Transmit FIFO empty interrupt
  571. * @arg SDMMC_IT_RXFIFOE: Receive FIFO empty interrupt
  572. * @arg SDMMC_IT_TXDAVL: Data available in transmit FIFO interrupt
  573. * @arg SDMMC_IT_RXDAVL: Data available in receive FIFO interrupt
  574. * @arg SDMMC_IT_BUSYD0END: End of SDMMC_D0 Busy following a CMD response detected interrupt
  575. * @arg SDMMC_IT_SDIOIT: SD I/O interrupt received interrupt
  576. * @arg SDMMC_IT_ACKFAIL: Boot Acknowledgment received interrupt
  577. * @arg SDMMC_IT_ACKTIMEOUT: Boot Acknowledgment timeout interrupt
  578. * @arg SDMMC_IT_VSWEND: Voltage switch critical timing section completion interrupt
  579. * @arg SDMMC_IT_CKSTOP: SDMMC_CK stopped in Voltage switch procedure interrupt
  580. * @arg SDMMC_IT_IDMABTC: IDMA buffer transfer complete interrupt
  581. * @retval The new state of MMC IT (SET or RESET).
  582. */
  583. #define __HAL_MMC_GET_IT(__HANDLE__, __INTERRUPT__) __SDMMC_GET_IT((__HANDLE__)->Instance, (__INTERRUPT__))
  584. /**
  585. * @brief Clear the MMC's interrupt pending bits.
  586. * @param __HANDLE__ MMC Handle
  587. * @param __INTERRUPT__ specifies the interrupt pending bit to clear.
  588. * This parameter can be one or a combination of the following values:
  589. * @arg SDMMC_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
  590. * @arg SDMMC_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
  591. * @arg SDMMC_IT_CTIMEOUT: Command response timeout interrupt
  592. * @arg SDMMC_IT_DTIMEOUT: Data timeout interrupt
  593. * @arg SDMMC_IT_TXUNDERR: Transmit FIFO underrun error interrupt
  594. * @arg SDMMC_IT_RXOVERR: Received FIFO overrun error interrupt
  595. * @arg SDMMC_IT_CMDREND: Command response received (CRC check passed) interrupt
  596. * @arg SDMMC_IT_CMDSENT: Command sent (no response required) interrupt
  597. * @arg SDMMC_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt
  598. * @arg SDMMC_IT_DHOLD: Data transfer Hold interrupt
  599. * @arg SDMMC_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt
  600. * @arg SDMMC_IT_DABORT: Data transfer aborted by CMD12 interrupt
  601. * @arg SDMMC_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
  602. * @arg SDMMC_IT_RXFIFOHF: Receive FIFO Half Full interrupt
  603. * @arg SDMMC_IT_RXFIFOF: Receive FIFO full interrupt
  604. * @arg SDMMC_IT_TXFIFOE: Transmit FIFO empty interrupt
  605. * @arg SDMMC_IT_BUSYD0END: End of SDMMC_D0 Busy following a CMD response detected interrupt
  606. * @arg SDMMC_IT_SDIOIT: SD I/O interrupt received interrupt
  607. * @arg SDMMC_IT_ACKFAIL: Boot Acknowledgment received interrupt
  608. * @arg SDMMC_IT_ACKTIMEOUT: Boot Acknowledgment timeout interrupt
  609. * @arg SDMMC_IT_VSWEND: Voltage switch critical timing section completion interrupt
  610. * @arg SDMMC_IT_CKSTOP: SDMMC_CK stopped in Voltage switch procedure interrupt
  611. * @arg SDMMC_IT_IDMABTC: IDMA buffer transfer complete interrupt
  612. * @retval None
  613. */
  614. #define __HAL_MMC_CLEAR_IT(__HANDLE__, __INTERRUPT__) __SDMMC_CLEAR_IT((__HANDLE__)->Instance, (__INTERRUPT__))
  615. /**
  616. * @}
  617. */
  618. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  619. /* Include MMC HAL Extension module */
  620. #include "stm32l4xx_hal_mmc_ex.h"
  621. #endif
  622. /* Exported functions --------------------------------------------------------*/
  623. /** @addtogroup MMC_Exported_Functions
  624. * @{
  625. */
  626. /** @addtogroup MMC_Exported_Functions_Group1
  627. * @{
  628. */
  629. HAL_StatusTypeDef HAL_MMC_Init(MMC_HandleTypeDef *hmmc);
  630. HAL_StatusTypeDef HAL_MMC_InitCard(MMC_HandleTypeDef *hmmc);
  631. HAL_StatusTypeDef HAL_MMC_DeInit (MMC_HandleTypeDef *hmmc);
  632. void HAL_MMC_MspInit(MMC_HandleTypeDef *hmmc);
  633. void HAL_MMC_MspDeInit(MMC_HandleTypeDef *hmmc);
  634. /**
  635. * @}
  636. */
  637. /** @defgroup MMC_Exported_Functions_Group2 Input and Output operation functions
  638. * @{
  639. */
  640. /* Blocking mode: Polling */
  641. HAL_StatusTypeDef HAL_MMC_ReadBlocks(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout);
  642. HAL_StatusTypeDef HAL_MMC_WriteBlocks(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout);
  643. HAL_StatusTypeDef HAL_MMC_Erase(MMC_HandleTypeDef *hmmc, uint32_t BlockStartAdd, uint32_t BlockEndAdd);
  644. /* Non-Blocking mode: IT */
  645. HAL_StatusTypeDef HAL_MMC_ReadBlocks_IT(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks);
  646. HAL_StatusTypeDef HAL_MMC_WriteBlocks_IT(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks);
  647. /* Non-Blocking mode: DMA */
  648. HAL_StatusTypeDef HAL_MMC_ReadBlocks_DMA(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks);
  649. HAL_StatusTypeDef HAL_MMC_WriteBlocks_DMA(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks);
  650. void HAL_MMC_IRQHandler(MMC_HandleTypeDef *hmmc);
  651. /* Callback in non blocking modes (DMA) */
  652. void HAL_MMC_TxCpltCallback(MMC_HandleTypeDef *hmmc);
  653. void HAL_MMC_RxCpltCallback(MMC_HandleTypeDef *hmmc);
  654. void HAL_MMC_ErrorCallback(MMC_HandleTypeDef *hmmc);
  655. void HAL_MMC_AbortCallback(MMC_HandleTypeDef *hmmc);
  656. #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U)
  657. /* MMC callback registering/unregistering */
  658. HAL_StatusTypeDef HAL_MMC_RegisterCallback (MMC_HandleTypeDef *hmmc, HAL_MMC_CallbackIDTypeDef CallbackId, pMMC_CallbackTypeDef pCallback);
  659. HAL_StatusTypeDef HAL_MMC_UnRegisterCallback(MMC_HandleTypeDef *hmmc, HAL_MMC_CallbackIDTypeDef CallbackId);
  660. #endif
  661. /**
  662. * @}
  663. */
  664. /** @defgroup MMC_Exported_Functions_Group3 Peripheral Control functions
  665. * @{
  666. */
  667. HAL_StatusTypeDef HAL_MMC_ConfigWideBusOperation(MMC_HandleTypeDef *hmmc, uint32_t WideMode);
  668. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  669. HAL_StatusTypeDef HAL_MMC_ConfigSpeedBusOperation(MMC_HandleTypeDef *hmmc, uint32_t SpeedMode);
  670. #endif
  671. /**
  672. * @}
  673. */
  674. /** @defgroup MMC_Exported_Functions_Group4 MMC card related functions
  675. * @{
  676. */
  677. HAL_MMC_CardStateTypeDef HAL_MMC_GetCardState(MMC_HandleTypeDef *hmmc);
  678. HAL_StatusTypeDef HAL_MMC_GetCardCID(MMC_HandleTypeDef *hmmc, HAL_MMC_CardCIDTypeDef *pCID);
  679. HAL_StatusTypeDef HAL_MMC_GetCardCSD(MMC_HandleTypeDef *hmmc, HAL_MMC_CardCSDTypeDef *pCSD);
  680. HAL_StatusTypeDef HAL_MMC_GetCardInfo(MMC_HandleTypeDef *hmmc, HAL_MMC_CardInfoTypeDef *pCardInfo);
  681. HAL_StatusTypeDef HAL_MMC_GetCardExtCSD(MMC_HandleTypeDef *hmmc, uint32_t *pExtCSD, uint32_t Timeout);
  682. /**
  683. * @}
  684. */
  685. /** @defgroup MMC_Exported_Functions_Group5 Peripheral State and Errors functions
  686. * @{
  687. */
  688. HAL_MMC_StateTypeDef HAL_MMC_GetState(MMC_HandleTypeDef *hmmc);
  689. uint32_t HAL_MMC_GetError(MMC_HandleTypeDef *hmmc);
  690. /**
  691. * @}
  692. */
  693. /** @defgroup MMC_Exported_Functions_Group6 Peripheral Abort management
  694. * @{
  695. */
  696. HAL_StatusTypeDef HAL_MMC_Abort(MMC_HandleTypeDef *hmmc);
  697. HAL_StatusTypeDef HAL_MMC_Abort_IT(MMC_HandleTypeDef *hmmc);
  698. /**
  699. * @}
  700. */
  701. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  702. /** @defgroup MMC_Exported_Functions_Group7 Peripheral Erase management
  703. * @{
  704. */
  705. HAL_StatusTypeDef HAL_MMC_EraseSequence(MMC_HandleTypeDef *hmmc, uint32_t EraseType, uint32_t BlockStartAdd, uint32_t BlockEndAdd);
  706. HAL_StatusTypeDef HAL_MMC_Sanitize(MMC_HandleTypeDef *hmmc);
  707. HAL_StatusTypeDef HAL_MMC_ConfigSecRemovalType(MMC_HandleTypeDef *hmmc, uint32_t SRTMode);
  708. HAL_StatusTypeDef HAL_MMC_GetSupportedSecRemovalType(MMC_HandleTypeDef *hmmc, uint32_t *SupportedSRT);
  709. /**
  710. * @}
  711. */
  712. /** @defgroup MMC_Exported_Functions_Group8 Peripheral Sleep management
  713. * @{
  714. */
  715. HAL_StatusTypeDef HAL_MMC_SleepDevice(MMC_HandleTypeDef *hmmc);
  716. HAL_StatusTypeDef HAL_MMC_AwakeDevice(MMC_HandleTypeDef *hmmc);
  717. /**
  718. * @}
  719. */
  720. #endif /* defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) */
  721. /**
  722. * @}
  723. */
  724. /* Private types -------------------------------------------------------------*/
  725. /** @defgroup MMC_Private_Types MMC Private Types
  726. * @{
  727. */
  728. /**
  729. * @}
  730. */
  731. /* Private defines -----------------------------------------------------------*/
  732. /** @defgroup MMC_Private_Defines MMC Private Defines
  733. * @{
  734. */
  735. /**
  736. * @}
  737. */
  738. /* Private variables ---------------------------------------------------------*/
  739. /** @defgroup MMC_Private_Variables MMC Private Variables
  740. * @{
  741. */
  742. /**
  743. * @}
  744. */
  745. /* Private constants ---------------------------------------------------------*/
  746. /** @defgroup MMC_Private_Constants MMC Private Constants
  747. * @{
  748. */
  749. /**
  750. * @}
  751. */
  752. /* Private macros ------------------------------------------------------------*/
  753. /** @defgroup MMC_Private_Macros MMC Private Macros
  754. * @{
  755. */
  756. /**
  757. * @}
  758. */
  759. /* Private functions prototypes ----------------------------------------------*/
  760. /** @defgroup MMC_Private_Functions_Prototypes MMC Private Functions Prototypes
  761. * @{
  762. */
  763. /**
  764. * @}
  765. */
  766. /* Private functions ---------------------------------------------------------*/
  767. /** @defgroup MMC_Private_Functions MMC Private Functions
  768. * @{
  769. */
  770. /**
  771. * @}
  772. */
  773. /**
  774. * @}
  775. */
  776. /**
  777. * @}
  778. */
  779. #endif /* SDMMC1 */
  780. /**
  781. * @}
  782. */
  783. #ifdef __cplusplus
  784. }
  785. #endif
  786. #endif /* STM32L4xx_HAL_MMC_H */