at32f413_sdio.h 23 KB

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