at32f403a_407_dma.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. /**
  2. **************************************************************************
  3. * @file at32f403a_407_dma.h
  4. * @brief at32f403a_407 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 __AT32F403A_407_DMA_H
  26. #define __AT32F403A_407_DMA_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "at32f403a_407.h"
  32. /** @addtogroup AT32F403A_407_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. #define DMA2_GL1_FLAG ((uint32_t)0x10000001) /*!< dma2 channel1 global flag */
  94. #define DMA2_FDT1_FLAG ((uint32_t)0x10000002) /*!< dma2 channel1 full data transfer flag */
  95. #define DMA2_HDT1_FLAG ((uint32_t)0x10000004) /*!< dma2 channel1 half data transfer flag */
  96. #define DMA2_DTERR1_FLAG ((uint32_t)0x10000008) /*!< dma2 channel1 error flag */
  97. #define DMA2_GL2_FLAG ((uint32_t)0x10000010) /*!< dma2 channel2 global flag */
  98. #define DMA2_FDT2_FLAG ((uint32_t)0x10000020) /*!< dma2 channel2 full data transfer flag */
  99. #define DMA2_HDT2_FLAG ((uint32_t)0x10000040) /*!< dma2 channel2 half data transfer flag */
  100. #define DMA2_DTERR2_FLAG ((uint32_t)0x10000080) /*!< dma2 channel2 error flag */
  101. #define DMA2_GL3_FLAG ((uint32_t)0x10000100) /*!< dma2 channel3 global flag */
  102. #define DMA2_FDT3_FLAG ((uint32_t)0x10000200) /*!< dma2 channel3 full data transfer flag */
  103. #define DMA2_HDT3_FLAG ((uint32_t)0x10000400) /*!< dma2 channel3 half data transfer flag */
  104. #define DMA2_DTERR3_FLAG ((uint32_t)0x10000800) /*!< dma2 channel3 error flag */
  105. #define DMA2_GL4_FLAG ((uint32_t)0x10001000) /*!< dma2 channel4 global flag */
  106. #define DMA2_FDT4_FLAG ((uint32_t)0x10002000) /*!< dma2 channel4 full data transfer flag */
  107. #define DMA2_HDT4_FLAG ((uint32_t)0x10004000) /*!< dma2 channel4 half data transfer flag */
  108. #define DMA2_DTERR4_FLAG ((uint32_t)0x10008000) /*!< dma2 channel4 error flag */
  109. #define DMA2_GL5_FLAG ((uint32_t)0x10010000) /*!< dma2 channel5 global flag */
  110. #define DMA2_FDT5_FLAG ((uint32_t)0x10020000) /*!< dma2 channel5 full data transfer flag */
  111. #define DMA2_HDT5_FLAG ((uint32_t)0x10040000) /*!< dma2 channel5 half data transfer flag */
  112. #define DMA2_DTERR5_FLAG ((uint32_t)0x10080000) /*!< dma2 channel5 error flag */
  113. #define DMA2_GL6_FLAG ((uint32_t)0x10100000) /*!< dma2 channel6 global flag */
  114. #define DMA2_FDT6_FLAG ((uint32_t)0x10200000) /*!< dma2 channel6 full data transfer flag */
  115. #define DMA2_HDT6_FLAG ((uint32_t)0x10400000) /*!< dma2 channel6 half data transfer flag */
  116. #define DMA2_DTERR6_FLAG ((uint32_t)0x10800000) /*!< dma2 channel6 error flag */
  117. #define DMA2_GL7_FLAG ((uint32_t)0x11000000) /*!< dma2 channel7 global flag */
  118. #define DMA2_FDT7_FLAG ((uint32_t)0x12000000) /*!< dma2 channel7 full data transfer flag */
  119. #define DMA2_HDT7_FLAG ((uint32_t)0x14000000) /*!< dma2 channel7 half data transfer flag */
  120. #define DMA2_DTERR7_FLAG ((uint32_t)0x18000000) /*!< dma2 channel7 error flag */
  121. /**
  122. * @}
  123. */
  124. /** @defgroup DMA_exported_types
  125. * @{
  126. */
  127. /**
  128. * @brief dma flexible request type
  129. */
  130. typedef enum
  131. {
  132. DMA_FLEXIBLE_ADC1 = 0x01, /*!< adc1 flexible request id */
  133. DMA_FLEXIBLE_ADC3 = 0x03, /*!< adc3 flexible request id */
  134. DMA_FLEXIBLE_DAC1 = 0x05, /*!< dac1 flexible request id */
  135. DMA_FLEXIBLE_DAC2 = 0x06, /*!< dac2 flexible request id */
  136. DMA_FLEXIBLE_SPI1_RX = 0x09, /*!< spi1_rx flexible request id */
  137. DMA_FLEXIBLE_SPI1_TX = 0x0A, /*!< spi1_tx flexible request id */
  138. DMA_FLEXIBLE_SPI2_RX = 0x0B, /*!< spi2_rx flexible request id */
  139. DMA_FLEXIBLE_SPI2_TX = 0x0C, /*!< spi2_tx flexible request id */
  140. DMA_FLEXIBLE_SPI3_RX = 0x0D, /*!< spi3_rx flexible request id */
  141. DMA_FLEXIBLE_SPI3_TX = 0x0E, /*!< spi3_tx flexible request id */
  142. DMA_FLEXIBLE_SPI4_RX = 0x0F, /*!< spi4_rx flexible request id */
  143. DMA_FLEXIBLE_SPI4_TX = 0x10, /*!< spi4_tx flexible request id */
  144. DMA_FLEXIBLE_I2S2EXT_RX = 0x11, /*!< i2s2ext_rx flexible request id */
  145. DMA_FLEXIBLE_I2S2EXT_TX = 0x12, /*!< i2s2ext_tx flexible request id */
  146. DMA_FLEXIBLE_I2S3EXT_RX = 0x13, /*!< i2s3ext_rx flexible request id */
  147. DMA_FLEXIBLE_I2S3EXT_TX = 0x14, /*!< i2s3ext_tx flexible request id */
  148. DMA_FLEXIBLE_UART1_RX = 0x19, /*!< uart1_rx flexible request id */
  149. DMA_FLEXIBLE_UART1_TX = 0x1A, /*!< uart1_tx flexible request id */
  150. DMA_FLEXIBLE_UART2_RX = 0x1B, /*!< uart2_rx flexible request id */
  151. DMA_FLEXIBLE_UART2_TX = 0x1C, /*!< uart2_tx flexible request id */
  152. DMA_FLEXIBLE_UART3_RX = 0x1D, /*!< uart3_rx flexible request id */
  153. DMA_FLEXIBLE_UART3_TX = 0x1E, /*!< uart3_tx flexible request id */
  154. DMA_FLEXIBLE_UART4_RX = 0x1F, /*!< uart4_rx flexible request id */
  155. DMA_FLEXIBLE_UART4_TX = 0x20, /*!< uart4_tx flexible request id */
  156. DMA_FLEXIBLE_UART5_RX = 0x21, /*!< uart5_rx flexible request id */
  157. DMA_FLEXIBLE_UART5_TX = 0x22, /*!< uart5_tx flexible request id */
  158. DMA_FLEXIBLE_UART6_RX = 0x23, /*!< uart6_rx flexible request id */
  159. DMA_FLEXIBLE_UART6_TX = 0x24, /*!< uart6_tx flexible request id */
  160. DMA_FLEXIBLE_UART7_RX = 0x25, /*!< uart7_rx flexible request id */
  161. DMA_FLEXIBLE_UART7_TX = 0x26, /*!< uart7_tx flexible request id */
  162. DMA_FLEXIBLE_UART8_RX = 0x27, /*!< uart8_rx flexible request id */
  163. DMA_FLEXIBLE_UART8_TX = 0x28, /*!< uart8_tx flexible request id */
  164. DMA_FLEXIBLE_I2C1_RX = 0x29, /*!< i2c1_rx flexible request id */
  165. DMA_FLEXIBLE_I2C1_TX = 0x2A, /*!< i2c1_tx flexible request id */
  166. DMA_FLEXIBLE_I2C2_RX = 0x2B, /*!< i2c2_rx flexible request id */
  167. DMA_FLEXIBLE_I2C2_TX = 0x2C, /*!< i2c2_tx flexible request id */
  168. DMA_FLEXIBLE_I2C3_RX = 0x2D, /*!< i2c3_rx flexible request id */
  169. DMA_FLEXIBLE_I2C3_TX = 0x2E, /*!< i2c3_tx flexible request id */
  170. DMA_FLEXIBLE_SDIO1 = 0x31, /*!< sdio1 flexible request id */
  171. DMA_FLEXIBLE_SDIO2 = 0x32, /*!< sdio2 flexible request id */
  172. DMA_FLEXIBLE_TMR1_TRIG = 0x35, /*!< tmr1_trig flexible request id */
  173. DMA_FLEXIBLE_TMR1_HALL = 0x36, /*!< tmr1_hall flexible request id */
  174. DMA_FLEXIBLE_TMR1_OVERFLOW = 0x37, /*!< tmr1_overflow flexible request id */
  175. DMA_FLEXIBLE_TMR1_CH1 = 0x38, /*!< tmr1_ch1 flexible request id */
  176. DMA_FLEXIBLE_TMR1_CH2 = 0x39, /*!< tmr1_ch2 flexible request id */
  177. DMA_FLEXIBLE_TMR1_CH3 = 0x3A, /*!< tmr1_ch3 flexible request id */
  178. DMA_FLEXIBLE_TMR1_CH4 = 0x3B, /*!< tmr1_ch4 flexible request id */
  179. DMA_FLEXIBLE_TMR2_TRIG = 0x3D, /*!< tmr2_trig flexible request id */
  180. DMA_FLEXIBLE_TMR2_OVERFLOW = 0x3F, /*!< tmr2_overflow flexible request id */
  181. DMA_FLEXIBLE_TMR2_CH1 = 0x40, /*!< tmr2_ch1 flexible request id */
  182. DMA_FLEXIBLE_TMR2_CH2 = 0x41, /*!< tmr2_ch2 flexible request id */
  183. DMA_FLEXIBLE_TMR2_CH3 = 0x42, /*!< tmr2_ch3 flexible request id */
  184. DMA_FLEXIBLE_TMR2_CH4 = 0x43, /*!< tmr2_ch4 flexible request id */
  185. DMA_FLEXIBLE_TMR3_TRIG = 0x45, /*!< tmr3_trig flexible request id */
  186. DMA_FLEXIBLE_TMR3_OVERFLOW = 0x47, /*!< tmr3_overflow flexible request id */
  187. DMA_FLEXIBLE_TMR3_CH1 = 0x48, /*!< tmr3_ch1 flexible request id */
  188. DMA_FLEXIBLE_TMR3_CH2 = 0x49, /*!< tmr3_ch2 flexible request id */
  189. DMA_FLEXIBLE_TMR3_CH3 = 0x4A, /*!< tmr3_ch3 flexible request id */
  190. DMA_FLEXIBLE_TMR3_CH4 = 0x4B, /*!< tmr3_ch4 flexible request id */
  191. DMA_FLEXIBLE_TMR4_TRIG = 0x4D, /*!< tmr4_trig flexible request id */
  192. DMA_FLEXIBLE_TMR4_OVERFLOW = 0x4F, /*!< tmr4_overflow flexible request id */
  193. DMA_FLEXIBLE_TMR4_CH1 = 0x50, /*!< tmr4_ch1 flexible request id */
  194. DMA_FLEXIBLE_TMR4_CH2 = 0x51, /*!< tmr4_ch2 flexible request id */
  195. DMA_FLEXIBLE_TMR4_CH3 = 0x52, /*!< tmr4_ch3 flexible request id */
  196. DMA_FLEXIBLE_TMR4_CH4 = 0x53, /*!< tmr4_ch4 flexible request id */
  197. DMA_FLEXIBLE_TMR5_TRIG = 0x55, /*!< tmr5_trig flexible request id */
  198. DMA_FLEXIBLE_TMR5_OVERFLOW = 0x57, /*!< tmr5_overflow flexible request id */
  199. DMA_FLEXIBLE_TMR5_CH1 = 0x58, /*!< tmr5_ch1 flexible request id */
  200. DMA_FLEXIBLE_TMR5_CH2 = 0x59, /*!< tmr5_ch2 flexible request id */
  201. DMA_FLEXIBLE_TMR5_CH3 = 0x5A, /*!< tmr5_ch3 flexible request id */
  202. DMA_FLEXIBLE_TMR5_CH4 = 0x5B, /*!< tmr5_ch4 flexible request id */
  203. DMA_FLEXIBLE_TMR6_OVERFLOW = 0x5F, /*!< tmr6_overflow flexible request id */
  204. DMA_FLEXIBLE_TMR7_OVERFLOW = 0x67, /*!< tmr7_overflow flexible request id */
  205. DMA_FLEXIBLE_TMR8_TRIG = 0x6D, /*!< tmr8_trig flexible request id */
  206. DMA_FLEXIBLE_TMR8_HALL = 0x6E, /*!< tmr8_hall flexible request id */
  207. DMA_FLEXIBLE_TMR8_OVERFLOW = 0x6F, /*!< tmr8_overflow flexible request id */
  208. DMA_FLEXIBLE_TMR8_CH1 = 0x70, /*!< tmr8_ch1 flexible request id */
  209. DMA_FLEXIBLE_TMR8_CH2 = 0x71, /*!< tmr8_ch2 flexible request id */
  210. DMA_FLEXIBLE_TMR8_CH3 = 0x72, /*!< tmr8_ch3 flexible request id */
  211. DMA_FLEXIBLE_TMR8_CH4 = 0x73 /*!< tmr8_ch4 flexible request id */
  212. } dma_flexible_request_type;
  213. /**
  214. * @brief dma direction type
  215. */
  216. typedef enum
  217. {
  218. DMA_DIR_PERIPHERAL_TO_MEMORY = 0x0000, /*!< dma data transfer direction:peripheral to memory */
  219. DMA_DIR_MEMORY_TO_PERIPHERAL = 0x0010, /*!< dma data transfer direction:memory to peripheral */
  220. DMA_DIR_MEMORY_TO_MEMORY = 0x4000 /*!< dma data transfer direction:memory to memory */
  221. } dma_dir_type;
  222. /**
  223. * @brief dma peripheral incremented type
  224. */
  225. typedef enum
  226. {
  227. DMA_PERIPHERAL_INC_DISABLE = 0x00, /*!< dma peripheral increment mode disable */
  228. DMA_PERIPHERAL_INC_ENABLE = 0x01 /*!< dma peripheral increment mode enable */
  229. } dma_peripheral_inc_type;
  230. /**
  231. * @brief dma memory incremented type
  232. */
  233. typedef enum
  234. {
  235. DMA_MEMORY_INC_DISABLE = 0x00, /*!< dma memory increment mode disable */
  236. DMA_MEMORY_INC_ENABLE = 0x01 /*!< dma memory increment mode enable */
  237. } dma_memory_inc_type;
  238. /**
  239. * @brief dma peripheral data size type
  240. */
  241. typedef enum
  242. {
  243. DMA_PERIPHERAL_DATA_WIDTH_BYTE = 0x00, /*!< dma peripheral databus width 8bit */
  244. DMA_PERIPHERAL_DATA_WIDTH_HALFWORD = 0x01, /*!< dma peripheral databus width 16bit */
  245. DMA_PERIPHERAL_DATA_WIDTH_WORD = 0x02 /*!< dma peripheral databus width 32bit */
  246. } dma_peripheral_data_size_type;
  247. /**
  248. * @brief dma memory data size type
  249. */
  250. typedef enum
  251. {
  252. DMA_MEMORY_DATA_WIDTH_BYTE = 0x00, /*!< dma memory databus width 8bit */
  253. DMA_MEMORY_DATA_WIDTH_HALFWORD = 0x01, /*!< dma memory databus width 16bit */
  254. DMA_MEMORY_DATA_WIDTH_WORD = 0x02 /*!< dma memory databus width 32bit */
  255. } dma_memory_data_size_type;
  256. /**
  257. * @brief dma priority level type
  258. */
  259. typedef enum
  260. {
  261. DMA_PRIORITY_LOW = 0x00, /*!< dma channel priority: low */
  262. DMA_PRIORITY_MEDIUM = 0x01, /*!< dma channel priority: mediue */
  263. DMA_PRIORITY_HIGH = 0x02, /*!< dma channel priority: high */
  264. DMA_PRIORITY_VERY_HIGH = 0x03 /*!< dma channel priority: very high */
  265. } dma_priority_level_type;
  266. /**
  267. * @brief dma init type
  268. */
  269. typedef struct
  270. {
  271. uint32_t peripheral_base_addr; /*!< base addrress for peripheral */
  272. uint32_t memory_base_addr; /*!< base addrress for memory */
  273. dma_dir_type direction; /*!< dma transmit direction, peripheral as source or as destnation */
  274. uint16_t buffer_size; /*!< counter to transfer */
  275. confirm_state peripheral_inc_enable; /*!< periphera address increment after one transmit */
  276. confirm_state memory_inc_enable; /*!< memory address increment after one transmit */
  277. dma_peripheral_data_size_type peripheral_data_width; /*!< peripheral data width for transmit */
  278. dma_memory_data_size_type memory_data_width; /*!< memory data width for transmit */
  279. confirm_state loop_mode_enable; /*!< when circular mode enable, buffer size will reload if count to 0 */
  280. dma_priority_level_type priority; /*!< dma priority can choose from very high, high, dedium or low */
  281. } dma_init_type;
  282. /**
  283. * @brief type define dma register
  284. */
  285. typedef struct
  286. {
  287. /**
  288. * @brief dma sts register, offset:0x00
  289. */
  290. union
  291. {
  292. __IO uint32_t sts;
  293. struct
  294. {
  295. __IO uint32_t gf1 : 1; /* [0] */
  296. __IO uint32_t fdtf1 : 1; /* [1] */
  297. __IO uint32_t hdtf1 : 1; /* [2] */
  298. __IO uint32_t dterrf1 : 1; /* [3] */
  299. __IO uint32_t gf2 : 1; /* [4] */
  300. __IO uint32_t fdtf2 : 1; /* [5] */
  301. __IO uint32_t hdtf2 : 1; /* [6] */
  302. __IO uint32_t dterrf2 : 1; /* [7] */
  303. __IO uint32_t gf3 : 1; /* [8] */
  304. __IO uint32_t fdtf3 : 1; /* [9] */
  305. __IO uint32_t hdtf3 : 1; /* [10] */
  306. __IO uint32_t dterrf3 : 1; /* [11] */
  307. __IO uint32_t gf4 : 1; /* [12] */
  308. __IO uint32_t fdtf4 : 1; /* [13] */
  309. __IO uint32_t hdtf4 : 1; /* [14] */
  310. __IO uint32_t dterrf4 : 1; /* [15] */
  311. __IO uint32_t gf5 : 1; /* [16] */
  312. __IO uint32_t fdtf5 : 1; /* [17] */
  313. __IO uint32_t hdtf5 : 1; /* [18] */
  314. __IO uint32_t dterrf5 : 1; /* [19] */
  315. __IO uint32_t gf6 : 1; /* [20] */
  316. __IO uint32_t fdtf6 : 1; /* [21] */
  317. __IO uint32_t hdtf6 : 1; /* [22] */
  318. __IO uint32_t dterrf6 : 1; /* [23] */
  319. __IO uint32_t gf7 : 1; /* [24] */
  320. __IO uint32_t fdtf7 : 1; /* [25] */
  321. __IO uint32_t hdtf7 : 1; /* [26] */
  322. __IO uint32_t dterrf7 : 1; /* [27] */
  323. __IO uint32_t reserved1 : 4; /* [31:28] */
  324. } sts_bit;
  325. };
  326. /**
  327. * @brief dma clr register, offset:0x04
  328. */
  329. union
  330. {
  331. __IO uint32_t clr;
  332. struct
  333. {
  334. __IO uint32_t gfc1 : 1; /* [0] */
  335. __IO uint32_t fdtfc1 : 1; /* [1] */
  336. __IO uint32_t hdtfc1 : 1; /* [2] */
  337. __IO uint32_t dterrfc1 : 1; /* [3] */
  338. __IO uint32_t gfc2 : 1; /* [4] */
  339. __IO uint32_t fdtfc2 : 1; /* [5] */
  340. __IO uint32_t hdtfc2 : 1; /* [6] */
  341. __IO uint32_t dterrfc2 : 1; /* [7] */
  342. __IO uint32_t gfc3 : 1; /* [8] */
  343. __IO uint32_t fdtfc3 : 1; /* [9] */
  344. __IO uint32_t hdtfc3 : 1; /* [10] */
  345. __IO uint32_t dterrfc3 : 1; /* [11] */
  346. __IO uint32_t gfc4 : 1; /* [12] */
  347. __IO uint32_t fdtfc4 : 1; /* [13] */
  348. __IO uint32_t hdtfc4 : 1; /* [14] */
  349. __IO uint32_t dterrfc4 : 1; /* [15] */
  350. __IO uint32_t gfc5 : 1; /* [16] */
  351. __IO uint32_t fdtfc5 : 1; /* [17] */
  352. __IO uint32_t hdtfc5 : 1; /* [18] */
  353. __IO uint32_t dterrfc5 : 1; /* [19] */
  354. __IO uint32_t gfc6 : 1; /* [20] */
  355. __IO uint32_t fdtfc6 : 1; /* [21] */
  356. __IO uint32_t hdtfc6 : 1; /* [22] */
  357. __IO uint32_t dterrfc6 : 1; /* [23] */
  358. __IO uint32_t gfc7 : 1; /* [24] */
  359. __IO uint32_t fdtfc7 : 1; /* [25] */
  360. __IO uint32_t hdtfc7 : 1; /* [26] */
  361. __IO uint32_t dterrfc7 : 1; /* [27] */
  362. __IO uint32_t reserved1 : 4; /* [31:28] */
  363. } clr_bit;
  364. };
  365. /**
  366. * @brief reserved, offset:0x08~0x9C
  367. */
  368. __IO uint32_t reserved1[38];
  369. /**
  370. * @brief dma src_sel0 register, offset:0xA0
  371. */
  372. union
  373. {
  374. __IO uint32_t src_sel0;
  375. struct
  376. {
  377. __IO uint32_t ch1_src : 8; /* [7:0] */
  378. __IO uint32_t ch2_src : 8; /* [15:8] */
  379. __IO uint32_t ch3_src : 8; /* [23:16] */
  380. __IO uint32_t ch4_src : 8; /* [31:24] */
  381. } src_sel0_bit;
  382. };
  383. /**
  384. * @brief dma src_sel1 register, offset:0xA4
  385. */
  386. union
  387. {
  388. __IO uint32_t src_sel1;
  389. struct
  390. {
  391. __IO uint32_t ch5_src : 8; /* [7:0] */
  392. __IO uint32_t ch6_src : 8; /* [15:8] */
  393. __IO uint32_t ch7_src : 8; /* [23:16] */
  394. __IO uint32_t dma_flex_en : 1; /* [24] */
  395. __IO uint32_t reserved1 : 7; /* [31:25] */
  396. } src_sel1_bit;
  397. };
  398. } dma_type;
  399. /**
  400. * @brief type define dma channel register all
  401. */
  402. typedef struct
  403. {
  404. /**
  405. * @brief dma ctrl register, offset:0x08+20*(x-1) x=1...7
  406. */
  407. union
  408. {
  409. __IO uint32_t ctrl;
  410. struct
  411. {
  412. __IO uint32_t chen : 1; /* [0] */
  413. __IO uint32_t fdtien : 1; /* [1] */
  414. __IO uint32_t hdtien : 1; /* [2] */
  415. __IO uint32_t dterrien : 1; /* [3] */
  416. __IO uint32_t dtd : 1; /* [4] */
  417. __IO uint32_t lm : 1; /* [5] */
  418. __IO uint32_t pincm : 1; /* [6] */
  419. __IO uint32_t mincm : 1; /* [7] */
  420. __IO uint32_t pwidth : 2; /* [9:8] */
  421. __IO uint32_t mwidth : 2; /* [11:10] */
  422. __IO uint32_t chpl : 2; /* [13:12] */
  423. __IO uint32_t m2m : 1; /* [14] */
  424. __IO uint32_t reserved1 : 17;/* [31:15] */
  425. } ctrl_bit;
  426. };
  427. /**
  428. * @brief dma dtcnt register, offset:0x0C+20*(x-1) x=1...7
  429. */
  430. union
  431. {
  432. __IO uint32_t dtcnt;
  433. struct
  434. {
  435. __IO uint32_t cnt : 16;/* [15:0] */
  436. __IO uint32_t reserved1 : 16;/* [31:16] */
  437. } dtcnt_bit;
  438. };
  439. /**
  440. * @brief dma cpba register, offset:0x10+20*(x-1) x=1...7
  441. */
  442. union
  443. {
  444. __IO uint32_t paddr;
  445. struct
  446. {
  447. __IO uint32_t paddr : 32;/* [31:0] */
  448. } paddr_bit;
  449. };
  450. /**
  451. * @brief dma cmba register, offset:0x14+20*(x-1) x=1...7
  452. */
  453. union
  454. {
  455. __IO uint32_t maddr;
  456. struct
  457. {
  458. __IO uint32_t maddr : 32;/* [31:0] */
  459. } maddr_bit;
  460. };
  461. } dma_channel_type;
  462. /**
  463. * @}
  464. */
  465. #define DMA1 ((dma_type *) DMA1_BASE)
  466. #define DMA1_CHANNEL1 ((dma_channel_type *) DMA1_CHANNEL1_BASE)
  467. #define DMA1_CHANNEL2 ((dma_channel_type *) DMA1_CHANNEL2_BASE)
  468. #define DMA1_CHANNEL3 ((dma_channel_type *) DMA1_CHANNEL3_BASE)
  469. #define DMA1_CHANNEL4 ((dma_channel_type *) DMA1_CHANNEL4_BASE)
  470. #define DMA1_CHANNEL5 ((dma_channel_type *) DMA1_CHANNEL5_BASE)
  471. #define DMA1_CHANNEL6 ((dma_channel_type *) DMA1_CHANNEL6_BASE)
  472. #define DMA1_CHANNEL7 ((dma_channel_type *) DMA1_CHANNEL7_BASE)
  473. #define DMA2 ((dma_type *) DMA2_BASE)
  474. #define DMA2_CHANNEL1 ((dma_channel_type *) DMA2_CHANNEL1_BASE)
  475. #define DMA2_CHANNEL2 ((dma_channel_type *) DMA2_CHANNEL2_BASE)
  476. #define DMA2_CHANNEL3 ((dma_channel_type *) DMA2_CHANNEL3_BASE)
  477. #define DMA2_CHANNEL4 ((dma_channel_type *) DMA2_CHANNEL4_BASE)
  478. #define DMA2_CHANNEL5 ((dma_channel_type *) DMA2_CHANNEL5_BASE)
  479. #define DMA2_CHANNEL6 ((dma_channel_type *) DMA2_CHANNEL6_BASE)
  480. #define DMA2_CHANNEL7 ((dma_channel_type *) DMA2_CHANNEL7_BASE)
  481. /** @defgroup DMA_exported_functions
  482. * @{
  483. */
  484. void dma_reset(dma_channel_type* dmax_channely);
  485. void dma_data_number_set(dma_channel_type* dmax_channely, uint16_t data_number);
  486. uint16_t dma_data_number_get(dma_channel_type* dmax_channely);
  487. void dma_interrupt_enable(dma_channel_type* dmax_channely, uint32_t dma_int, confirm_state new_state);
  488. void dma_channel_enable(dma_channel_type* dmax_channely, confirm_state new_state);
  489. void dma_flexible_config(dma_type* dma_x, uint8_t flex_channelx, dma_flexible_request_type flexible_request);
  490. flag_status dma_flag_get(uint32_t dmax_flag);
  491. void dma_flag_clear(uint32_t dmax_flag);
  492. void dma_default_para_init(dma_init_type* dma_init_struct);
  493. void dma_init(dma_channel_type* dmax_channely, dma_init_type* dma_init_struct);
  494. /**
  495. * @}
  496. */
  497. /**
  498. * @}
  499. */
  500. /**
  501. * @}
  502. */
  503. #ifdef __cplusplus
  504. }
  505. #endif
  506. #endif