at32f413_sdio.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. /**
  2. **************************************************************************
  3. * @file at32f413_sdio.h
  4. * @version v2.0.5
  5. * @date 2022-05-20
  6. * @brief at32f413 sdio header file
  7. **************************************************************************
  8. * Copyright notice & Disclaimer
  9. *
  10. * The software Board Support Package (BSP) that is made available to
  11. * download from Artery official website is the copyrighted work of Artery.
  12. * Artery authorizes customers to use, copy, and distribute the BSP
  13. * software and its related documentation for the purpose of design and
  14. * development in conjunction with Artery microcontrollers. Use of the
  15. * software is governed by this copyright notice and the following disclaimer.
  16. *
  17. * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  18. * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  19. * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  20. * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  21. * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  22. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  23. *
  24. **************************************************************************
  25. */
  26. /* define to prevent recursive inclusion -------------------------------------*/
  27. #ifndef __AT32F413_SDIO_H
  28. #define __AT32F413_SDIO_H
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /* includes ------------------------------------------------------------------*/
  33. #include "at32f413.h"
  34. /** @addtogroup AT32F413_periph_driver
  35. * @{
  36. */
  37. /** @addtogroup SDIO
  38. * @{
  39. */
  40. /** @defgroup SDIO_interrupts_definition
  41. * @brief sdio interrupt
  42. * @{
  43. */
  44. #define SDIO_CMDFAIL_INT ((uint32_t)0x00000001) /*!< command response received check failed interrupt */
  45. #define SDIO_DTFAIL_INT ((uint32_t)0x00000002) /*!< data block sent/received check failed interrupt */
  46. #define SDIO_CMDTIMEOUT_INT ((uint32_t)0x00000004) /*!< command response timerout interrupt */
  47. #define SDIO_DTTIMEOUT_INT ((uint32_t)0x00000008) /*!< data timeout interrupt */
  48. #define SDIO_TXERRU_INT ((uint32_t)0x00000010) /*!< transmit underrun error interrupt */
  49. #define SDIO_RXERRO_INT ((uint32_t)0x00000020) /*!< received overrun error interrupt */
  50. #define SDIO_CMDRSPCMPL_INT ((uint32_t)0x00000040) /*!< command response received interrupt */
  51. #define SDIO_CMDCMPL_INT ((uint32_t)0x00000080) /*!< command sent interrupt */
  52. #define SDIO_DTCMP_INT ((uint32_t)0x00000100) /*!< data sent interrupt */
  53. #define SDIO_SBITERR_INT ((uint32_t)0x00000200) /*!< start bit not detected on data bus interrupt */
  54. #define SDIO_DTBLKCMPL_INT ((uint32_t)0x00000400) /*!< data block sent/received interrupt */
  55. #define SDIO_DOCMD_INT ((uint32_t)0x00000800) /*!< command transfer in progress interrupt */
  56. #define SDIO_DOTX_INT ((uint32_t)0x00001000) /*!< data transmit in progress interrupt */
  57. #define SDIO_DORX_INT ((uint32_t)0x00002000) /*!< data receive in progress interrupt */
  58. #define SDIO_TXBUFH_INT ((uint32_t)0x00004000) /*!< transmit buf half empty interrupt */
  59. #define SDIO_RXBUFH_INT ((uint32_t)0x00008000) /*!< receive buf half full interrupt */
  60. #define SDIO_TXBUFF_INT ((uint32_t)0x00010000) /*!< transmit buf full interrupt */
  61. #define SDIO_RXBUFF_INT ((uint32_t)0x00020000) /*!< receive buf full interrupt */
  62. #define SDIO_TXBUFE_INT ((uint32_t)0x00040000) /*!< transmit buf empty interrupt */
  63. #define SDIO_RXBUFE_INT ((uint32_t)0x00080000) /*!< receive buf empty interrupt */
  64. #define SDIO_TXBUF_INT ((uint32_t)0x00100000) /*!< data available in transmit interrupt */
  65. #define SDIO_RXBUF_INT ((uint32_t)0x00200000) /*!< data available in receive interrupt */
  66. #define SDIO_SDIOIF_INT ((uint32_t)0x00400000) /*!< sdio interface received interrupt */
  67. /**
  68. * @}
  69. */
  70. /** @defgroup SDIO_flags_definition
  71. * @brief sdio flag
  72. * @{
  73. */
  74. #define SDIO_CMDFAIL_FLAG ((uint32_t)0x00000001) /*!< command response received check failed flag */
  75. #define SDIO_DTFAIL_FLAG ((uint32_t)0x00000002) /*!< data block sent/received check failed flag */
  76. #define SDIO_CMDTIMEOUT_FLAG ((uint32_t)0x00000004) /*!< command response timerout flag */
  77. #define SDIO_DTTIMEOUT_FLAG ((uint32_t)0x00000008) /*!< data timeout flag */
  78. #define SDIO_TXERRU_FLAG ((uint32_t)0x00000010) /*!< transmit underrun error flag */
  79. #define SDIO_RXERRO_FLAG ((uint32_t)0x00000020) /*!< received overrun error flag */
  80. #define SDIO_CMDRSPCMPL_FLAG ((uint32_t)0x00000040) /*!< command response received flag */
  81. #define SDIO_CMDCMPL_FLAG ((uint32_t)0x00000080) /*!< command sent flag */
  82. #define SDIO_DTCMPL_FLAG ((uint32_t)0x00000100) /*!< data sent flag */
  83. #define SDIO_SBITERR_FLAG ((uint32_t)0x00000200) /*!< start bit not detected on data bus flag */
  84. #define SDIO_DTBLKCMPL_FLAG ((uint32_t)0x00000400) /*!< data block sent/received flag */
  85. #define SDIO_DOCMD_FLAG ((uint32_t)0x00000800) /*!< command transfer in progress flag */
  86. #define SDIO_DOTX_FLAG ((uint32_t)0x00001000) /*!< data transmit in progress flag */
  87. #define SDIO_DORX_FLAG ((uint32_t)0x00002000) /*!< data receive in progress flag */
  88. #define SDIO_TXBUFH_FLAG ((uint32_t)0x00004000) /*!< transmit buf half empty flag */
  89. #define SDIO_RXBUFH_FLAG ((uint32_t)0x00008000) /*!< receive buf half full flag */
  90. #define SDIO_TXBUFF_FLAG ((uint32_t)0x00010000) /*!< transmit buf full flag */
  91. #define SDIO_RXBUFF_FLAG ((uint32_t)0x00020000) /*!< receive buf full flag */
  92. #define SDIO_TXBUFE_FLAG ((uint32_t)0x00040000) /*!< transmit buf empty flag */
  93. #define SDIO_RXBUFE_FLAG ((uint32_t)0x00080000) /*!< receive buf empty flag */
  94. #define SDIO_TXBUF_FLAG ((uint32_t)0x00100000) /*!< data available in transmit flag */
  95. #define SDIO_RXBUF_FLAG ((uint32_t)0x00200000) /*!< data available in receive flag */
  96. #define SDIO_SDIOIF_FLAG ((uint32_t)0x00400000) /*!< sdio interface received flag */
  97. /**
  98. * @}
  99. */
  100. /** @defgroup SDIO_exported_types
  101. * @{
  102. */
  103. /**
  104. * @brief sdio power state
  105. */
  106. typedef enum
  107. {
  108. SDIO_POWER_OFF = 0x00, /*!< power-off, clock to card is stopped */
  109. SDIO_POWER_ON = 0x03 /*!< power-on, the card is clocked */
  110. } sdio_power_state_type;
  111. /**
  112. * @brief sdio edge phase
  113. */
  114. typedef enum
  115. {
  116. SDIO_CLOCK_EDGE_RISING = 0x00, /*!< sdio bus clock generated on the rising edge of the master clock */
  117. SDIO_CLOCK_EDGE_FALLING = 0x01 /*!< sdio bus clock generated on the falling edge of the master clock */
  118. } sdio_edge_phase_type;
  119. /**
  120. * @brief sdio bus width
  121. */
  122. typedef enum
  123. {
  124. SDIO_BUS_WIDTH_D1 = 0x00, /*!< sdio wide bus select 1-bit */
  125. SDIO_BUS_WIDTH_D4 = 0x01, /*!< sdio wide bus select 4-bit */
  126. SDIO_BUS_WIDTH_D8 = 0x02 /*!< sdio wide bus select 8-bit */
  127. } sdio_bus_width_type;
  128. /**
  129. * @brief sdio response type
  130. */
  131. typedef enum
  132. {
  133. SDIO_RESPONSE_NO = 0x00, /*!< no response */
  134. SDIO_RESPONSE_SHORT = 0x01, /*!< short response */
  135. SDIO_RESPONSE_LONG = 0x03 /*!< long response */
  136. } sdio_reponse_type;
  137. /**
  138. * @brief sdio wait type
  139. */
  140. typedef enum
  141. {
  142. SDIO_WAIT_FOR_NO = 0x00, /*!< no wait */
  143. SDIO_WAIT_FOR_INT = 0x01, /*!< wait interrupt request */
  144. SDIO_WAIT_FOR_PEND = 0x02 /*!< wait end of transfer */
  145. } sdio_wait_type;
  146. /**
  147. * @brief sdio response register index
  148. */
  149. typedef enum
  150. {
  151. SDIO_RSP1_INDEX = 0x00, /*!< response index 1, corresponding to sdio_rsp register 1 */
  152. SDIO_RSP2_INDEX = 0x01, /*!< response index 2, corresponding to sdio_rsp register 2 */
  153. SDIO_RSP3_INDEX = 0x02, /*!< response index 3, corresponding to sdio_rsp register 3 */
  154. SDIO_RSP4_INDEX = 0x03 /*!< response index 4, corresponding to sdio_rsp register 4 */
  155. } sdio_rsp_index_type;
  156. /**
  157. * @brief sdio data block size
  158. */
  159. typedef enum
  160. {
  161. SDIO_DATA_BLOCK_SIZE_1B = 0x00, /*!< data block size 1 byte */
  162. SDIO_DATA_BLOCK_SIZE_2B = 0x01, /*!< data block size 2 bytes */
  163. SDIO_DATA_BLOCK_SIZE_4B = 0x02, /*!< data block size 4 bytes */
  164. SDIO_DATA_BLOCK_SIZE_8B = 0x03, /*!< data block size 8 bytes */
  165. SDIO_DATA_BLOCK_SIZE_16B = 0x04, /*!< data block size 16 bytes */
  166. SDIO_DATA_BLOCK_SIZE_32B = 0x05, /*!< data block size 32 bytes */
  167. SDIO_DATA_BLOCK_SIZE_64B = 0x06, /*!< data block size 64 bytes */
  168. SDIO_DATA_BLOCK_SIZE_128B = 0x07, /*!< data block size 128 bytes */
  169. SDIO_DATA_BLOCK_SIZE_256B = 0x08, /*!< data block size 256 bytes */
  170. SDIO_DATA_BLOCK_SIZE_512B = 0x09, /*!< data block size 512 bytes */
  171. SDIO_DATA_BLOCK_SIZE_1024B = 0x0A, /*!< data block size 1024 bytes */
  172. SDIO_DATA_BLOCK_SIZE_2048B = 0x0B, /*!< data block size 2048 bytes */
  173. SDIO_DATA_BLOCK_SIZE_4096B = 0x0C, /*!< data block size 4096 bytes */
  174. SDIO_DATA_BLOCK_SIZE_8192B = 0x0D, /*!< data block size 8192 bytes */
  175. SDIO_DATA_BLOCK_SIZE_16384B = 0x0E /*!< data block size 16384 bytes */
  176. } sdio_block_size_type;
  177. /**
  178. * @brief sdio data transfer mode
  179. */
  180. typedef enum
  181. {
  182. SDIO_DATA_BLOCK_TRANSFER = 0x00, /*!< the sdio block transfer mode */
  183. SDIO_DATA_STREAM_TRANSFER = 0x01 /*!< the sdio stream transfer mode */
  184. } sdio_transfer_mode_type;
  185. /**
  186. * @brief sdio data transfer direction
  187. */
  188. typedef enum
  189. {
  190. SDIO_DATA_TRANSFER_TO_CARD = 0x00, /*!< the sdio controller write */
  191. SDIO_DATA_TRANSFER_TO_CONTROLLER = 0x01 /*!< the sdio controller read */
  192. } sdio_transfer_direction_type;
  193. /**
  194. * @brief sdio read wait mode
  195. */
  196. typedef enum
  197. {
  198. SDIO_READ_WAIT_CONTROLLED_BY_D2 = 0x00, /*!< the sdio read wait on data2 line */
  199. SDIO_READ_WAIT_CONTROLLED_BY_CK = 0x01 /*!< the sdio read wait on clock line */
  200. } sdio_read_wait_mode_type;
  201. /**
  202. * @brief sdio command structure
  203. */
  204. typedef struct
  205. {
  206. uint32_t argument; /*!< the sdio command argument is sent to a card as part of command message */
  207. uint8_t cmd_index; /*!< the sdio command index */
  208. sdio_reponse_type rsp_type; /*!< the sdio response type */
  209. sdio_wait_type wait_type; /*!< the sdio wait for interrupt request is enabled or disable */
  210. } sdio_command_struct_type;
  211. /**
  212. * @brief sdio data structure
  213. */
  214. typedef struct
  215. {
  216. uint32_t timeout; /*!< the sdio data timeout period in car bus clock periods */
  217. uint32_t data_length; /*!< the sdio data length */
  218. sdio_block_size_type block_size; /*!< the sdio data block size of block transfer mode */
  219. sdio_transfer_mode_type transfer_mode; /*!< the sdio transfer mode, block or stream */
  220. sdio_transfer_direction_type transfer_direction; /*!< the sdio data transfer direction */
  221. } sdio_data_struct_type;
  222. /**
  223. * @brief type define sdio register all
  224. */
  225. typedef struct
  226. {
  227. /**
  228. * @brief sdio pwrctrl register, offset:0x00
  229. */
  230. union
  231. {
  232. __IO uint32_t pwrctrl;
  233. struct
  234. {
  235. __IO uint32_t ps : 2; /* [1:0] */
  236. __IO uint32_t reserved1 : 30;/* [31:2] */
  237. } pwrctrl_bit;
  238. };
  239. /**
  240. * @brief sdio clkctrl register, offset:0x04
  241. */
  242. union
  243. {
  244. __IO uint32_t clkctrl;
  245. struct
  246. {
  247. __IO uint32_t clkdiv_l : 8; /* [7:0] */
  248. __IO uint32_t clkoen : 1; /* [8] */
  249. __IO uint32_t pwrsven : 1; /* [9] */
  250. __IO uint32_t bypsen : 1; /* [10] */
  251. __IO uint32_t busws : 2; /* [12:11] */
  252. __IO uint32_t clkegs : 1; /* [13] */
  253. __IO uint32_t hfcen : 1; /* [14] */
  254. __IO uint32_t clkdiv_h : 2; /* [16:15] */
  255. __IO uint32_t reserved1 : 15;/* [31:17] */
  256. } clkctrl_bit;
  257. };
  258. /**
  259. * @brief sdio argu register, offset:0x08
  260. */
  261. union
  262. {
  263. __IO uint32_t argu;
  264. struct
  265. {
  266. __IO uint32_t argu : 32;/* [31:0] */
  267. } argu_bit;
  268. };
  269. /**
  270. * @brief sdio cmdctrl register, offset:0x0C
  271. */
  272. union
  273. {
  274. __IO uint32_t cmdctrl;
  275. struct
  276. {
  277. __IO uint32_t cmdidx : 6; /* [5:0] */
  278. __IO uint32_t rspwt : 2; /* [7:6] */
  279. __IO uint32_t intwt : 1; /* [8] */
  280. __IO uint32_t pndwt : 1; /* [9] */
  281. __IO uint32_t ccsmen : 1; /* [10] */
  282. __IO uint32_t iosusp : 1; /* [11] */
  283. __IO uint32_t reserved1 : 20;/* [31:12] */
  284. } cmdctrl_bit;
  285. };
  286. /**
  287. * @brief sdio rspcmd register, offset:0x10
  288. */
  289. union
  290. {
  291. __IO uint32_t rspcmd;
  292. struct
  293. {
  294. __IO uint32_t rspcmd : 6; /* [5:0] */
  295. __IO uint32_t reserved1 : 26;/* [31:6] */
  296. } rspcmd_bit;
  297. };
  298. /**
  299. * @brief sdio rsp1 register, offset:0x14
  300. */
  301. union
  302. {
  303. __IO uint32_t rsp1;
  304. struct
  305. {
  306. __IO uint32_t cardsts1 : 32;/* [31:0] */
  307. } rsp1_bit;
  308. };
  309. /**
  310. * @brief sdio rsp2 register, offset:0x18
  311. */
  312. union
  313. {
  314. __IO uint32_t rsp2;
  315. struct
  316. {
  317. __IO uint32_t cardsts2 : 32;/* [31:0] */
  318. } rsp2_bit;
  319. };
  320. /**
  321. * @brief sdio rsp3 register, offset:0x1C
  322. */
  323. union
  324. {
  325. __IO uint32_t rsp3;
  326. struct
  327. {
  328. __IO uint32_t cardsts3 : 32;/* [31:0] */
  329. } rsp3_bit;
  330. };
  331. /**
  332. * @brief sdio rsp4 register, offset:0x20
  333. */
  334. union
  335. {
  336. __IO uint32_t rsp4;
  337. struct
  338. {
  339. __IO uint32_t cardsts4 : 32;/* [31:0] */
  340. } rsp4_bit;
  341. };
  342. /**
  343. * @brief sdio dttmr register, offset:0x24
  344. */
  345. union
  346. {
  347. __IO uint32_t dttmr;
  348. struct
  349. {
  350. __IO uint32_t timeout : 32;/* [31:0] */
  351. } dttmr_bit;
  352. };
  353. /**
  354. * @brief sdio dtlen register, offset:0x28
  355. */
  356. union
  357. {
  358. __IO uint32_t dtlen;
  359. struct
  360. {
  361. __IO uint32_t dtlen : 25;/* [24:0] */
  362. __IO uint32_t reserved1 : 7; /* [31:25] */
  363. } dtlen_bit;
  364. };
  365. /**
  366. * @brief sdio dtctrl register, offset:0x2C
  367. */
  368. union
  369. {
  370. __IO uint32_t dtctrl;
  371. struct
  372. {
  373. __IO uint32_t tfren : 1; /* [0] */
  374. __IO uint32_t tfrdir : 1; /* [1] */
  375. __IO uint32_t tfrmode : 1; /* [2] */
  376. __IO uint32_t dmaen : 1; /* [3] */
  377. __IO uint32_t blksize : 4; /* [7:4] */
  378. __IO uint32_t rdwtstart : 1; /* [8] */
  379. __IO uint32_t rdwtstop : 1; /* [9] */
  380. __IO uint32_t rdwtmode : 1; /* [10] */
  381. __IO uint32_t ioen : 1; /* [11] */
  382. __IO uint32_t reserved1 : 20;/* [31:12] */
  383. } dtctrl_bit;
  384. };
  385. /**
  386. * @brief sdio dtcnt register, offset:0x30
  387. */
  388. union
  389. {
  390. __IO uint32_t dtcnt;
  391. struct
  392. {
  393. __IO uint32_t cnt : 25;/* [24:0] */
  394. __IO uint32_t reserved1 : 7; /* [31:25] */
  395. } dtcnt_bit;
  396. };
  397. /**
  398. * @brief sdio sts register, offset:0x34
  399. */
  400. union
  401. {
  402. __IO uint32_t sts;
  403. struct
  404. {
  405. __IO uint32_t cmdfail : 1; /* [0] */
  406. __IO uint32_t dtfail : 1; /* [1] */
  407. __IO uint32_t cmdtimeout : 1; /* [2] */
  408. __IO uint32_t dttimeout : 1; /* [3] */
  409. __IO uint32_t txerru : 1; /* [4] */
  410. __IO uint32_t rxerro : 1; /* [5] */
  411. __IO uint32_t cmdrspcmpl : 1; /* [6] */
  412. __IO uint32_t cmdcmpl : 1; /* [7] */
  413. __IO uint32_t dtcmpl : 1; /* [8] */
  414. __IO uint32_t sbiterr : 1; /* [9] */
  415. __IO uint32_t dtblkcmpl : 1; /* [10] */
  416. __IO uint32_t docmd : 1; /* [11] */
  417. __IO uint32_t dotx : 1; /* [12] */
  418. __IO uint32_t dorx : 1; /* [13] */
  419. __IO uint32_t txbufh : 1; /* [14] */
  420. __IO uint32_t rxbufh : 1; /* [15] */
  421. __IO uint32_t txbuff : 1; /* [16] */
  422. __IO uint32_t rxbuff : 1; /* [17] */
  423. __IO uint32_t txbufe : 1; /* [18] */
  424. __IO uint32_t rxbufe : 1; /* [19] */
  425. __IO uint32_t txbuf : 1; /* [20] */
  426. __IO uint32_t rxbuf : 1; /* [21] */
  427. __IO uint32_t ioif : 1; /* [22] */
  428. __IO uint32_t reserved1 : 9; /* [31:23] */
  429. } sts_bit;
  430. };
  431. /**
  432. * @brief sdio intclr register, offset:0x38
  433. */
  434. union
  435. {
  436. __IO uint32_t intclr;
  437. struct
  438. {
  439. __IO uint32_t cmdfail : 1; /* [0] */
  440. __IO uint32_t dtfail : 1; /* [1] */
  441. __IO uint32_t cmdtimeout : 1; /* [2] */
  442. __IO uint32_t dttimeout : 1; /* [3] */
  443. __IO uint32_t txerru : 1; /* [4] */
  444. __IO uint32_t rxerro : 1; /* [5] */
  445. __IO uint32_t cmdrspcmpl : 1; /* [6] */
  446. __IO uint32_t cmdcmpl : 1; /* [7] */
  447. __IO uint32_t dtcmpl : 1; /* [8] */
  448. __IO uint32_t sbiterr : 1; /* [9] */
  449. __IO uint32_t dtblkcmpl : 1; /* [10] */
  450. __IO uint32_t reserved1 : 11;/* [21:11] */
  451. __IO uint32_t ioif : 1; /* [22] */
  452. __IO uint32_t reserved2 : 9; /* [31:23] */
  453. } intclr_bit;
  454. };
  455. /**
  456. * @brief sdio inten register, offset:0x3C
  457. */
  458. union
  459. {
  460. __IO uint32_t inten;
  461. struct
  462. {
  463. __IO uint32_t cmdfailien : 1; /* [0] */
  464. __IO uint32_t dtfailien : 1; /* [1] */
  465. __IO uint32_t cmdtimeoutien : 1; /* [2] */
  466. __IO uint32_t dttimeoutien : 1; /* [3] */
  467. __IO uint32_t txerruien : 1; /* [4] */
  468. __IO uint32_t rxerroien : 1; /* [5] */
  469. __IO uint32_t cmdrspcmplien : 1; /* [6] */
  470. __IO uint32_t cmdcmplien : 1; /* [7] */
  471. __IO uint32_t dtcmplien : 1; /* [8] */
  472. __IO uint32_t sbiterrien : 1; /* [9] */
  473. __IO uint32_t dtblkcmplien : 1; /* [10] */
  474. __IO uint32_t docmdien : 1; /* [11] */
  475. __IO uint32_t dotxien : 1; /* [12] */
  476. __IO uint32_t dorxien : 1; /* [13] */
  477. __IO uint32_t txbufhien : 1; /* [14] */
  478. __IO uint32_t rxbufhien : 1; /* [15] */
  479. __IO uint32_t txbuffien : 1; /* [16] */
  480. __IO uint32_t rxbuffien : 1; /* [17] */
  481. __IO uint32_t txbufeien : 1; /* [18] */
  482. __IO uint32_t rxbufeien : 1; /* [19] */
  483. __IO uint32_t txbufien : 1; /* [20] */
  484. __IO uint32_t rxbufien : 1; /* [21] */
  485. __IO uint32_t ioifien : 1; /* [22] */
  486. __IO uint32_t reserved1 : 9; /* [31:23] */
  487. } inten_bit;
  488. };
  489. /**
  490. * @brief sdio reserved1 register, offset:0x40~0x44
  491. */
  492. __IO uint32_t reserved1[2];
  493. /**
  494. * @brief sdio bufcnt register, offset:0x48
  495. */
  496. union
  497. {
  498. __IO uint32_t bufcnt;
  499. struct
  500. {
  501. __IO uint32_t cnt : 24;/* [23:0] */
  502. __IO uint32_t reserved1 : 8; /* [31:24] */
  503. } bufcnt_bit;
  504. };
  505. /**
  506. * @brief sdio reserved2 register, offset:0x4C~0x7C
  507. */
  508. __IO uint32_t reserved2[13];
  509. /**
  510. * @brief sdio buf register, offset:0x80
  511. */
  512. union
  513. {
  514. __IO uint32_t buf;
  515. struct
  516. {
  517. __IO uint32_t dt : 32;/* [31:0] */
  518. } buf_bit;
  519. };
  520. } sdio_type;
  521. /**
  522. * @}
  523. */
  524. #define SDIO1 ((sdio_type *) SDIO1_BASE)
  525. /** @defgroup SDIO_exported_functions
  526. * @{
  527. */
  528. void sdio_reset(sdio_type *sdio_x);
  529. void sdio_power_set(sdio_type *sdio_x, sdio_power_state_type power_state);
  530. flag_status sdio_power_status_get(sdio_type *sdio_x);
  531. void sdio_clock_config(sdio_type *sdio_x, uint16_t clk_div, sdio_edge_phase_type clk_edg);
  532. void sdio_bus_width_config(sdio_type *sdio_x, sdio_bus_width_type width);
  533. void sdio_clock_bypass(sdio_type *sdio_x, confirm_state new_state);
  534. void sdio_power_saving_mode_enable(sdio_type *sdio_x, confirm_state new_state);
  535. void sdio_flow_control_enable(sdio_type *sdio_x, confirm_state new_state);
  536. void sdio_clock_enable(sdio_type *sdio_x, confirm_state new_state);
  537. void sdio_dma_enable(sdio_type *sdio_x, confirm_state new_state);
  538. void sdio_interrupt_enable(sdio_type *sdio_x, uint32_t int_opt, confirm_state new_state);
  539. flag_status sdio_flag_get(sdio_type *sdio_x, uint32_t flag);
  540. void sdio_flag_clear(sdio_type *sdio_x, uint32_t flag);
  541. void sdio_command_config(sdio_type *sdio_x, sdio_command_struct_type *command_struct);
  542. void sdio_command_state_machine_enable(sdio_type *sdio_x, confirm_state new_state);
  543. uint8_t sdio_command_response_get(sdio_type *sdio_x);
  544. uint32_t sdio_response_get(sdio_type *sdio_x, sdio_rsp_index_type reg_index);
  545. void sdio_data_config(sdio_type *sdio_x, sdio_data_struct_type *data_struct);
  546. void sdio_data_state_machine_enable(sdio_type *sdio_x, confirm_state new_state);
  547. uint32_t sdio_data_counter_get(sdio_type *sdio_x);
  548. uint32_t sdio_data_read(sdio_type *sdio_x);
  549. uint32_t sdio_buffer_counter_get(sdio_type *sdio_x);
  550. void sdio_data_write(sdio_type *sdio_x, uint32_t data);
  551. void sdio_read_wait_mode_set(sdio_type *sdio_x, sdio_read_wait_mode_type mode);
  552. void sdio_read_wait_start(sdio_type *sdio_x, confirm_state new_state);
  553. void sdio_read_wait_stop(sdio_type *sdio_x, confirm_state new_state);
  554. void sdio_io_function_enable(sdio_type *sdio_x, confirm_state new_state);
  555. void sdio_io_suspend_command_set(sdio_type *sdio_x, confirm_state new_state);
  556. /**
  557. * @}
  558. */
  559. /**
  560. * @}
  561. */
  562. /**
  563. * @}
  564. */
  565. #ifdef __cplusplus
  566. }
  567. #endif
  568. #endif