hc32_ll_dma.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. /**
  2. *******************************************************************************
  3. * @file hc32_ll_dma.h
  4. * @brief This file contains all the functions prototypes of the DMA driver
  5. * library.
  6. @verbatim
  7. Change Logs:
  8. Date Author Notes
  9. 2022-12-31 CDT First version
  10. @endverbatim
  11. *******************************************************************************
  12. * Copyright (C) 2022, Xiaohua Semiconductor Co., Ltd. All rights reserved.
  13. *
  14. * This software component is licensed by XHSC under BSD 3-Clause license
  15. * (the "License"); You may not use this file except in compliance with the
  16. * License. You may obtain a copy of the License at:
  17. * opensource.org/licenses/BSD-3-Clause
  18. *
  19. *******************************************************************************
  20. */
  21. #ifndef __HC32_LL_DMA_H__
  22. #define __HC32_LL_DMA_H__
  23. /* C binding of definitions if building with C++ compiler */
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. /*******************************************************************************
  29. * Include files
  30. ******************************************************************************/
  31. #include "hc32_ll_def.h"
  32. #include "hc32f4xx.h"
  33. #include "hc32f4xx_conf.h"
  34. /**
  35. * @addtogroup LL_Driver
  36. * @{
  37. */
  38. /**
  39. * @addtogroup LL_DMA
  40. * @{
  41. */
  42. #if (LL_DMA_ENABLE == DDL_ON)
  43. /*******************************************************************************
  44. * Global type definitions ('typedef')
  45. ******************************************************************************/
  46. /**
  47. * @defgroup DMA_Global_Types DMA Global Types
  48. * @{
  49. */
  50. /**
  51. * @brief DMA basic configuration
  52. */
  53. typedef struct {
  54. uint32_t u32IntEn; /*!< Specifies the DMA interrupt function.
  55. This parameter can be a value of @ref DMA_Int_Config */
  56. uint32_t u32SrcAddr; /*!< Specifies the DMA source address. */
  57. uint32_t u32DestAddr; /*!< Specifies the DMA destination address. */
  58. uint32_t u32DataWidth; /*!< Specifies the DMA transfer data width.
  59. This parameter can be a value of @ref DMA_DataWidth_Sel */
  60. uint32_t u32BlockSize; /*!< Specifies the DMA block size. */
  61. uint32_t u32TransCount; /*!< Specifies the DMA transfer count. */
  62. uint32_t u32SrcAddrInc; /*!< Specifies the source address increment mode.
  63. This parameter can be a value of @ref DMA_SrcAddr_Incremented_Mode */
  64. uint32_t u32DestAddrInc; /*!< Specifies the destination address increment mode.
  65. This parameter can be a value of @ref DMA_DesAddr_Incremented_Mode */
  66. } stc_dma_init_t;
  67. /**
  68. * @brief DMA repeat mode configuration
  69. */
  70. typedef struct {
  71. uint32_t u32Mode; /*!< Specifies the DMA source repeat function.
  72. This parameter can be a value of @ref DMA_Repeat_Config */
  73. uint32_t u32SrcCount; /*!< Specifies the DMA source repeat size. */
  74. uint32_t u32DestCount; /*!< Specifies the DMA destination repeat size. */
  75. } stc_dma_repeat_init_t;
  76. /**
  77. * @brief DMA non-sequence mode configuration
  78. */
  79. typedef struct {
  80. uint32_t u32Mode; /*!< Specifies the DMA source non-sequence function.
  81. This parameter can be a value of @ref DMA_NonSeq_Config */
  82. uint32_t u32SrcCount; /*!< Specifies the DMA source non-sequence function count. */
  83. uint32_t u32SrcOffset; /*!< Specifies the DMA source non-sequence function offset. */
  84. uint32_t u32DestCount; /*!< Specifies the DMA destination non-sequence function count. */
  85. uint32_t u32DestOffset; /*!< Specifies the DMA destination non-sequence function offset. */
  86. } stc_dma_nonseq_init_t;
  87. /**
  88. * @brief DMA Link List Pointer (LLP) mode configuration
  89. */
  90. typedef struct {
  91. uint32_t u32State; /*!< Specifies the DMA LLP function.
  92. This parameter can be a value of @ref DMA_Llp_En */
  93. uint32_t u32Mode; /*!< Specifies the DMA LLP auto or wait REQ.
  94. This parameter can be a value of @ref DMA_Llp_Mode */
  95. uint32_t u32Addr; /*!< Specifies the DMA list pointer address for LLP function. */
  96. } stc_dma_llp_init_t;
  97. /**
  98. * @brief DMA re-config function configuration
  99. */
  100. typedef struct {
  101. uint32_t u32CountMode; /*!< Specifies the DMA reconfig function count mode.
  102. This parameter can be a value of @ref DMA_Reconfig_Count_Sel */
  103. uint32_t u32DestAddrMode; /*!< Specifies the DMA reconfig function destination address mode.
  104. This parameter can be a value of @ref DMA_Reconfig_DestAddr_Sel */
  105. uint32_t u32SrcAddrMode; /*!< Specifies the DMA reconfig function source address mode.
  106. This parameter can be a value of @ref DMA_Reconfig_SrcAddr_Sel */
  107. } stc_dma_reconfig_init_t;
  108. /**
  109. * @brief Dma LLP(linked list pointer) descriptor structure definition
  110. */
  111. typedef struct {
  112. uint32_t SARx; /*!< LLP source address */
  113. uint32_t DARx; /*!< LLP destination address */
  114. uint32_t DTCTLx; /*!< LLP transfer count and block size */
  115. uint32_t RPTx; /*!< LLP source & destination repeat size */
  116. uint32_t SNSEQCTLx; /*!< LLP source non-seq count and offset */
  117. uint32_t DNSEQCTLx; /*!< LLP destination non-seq count and offset */
  118. uint32_t LLPx; /*!< LLP next list pointer */
  119. uint32_t CHCTLx; /*!< LLP channel control */
  120. } stc_dma_llp_descriptor_t;
  121. /**
  122. * @}
  123. */
  124. /*******************************************************************************
  125. * Global pre-processor symbols/macros ('#define')
  126. ******************************************************************************/
  127. /**
  128. * @defgroup DMA_Global_Macros DMA Global Macros
  129. * @{
  130. */
  131. /**
  132. * @defgroup DMA_Channel_selection DMA Channel Position selection
  133. * @{
  134. */
  135. #define DMA_CH0 (0x00U) /*!< DMA Channel 0 */
  136. #define DMA_CH1 (0x01U) /*!< DMA Channel 1 */
  137. #define DMA_CH2 (0x02U) /*!< DMA Channel 2 */
  138. #define DMA_CH3 (0x03U) /*!< DMA Channel 3 */
  139. #define DMA_CH4 (0x04U) /*!< DMA Channel 4 */
  140. #define DMA_CH5 (0x05U) /*!< DMA Channel 5 */
  141. /**
  142. * @}
  143. */
  144. /**
  145. * @defgroup DMA_Mx_Channel_selection DMA Multiplex Channel selection
  146. * @{
  147. */
  148. #define DMA_MX_CH0 (0x01UL) /*!< DMA Channel 0 position */
  149. #define DMA_MX_CH1 (0x02UL) /*!< DMA Channel 1 position */
  150. #define DMA_MX_CH_ALL (DMA_CHEN_CHEN) /*!< DMA Channel mask position */
  151. #define DMA_MX_CH2 (0x04UL) /*!< DMA Channel 2 position */
  152. #define DMA_MX_CH3 (0x08UL) /*!< DMA Channel 3 position */
  153. #define DMA_MX_CH4 (0x10UL) /*!< DMA Channel 4 position */
  154. #define DMA_MX_CH5 (0x20UL) /*!< DMA Channel 5 position */
  155. /**
  156. * @}
  157. */
  158. /**
  159. * @defgroup DMA_Flag_Request_Err_Sel DMA request error flag selection
  160. * @{
  161. */
  162. #define DMA_FLAG_REQ_ERR_CH0 (DMA_INTSTAT0_REQERR_0) /*!< DMA request error flag CH.0 */
  163. #define DMA_FLAG_REQ_ERR_CH1 (DMA_INTSTAT0_REQERR_1) /*!< DMA request error flag CH.1 */
  164. #define DMA_FLAG_REQ_ERR_CH2 (DMA_INTSTAT0_REQERR_2) /*!< DMA request error flag CH.2 */
  165. #define DMA_FLAG_REQ_ERR_CH3 (DMA_INTSTAT0_REQERR_3) /*!< DMA request error flag CH.3 */
  166. #define DMA_FLAG_REQ_ERR_CH4 (DMA_INTSTAT0_REQERR_4) /*!< DMA request error flag CH.4 */
  167. #define DMA_FLAG_REQ_ERR_CH5 (DMA_INTSTAT0_REQERR_5) /*!< DMA request error flag CH.5 */
  168. /**
  169. * @}
  170. */
  171. /**
  172. * @defgroup DMA_Flag_Trans_Err_Sel DMA transfer error flag selection
  173. * @{
  174. */
  175. #define DMA_FLAG_TRANS_ERR_CH0 (DMA_INTSTAT0_TRNERR_0) /*!< DMA transfer error flag CH.0 */
  176. #define DMA_FLAG_TRANS_ERR_CH1 (DMA_INTSTAT0_TRNERR_1) /*!< DMA transfer error flag CH.1 */
  177. #define DMA_FLAG_TRANS_ERR_CH2 (DMA_INTSTAT0_TRNERR_2) /*!< DMA transfer error flag CH.2 */
  178. #define DMA_FLAG_TRANS_ERR_CH3 (DMA_INTSTAT0_TRNERR_3) /*!< DMA transfer error flag CH.3 */
  179. #define DMA_FLAG_TRANS_ERR_CH4 (DMA_INTSTAT0_TRNERR_4) /*!< DMA transfer error flag CH.4 */
  180. #define DMA_FLAG_TRANS_ERR_CH5 (DMA_INTSTAT0_TRNERR_5) /*!< DMA transfer error flag CH.5 */
  181. /**
  182. * @}
  183. */
  184. /**
  185. * @defgroup DMA_Flag_Btc_Sel DMA block transfer completed flag selection
  186. * @{
  187. */
  188. #define DMA_FLAG_BTC_CH0 (DMA_INTSTAT1_BTC_0) /*!< DMA block transfer completed flag CH.0 */
  189. #define DMA_FLAG_BTC_CH1 (DMA_INTSTAT1_BTC_1) /*!< DMA block transfer completed flag CH.1 */
  190. #define DMA_FLAG_BTC_CH2 (DMA_INTSTAT1_BTC_2) /*!< DMA block transfer completed flag CH.2 */
  191. #define DMA_FLAG_BTC_CH3 (DMA_INTSTAT1_BTC_3) /*!< DMA block transfer completed flag CH.3 */
  192. #define DMA_FLAG_BTC_CH4 (DMA_INTSTAT1_BTC_4) /*!< DMA block transfer completed flag CH.4 */
  193. #define DMA_FLAG_BTC_CH5 (DMA_INTSTAT1_BTC_5) /*!< DMA block transfer completed flag CH.5 */
  194. /**
  195. * @}
  196. */
  197. /**
  198. * @defgroup DMA_Flag_Tc_Sel DMA transfer completed flag selection
  199. * @{
  200. */
  201. #define DMA_FLAG_TC_CH0 (DMA_INTSTAT1_TC_0) /*!< DMA transfer completed flag CH.0 */
  202. #define DMA_FLAG_TC_CH1 (DMA_INTSTAT1_TC_1) /*!< DMA transfer completed flag CH.1 */
  203. #define DMA_FLAG_TC_CH2 (DMA_INTSTAT1_TC_2) /*!< DMA transfer completed flag CH.2 */
  204. #define DMA_FLAG_TC_CH3 (DMA_INTSTAT1_TC_3) /*!< DMA transfer completed flag CH.3 */
  205. #define DMA_FLAG_TC_CH4 (DMA_INTSTAT1_TC_4) /*!< DMA transfer completed flag CH.4 */
  206. #define DMA_FLAG_TC_CH5 (DMA_INTSTAT1_TC_5) /*!< DMA transfer completed flag CH.5 */
  207. /**
  208. * @}
  209. */
  210. /**
  211. * @defgroup DMA_Int_Request_Err_Sel DMA request error interrupt selection
  212. * @{
  213. */
  214. #define DMA_INT_REQ_ERR_CH0 (DMA_INTMASK0_MSKREQERR_0) /*!< DMA request error interrupt CH.0 */
  215. #define DMA_INT_REQ_ERR_CH1 (DMA_INTMASK0_MSKREQERR_1) /*!< DMA request error interrupt CH.1 */
  216. #define DMA_INT_REQ_ERR_CH2 (DMA_INTMASK0_MSKREQERR_2) /*!< DMA request error interrupt CH.2 */
  217. #define DMA_INT_REQ_ERR_CH3 (DMA_INTMASK0_MSKREQERR_3) /*!< DMA request error interrupt CH.3 */
  218. #define DMA_INT_REQ_ERR_CH4 (DMA_INTMASK0_MSKREQERR_4) /*!< DMA request error interrupt CH.4 */
  219. #define DMA_INT_REQ_ERR_CH5 (DMA_INTMASK0_MSKREQERR_5) /*!< DMA request error interrupt CH.5 */
  220. /**
  221. * @}
  222. */
  223. /**
  224. * @defgroup DMA_Int_Trans_Err_Sel DMA transfer error interrupt selection
  225. * @{
  226. */
  227. #define DMA_INT_TRANS_ERR_CH0 (DMA_INTMASK0_MSKTRNERR_0) /*!< DMA transfer error interrupt CH.0 */
  228. #define DMA_INT_TRANS_ERR_CH1 (DMA_INTMASK0_MSKTRNERR_1) /*!< DMA transfer error interrupt CH.1 */
  229. #define DMA_INT_TRANS_ERR_CH2 (DMA_INTMASK0_MSKTRNERR_2) /*!< DMA transfer error interrupt CH.2 */
  230. #define DMA_INT_TRANS_ERR_CH3 (DMA_INTMASK0_MSKTRNERR_3) /*!< DMA transfer error interrupt CH.3 */
  231. #define DMA_INT_TRANS_ERR_CH4 (DMA_INTMASK0_MSKTRNERR_4) /*!< DMA transfer error interrupt CH.4 */
  232. #define DMA_INT_TRANS_ERR_CH5 (DMA_INTMASK0_MSKTRNERR_5) /*!< DMA transfer error interrupt CH.5 */
  233. /**
  234. * @}
  235. */
  236. /**
  237. * @defgroup DMA_Int_Btc_Sel DMA block transfer completed interrupt selection
  238. * @{
  239. */
  240. #define DMA_INT_BTC_CH0 (DMA_INTMASK1_MSKBTC_0) /*!< DMA block transfer completed interrupt CH.0 */
  241. #define DMA_INT_BTC_CH1 (DMA_INTMASK1_MSKBTC_1) /*!< DMA block transfer completed interrupt CH.1 */
  242. #define DMA_INT_BTC_CH2 (DMA_INTMASK1_MSKBTC_2) /*!< DMA block transfer completed interrupt CH.2 */
  243. #define DMA_INT_BTC_CH3 (DMA_INTMASK1_MSKBTC_3) /*!< DMA block transfer completed interrupt CH.3 */
  244. #define DMA_INT_BTC_CH4 (DMA_INTMASK1_MSKBTC_4) /*!< DMA block transfer completed interrupt CH.4 */
  245. #define DMA_INT_BTC_CH5 (DMA_INTMASK1_MSKBTC_5) /*!< DMA block transfer completed interrupt CH.5 */
  246. /**
  247. * @}
  248. */
  249. /**
  250. * @defgroup DMA_Int_Tc_Sel DMA transfer completed interrupt selection
  251. * @{
  252. */
  253. #define DMA_INT_TC_CH0 (DMA_INTMASK1_MSKTC_0) /*!< DMA transfer completed interrupt CH.0 */
  254. #define DMA_INT_TC_CH1 (DMA_INTMASK1_MSKTC_1) /*!< DMA transfer completed interrupt CH.1 */
  255. #define DMA_INT_TC_CH2 (DMA_INTMASK1_MSKTC_2) /*!< DMA transfer completed interrupt CH.2 */
  256. #define DMA_INT_TC_CH3 (DMA_INTMASK1_MSKTC_3) /*!< DMA transfer completed interrupt CH.3 */
  257. #define DMA_INT_TC_CH4 (DMA_INTMASK1_MSKTC_4) /*!< DMA transfer completed interrupt CH.4 */
  258. #define DMA_INT_TC_CH5 (DMA_INTMASK1_MSKTC_5) /*!< DMA transfer completed interrupt CH.5 */
  259. /**
  260. * @}
  261. */
  262. /**
  263. * @defgroup DMA_FlagMsk_Sel DMA flag mask selection
  264. * @{
  265. */
  266. #define DMA_FLAG_ERR_MASK (DMA_INTSTAT0_TRNERR | DMA_INTSTAT0_REQERR) /*!< DMA error flag mask */
  267. #define DMA_FLAG_TRANS_MASK (DMA_INTSTAT1_TC | DMA_INTSTAT1_BTC) /*!< DMA transfer flag mask */
  268. /**
  269. * @}
  270. */
  271. /**
  272. * @defgroup DMA_IntMsk_Sel DMA interrupt mask selection
  273. * @{
  274. */
  275. #define DMA_INT_ERR_MASK (DMA_INTMASK0_MSKREQERR | DMA_INTMASK0_MSKTRNERR) /*!< DMA error interrupt mask */
  276. #define DMA_INT_TRANS_MASK (DMA_INTMASK1_MSKTC | DMA_INTMASK1_MSKBTC) /*!< DMA transfer interrupt mask */
  277. /**
  278. * @}
  279. */
  280. /**
  281. * @defgroup DMA_Req_Status_Sel DMA request status
  282. * @{
  283. */
  284. #define DMA_STAT_REQ_RECONFIG (DMA_REQSTAT_RCFGREQ) /*!< DMA request from reconfig */
  285. #define DMA_STAT_REQ_CH0 (DMA_REQSTAT_CHREQ_0) /*!< DMA request from CH.0 */
  286. #define DMA_STAT_REQ_CH1 (DMA_REQSTAT_CHREQ_1) /*!< DMA request from CH.1 */
  287. #define DMA_STAT_REQ_CH2 (DMA_REQSTAT_CHREQ_2) /*!< DMA request from CH.2 */
  288. #define DMA_STAT_REQ_CH3 (DMA_REQSTAT_CHREQ_3) /*!< DMA request from CH.3 */
  289. #define DMA_STAT_REQ_CH4 (DMA_REQSTAT_CHREQ_4) /*!< DMA request from CH.4 */
  290. #define DMA_STAT_REQ_CH5 (DMA_REQSTAT_CHREQ_5) /*!< DMA request from CH.5 */
  291. #define DMA_STAT_REQ_MASK (DMA_REQSTAT_CHREQ | DMA_REQSTAT_RCFGREQ) /*!< DMA request mask */
  292. /**
  293. * @}
  294. */
  295. /**
  296. * @defgroup DMA_Trans_Status_Sel DMA transfer status
  297. * @{
  298. */
  299. #define DMA_STAT_TRANS_CH0 (DMA_CHSTAT_CHACT_0) /*!< DMA transfer status of CH.0 */
  300. #define DMA_STAT_TRANS_CH1 (DMA_CHSTAT_CHACT_1) /*!< DMA transfer status of CH.1 */
  301. #define DMA_STAT_TRANS_CH2 (DMA_CHSTAT_CHACT_2) /*!< DMA transfer status of CH.2 */
  302. #define DMA_STAT_TRANS_CH3 (DMA_CHSTAT_CHACT_3) /*!< DMA transfer status of CH.3 */
  303. #define DMA_STAT_TRANS_CH4 (DMA_CHSTAT_CHACT_4) /*!< DMA transfer status of CH.4 */
  304. #define DMA_STAT_TRANS_CH5 (DMA_CHSTAT_CHACT_5) /*!< DMA transfer status of CH.5 */
  305. #define DMA_STAT_TRANS_DMA (DMA_CHSTAT_DMAACT) /*!< DMA transfer status of the DMA */
  306. #define DMA_STAT_TRANS_RECONFIG (DMA_CHSTAT_RCFGACT) /*!< DMA reconfig status */
  307. #define DMA_STAT_TRANS_MASK (DMA_CHSTAT_DMAACT | DMA_CHSTAT_CHACT | DMA_CHSTAT_RCFGACT)
  308. /**
  309. * @}
  310. */
  311. /**
  312. * @defgroup DMA_DataWidth_Sel DMA transfer data width
  313. * @{
  314. */
  315. #define DMA_DATAWIDTH_8BIT (0x00000000UL) /*!< DMA transfer data width 8bit */
  316. #define DMA_DATAWIDTH_16BIT (DMA_CHCTL_HSIZE_0) /*!< DMA transfer data width 16bit */
  317. #define DMA_DATAWIDTH_32BIT (DMA_CHCTL_HSIZE_1) /*!< DMA transfer data width 32bit */
  318. /**
  319. * @}
  320. */
  321. /**
  322. * @defgroup DMA_Llp_En DMA LLP(linked list pinter) enable or disable
  323. * @{
  324. */
  325. #define DMA_LLP_DISABLE (0x00000000UL) /*!< DMA linked list pinter disable */
  326. #define DMA_LLP_ENABLE (DMA_CHCTL_LLPEN) /*!< DMA linked list pinter enable */
  327. /**
  328. * @}
  329. */
  330. /**
  331. * @defgroup DMA_Llp_Mode DMA linked list pinter mode while transferring complete
  332. * @{
  333. */
  334. #define DMA_LLP_WAIT (0x00000000UL) /*!< DMA Llp wait next request while transferring complete */
  335. #define DMA_LLP_RUN (DMA_CHCTL_LLPRUN) /*!< DMA Llp run right now while transferring complete */
  336. /**
  337. * @}
  338. */
  339. /**
  340. * @defgroup DMA_SrcAddr_Incremented_Mode DMA source address increment mode
  341. * @{
  342. */
  343. #define DMA_SRC_ADDR_FIX (0x00000000UL) /*!< DMA source address fix */
  344. #define DMA_SRC_ADDR_INC (DMA_CHCTL_SINC_0) /*!< DMA source address increment */
  345. #define DMA_SRC_ADDR_DEC (DMA_CHCTL_SINC_1) /*!< DMA source address decrement */
  346. /**
  347. * @}
  348. */
  349. /**
  350. * @defgroup DMA_DesAddr_Incremented_Mode DMA destination address increment mode
  351. * @{
  352. */
  353. #define DMA_DEST_ADDR_FIX (0x00000000UL) /*!< DMA destination address fix */
  354. #define DMA_DEST_ADDR_INC (DMA_CHCTL_DINC_0) /*!< DMA destination address increment */
  355. #define DMA_DEST_ADDR_DEC (DMA_CHCTL_DINC_1) /*!< DMA destination address decrement */
  356. /**
  357. * @}
  358. */
  359. /**
  360. * @defgroup DMA_Int_Config DMA interrupt function config
  361. * @{
  362. */
  363. #define DMA_INT_ENABLE (DMA_CHCTL_IE) /*!< DMA interrupt enable */
  364. #define DMA_INT_DISABLE (0x00000000UL) /*!< DMA interrupt disable */
  365. /**
  366. * @}
  367. */
  368. /**
  369. * @defgroup DMA_Repeat_Config DMA repeat mode function config
  370. * @{
  371. */
  372. #define DMA_RPT_NONE (0x00000000UL) /*!< DMA repeat disable */
  373. #define DMA_RPT_SRC (DMA_CHCTL_SRPTEN) /*!< DMA source repeat enable */
  374. #define DMA_RPT_DEST (DMA_CHCTL_DRPTEN) /*!< DMA destination repeat enable */
  375. #define DMA_RPT_BOTH (DMA_CHCTL_SRPTEN | DMA_CHCTL_DRPTEN) /*!< DMA source & destination repeat enable */
  376. /**
  377. * @}
  378. */
  379. /**
  380. * @defgroup DMA_NonSeq_Config DMA non-sequence mode function config
  381. * @{
  382. */
  383. #define DMA_NON_SEQ_NONE (0x00000000UL) /*!< DMA non-sequence disable */
  384. #define DMA_NON_SEQ_SRC (DMA_CHCTL_SNSEQEN) /*!< DMA source non-sequence enable */
  385. #define DMA_NON_SEQ_DEST (DMA_CHCTL_DNSEQEN) /*!< DMA destination non-sequence enable */
  386. #define DMA_NON_SEQ_BOTH (DMA_CHCTL_SNSEQEN | DMA_CHCTL_DNSEQEN) /*!< DMA source & destination non-sequence enable */
  387. /**
  388. * @}
  389. */
  390. /**
  391. * @defgroup DMA_Reconfig_Count_Sel DMA reconfig count mode selection
  392. * @{
  393. */
  394. #define DMA_RC_CNT_KEEP (0x00000000UL) /*!< Keep the original counting method */
  395. #define DMA_RC_CNT_SRC (DMA_RCFGCTL_CNTMD_0) /*!< Use source address counting method */
  396. #define DMA_RC_CNT_DEST (DMA_RCFGCTL_CNTMD_1) /*!< Use destination address counting method */
  397. /**
  398. * @}
  399. */
  400. /**
  401. * @defgroup DMA_Reconfig_DestAddr_Sel DMA reconfig destination address mode selection
  402. * @{
  403. */
  404. #define DMA_RC_DEST_ADDR_KEEP (0x00000000UL) /*!< Destination address Keep the original mode */
  405. #define DMA_RC_DEST_ADDR_NS (DMA_RCFGCTL_DARMD_0) /*!< Destination address non-sequence */
  406. #define DMA_RC_DEST_ADDR_RPT (DMA_RCFGCTL_DARMD_1) /*!< Destination address repeat */
  407. /**
  408. * @}
  409. */
  410. /**
  411. * @defgroup DMA_Reconfig_SrcAddr_Sel DMA reconfig source address mode selection
  412. * @{
  413. */
  414. #define DMA_RC_SRC_ADDR_KEEP (0x00000000UL) /*!< Source address Keep the original mode */
  415. #define DMA_RC_SRC_ADDR_NS (DMA_RCFGCTL_SARMD_0) /*!< Source address non-sequence */
  416. #define DMA_RC_SRC_ADDR_RPT (DMA_RCFGCTL_SARMD_1) /*!< Source address repeat */
  417. /**
  418. * @}
  419. */
  420. /**
  421. * @}
  422. */
  423. /*******************************************************************************
  424. * Global variable definitions ('extern')
  425. ******************************************************************************/
  426. /*******************************************************************************
  427. Global function prototypes (definition in C source)
  428. ******************************************************************************/
  429. /**
  430. * @addtogroup DMA_Global_Functions
  431. * @{
  432. */
  433. void DMA_Cmd(CM_DMA_TypeDef *DMAx, en_functional_state_t enNewState);
  434. void DMA_ErrIntCmd(CM_DMA_TypeDef *DMAx, uint32_t u32ErrInt, en_functional_state_t enNewState);
  435. en_flag_status_t DMA_GetErrStatus(const CM_DMA_TypeDef *DMAx, uint32_t u32Flag);
  436. void DMA_ClearErrStatus(CM_DMA_TypeDef *DMAx, uint32_t u32Flag);
  437. void DMA_TransCompleteIntCmd(CM_DMA_TypeDef *DMAx, uint32_t u32TransCompleteInt, en_functional_state_t enNewState);
  438. en_flag_status_t DMA_GetTransCompleteStatus(const CM_DMA_TypeDef *DMAx, uint32_t u32Flag);
  439. void DMA_ClearTransCompleteStatus(CM_DMA_TypeDef *DMAx, uint32_t u32Flag);
  440. void DMA_MxChCmd(CM_DMA_TypeDef *DMAx, uint8_t u8MxCh, en_functional_state_t enNewState);
  441. int32_t DMA_ChCmd(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, en_functional_state_t enNewState);
  442. en_flag_status_t DMA_GetRequestStatus(const CM_DMA_TypeDef *DMAx, uint32_t u32Status);
  443. en_flag_status_t DMA_GetTransStatus(const CM_DMA_TypeDef *DMAx, uint32_t u32Status);
  444. int32_t DMA_SetSrcAddr(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, uint32_t u32Addr);
  445. int32_t DMA_SetDestAddr(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, uint32_t u32Addr);
  446. int32_t DMA_SetTransCount(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, uint16_t u16Count);
  447. int32_t DMA_SetBlockSize(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, uint16_t u16Size);
  448. int32_t DMA_SetSrcRepeatSize(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, uint16_t u16Size);
  449. int32_t DMA_SetDestRepeatSize(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, uint16_t u16Size);
  450. int32_t DMA_SetNonSeqSrcCount(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, uint32_t u32Count);
  451. int32_t DMA_SetNonSeqDestCount(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, uint32_t u32Count);
  452. int32_t DMA_SetNonSeqSrcOffset(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, uint32_t u32Offset);
  453. int32_t DMA_SetNonSeqDestOffset(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, uint32_t u32Offset);
  454. void DMA_SetLlpAddr(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, uint32_t u32Addr);
  455. int32_t DMA_StructInit(stc_dma_init_t *pstcDmaInit);
  456. int32_t DMA_Init(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, const stc_dma_init_t *pstcDmaInit);
  457. void DMA_DeInit(CM_DMA_TypeDef *DMAx, uint8_t u8Ch);
  458. int32_t DMA_RepeatStructInit(stc_dma_repeat_init_t *pstcDmaRepeatInit);
  459. int32_t DMA_RepeatInit(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, const stc_dma_repeat_init_t *pstcDmaRepeatInit);
  460. int32_t DMA_NonSeqStructInit(stc_dma_nonseq_init_t *pstcDmaNonSeqInit);
  461. int32_t DMA_NonSeqInit(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, const stc_dma_nonseq_init_t *pstcDmaNonSeqInit);
  462. int32_t DMA_LlpStructInit(stc_dma_llp_init_t *pstcDmaLlpInit);
  463. int32_t DMA_LlpInit(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, const stc_dma_llp_init_t *pstcDmaLlpInit);
  464. void DMA_LlpCmd(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, en_functional_state_t enNewState);
  465. int32_t DMA_ReconfigStructInit(stc_dma_reconfig_init_t *pstcDmaRCInit);
  466. int32_t DMA_ReconfigInit(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, const stc_dma_reconfig_init_t *pstcDmaRCInit);
  467. void DMA_ReconfigCmd(CM_DMA_TypeDef *DMAx, en_functional_state_t enNewState);
  468. void DMA_ReconfigLlpCmd(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, en_functional_state_t enNewState);
  469. uint32_t DMA_GetSrcAddr(const CM_DMA_TypeDef *DMAx, uint8_t u8Ch);
  470. uint32_t DMA_GetDestAddr(const CM_DMA_TypeDef *DMAx, uint8_t u8Ch);
  471. uint32_t DMA_GetTransCount(const CM_DMA_TypeDef *DMAx, uint8_t u8Ch);
  472. uint32_t DMA_GetBlockSize(const CM_DMA_TypeDef *DMAx, uint8_t u8Ch);
  473. uint32_t DMA_GetSrcRepeatSize(const CM_DMA_TypeDef *DMAx, uint8_t u8Ch);
  474. uint32_t DMA_GetDestRepeatSize(const CM_DMA_TypeDef *DMAx, uint8_t u8Ch);
  475. uint32_t DMA_GetNonSeqSrcCount(const CM_DMA_TypeDef *DMAx, uint8_t u8Ch);
  476. uint32_t DMA_GetNonSeqDestCount(const CM_DMA_TypeDef *DMAx, uint8_t u8Ch);
  477. uint32_t DMA_GetNonSeqSrcOffset(const CM_DMA_TypeDef *DMAx, uint8_t u8Ch);
  478. uint32_t DMA_GetNonSeqDestOffset(const CM_DMA_TypeDef *DMAx, uint8_t u8Ch);
  479. /**
  480. * @}
  481. */
  482. #endif /* LL_DMA_ENABLE */
  483. /**
  484. * @}
  485. */
  486. /**
  487. * @}
  488. */
  489. #ifdef __cplusplus
  490. }
  491. #endif
  492. #endif /* __HC32_LL_DMA_H__ */
  493. /*******************************************************************************
  494. * EOF (not truncated)
  495. ******************************************************************************/