at32f425_dma.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. /**
  2. **************************************************************************
  3. * @file at32f425_dma.h
  4. * @brief at32f425 dma 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 __AT32F425_DMA_H
  26. #define __AT32F425_DMA_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "at32f425.h"
  32. /** @addtogroup AT32F425_periph_driver
  33. * @{
  34. */
  35. /** @addtogroup DMA
  36. * @{
  37. */
  38. /** @defgroup DMA_interrupts_definition
  39. * @brief dma interrupt
  40. * @{
  41. */
  42. #define DMA_FDT_INT ((uint32_t)0x00000002) /*!< dma full data transfer interrupt */
  43. #define DMA_HDT_INT ((uint32_t)0x00000004) /*!< dma half data transfer interrupt */
  44. #define DMA_DTERR_INT ((uint32_t)0x00000008) /*!< dma errorr interrupt */
  45. /**
  46. * @}
  47. */
  48. /** @defgroup DMA_flexible_channel
  49. * @{
  50. */
  51. #define FLEX_CHANNEL1 ((uint8_t)0x01) /*!< dma flexible channel1 */
  52. #define FLEX_CHANNEL2 ((uint8_t)0x02) /*!< dma flexible channel2 */
  53. #define FLEX_CHANNEL3 ((uint8_t)0x03) /*!< dma flexible channel3 */
  54. #define FLEX_CHANNEL4 ((uint8_t)0x04) /*!< dma flexible channel4 */
  55. #define FLEX_CHANNEL5 ((uint8_t)0x05) /*!< dma flexible channel5 */
  56. #define FLEX_CHANNEL6 ((uint8_t)0x06) /*!< dma flexible channel6 */
  57. #define FLEX_CHANNEL7 ((uint8_t)0x07) /*!< dma flexible channel7 */
  58. /**
  59. * @}
  60. */
  61. /** @defgroup DMA_flags_definition
  62. * @brief dma flag
  63. * @{
  64. */
  65. #define DMA1_GL1_FLAG ((uint32_t)0x00000001) /*!< dma1 channel1 global flag */
  66. #define DMA1_FDT1_FLAG ((uint32_t)0x00000002) /*!< dma1 channel1 full data transfer flag */
  67. #define DMA1_HDT1_FLAG ((uint32_t)0x00000004) /*!< dma1 channel1 half data transfer flag */
  68. #define DMA1_DTERR1_FLAG ((uint32_t)0x00000008) /*!< dma1 channel1 error flag */
  69. #define DMA1_GL2_FLAG ((uint32_t)0x00000010) /*!< dma1 channel2 global flag */
  70. #define DMA1_FDT2_FLAG ((uint32_t)0x00000020) /*!< dma1 channel2 full data transfer flag */
  71. #define DMA1_HDT2_FLAG ((uint32_t)0x00000040) /*!< dma1 channel2 half data transfer flag */
  72. #define DMA1_DTERR2_FLAG ((uint32_t)0x00000080) /*!< dma1 channel2 error flag */
  73. #define DMA1_GL3_FLAG ((uint32_t)0x00000100) /*!< dma1 channel3 global flag */
  74. #define DMA1_FDT3_FLAG ((uint32_t)0x00000200) /*!< dma1 channel3 full data transfer flag */
  75. #define DMA1_HDT3_FLAG ((uint32_t)0x00000400) /*!< dma1 channel3 half data transfer flag */
  76. #define DMA1_DTERR3_FLAG ((uint32_t)0x00000800) /*!< dma1 channel3 error flag */
  77. #define DMA1_GL4_FLAG ((uint32_t)0x00001000) /*!< dma1 channel4 global flag */
  78. #define DMA1_FDT4_FLAG ((uint32_t)0x00002000) /*!< dma1 channel4 full data transfer flag */
  79. #define DMA1_HDT4_FLAG ((uint32_t)0x00004000) /*!< dma1 channel4 half data transfer flag */
  80. #define DMA1_DTERR4_FLAG ((uint32_t)0x00008000) /*!< dma1 channel4 error flag */
  81. #define DMA1_GL5_FLAG ((uint32_t)0x00010000) /*!< dma1 channel5 global flag */
  82. #define DMA1_FDT5_FLAG ((uint32_t)0x00020000) /*!< dma1 channel5 full data transfer flag */
  83. #define DMA1_HDT5_FLAG ((uint32_t)0x00040000) /*!< dma1 channel5 half data transfer flag */
  84. #define DMA1_DTERR5_FLAG ((uint32_t)0x00080000) /*!< dma1 channel5 error flag */
  85. #define DMA1_GL6_FLAG ((uint32_t)0x00100000) /*!< dma1 channel6 global flag */
  86. #define DMA1_FDT6_FLAG ((uint32_t)0x00200000) /*!< dma1 channel6 full data transfer flag */
  87. #define DMA1_HDT6_FLAG ((uint32_t)0x00400000) /*!< dma1 channel6 half data transfer flag */
  88. #define DMA1_DTERR6_FLAG ((uint32_t)0x00800000) /*!< dma1 channel6 error flag */
  89. #define DMA1_GL7_FLAG ((uint32_t)0x01000000) /*!< dma1 channel7 global flag */
  90. #define DMA1_FDT7_FLAG ((uint32_t)0x02000000) /*!< dma1 channel7 full data transfer flag */
  91. #define DMA1_HDT7_FLAG ((uint32_t)0x04000000) /*!< dma1 channel7 half data transfer flag */
  92. #define DMA1_DTERR7_FLAG ((uint32_t)0x08000000) /*!< dma1 channel7 error flag */
  93. /**
  94. * @}
  95. */
  96. /** @defgroup DMA_exported_types
  97. * @{
  98. */
  99. /**
  100. * @brief dma flexible request type
  101. */
  102. typedef enum
  103. {
  104. DMA_FLEXIBLE_ADC1 = 0x05, /*!< adc1 flexible request id */
  105. DMA_FLEXIBLE_SPI1_RX = 0x10, /*!< spi1_rx flexible request id */
  106. DMA_FLEXIBLE_SPI1_TX = 0x11, /*!< spi1_tx flexible request id */
  107. DMA_FLEXIBLE_SPI2_RX = 0x12, /*!< spi2_rx flexible request id */
  108. DMA_FLEXIBLE_SPI2_TX = 0x13, /*!< spi2_tx flexible request id */
  109. DMA_FLEXIBLE_SPI3_RX = 0x3C, /*!< spi3_rx flexible request id */
  110. DMA_FLEXIBLE_SPI3_TX = 0x3D, /*!< spi3_tx flexible request id */
  111. DMA_FLEXIBLE_UART1_RX = 0x32, /*!< usart1_rx flexible request id */
  112. DMA_FLEXIBLE_UART1_TX = 0x33, /*!< usart1_tx flexible request id */
  113. DMA_FLEXIBLE_UART2_RX = 0x34, /*!< usart2_rx flexible request id */
  114. DMA_FLEXIBLE_UART2_TX = 0x35, /*!< usart2_tx flexible request id */
  115. DMA_FLEXIBLE_UART3_RX = 0x36, /*!< usart3_rx flexible request id */
  116. DMA_FLEXIBLE_UART3_TX = 0x37, /*!< usart3_tx flexible request id */
  117. DMA_FLEXIBLE_UART4_RX = 0x38, /*!< usart4_rx flexible request id */
  118. DMA_FLEXIBLE_UART4_TX = 0x39, /*!< usart4_tx flexible request id */
  119. DMA_FLEXIBLE_I2C1_RX = 0x0A, /*!< i2c1_rx flexible request id */
  120. DMA_FLEXIBLE_I2C1_TX = 0x0B, /*!< i2c1_tx flexible request id */
  121. DMA_FLEXIBLE_I2C2_RX = 0x0C, /*!< i2c2_rx flexible request id */
  122. DMA_FLEXIBLE_I2C2_TX = 0x0D, /*!< i2c2_tx flexible request id */
  123. DMA_FLEXIBLE_TMR1_TRIG = 0x18, /*!< tmr1_trig flexible request id */
  124. DMA_FLEXIBLE_TMR1_HALL = 0x18, /*!< tmr1_hall flexible request id */
  125. DMA_FLEXIBLE_TMR1_OVERFLOW = 0x19, /*!< tmr1_overflow flexible request id */
  126. DMA_FLEXIBLE_TMR1_CH1 = 0x14, /*!< tmr1_ch1 flexible request id */
  127. DMA_FLEXIBLE_TMR1_CH2 = 0x15, /*!< tmr1_ch2 flexible request id */
  128. DMA_FLEXIBLE_TMR1_CH3 = 0x16, /*!< tmr1_ch3 flexible request id */
  129. DMA_FLEXIBLE_TMR1_CH4 = 0x17, /*!< tmr1_ch4 flexible request id */
  130. DMA_FLEXIBLE_TMR2_TRIG = 0x1E, /*!< tmr2_trig flexible request id */
  131. DMA_FLEXIBLE_TMR2_OVERFLOW = 0x1F, /*!< tmr2_overflow flexible request id */
  132. DMA_FLEXIBLE_TMR2_CH1 = 0x1A, /*!< tmr2_ch1 flexible request id */
  133. DMA_FLEXIBLE_TMR2_CH2 = 0x1B, /*!< tmr2_ch2 flexible request id */
  134. DMA_FLEXIBLE_TMR2_CH3 = 0x1C, /*!< tmr2_ch3 flexible request id */
  135. DMA_FLEXIBLE_TMR2_CH4 = 0x1D, /*!< tmr2_ch4 flexible request id */
  136. DMA_FLEXIBLE_TMR3_TRIG = 0x24, /*!< tmr3_trig flexible request id */
  137. DMA_FLEXIBLE_TMR3_OVERFLOW = 0x25, /*!< tmr3_overflow flexible request id */
  138. DMA_FLEXIBLE_TMR3_CH1 = 0x20, /*!< tmr3_ch1 flexible request id */
  139. DMA_FLEXIBLE_TMR3_CH2 = 0x21, /*!< tmr3_ch2 flexible request id */
  140. DMA_FLEXIBLE_TMR3_CH3 = 0x22, /*!< tmr3_ch3 flexible request id */
  141. DMA_FLEXIBLE_TMR3_CH4 = 0x23, /*!< tmr3_ch4 flexible request id */
  142. DMA_FLEXIBLE_TMR6_OVERFLOW = 0x26, /*!< tmr6_overflow flexible request id */
  143. DMA_FLEXIBLE_TMR7_OVERFLOW = 0x27, /*!< tmr7_overflow flexible request id */
  144. DMA_FLEXIBLE_TMR15_TRIG = 0x2A, /*!< tmr15_trig flexible request id */
  145. DMA_FLEXIBLE_TMR15_HALL = 0x2A, /*!< tmr15_hall flexible request id */
  146. DMA_FLEXIBLE_TMR15_OVERFLOW = 0x2B, /*!< tmr15_overflow flexible request id */
  147. DMA_FLEXIBLE_TMR15_CH1 = 0x28, /*!< tmr15_ch1 flexible request id */
  148. DMA_FLEXIBLE_TMR15_CH2 = 0x29, /*!< tmr15_ch2 flexible request id */
  149. DMA_FLEXIBLE_TMR16_OVERFLOW = 0x2E, /*!< tmr16_overflow flexible request id */
  150. DMA_FLEXIBLE_TMR16_CH1 = 0x2C, /*!< tmr16_ch1 flexible request id */
  151. DMA_FLEXIBLE_TMR17_OVERFLOW = 0x31, /*!< tmr17_overflow flexible request id */
  152. DMA_FLEXIBLE_TMR17_CH1 = 0x2F, /*!< tmr17_ch1 flexible request id */
  153. } dma_flexible_request_type;
  154. /**
  155. * @brief dma direction type
  156. */
  157. typedef enum
  158. {
  159. DMA_DIR_PERIPHERAL_TO_MEMORY = 0x0000, /*!< dma data transfer direction:peripheral to memory */
  160. DMA_DIR_MEMORY_TO_PERIPHERAL = 0x0010, /*!< dma data transfer direction:memory to peripheral */
  161. DMA_DIR_MEMORY_TO_MEMORY = 0x4000 /*!< dma data transfer direction:memory to memory */
  162. } dma_dir_type;
  163. /**
  164. * @brief dma peripheral incremented type
  165. */
  166. typedef enum
  167. {
  168. DMA_PERIPHERAL_INC_DISABLE = 0x00, /*!< dma peripheral increment mode disable */
  169. DMA_PERIPHERAL_INC_ENABLE = 0x01 /*!< dma peripheral increment mode enable */
  170. } dma_peripheral_inc_type;
  171. /**
  172. * @brief dma memory incremented type
  173. */
  174. typedef enum
  175. {
  176. DMA_MEMORY_INC_DISABLE = 0x00, /*!< dma memory increment mode disable */
  177. DMA_MEMORY_INC_ENABLE = 0x01 /*!< dma memory increment mode enable */
  178. } dma_memory_inc_type;
  179. /**
  180. * @brief dma peripheral data size type
  181. */
  182. typedef enum
  183. {
  184. DMA_PERIPHERAL_DATA_WIDTH_BYTE = 0x00, /*!< dma peripheral databus width 8bit */
  185. DMA_PERIPHERAL_DATA_WIDTH_HALFWORD = 0x01, /*!< dma peripheral databus width 16bit */
  186. DMA_PERIPHERAL_DATA_WIDTH_WORD = 0x02 /*!< dma peripheral databus width 32bit */
  187. } dma_peripheral_data_size_type;
  188. /**
  189. * @brief dma memory data size type
  190. */
  191. typedef enum
  192. {
  193. DMA_MEMORY_DATA_WIDTH_BYTE = 0x00, /*!< dma memory databus width 8bit */
  194. DMA_MEMORY_DATA_WIDTH_HALFWORD = 0x01, /*!< dma memory databus width 16bit */
  195. DMA_MEMORY_DATA_WIDTH_WORD = 0x02 /*!< dma memory databus width 32bit */
  196. } dma_memory_data_size_type;
  197. /**
  198. * @brief dma priority level type
  199. */
  200. typedef enum
  201. {
  202. DMA_PRIORITY_LOW = 0x00, /*!< dma channel priority: low */
  203. DMA_PRIORITY_MEDIUM = 0x01, /*!< dma channel priority: mediue */
  204. DMA_PRIORITY_HIGH = 0x02, /*!< dma channel priority: high */
  205. DMA_PRIORITY_VERY_HIGH = 0x03 /*!< dma channel priority: very high */
  206. } dma_priority_level_type;
  207. /**
  208. * @brief dma init type
  209. */
  210. typedef struct
  211. {
  212. uint32_t peripheral_base_addr; /*!< base addrress for peripheral */
  213. uint32_t memory_base_addr; /*!< base addrress for memory */
  214. dma_dir_type direction; /*!< dma transmit direction, peripheral as source or as destnation */
  215. uint16_t buffer_size; /*!< counter to transfer */
  216. confirm_state peripheral_inc_enable; /*!< periphera address increment after one transmit */
  217. confirm_state memory_inc_enable; /*!< memory address increment after one transmit */
  218. dma_peripheral_data_size_type peripheral_data_width; /*!< peripheral data width for transmit */
  219. dma_memory_data_size_type memory_data_width; /*!< memory data width for transmit */
  220. confirm_state loop_mode_enable; /*!< when circular mode enable, buffer size will reload if count to 0 */
  221. dma_priority_level_type priority; /*!< dma priority can choose from very high, high, dedium or low */
  222. } dma_init_type;
  223. /**
  224. * @brief type define dma register
  225. */
  226. typedef struct
  227. {
  228. /**
  229. * @brief dma sts register, offset:0x00
  230. */
  231. union
  232. {
  233. __IO uint32_t sts;
  234. struct
  235. {
  236. __IO uint32_t gf1 : 1; /* [0] */
  237. __IO uint32_t fdtf1 : 1; /* [1] */
  238. __IO uint32_t hdtf1 : 1; /* [2] */
  239. __IO uint32_t dterrf1 : 1; /* [3] */
  240. __IO uint32_t gf2 : 1; /* [4] */
  241. __IO uint32_t fdtf2 : 1; /* [5] */
  242. __IO uint32_t hdtf2 : 1; /* [6] */
  243. __IO uint32_t dterrf2 : 1; /* [7] */
  244. __IO uint32_t gf3 : 1; /* [8] */
  245. __IO uint32_t fdtf3 : 1; /* [9] */
  246. __IO uint32_t hdtf3 : 1; /* [10] */
  247. __IO uint32_t dterrf3 : 1; /* [11] */
  248. __IO uint32_t gf4 : 1; /* [12] */
  249. __IO uint32_t fdtf4 : 1; /* [13] */
  250. __IO uint32_t hdtf4 : 1; /* [14] */
  251. __IO uint32_t dterrf4 : 1; /* [15] */
  252. __IO uint32_t gf5 : 1; /* [16] */
  253. __IO uint32_t fdtf5 : 1; /* [17] */
  254. __IO uint32_t hdtf5 : 1; /* [18] */
  255. __IO uint32_t dterrf5 : 1; /* [19] */
  256. __IO uint32_t gf6 : 1; /* [20] */
  257. __IO uint32_t fdtf6 : 1; /* [21] */
  258. __IO uint32_t hdtf6 : 1; /* [22] */
  259. __IO uint32_t dterrf6 : 1; /* [23] */
  260. __IO uint32_t gf7 : 1; /* [24] */
  261. __IO uint32_t fdtf7 : 1; /* [25] */
  262. __IO uint32_t hdtf7 : 1; /* [26] */
  263. __IO uint32_t dterrf7 : 1; /* [27] */
  264. __IO uint32_t reserved1 : 4; /* [31:28] */
  265. } sts_bit;
  266. };
  267. /**
  268. * @brief dma clr register, offset:0x04
  269. */
  270. union
  271. {
  272. __IO uint32_t clr;
  273. struct
  274. {
  275. __IO uint32_t gfc1 : 1; /* [0] */
  276. __IO uint32_t fdtfc1 : 1; /* [1] */
  277. __IO uint32_t hdtfc1 : 1; /* [2] */
  278. __IO uint32_t dterrfc1 : 1; /* [3] */
  279. __IO uint32_t gfc2 : 1; /* [4] */
  280. __IO uint32_t fdtfc2 : 1; /* [5] */
  281. __IO uint32_t hdtfc2 : 1; /* [6] */
  282. __IO uint32_t dterrfc2 : 1; /* [7] */
  283. __IO uint32_t gfc3 : 1; /* [8] */
  284. __IO uint32_t fdtfc3 : 1; /* [9] */
  285. __IO uint32_t hdtfc3 : 1; /* [10] */
  286. __IO uint32_t dterrfc3 : 1; /* [11] */
  287. __IO uint32_t gfc4 : 1; /* [12] */
  288. __IO uint32_t fdtfc4 : 1; /* [13] */
  289. __IO uint32_t hdtfc4 : 1; /* [14] */
  290. __IO uint32_t dterrfc4 : 1; /* [15] */
  291. __IO uint32_t gfc5 : 1; /* [16] */
  292. __IO uint32_t fdtfc5 : 1; /* [17] */
  293. __IO uint32_t hdtfc5 : 1; /* [18] */
  294. __IO uint32_t dterrfc5 : 1; /* [19] */
  295. __IO uint32_t gfc6 : 1; /* [20] */
  296. __IO uint32_t fdtfc6 : 1; /* [21] */
  297. __IO uint32_t hdtfc6 : 1; /* [22] */
  298. __IO uint32_t dterrfc6 : 1; /* [23] */
  299. __IO uint32_t gfc7 : 1; /* [24] */
  300. __IO uint32_t fdtfc7 : 1; /* [25] */
  301. __IO uint32_t hdtfc7 : 1; /* [26] */
  302. __IO uint32_t dterrfc7 : 1; /* [27] */
  303. __IO uint32_t reserved1 : 4; /* [31:28] */
  304. } clr_bit;
  305. };
  306. /**
  307. * @brief reserved, offset:0x08~0x9C
  308. */
  309. __IO uint32_t reserved1[38];
  310. /**
  311. * @brief dma src_sel0 register, offset:0xA0
  312. */
  313. union
  314. {
  315. __IO uint32_t src_sel0;
  316. struct
  317. {
  318. __IO uint32_t ch1_src : 8; /* [7:0] */
  319. __IO uint32_t ch2_src : 8; /* [15:8] */
  320. __IO uint32_t ch3_src : 8; /* [23:16] */
  321. __IO uint32_t ch4_src : 8; /* [31:24] */
  322. } src_sel0_bit;
  323. };
  324. /**
  325. * @brief dma src_sel1 register, offset:0xA4
  326. */
  327. union
  328. {
  329. __IO uint32_t src_sel1;
  330. struct
  331. {
  332. __IO uint32_t ch5_src : 8; /* [7:0] */
  333. __IO uint32_t ch6_src : 8; /* [15:8] */
  334. __IO uint32_t ch7_src : 8; /* [23:16] */
  335. __IO uint32_t dma_flex_en : 1; /* [24] */
  336. __IO uint32_t reserved1 : 7; /* [31:25] */
  337. } src_sel1_bit;
  338. };
  339. } dma_type;
  340. /**
  341. * @brief type define dma channel register all
  342. */
  343. typedef struct
  344. {
  345. /**
  346. * @brief dma ctrl register, offset:0x08+20*(x-1) x=1...7
  347. */
  348. union
  349. {
  350. __IO uint32_t ctrl;
  351. struct
  352. {
  353. __IO uint32_t chen : 1; /* [0] */
  354. __IO uint32_t fdtien : 1; /* [1] */
  355. __IO uint32_t hdtien : 1; /* [2] */
  356. __IO uint32_t dterrien : 1; /* [3] */
  357. __IO uint32_t dtd : 1; /* [4] */
  358. __IO uint32_t lm : 1; /* [5] */
  359. __IO uint32_t pincm : 1; /* [6] */
  360. __IO uint32_t mincm : 1; /* [7] */
  361. __IO uint32_t pwidth : 2; /* [9:8] */
  362. __IO uint32_t mwidth : 2; /* [11:10] */
  363. __IO uint32_t chpl : 2; /* [13:12] */
  364. __IO uint32_t m2m : 1; /* [14] */
  365. __IO uint32_t reserved1 : 17;/* [31:15] */
  366. } ctrl_bit;
  367. };
  368. /**
  369. * @brief dma dtcnt register, offset:0x0C+20*(x-1) x=1...7
  370. */
  371. union
  372. {
  373. __IO uint32_t dtcnt;
  374. struct
  375. {
  376. __IO uint32_t cnt : 16;/* [15:0] */
  377. __IO uint32_t reserved1 : 16;/* [31:16] */
  378. } dtcnt_bit;
  379. };
  380. /**
  381. * @brief dma cpba register, offset:0x10+20*(x-1) x=1...7
  382. */
  383. union
  384. {
  385. __IO uint32_t paddr;
  386. struct
  387. {
  388. __IO uint32_t paddr : 32;/* [31:0] */
  389. } paddr_bit;
  390. };
  391. /**
  392. * @brief dma cmba register, offset:0x14+20*(x-1) x=1...7
  393. */
  394. union
  395. {
  396. __IO uint32_t maddr;
  397. struct
  398. {
  399. __IO uint32_t maddr : 32;/* [31:0] */
  400. } maddr_bit;
  401. };
  402. } dma_channel_type;
  403. /**
  404. * @}
  405. */
  406. #define DMA1 ((dma_type *) DMA1_BASE)
  407. #define DMA1_CHANNEL1 ((dma_channel_type *) DMA1_CHANNEL1_BASE)
  408. #define DMA1_CHANNEL2 ((dma_channel_type *) DMA1_CHANNEL2_BASE)
  409. #define DMA1_CHANNEL3 ((dma_channel_type *) DMA1_CHANNEL3_BASE)
  410. #define DMA1_CHANNEL4 ((dma_channel_type *) DMA1_CHANNEL4_BASE)
  411. #define DMA1_CHANNEL5 ((dma_channel_type *) DMA1_CHANNEL5_BASE)
  412. #define DMA1_CHANNEL6 ((dma_channel_type *) DMA1_CHANNEL6_BASE)
  413. #define DMA1_CHANNEL7 ((dma_channel_type *) DMA1_CHANNEL7_BASE)
  414. /** @defgroup DMA_exported_functions
  415. * @{
  416. */
  417. void dma_reset(dma_channel_type* dmax_channely);
  418. void dma_data_number_set(dma_channel_type* dmax_channely, uint16_t data_number);
  419. uint16_t dma_data_number_get(dma_channel_type* dmax_channely);
  420. void dma_interrupt_enable(dma_channel_type* dmax_channely, uint32_t dma_int, confirm_state new_state);
  421. void dma_channel_enable(dma_channel_type* dmax_channely, confirm_state new_state);
  422. void dma_flexible_config(dma_type* dma_x, uint8_t flex_channelx, dma_flexible_request_type flexible_request);
  423. flag_status dma_flag_get(uint32_t dmax_flag);
  424. void dma_flag_clear(uint32_t dmax_flag);
  425. void dma_default_para_init(dma_init_type* dma_init_struct);
  426. void dma_init(dma_channel_type* dmax_channely, dma_init_type* dma_init_struct);
  427. /**
  428. * @}
  429. */
  430. /**
  431. * @}
  432. */
  433. /**
  434. * @}
  435. */
  436. #ifdef __cplusplus
  437. }
  438. #endif
  439. #endif