gd32e23x_dma.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. /*!
  2. \file gd32e23x_dma.c
  3. \brief DMA driver
  4. \version 2024-02-22, V2.1.0, firmware for GD32E23x
  5. */
  6. /*
  7. Copyright (c) 2024, GigaDevice Semiconductor Inc.
  8. Redistribution and use in source and binary forms, with or without modification,
  9. are permitted provided that the following conditions are met:
  10. 1. Redistributions of source code must retain the above copyright notice, this
  11. list of conditions and the following disclaimer.
  12. 2. Redistributions in binary form must reproduce the above copyright notice,
  13. this list of conditions and the following disclaimer in the documentation
  14. and/or other materials provided with the distribution.
  15. 3. Neither the name of the copyright holder nor the names of its contributors
  16. may be used to endorse or promote products derived from this software without
  17. specific prior written permission.
  18. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  19. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  21. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  22. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  23. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  24. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  25. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  26. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  27. OF SUCH DAMAGE.
  28. */
  29. #include "gd32e23x_dma.h"
  30. /*!
  31. \brief deinitialize DMA a channel registers
  32. \param[in] channelx: specify which DMA channel is deinitialized
  33. only one parameter can be selected which is shown as below:
  34. \arg DMA_CHx(x=0..4)
  35. \param[out] none
  36. \retval none
  37. */
  38. void dma_deinit(dma_channel_enum channelx)
  39. {
  40. /* disable DMA a channel */
  41. DMA_CHCTL(channelx) &= ~DMA_CHXCTL_CHEN;
  42. /* reset DMA channel registers */
  43. DMA_CHCTL(channelx) = DMA_CHCTL_RESET_VALUE;
  44. DMA_CHCNT(channelx) = DMA_CHCNT_RESET_VALUE;
  45. DMA_CHPADDR(channelx) = DMA_CHPADDR_RESET_VALUE;
  46. DMA_CHMADDR(channelx) = DMA_CHMADDR_RESET_VALUE;
  47. DMA_INTC |= DMA_FLAG_ADD(DMA_CHINTF_RESET_VALUE, channelx);
  48. }
  49. /*!
  50. \brief initialize the parameters of DMA struct with the default values
  51. \param[in] init_struct: the initialization data needed to initialize DMA channel
  52. \param[out] none
  53. \retval none
  54. */
  55. void dma_struct_para_init(dma_parameter_struct* init_struct)
  56. {
  57. /* set the DMA struct with the default values */
  58. init_struct->periph_addr = 0U;
  59. init_struct->periph_width = 0U;
  60. init_struct->periph_inc = (uint8_t)DMA_PERIPH_INCREASE_DISABLE;
  61. init_struct->memory_addr = 0U;
  62. init_struct->memory_width = 0U;
  63. init_struct->memory_inc = (uint8_t)DMA_MEMORY_INCREASE_DISABLE;
  64. init_struct->number = 0U;
  65. init_struct->direction = (uint8_t)DMA_PERIPHERAL_TO_MEMORY;
  66. init_struct->priority = (uint32_t)DMA_PRIORITY_LOW;
  67. }
  68. /*!
  69. \brief initialize DMA channel
  70. \param[in] channelx: specify which DMA channel is initialized
  71. only one parameter can be selected which is shown as below:
  72. \arg DMA_CHx(x=0..4)
  73. \param[in] init_struct: the data needed to initialize DMA channel
  74. periph_addr: peripheral base address
  75. periph_width: DMA_PERIPHERAL_WIDTH_8BIT,DMA_PERIPHERAL_WIDTH_16BIT,DMA_PERIPHERAL_WIDTH_32BIT
  76. periph_inc: DMA_PERIPH_INCREASE_ENABLE,DMA_PERIPH_INCREASE_DISABLE
  77. memory_addr: memory base address
  78. memory_width: DMA_MEMORY_WIDTH_8BIT,DMA_MEMORY_WIDTH_16BIT,DMA_MEMORY_WIDTH_32BIT
  79. memory_inc: DMA_MEMORY_INCREASE_ENABLE,DMA_MEMORY_INCREASE_DISABLE
  80. direction: DMA_PERIPHERAL_TO_MEMORY,DMA_MEMORY_TO_PERIPHERAL
  81. number: the number of remaining data to be transferred by the DMA
  82. priority: DMA_PRIORITY_LOW,DMA_PRIORITY_MEDIUM,DMA_PRIORITY_HIGH,DMA_PRIORITY_ULTRA_HIGH
  83. \param[out] none
  84. \retval none
  85. */
  86. void dma_init(dma_channel_enum channelx, dma_parameter_struct* init_struct)
  87. {
  88. uint32_t ctl;
  89. dma_channel_disable(channelx);
  90. /* configure peripheral base address */
  91. DMA_CHPADDR(channelx) = init_struct->periph_addr;
  92. /* configure memory base address */
  93. DMA_CHMADDR(channelx) = init_struct->memory_addr;
  94. /* configure the number of remaining data to be transferred */
  95. DMA_CHCNT(channelx) = (init_struct->number & DMA_CHANNEL_CNT_MASK);
  96. /* configure peripheral transfer width,memory transfer width,channel priotity */
  97. ctl = DMA_CHCTL(channelx);
  98. ctl &= ~(DMA_CHXCTL_PWIDTH | DMA_CHXCTL_MWIDTH | DMA_CHXCTL_PRIO);
  99. ctl |= (init_struct->periph_width | init_struct->memory_width | init_struct->priority);
  100. DMA_CHCTL(channelx) = ctl;
  101. /* configure peripheral increasing mode */
  102. if(DMA_PERIPH_INCREASE_ENABLE == init_struct->periph_inc){
  103. DMA_CHCTL(channelx) |= DMA_CHXCTL_PNAGA;
  104. }else{
  105. DMA_CHCTL(channelx) &= ~DMA_CHXCTL_PNAGA;
  106. }
  107. /* configure memory increasing mode */
  108. if(DMA_MEMORY_INCREASE_ENABLE == init_struct->memory_inc){
  109. DMA_CHCTL(channelx) |= DMA_CHXCTL_MNAGA;
  110. }else{
  111. DMA_CHCTL(channelx) &= ~DMA_CHXCTL_MNAGA;
  112. }
  113. /* configure the direction of data transfer */
  114. if(DMA_PERIPHERAL_TO_MEMORY == init_struct->direction){
  115. DMA_CHCTL(channelx) &= ~DMA_CHXCTL_DIR;
  116. }else{
  117. DMA_CHCTL(channelx) |= DMA_CHXCTL_DIR;
  118. }
  119. }
  120. /*!
  121. \brief enable DMA circulation mode
  122. \param[in] channelx: specify which DMA channel to set
  123. only one parameter can be selected which is shown as below:
  124. \arg DMA_CHx(x=0..4)
  125. \param[out] none
  126. \retval none
  127. */
  128. void dma_circulation_enable(dma_channel_enum channelx)
  129. {
  130. DMA_CHCTL(channelx) |= DMA_CHXCTL_CMEN;
  131. }
  132. /*!
  133. \brief disable DMA circulation mode
  134. \param[in] channelx: specify which DMA channel to set
  135. only one parameter can be selected which is shown as below:
  136. \arg DMA_CHx(x=0..4)
  137. \param[out] none
  138. \retval none
  139. */
  140. void dma_circulation_disable(dma_channel_enum channelx)
  141. {
  142. DMA_CHCTL(channelx) &= ~DMA_CHXCTL_CMEN;
  143. }
  144. /*!
  145. \brief enable memory to memory mode
  146. \param[in] channelx: specify which DMA channel to set
  147. only one parameter can be selected which is shown as below:
  148. \arg DMA_CHx(x=0..4)
  149. \param[out] none
  150. \retval none
  151. */
  152. void dma_memory_to_memory_enable(dma_channel_enum channelx)
  153. {
  154. DMA_CHCTL(channelx) |= DMA_CHXCTL_M2M;
  155. }
  156. /*!
  157. \brief disable memory to memory mode
  158. \param[in] channelx: specify which DMA channel to set
  159. only one parameter can be selected which is shown as below:
  160. \arg DMA_CHx(x=0..4)
  161. \param[out] none
  162. \retval none
  163. */
  164. void dma_memory_to_memory_disable(dma_channel_enum channelx)
  165. {
  166. DMA_CHCTL(channelx) &= ~DMA_CHXCTL_M2M;
  167. }
  168. /*!
  169. \brief enable DMA channel
  170. \param[in] channelx: specify which DMA channel to set
  171. only one parameter can be selected which is shown as below:
  172. \arg DMA_CHx(x=0..4)
  173. \param[out] none
  174. \retval none
  175. */
  176. void dma_channel_enable(dma_channel_enum channelx)
  177. {
  178. DMA_CHCTL(channelx) |= DMA_CHXCTL_CHEN;
  179. }
  180. /*!
  181. \brief disable DMA channel
  182. \param[in] channelx: specify which DMA channel to set
  183. only one parameter can be selected which is shown as below:
  184. \arg DMA_CHx(x=0..4)
  185. \param[out] none
  186. \retval none
  187. */
  188. void dma_channel_disable(dma_channel_enum channelx)
  189. {
  190. DMA_CHCTL(channelx) &= ~DMA_CHXCTL_CHEN;
  191. }
  192. /*!
  193. \brief set DMA peripheral base address
  194. \param[in] channelx: specify which DMA channel to set peripheral base address
  195. only one parameter can be selected which is shown as below:
  196. \arg DMA_CHx(x=0..4)
  197. \param[in] address: peripheral base address
  198. \param[out] none
  199. \retval none
  200. */
  201. void dma_periph_address_config(dma_channel_enum channelx, uint32_t address)
  202. {
  203. DMA_CHPADDR(channelx) = address;
  204. }
  205. /*!
  206. \brief set DMA memory base address
  207. \param[in] channelx: specify which DMA channel to set memory base address
  208. only one parameter can be selected which is shown as below:
  209. \arg DMA_CHx(x=0..4)
  210. \param[in] address: memory base address
  211. \param[out] none
  212. \retval none
  213. */
  214. void dma_memory_address_config(dma_channel_enum channelx, uint32_t address)
  215. {
  216. DMA_CHMADDR(channelx) = address;
  217. }
  218. /*!
  219. \brief set the number of remaining data to be transferred by the DMA
  220. \param[in] channelx: specify which DMA channel to set number
  221. only one parameter can be selected which is shown as below:
  222. \arg DMA_CHx(x=0..4)
  223. \param[in] number: the number of remaining data to be transferred by the DMA
  224. \param[out] none
  225. \retval none
  226. */
  227. void dma_transfer_number_config(dma_channel_enum channelx, uint32_t number)
  228. {
  229. DMA_CHCNT(channelx) = (number & DMA_CHANNEL_CNT_MASK);
  230. }
  231. /*!
  232. \brief get the number of remaining data to be transferred by the DMA
  233. \param[in] channelx: specify which DMA channel to set number
  234. only one parameter can be selected which is shown as below:
  235. \arg DMA_CHx(x=0..4)
  236. \param[out] none
  237. \retval the number of remaining data to be transferred by the DMA
  238. */
  239. uint32_t dma_transfer_number_get(dma_channel_enum channelx)
  240. {
  241. return (uint32_t)DMA_CHCNT(channelx);
  242. }
  243. /*!
  244. \brief configure priority level of DMA channel
  245. \param[in] channelx: specify which DMA channel to set
  246. only one parameter can be selected which is shown as below:
  247. \arg DMA_CHx(x=0..4)
  248. \param[in] priority: priority level of this channel
  249. only one parameter can be selected which is shown as below:
  250. \arg DMA_PRIORITY_LOW: low priority
  251. \arg DMA_PRIORITY_MEDIUM: medium priority
  252. \arg DMA_PRIORITY_HIGH: high priority
  253. \arg DMA_PRIORITY_ULTRA_HIGH: ultra high priority
  254. \param[out] none
  255. \retval none
  256. */
  257. void dma_priority_config(dma_channel_enum channelx, uint32_t priority)
  258. {
  259. uint32_t ctl;
  260. /* acquire DMA_CHxCTL register */
  261. ctl = DMA_CHCTL(channelx);
  262. /* assign regiser */
  263. ctl &= ~DMA_CHXCTL_PRIO;
  264. ctl |= priority;
  265. DMA_CHCTL(channelx) = ctl;
  266. }
  267. /*!
  268. \brief configure transfer data width of memory
  269. \param[in] channelx: specify which DMA channel to set
  270. only one parameter can be selected which is shown as below:
  271. \arg DMA_CHx(x=0..4)
  272. \param[in] mwidth: transfer data width of memory
  273. only one parameter can be selected which is shown as below:
  274. \arg DMA_MEMORY_WIDTH_8BIT: transfer data width of memory is 8-bit
  275. \arg DMA_MEMORY_WIDTH_16BIT: transfer data width of memory is 16-bit
  276. \arg DMA_MEMORY_WIDTH_32BIT: transfer data width of memory is 32-bit
  277. \param[out] none
  278. \retval none
  279. */
  280. void dma_memory_width_config(dma_channel_enum channelx, uint32_t mwidth)
  281. {
  282. uint32_t ctl;
  283. /* acquire DMA_CHxCTL register */
  284. ctl = DMA_CHCTL(channelx);
  285. /* assign regiser */
  286. ctl &= ~DMA_CHXCTL_MWIDTH;
  287. ctl |= mwidth;
  288. DMA_CHCTL(channelx) = ctl;
  289. }
  290. /*!
  291. \brief configure transfer data width of peripheral
  292. \param[in] channelx: specify which DMA channel to set
  293. only one parameter can be selected which is shown as below:
  294. \arg DMA_CHx(x=0..4)
  295. \param[in] pwidth: transfer data width of peripheral
  296. only one parameter can be selected which is shown as below:
  297. \arg DMA_PERIPHERAL_WIDTH_8BIT: transfer data width of peripheral is 8-bit
  298. \arg DMA_PERIPHERAL_WIDTH_16BIT: transfer data width of peripheral is 16-bit
  299. \arg DMA_PERIPHERAL_WIDTH_32BIT: transfer data width of peripheral is 32-bit
  300. \param[out] none
  301. \retval none
  302. */
  303. void dma_periph_width_config(dma_channel_enum channelx, uint32_t pwidth)
  304. {
  305. uint32_t ctl;
  306. /* acquire DMA_CHxCTL register */
  307. ctl = DMA_CHCTL(channelx);
  308. /* assign regiser */
  309. ctl &= ~DMA_CHXCTL_PWIDTH;
  310. ctl |= pwidth;
  311. DMA_CHCTL(channelx) = ctl;
  312. }
  313. /*!
  314. \brief enable next address increasement algorithm of memory
  315. \param[in] channelx: specify which DMA channel to set
  316. only one parameter can be selected which is shown as below:
  317. \arg DMA_CHx(x=0..4)
  318. \param[out] none
  319. \retval none
  320. */
  321. void dma_memory_increase_enable(dma_channel_enum channelx)
  322. {
  323. DMA_CHCTL(channelx) |= DMA_CHXCTL_MNAGA;
  324. }
  325. /*!
  326. \brief disable next address increasement algorithm of memory
  327. \param[in] channelx: specify which DMA channel to set
  328. only one parameter can be selected which is shown as below:
  329. \arg DMA_CHx(x=0..4)
  330. \param[out] none
  331. \retval none
  332. */
  333. void dma_memory_increase_disable(dma_channel_enum channelx)
  334. {
  335. DMA_CHCTL(channelx) &= ~DMA_CHXCTL_MNAGA;
  336. }
  337. /*!
  338. \brief enable next address increasement algorithm of peripheral
  339. \param[in] channelx: specify which DMA channel to set
  340. only one parameter can be selected which is shown as below:
  341. \arg DMA_CHx(x=0..4)
  342. \param[out] none
  343. \retval none
  344. */
  345. void dma_periph_increase_enable(dma_channel_enum channelx)
  346. {
  347. DMA_CHCTL(channelx) |= DMA_CHXCTL_PNAGA;
  348. }
  349. /*!
  350. \brief disable next address increasement algorithm of peripheral
  351. \param[in] channelx: specify which DMA channel to set
  352. only one parameter can be selected which is shown as below:
  353. \arg DMA_CHx(x=0..4)
  354. \param[out] none
  355. \retval none
  356. */
  357. void dma_periph_increase_disable(dma_channel_enum channelx)
  358. {
  359. DMA_CHCTL(channelx) &= ~DMA_CHXCTL_PNAGA;
  360. }
  361. /*!
  362. \brief configure the direction of data transfer on the channel
  363. \param[in] channelx: specify which DMA channel to set
  364. only one parameter can be selected which is shown as below:
  365. \arg DMA_CHx(x=0..4)
  366. \param[in] direction: specify the direction of data transfer
  367. only one parameter can be selected which is shown as below:
  368. \arg DMA_PERIPHERAL_TO_MEMORY: read from peripheral and write to memory
  369. \arg DMA_MEMORY_TO_PERIPHERAL: read from memory and write to peripheral
  370. \param[out] none
  371. \retval none
  372. */
  373. void dma_transfer_direction_config(dma_channel_enum channelx, uint8_t direction)
  374. {
  375. if(DMA_PERIPHERAL_TO_MEMORY == direction){
  376. DMA_CHCTL(channelx) &= ~DMA_CHXCTL_DIR;
  377. } else {
  378. DMA_CHCTL(channelx) |= DMA_CHXCTL_DIR;
  379. }
  380. }
  381. /*!
  382. \brief check DMA flag is set or not
  383. \param[in] channelx: specify which DMA channel to get flag
  384. only one parameter can be selected which is shown as below:
  385. \arg DMA_CHx(x=0..4)
  386. \param[in] flag: specify get which flag
  387. only one parameter can be selected which is shown as below:
  388. \arg DMA_FLAG_G: global interrupt flag of channel
  389. \arg DMA_FLAG_FTF: full transfer finish flag of channel
  390. \arg DMA_FLAG_HTF: half transfer finish flag of channel
  391. \arg DMA_FLAG_ERR: error flag of channel
  392. \param[out] none
  393. \retval FlagStatus: SET or RESET
  394. */
  395. FlagStatus dma_flag_get(dma_channel_enum channelx, uint32_t flag)
  396. {
  397. FlagStatus reval;
  398. if(RESET != (DMA_INTF & DMA_FLAG_ADD(flag, channelx))){
  399. reval = SET;
  400. }else{
  401. reval = RESET;
  402. }
  403. return reval;
  404. }
  405. /*!
  406. \brief clear DMA a channel flag
  407. \param[in] channelx: specify which DMA channel to clear flag
  408. only one parameter can be selected which is shown as below:
  409. \arg DMA_CHx(x=0..4)
  410. \param[in] flag: specify get which flag
  411. only one parameter can be selected which is shown as below:
  412. \arg DMA_FLAG_G: global interrupt flag of channel
  413. \arg DMA_FLAG_FTF: full transfer finish flag of channel
  414. \arg DMA_FLAG_HTF: half transfer finish flag of channel
  415. \arg DMA_FLAG_ERR: error flag of channel
  416. \param[out] none
  417. \retval none
  418. */
  419. void dma_flag_clear(dma_channel_enum channelx, uint32_t flag)
  420. {
  421. DMA_INTC |= DMA_FLAG_ADD(flag, channelx);
  422. }
  423. /*!
  424. \brief check DMA flag and interrupt enable bit is set or not
  425. \param[in] channelx: specify which DMA channel to get flag
  426. only one parameter can be selected which is shown as below:
  427. \arg DMA_CHx(x=0..4)
  428. \param[in] flag: specify get which flag
  429. only one parameter can be selected which is shown as below:
  430. \arg DMA_INT_FLAG_FTF: transfer finish flag of channel
  431. \arg DMA_INT_FLAG_HTF: half transfer finish flag of channel
  432. \arg DMA_INT_FLAG_ERR: error flag of channel
  433. \param[out] none
  434. \retval FlagStatus: SET or RESET
  435. */
  436. FlagStatus dma_interrupt_flag_get(dma_channel_enum channelx, uint32_t flag)
  437. {
  438. uint32_t interrupt_enable = 0U, interrupt_flag = 0U;
  439. switch(flag){
  440. case DMA_INT_FLAG_FTF:
  441. interrupt_flag = DMA_INTF & DMA_FLAG_ADD(flag, channelx);
  442. interrupt_enable = DMA_CHCTL(channelx) & DMA_CHXCTL_FTFIE;
  443. break;
  444. case DMA_INT_FLAG_HTF:
  445. interrupt_flag = DMA_INTF & DMA_FLAG_ADD(flag, channelx);
  446. interrupt_enable = DMA_CHCTL(channelx) & DMA_CHXCTL_HTFIE;
  447. break;
  448. case DMA_INT_FLAG_ERR:
  449. interrupt_flag = DMA_INTF & DMA_FLAG_ADD(flag, channelx);
  450. interrupt_enable = DMA_CHCTL(channelx) & DMA_CHXCTL_ERRIE;
  451. break;
  452. default:
  453. break;
  454. }
  455. if(interrupt_flag && interrupt_enable){
  456. return SET;
  457. }else{
  458. return RESET;
  459. }
  460. }
  461. /*!
  462. \brief clear DMA a channel interrupt flag
  463. \param[in] channelx: specify which DMA channel to clear flag
  464. only one parameter can be selected which is shown as below:
  465. \arg DMA_CHx(x=0..4)
  466. \param[in] flag: specify get which flag
  467. only one parameter can be selected which is shown as below:
  468. \arg DMA_INT_FLAG_G: global interrupt flag of channel
  469. \arg DMA_INT_FLAG_FTF: transfer finish flag of channel
  470. \arg DMA_INT_FLAG_HTF: half transfer finish flag of channel
  471. \arg DMA_INT_FLAG_ERR: error flag of channel
  472. \param[out] none
  473. \retval none
  474. */
  475. void dma_interrupt_flag_clear(dma_channel_enum channelx, uint32_t flag)
  476. {
  477. DMA_INTC |= DMA_FLAG_ADD(flag,channelx);
  478. }
  479. /*!
  480. \brief enable DMA interrupt
  481. \param[in] channelx: specify which DMA channel to set
  482. only one parameter can be selected which is shown as below:
  483. \arg DMA_CHx(x=0..4)
  484. \param[in] source: specify which interrupt to enable
  485. only one parameter can be selected which is shown as below:
  486. \arg DMA_INT_ERR: channel error interrupt
  487. \arg DMA_INT_HTF: channel half transfer finish interrupt
  488. \arg DMA_INT_FTF: channel full transfer finish interrupt
  489. \param[out] none
  490. \retval none
  491. */
  492. void dma_interrupt_enable(dma_channel_enum channelx, uint32_t source)
  493. {
  494. DMA_CHCTL(channelx) |= source;
  495. }
  496. /*!
  497. \brief disable DMA interrupt
  498. \param[in] channelx: specify which DMA channel to set
  499. only one parameter can be selected which is shown as below:
  500. \arg DMA_CHx(x=0..4)
  501. \param[in] source: specify which interrupt to disable
  502. only one parameter can be selected which is shown as below:
  503. \arg DMA_INT_ERR: channel error interrupt
  504. \arg DMA_INT_HTF: channel half transfer finish interrupt
  505. \arg DMA_INT_FTF: channel full transfer finish interrupt
  506. \param[out] none
  507. \retval none
  508. */
  509. void dma_interrupt_disable(dma_channel_enum channelx, uint32_t source)
  510. {
  511. DMA_CHCTL(channelx) &= ~source;
  512. }