gd32e23x_dma.c 20 KB

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