gd32f10x_dma.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. /**
  2. ******************************************************************************
  3. * @brief DMA header file of the firmware library.
  4. ******************************************************************************
  5. */
  6. /* Define to prevent recursive inclusion -------------------------------------*/
  7. #ifndef __GD32F10X_DMA_H
  8. #define __GD32F10X_DMA_H
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. /* Includes ------------------------------------------------------------------*/
  13. #include "gd32f10x.h"
  14. /** @addtogroup GD32F10x_Firmware
  15. * @{
  16. */
  17. /** @addtogroup DMA
  18. * @{
  19. */
  20. /** @defgroup DMA_Exported_Types
  21. * @{
  22. */
  23. /**
  24. * @brief DMA Initial Parameters
  25. */
  26. typedef struct {
  27. uint32_t DMA_PeripheralBaseAddr; /*!< The base address of the peripheral. */
  28. uint32_t DMA_MemoryBaseAddr; /*!< The base address of the memory. */
  29. uint32_t DMA_DIR; /*!< The direction of data transmission.
  30. detailed in @ref DMA_data_transfer_direction */
  31. uint32_t DMA_BufferSize; /*!< The buffer size of data transmission. */
  32. uint32_t DMA_PeripheralInc; /*!< The incremented_mode of the Peripheral address register.
  33. detailed in @ref DMA_peripheral_Address_incremented_mode */
  34. uint32_t DMA_MemoryInc; /*!< The incremented_mode of the memory address register.
  35. detailed in @ref DMA_memory_Address_incremented_mode */
  36. uint32_t DMA_PeripheralDataSize; /*!< The data transmission width of Peripheral.
  37. detailed in @ref DMA_peripheral_data_size */
  38. uint32_t DMA_MemoryDataSize; /*!< The data transmission width of Memory.
  39. detailed in @ref DMA_memory_data_size */
  40. uint32_t DMA_Mode; /*!< The mode of circular transmission.
  41. detailed in @ref DMA_circular_normal_mode */
  42. uint32_t DMA_Priority; /*!< The software priority for the DMAy Channelx.
  43. detailed in @ref DMA_priority_level */
  44. uint32_t DMA_MTOM; /*!< The mode of memory-to-memory transfer.
  45. detailed in @ref DMA_memory_to_memory */
  46. } DMA_InitPara;
  47. /**
  48. * @}
  49. */
  50. /** @defgroup DMA_Exported_Constants
  51. * @{
  52. */
  53. /** @defgroup DMA_data_transfer_direction
  54. * @{
  55. */
  56. #define DMA_DIR_PERIPHERALDST DMA_CTLR_DIR
  57. #define DMA_DIR_PERIPHERALSRC ((uint32_t)0x00000000)
  58. /**
  59. * @}
  60. */
  61. /** @defgroup DMA_peripheral_Address_Increasing_mode
  62. * @{
  63. */
  64. #define DMA_PERIPHERALINC_ENABLE DMA_CTLR_PNAGA
  65. #define DMA_PERIPHERALINC_DISABLE ((uint32_t)0x00000000)
  66. /**
  67. * @}
  68. */
  69. /** @defgroup DMA_memory_Address_Increasing_mode
  70. * @{
  71. */
  72. #define DMA_MEMORYINC_ENABLE DMA_CTLR_MNAGA
  73. #define DMA_MEMORYINC_DISABLE ((uint32_t)0x00000000)
  74. /**
  75. * @}
  76. */
  77. /** @defgroup DMA_peripheral_data_size
  78. * @{
  79. */
  80. #define DMA_PERIPHERALDATASIZE_BYTE ((uint32_t)0x00000000)
  81. #define DMA_PERIPHERALDATASIZE_HALFWORD DMA_CTLR_PSIZE_0
  82. #define DMA_PERIPHERALDATASIZE_WORD DMA_CTLR_PSIZE_1
  83. /**
  84. * @}
  85. */
  86. /** @defgroup DMA_memory_data_size
  87. * @{
  88. */
  89. #define DMA_MEMORYDATASIZE_BYTE ((uint32_t)0x00000000)
  90. #define DMA_MEMORYDATASIZE_HALFWORD DMA_CTLR_MSIZE_0
  91. #define DMA_MEMORYDATASIZE_WORD DMA_CTLR_MSIZE_1
  92. /**
  93. * @}
  94. */
  95. /** @defgroup DMA_circular_normal_mode
  96. * @{
  97. */
  98. #define DMA_MODE_CIRCULAR DMA_CTLR_CIRC
  99. #define DMA_MODE_NORMAL ((uint32_t)0x00000000)
  100. /**
  101. * @}
  102. */
  103. /** @defgroup DMA_priority_level
  104. * @{
  105. */
  106. #define DMA_PRIORITY_VERYHIGH DMA_CTLR_PRIO
  107. #define DMA_PRIORITY_HIGH DMA_CTLR_PRIO_1
  108. #define DMA_PRIORITY_MEDIUM DMA_CTLR_PRIO_0
  109. #define DMA_PRIORITY_LOW ((uint32_t)0x00000000)
  110. /**
  111. * @}
  112. */
  113. /** @defgroup DMA_memory_to_memory
  114. * @{
  115. */
  116. #define DMA_MEMTOMEM_ENABLE DMA_CTLR_MEMTOMEM
  117. #define DMA_MEMTOMEM_DISABLE ((uint32_t)0x00000000)
  118. /**
  119. * @}
  120. */
  121. /** @defgroup DMA_interrupts_definition
  122. * @{
  123. */
  124. #define DMA_INT_TC DMA_CTLR_TCIE
  125. #define DMA_INT_HT DMA_CTLR_HTIE
  126. #define DMA_INT_ERR DMA_CTLR_ERRIE
  127. #define DMA1_INT_GL1 DMA_IFR_GIF1
  128. #define DMA1_INT_TC1 DMA_IFR_TCIF1
  129. #define DMA1_INT_HT1 DMA_IFR_HTIF1
  130. #define DMA1_INT_ERR1 DMA_IFR_ERRIF1
  131. #define DMA1_INT_GL2 DMA_IFR_GIF2
  132. #define DMA1_INT_TC2 DMA_IFR_TCIF2
  133. #define DMA1_INT_HT2 DMA_IFR_HTIF2
  134. #define DMA1_INT_ERR2 DMA_IFR_ERRIF2
  135. #define DMA1_INT_GL3 DMA_IFR_GIF3
  136. #define DMA1_INT_TC3 DMA_IFR_TCIF3
  137. #define DMA1_INT_HT3 DMA_IFR_HTIF3
  138. #define DMA1_INT_ERR3 DMA_IFR_ERRIF3
  139. #define DMA1_INT_GL4 DMA_IFR_GIF4
  140. #define DMA1_INT_TC4 DMA_IFR_TCIF4
  141. #define DMA1_INT_HT4 DMA_IFR_HTIF4
  142. #define DMA1_INT_ERR4 DMA_IFR_ERRIF4
  143. #define DMA1_INT_GL5 DMA_IFR_GIF5
  144. #define DMA1_INT_TC5 DMA_IFR_TCIF5
  145. #define DMA1_INT_HT5 DMA_IFR_HTIF5
  146. #define DMA1_INT_ERR5 DMA_IFR_ERRIF5
  147. #define DMA1_INT_GL6 DMA_IFR_GIF6
  148. #define DMA1_INT_TC6 DMA_IFR_TCIF6
  149. #define DMA1_INT_HT6 DMA_IFR_HTIF6
  150. #define DMA1_INT_ERR6 DMA_IFR_ERRIF6
  151. #define DMA1_INT_GL7 DMA_IFR_GIF7
  152. #define DMA1_INT_TC7 DMA_IFR_TCIF7
  153. #define DMA1_INT_HT7 DMA_IFR_HTIF7
  154. #define DMA1_INT_ERR7 DMA_IFR_ERRIF7
  155. #define DMA2_INT_GL1 ((uint32_t)0x10000001)
  156. #define DMA2_INT_TC1 ((uint32_t)0x10000002)
  157. #define DMA2_INT_HT1 ((uint32_t)0x10000004)
  158. #define DMA2_INT_TE1 ((uint32_t)0x10000008)
  159. #define DMA2_INT_GL2 ((uint32_t)0x10000010)
  160. #define DMA2_INT_TC2 ((uint32_t)0x10000020)
  161. #define DMA2_INT_HT2 ((uint32_t)0x10000040)
  162. #define DMA2_INT_TE2 ((uint32_t)0x10000080)
  163. #define DMA2_INT_GL3 ((uint32_t)0x10000100)
  164. #define DMA2_INT_TC3 ((uint32_t)0x10000200)
  165. #define DMA2_INT_HT3 ((uint32_t)0x10000400)
  166. #define DMA2_INT_TE3 ((uint32_t)0x10000800)
  167. #define DMA2_INT_GL4 ((uint32_t)0x10001000)
  168. #define DMA2_INT_TC4 ((uint32_t)0x10002000)
  169. #define DMA2_INT_HT4 ((uint32_t)0x10004000)
  170. #define DMA2_INT_TE4 ((uint32_t)0x10008000)
  171. #define DMA2_INT_GL5 ((uint32_t)0x10010000)
  172. #define DMA2_INT_TC5 ((uint32_t)0x10020000)
  173. #define DMA2_INT_HT5 ((uint32_t)0x10040000)
  174. #define DMA2_INT_TE5 ((uint32_t)0x10080000)
  175. /**
  176. * @}
  177. */
  178. /** @defgroup DMA_flags_definition
  179. * @{
  180. */
  181. #define DMA1_FLAG_GL1 DMA_IFR_GIF1
  182. #define DMA1_FLAG_TC1 DMA_IFR_TCIF1
  183. #define DMA1_FLAG_HT1 DMA_IFR_HTIF1
  184. #define DMA1_FLAG_ERR1 DMA_IFR_ERRIF1
  185. #define DMA1_FLAG_GL2 DMA_IFR_GIF2
  186. #define DMA1_FLAG_TC2 DMA_IFR_TCIF2
  187. #define DMA1_FLAG_HT2 DMA_IFR_HTIF2
  188. #define DMA1_FLAG_ERR2 DMA_IFR_ERRIF2
  189. #define DMA1_FLAG_GL3 DMA_IFR_GIF3
  190. #define DMA1_FLAG_TC3 DMA_IFR_TCIF3
  191. #define DMA1_FLAG_HT3 DMA_IFR_HTIF3
  192. #define DMA1_FLAG_ERR3 DMA_IFR_ERRIF3
  193. #define DMA1_FLAG_GL4 DMA_IFR_GIF4
  194. #define DMA1_FLAG_TC4 DMA_IFR_TCIF4
  195. #define DMA1_FLAG_HT4 DMA_IFR_HTIF4
  196. #define DMA1_FLAG_ERR4 DMA_IFR_ERRIF4
  197. #define DMA1_FLAG_GL5 DMA_IFR_GIF5
  198. #define DMA1_FLAG_TC5 DMA_IFR_TCIF5
  199. #define DMA1_FLAG_HT5 DMA_IFR_HTIF5
  200. #define DMA1_FLAG_ERR5 DMA_IFR_ERRIF5
  201. #define DMA1_FLAG_GL6 DMA_IFR_GIF6
  202. #define DMA1_FLAG_TC6 DMA_IFR_TCIF6
  203. #define DMA1_FLAG_HT6 DMA_IFR_HTIF6
  204. #define DMA1_FLAG_ERR6 DMA_IFR_ERRIF6
  205. #define DMA1_FLAG_GL7 DMA_IFR_GIF7
  206. #define DMA1_FLAG_TC7 DMA_IFR_TCIF7
  207. #define DMA1_FLAG_HT7 DMA_IFR_HTIF7
  208. #define DMA1_FLAG_ERR7 DMA_IFR_ERRIF7
  209. #define DMA2_FLAG_GL1 ((uint32_t)0x10000001)
  210. #define DMA2_FLAG_TC1 ((uint32_t)0x10000002)
  211. #define DMA2_FLAG_HT1 ((uint32_t)0x10000004)
  212. #define DMA2_FLAG_TE1 ((uint32_t)0x10000008)
  213. #define DMA2_FLAG_GL2 ((uint32_t)0x10000010)
  214. #define DMA2_FLAG_TC2 ((uint32_t)0x10000020)
  215. #define DMA2_FLAG_HT2 ((uint32_t)0x10000040)
  216. #define DMA2_FLAG_TE2 ((uint32_t)0x10000080)
  217. #define DMA2_FLAG_GL3 ((uint32_t)0x10000100)
  218. #define DMA2_FLAG_TC3 ((uint32_t)0x10000200)
  219. #define DMA2_FLAG_HT3 ((uint32_t)0x10000400)
  220. #define DMA2_FLAG_TE3 ((uint32_t)0x10000800)
  221. #define DMA2_FLAG_GL4 ((uint32_t)0x10001000)
  222. #define DMA2_FLAG_TC4 ((uint32_t)0x10002000)
  223. #define DMA2_FLAG_HT4 ((uint32_t)0x10004000)
  224. #define DMA2_FLAG_TE4 ((uint32_t)0x10008000)
  225. #define DMA2_FLAG_GL5 ((uint32_t)0x10010000)
  226. #define DMA2_FLAG_TC5 ((uint32_t)0x10020000)
  227. #define DMA2_FLAG_HT5 ((uint32_t)0x10040000)
  228. #define DMA2_FLAG_TE5 ((uint32_t)0x10080000)
  229. /**
  230. * @}
  231. */
  232. /**
  233. * @}
  234. */
  235. /** @defgroup DMA_Exported_Functions
  236. * @{
  237. */
  238. /* Function used to reset the DMA configuration */
  239. void DMA_DeInit(DMA_Channel_TypeDef *DMAy_Channelx);
  240. /* The functions of Initialization and Configuration */
  241. void DMA_Init(DMA_Channel_TypeDef *DMAy_Channelx, DMA_InitPara *DMA_InitParaStruct);
  242. void DMA_ParaInit(DMA_InitPara *DMA_InitParaStruct);
  243. void DMA_Enable(DMA_Channel_TypeDef *DMAy_Channelx, TypeState NewValue);
  244. /* The functions of Data Counter */
  245. void DMA_SetCurrDataCounter(DMA_Channel_TypeDef *DMAy_Channelx, uint16_t DataNumber);
  246. uint16_t DMA_GetCurrDataCounter(DMA_Channel_TypeDef *DMAy_Channelx);
  247. /* The functions of Interrupts and flags management */
  248. void DMA_INTConfig(DMA_Channel_TypeDef *DMAy_Channelx, uint32_t DMA_INT, TypeState NewValue);
  249. TypeState DMA_GetBitState(uint32_t DMA_FLAG);
  250. void DMA_ClearBitState(uint32_t DMA_FLAG);
  251. TypeState DMA_GetIntBitState(uint32_t DMA_INT);
  252. void DMA_ClearIntBitState(uint32_t DMA_INT);
  253. #ifdef __cplusplus
  254. }
  255. #endif
  256. #endif /*__GD32F10x_DMA_H */
  257. /**
  258. * @}
  259. */
  260. /**
  261. * @}
  262. */
  263. /**
  264. * @}
  265. */