gd32f4xx_dac.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. /*!
  2. \file gd32f4xx_dac.c
  3. \brief DAC driver
  4. */
  5. /*
  6. Copyright (C) 2016 GigaDevice
  7. 2016-08-15, V1.0.0, firmware for GD32F4xx
  8. */
  9. #include "gd32f4xx_dac.h"
  10. /*!
  11. \brief deinitialize DAC
  12. \param[in] none
  13. \param[out] none
  14. \retval none
  15. */
  16. void dac_deinit(void)
  17. {
  18. rcu_periph_reset_enable(RCU_DACRST);
  19. rcu_periph_reset_disable(RCU_DACRST);
  20. }
  21. /*!
  22. \brief enable DAC
  23. \param[in] dac_periph
  24. \arg DACx(x =0,1)
  25. \param[out] none
  26. \retval none
  27. */
  28. void dac_enable(uint32_t dac_periph)
  29. {
  30. if(DAC0 == dac_periph){
  31. DAC_CTL |= DAC_CTL_DEN0;
  32. }else{
  33. DAC_CTL |= DAC_CTL_DEN1;
  34. }
  35. }
  36. /*!
  37. \brief disable DAC
  38. \param[in] dac_periph
  39. \arg DACx(x =0,1)
  40. \param[out] none
  41. \retval none
  42. */
  43. void dac_disable(uint32_t dac_periph)
  44. {
  45. if(DAC0 == dac_periph){
  46. DAC_CTL &= ~DAC_CTL_DEN0;
  47. }else{
  48. DAC_CTL &= ~DAC_CTL_DEN1;
  49. }
  50. }
  51. /*!
  52. \brief enable DAC DMA function
  53. \param[in] dac_periph
  54. \arg DACx(x=0,1)
  55. \param[out] none
  56. \retval none
  57. */
  58. void dac_dma_enable(uint32_t dac_periph)
  59. {
  60. if(DAC0 == dac_periph){
  61. DAC_CTL |= DAC_CTL_DDMAEN0;
  62. }else{
  63. DAC_CTL |= DAC_CTL_DDMAEN1;
  64. }
  65. }
  66. /*!
  67. \brief disable DAC DMA function
  68. \param[in] dac_periph
  69. \arg DACx(x=0,1)
  70. \param[out] none
  71. \retval none
  72. */
  73. void dac_dma_disable(uint32_t dac_periph)
  74. {
  75. if(DAC0 == dac_periph){
  76. DAC_CTL &= ~DAC_CTL_DDMAEN0;
  77. }else{
  78. DAC_CTL &= ~DAC_CTL_DDMAEN1;
  79. }
  80. }
  81. /*!
  82. \brief enable DAC output buffer
  83. \param[in] dac_periph
  84. \arg DACx(x =0,1)
  85. \param[out] none
  86. \retval none
  87. */
  88. void dac_output_buffer_enable(uint32_t dac_periph)
  89. {
  90. if(DAC0 == dac_periph){
  91. DAC_CTL &= ~DAC_CTL_DBOFF0;
  92. }else{
  93. DAC_CTL &= ~DAC_CTL_DBOFF1;
  94. }
  95. }
  96. /*!
  97. \brief disable DAC output buffer
  98. \param[in] dac_periph
  99. \arg DACx(x =0,1)
  100. \param[out] none
  101. \retval none
  102. */
  103. void dac_output_buffer_disable(uint32_t dac_periph)
  104. {
  105. if(DAC0 == dac_periph){
  106. DAC_CTL |= DAC_CTL_DBOFF0;
  107. }else{
  108. DAC_CTL |= DAC_CTL_DBOFF1;
  109. }
  110. }
  111. /*!
  112. \brief enable DAC trigger
  113. \param[in] dac_periph
  114. \arg DACx(x =0,1)
  115. \param[out] none
  116. \retval none
  117. */
  118. void dac_trigger_enable(uint32_t dac_periph)
  119. {
  120. if(DAC0 == dac_periph){
  121. DAC_CTL |= DAC_CTL_DTEN0;
  122. }else{
  123. DAC_CTL |= DAC_CTL_DTEN1;
  124. }
  125. }
  126. /*!
  127. \brief disable DAC trigger
  128. \param[in] dac_periph
  129. \arg DACx(x =0,1)
  130. \param[out] none
  131. \retval none
  132. */
  133. void dac_trigger_disable(uint32_t dac_periph)
  134. {
  135. if(DAC0 == dac_periph){
  136. DAC_CTL &= ~DAC_CTL_DTEN0;
  137. }else{
  138. DAC_CTL &= ~DAC_CTL_DTEN1;
  139. }
  140. }
  141. /*!
  142. \brief enable DAC software trigger
  143. \param[in] dac_periph
  144. \arg DACx(x =0,1)
  145. \retval none
  146. */
  147. void dac_software_trigger_enable(uint32_t dac_periph)
  148. {
  149. if(DAC0 == dac_periph){
  150. DAC_SWT |= DAC_SWT_SWTR0;
  151. }else{
  152. DAC_SWT |= DAC_SWT_SWTR1;
  153. }
  154. }
  155. /*!
  156. \brief disable DAC software trigger
  157. \param[in] dac_periph
  158. \arg DACx(x =0,1)
  159. \param[out] none
  160. \retval none
  161. */
  162. void dac_software_trigger_disable(uint32_t dac_periph)
  163. {
  164. if(DAC0 == dac_periph){
  165. DAC_SWT &= ~DAC_SWT_SWTR0;
  166. }else{
  167. DAC_SWT &= ~DAC_SWT_SWTR1;
  168. }
  169. }
  170. /*!
  171. \brief enable DAC interrupt(DAC0 DMA underrun interrupt)
  172. \param[in] dac_periph
  173. \arg DACx(x=0,1)
  174. \param[out] none
  175. \retval none
  176. */
  177. void dac_interrupt_enable(uint32_t dac_periph)
  178. {
  179. if(DAC0 == dac_periph){
  180. DAC_CTL |= DAC_CTL_DDUDRIE0;
  181. }else{
  182. DAC_CTL |= DAC_CTL_DDUDRIE1;
  183. }
  184. }
  185. /*!
  186. \brief disable DAC interrupt(DAC0 DMA underrun interrupt)
  187. \param[in] dac_periph
  188. \arg DACx(x=0,1)
  189. \param[out] none
  190. \retval none
  191. */
  192. void dac_interrupt_disable(uint32_t dac_periph)
  193. {
  194. if(DAC0 == dac_periph){
  195. DAC_CTL &= ~DAC_CTL_DDUDRIE0;
  196. }else{
  197. DAC_CTL &= ~DAC_CTL_DDUDRIE1;
  198. }
  199. }
  200. /*!
  201. \brief set DAC trigger source
  202. \param[in] dac_periph
  203. \arg DACx(x =0,1)
  204. \param[in] triggersource: external triggers of DAC
  205. \arg DAC_TRIGGER_T1_TRGO: TIMER1 TRGO
  206. \arg DAC_TRIGGER_T3_TRGO: TIMER3 TRGO
  207. \arg DAC_TRIGGER_T4_TRGO: TIMER4 TRGO
  208. \arg DAC_TRIGGER_T5_TRGO: TIMER5 TRGO
  209. \arg DAC_TRIGGER_T6_TRGO: TIMER6 TRGO
  210. \arg DAC_TRIGGER_T7_TRGO: TIMER7 TRGO
  211. \arg DAC_TRIGGER_EXTI_9: EXTI interrupt line9 event
  212. \arg DAC_TRIGGER_SOFTWARE: software trigger
  213. \param[out] none
  214. \retval none
  215. */
  216. void dac_trigger_source_config(uint32_t dac_periph,uint32_t triggersource)
  217. {
  218. if(DAC0 == dac_periph){
  219. DAC_CTL &= ~DAC_CTL_DTSEL0;
  220. DAC_CTL |= triggersource;
  221. }else{
  222. DAC_CTL &= ~DAC_CTL_DTSEL1;
  223. DAC_CTL |= (triggersource << 16);
  224. }
  225. }
  226. /*!
  227. \brief configure DAC wave mode
  228. \param[in] dac_periph
  229. \arg DACx(x=0,1)
  230. \param[in] wave_mode
  231. \arg DAC_WAVE_DISABLE: wave disable
  232. \arg DAC_WAVE_MODE_LFSR: LFSR noise mode
  233. \arg DAC_WAVE_MODE_TRIANGLE: triangle noise mode
  234. \param[out] none
  235. \retval none
  236. */
  237. void dac_wave_mode_config(uint32_t dac_periph, uint32_t wave_mode)
  238. {
  239. if(DAC0 == dac_periph){
  240. DAC_CTL &= ~DAC_CTL_DWM0;
  241. DAC_CTL |= wave_mode;
  242. }else{
  243. DAC_CTL &= ~DAC_CTL_DWM1;
  244. DAC_CTL |= wave_mode << 16;
  245. }
  246. }
  247. /*!
  248. \brief configure DAC wave bit width
  249. \param[in] dac_periph
  250. \arg DACx(x=0,1)
  251. \param[in] bit_width
  252. \arg DAC_WAVE_BIT_WIDTH_1: bit width of the wave signal is 1
  253. \arg DAC_WAVE_BIT_WIDTH_2: bit width of the wave signal is 2
  254. \arg DAC_WAVE_BIT_WIDTH_3: bit width of the wave signal is 3
  255. \arg DAC_WAVE_BIT_WIDTH_4: bit width of the wave signal is 4
  256. \arg DAC_WAVE_BIT_WIDTH_5: bit width of the wave signal is 5
  257. \arg DAC_WAVE_BIT_WIDTH_6: bit width of the wave signal is 6
  258. \arg DAC_WAVE_BIT_WIDTH_7: bit width of the wave signal is 7
  259. \arg DAC_WAVE_BIT_WIDTH_8: bit width of the wave signal is 8
  260. \arg DAC_WAVE_BIT_WIDTH_9: bit width of the wave signal is 9
  261. \arg DAC_WAVE_BIT_WIDTH_10: bit width of the wave signal is 10
  262. \arg DAC_WAVE_BIT_WIDTH_11: bit width of the wave signal is 11
  263. \arg DAC_WAVE_BIT_WIDTH_12: bit width of the wave signal is 12
  264. \param[out] none
  265. \retval none
  266. */
  267. void dac_wave_bit_width_config(uint32_t dac_periph, uint32_t bit_width)
  268. {
  269. if(DAC0 == dac_periph){
  270. DAC_CTL &= ~DAC_CTL_DWBW0;
  271. DAC_CTL |= bit_width;
  272. }else{
  273. DAC_CTL &= ~DAC_CTL_DWBW1;
  274. DAC_CTL |= bit_width << 16;
  275. }
  276. }
  277. /*!
  278. \brief configure DAC LFSR noise mode
  279. \param[in] dac_periph
  280. \arg DACx(x=0,1)
  281. \param[in] unmask_bits
  282. \arg DAC_LFSR_BIT0: unmask the LFSR bit0
  283. \arg DAC_LFSR_BITS1_0: unmask the LFSR bits[1:0]
  284. \arg DAC_LFSR_BITS2_0: unmask the LFSR bits[2:0]
  285. \arg DAC_LFSR_BITS3_0: unmask the LFSR bits[3:0]
  286. \arg DAC_LFSR_BITS4_0: unmask the LFSR bits[4:0]
  287. \arg DAC_LFSR_BITS5_0: unmask the LFSR bits[5:0]
  288. \arg DAC_LFSR_BITS6_0: unmask the LFSR bits[6:0]
  289. \arg DAC_LFSR_BITS7_0: unmask the LFSR bits[7:0]
  290. \arg DAC_LFSR_BITS8_0: unmask the LFSR bits[8:0]
  291. \arg DAC_LFSR_BITS9_0: unmask the LFSR bits[9:0]
  292. \arg DAC_LFSR_BITS10_0: unmask the LFSR bits[10:0]
  293. \arg DAC_LFSR_BITS11_0: unmask the LFSR bits[11:0]
  294. \param[out] none
  295. \retval none
  296. */
  297. void dac_lfsr_noise_config(uint32_t dac_periph, uint32_t unmask_bits)
  298. {
  299. if(DAC0 == dac_periph){
  300. DAC_CTL &= ~DAC_CTL_DWBW0;
  301. DAC_CTL |= unmask_bits;
  302. }else{
  303. DAC_CTL &= ~DAC_CTL_DWBW1;
  304. DAC_CTL |= unmask_bits << 16;
  305. }
  306. }
  307. /*!
  308. \brief configure DAC triangle noise mode
  309. \param[in] dac_periph
  310. \arg DACx(x=0,1)
  311. \param[in] amplitude
  312. \arg DAC_TRIANGLE_AMPLITUDE_1: triangle amplitude is 1
  313. \arg DAC_TRIANGLE_AMPLITUDE_3: triangle amplitude is 3
  314. \arg DAC_TRIANGLE_AMPLITUDE_7: triangle amplitude is 7
  315. \arg DAC_TRIANGLE_AMPLITUDE_15: triangle amplitude is 15
  316. \arg DAC_TRIANGLE_AMPLITUDE_31: triangle amplitude is 31
  317. \arg DAC_TRIANGLE_AMPLITUDE_63: triangle amplitude is 63
  318. \arg DAC_TRIANGLE_AMPLITUDE_127: triangle amplitude is 127
  319. \arg DAC_TRIANGLE_AMPLITUDE_255: triangle amplitude is 255
  320. \arg DAC_TRIANGLE_AMPLITUDE_511: triangle amplitude is 511
  321. \arg DAC_TRIANGLE_AMPLITUDE_1023: triangle amplitude is 1023
  322. \arg DAC_TRIANGLE_AMPLITUDE_2047: triangle amplitude is 2047
  323. \arg DAC_TRIANGLE_AMPLITUDE_4095: triangle amplitude is 4095
  324. \param[out] none
  325. \retval none
  326. */
  327. void dac_triangle_noise_config(uint32_t dac_periph, uint32_t amplitude)
  328. {
  329. if(DAC0 == dac_periph){
  330. DAC_CTL &= ~DAC_CTL_DWBW0;
  331. DAC_CTL |= amplitude;
  332. }else{
  333. DAC_CTL &= ~DAC_CTL_DWBW1;
  334. DAC_CTL |= amplitude << 16;
  335. }
  336. }
  337. /*!
  338. \brief get DAC output value
  339. \param[in] dac_periph
  340. \arg DACx(x=0,1)
  341. \param[out] none
  342. \retval DAC output data
  343. */
  344. uint16_t dac_output_value_get(uint32_t dac_periph)
  345. {
  346. uint16_t data = 0U;
  347. if(DAC0 == dac_periph){
  348. data = (uint16_t)DAC0_DO;
  349. }else{
  350. data = (uint16_t)DAC1_DO;
  351. }
  352. return data;
  353. }
  354. /*!
  355. \brief enable DAC concurrent mode
  356. \param[in] none
  357. \param[out] none
  358. \retval none
  359. */
  360. void dac_concurrent_enable(void)
  361. {
  362. uint32_t ctl = 0U;
  363. ctl = DAC_CTL_DEN0 | DAC_CTL_DEN1;
  364. DAC_CTL |= (ctl);
  365. }
  366. /*!
  367. \brief disable DAC concurrent mode
  368. \param[in] none
  369. \param[out] none
  370. \retval none
  371. */
  372. void dac_concurrent_disable(void)
  373. {
  374. uint32_t ctl = 0U;
  375. ctl = DAC_CTL_DEN0 | DAC_CTL_DEN1;
  376. DAC_CTL &= (~ctl);
  377. }
  378. /*!
  379. \brief enable DAC concurrent software trigger function
  380. \param[in] none
  381. \param[out] none
  382. \retval none
  383. */
  384. void dac_concurrent_software_trigger_enable(void)
  385. {
  386. uint32_t swt = 0U;
  387. swt = DAC_SWT_SWTR0 | DAC_SWT_SWTR1;
  388. DAC_SWT |= (swt);
  389. }
  390. /*!
  391. \brief disable DAC concurrent software trigger function
  392. \param[in] none
  393. \param[out] none
  394. \retval none
  395. */
  396. void dac_concurrent_software_trigger_disable(void)
  397. {
  398. uint32_t swt = 0U;
  399. swt = DAC_SWT_SWTR0 | DAC_SWT_SWTR1;
  400. DAC_SWT &= (~swt);
  401. }
  402. /*!
  403. \brief enable DAC concurrent buffer function
  404. \param[in] none
  405. \param[out] none
  406. \retval none
  407. */
  408. void dac_concurrent_output_buffer_enable(void)
  409. {
  410. uint32_t ctl = 0U;
  411. ctl = DAC_CTL_DBOFF0 | DAC_CTL_DBOFF1;
  412. DAC_CTL &= (~ctl);
  413. }
  414. /*!
  415. \brief disable DAC concurrent buffer function
  416. \param[in] none
  417. \param[out] none
  418. \retval none
  419. */
  420. void dac_concurrent_output_buffer_disable(void)
  421. {
  422. uint32_t ctl = 0U;
  423. ctl = DAC_CTL_DBOFF0 | DAC_CTL_DBOFF1;
  424. DAC_CTL |= (ctl);
  425. }
  426. /*!
  427. \brief enable DAC concurrent interrupt funcution
  428. \param[in] none
  429. \param[out] none
  430. \retval none
  431. */
  432. void dac_concurrent_interrupt_enable(void)
  433. {
  434. uint32_t ctl = 0U;
  435. ctl = DAC_CTL_DDUDRIE0 | DAC_CTL_DDUDRIE1;
  436. DAC_CTL |= (ctl);
  437. }
  438. /*!
  439. \brief disable DAC concurrent interrupt funcution
  440. \param[in] none
  441. \param[out] none
  442. \retval none
  443. */
  444. void dac_concurrent_interrupt_disable(void)
  445. {
  446. uint32_t ctl = 0U;
  447. ctl = DAC_CTL_DDUDRIE0 | DAC_CTL_DDUDRIE1;
  448. DAC_CTL &= (~ctl);
  449. }
  450. /*!
  451. \brief set the DAC specified data holding register value
  452. \param[in] dac_periph
  453. \arg DACx(x=0,1)
  454. \param[in] dac_align
  455. \arg DAC_ALIGN_8B_R: data right 8b alignment
  456. \arg DAC_ALIGN_12B_R: data right 12b alignment
  457. \arg DAC_ALIGN_12B_L: data left 12b alignment
  458. \param[in] data: data to be loaded
  459. \param[out] none
  460. \retval none
  461. */
  462. void dac_data_set(uint32_t dac_periph, uint32_t dac_align, uint16_t data)
  463. {
  464. if(DAC0 == dac_periph){
  465. switch(dac_align){
  466. /* data right 12b alignment */
  467. case DAC_ALIGN_12B_R:
  468. DAC0_R12DH = data;
  469. break;
  470. /* data left 12b alignment */
  471. case DAC_ALIGN_12B_L:
  472. DAC0_L12DH = data;
  473. break;
  474. /* data right 8b alignment */
  475. case DAC_ALIGN_8B_R:
  476. DAC0_R8DH = data;
  477. break;
  478. default:
  479. break;
  480. }
  481. }else{
  482. switch(dac_align){
  483. /* data right 12b alignment */
  484. case DAC_ALIGN_12B_R:
  485. DAC1_R12DH = data;
  486. break;
  487. /* data left 12b alignment */
  488. case DAC_ALIGN_12B_L:
  489. DAC1_L12DH = data;
  490. break;
  491. /* data right 8b alignment */
  492. case DAC_ALIGN_8B_R:
  493. DAC1_R8DH = data;
  494. break;
  495. default:
  496. break;
  497. }
  498. }
  499. }
  500. /*!
  501. \brief set DAC concurrent mode data holding register value
  502. \param[in] dac_align
  503. \arg DAC_ALIGN_8B_R: data right 8b alignment
  504. \arg DAC_ALIGN_12B_R: data right 12b alignment
  505. \arg DAC_ALIGN_12B_L: data left 12b alignment
  506. \param[in] data0: data to be loaded
  507. \param[in] data1: data to be loaded
  508. \param[out] none
  509. \retval none
  510. */
  511. void dac_concurrent_data_set(uint32_t dac_align, uint16_t data0, uint16_t data1)
  512. {
  513. uint32_t data = 0U;
  514. switch(dac_align){
  515. /* data right 12b alignment */
  516. case DAC_ALIGN_12B_R:
  517. data = ((uint32_t)data1 << 16) | data0;
  518. DACC_R12DH = data;
  519. break;
  520. /* data left 12b alignment */
  521. case DAC_ALIGN_12B_L:
  522. data = ((uint32_t)data1 << 16) | data0;
  523. DACC_L12DH = data;
  524. break;
  525. /* data right 8b alignment */
  526. case DAC_ALIGN_8B_R:
  527. data = ((uint32_t)data1 << 8) | data0;
  528. DACC_R8DH = data;
  529. break;
  530. default:
  531. break;
  532. }
  533. }
  534. /*!
  535. \brief get the specified DAC flag(DAC DMA underrun flag)
  536. \param[in] dac_periph
  537. \arg DACx(x=0,1)
  538. \param[out] none
  539. \retval the state of dac bit(SET or RESET)
  540. */
  541. FlagStatus dac_flag_get(uint32_t dac_periph)
  542. {
  543. FlagStatus temp_flag = RESET;
  544. if(DAC0 == dac_periph){
  545. /* check the DMA underrun flag */
  546. if(RESET != (DAC_STAT & DAC_STAT_DDUDR0)){
  547. temp_flag = SET;
  548. }
  549. }else{
  550. /* check the DMA underrun flag */
  551. if(RESET != (DAC_STAT & DAC_STAT_DDUDR1)){
  552. temp_flag = SET;
  553. }
  554. }
  555. return temp_flag;
  556. }
  557. /*!
  558. \brief clear the specified DAC flag(DAC DMA underrun flag)
  559. \param[in] dac_periph
  560. \arg DACx(x=0,1)
  561. \param[out] none
  562. \retval none
  563. */
  564. void dac_flag_clear(uint32_t dac_periph)
  565. {
  566. if(DAC0 == dac_periph){
  567. DAC_STAT |= DAC_STAT_DDUDR0;
  568. }else{
  569. DAC_STAT |= DAC_STAT_DDUDR1;
  570. }
  571. }
  572. /*!
  573. \brief get the specified DAC interrupt flag(DAC DMA underrun interrupt flag)
  574. \param[in] dac_periph
  575. \arg DACx(x=0,1)
  576. \param[out] none
  577. \retval the state of DAC interrupt flag(SET or RESET)
  578. */
  579. FlagStatus dac_interrupt_flag_get(uint32_t dac_periph)
  580. {
  581. FlagStatus temp_flag = RESET;
  582. uint32_t ddudr_flag = 0U, ddudrie_flag = 0U;
  583. if(DAC0 == dac_periph){
  584. /* check the DMA underrun flag and DAC DMA underrun interrupt enable flag */
  585. ddudr_flag = DAC_STAT & DAC_STAT_DDUDR0;
  586. ddudrie_flag = DAC_CTL & DAC_CTL_DDUDRIE0;
  587. if((RESET != ddudr_flag) && (RESET != ddudrie_flag)){
  588. temp_flag = SET;
  589. }
  590. }else{
  591. /* check the DMA underrun flag and DAC DMA underrun interrupt enable flag */
  592. ddudr_flag = DAC_STAT & DAC_STAT_DDUDR1;
  593. ddudrie_flag = DAC_CTL & DAC_CTL_DDUDRIE1;
  594. if((RESET != ddudr_flag) && (RESET != ddudrie_flag)){
  595. temp_flag = SET;
  596. }
  597. }
  598. return temp_flag;
  599. }
  600. /*!
  601. \brief clear the specified DAC interrupt flag(DAC DMA underrun interrupt flag)
  602. \param[in] dac_periph
  603. \arg DACx(x=0,1)
  604. \param[out] none
  605. \retval none
  606. */
  607. void dac_interrupt_flag_clear(uint32_t dac_periph)
  608. {
  609. if(DAC0 == dac_periph){
  610. DAC_STAT |= DAC_STAT_DDUDR0;
  611. }else{
  612. DAC_STAT |= DAC_STAT_DDUDR1;
  613. }
  614. }