stm32f10x_dac.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. /**
  2. ******************************************************************************
  3. * @file stm32f10x_dac.c
  4. * @author MCD Application Team
  5. * @version V3.5.0
  6. * @date 11-March-2011
  7. * @brief This file provides all the DAC firmware functions.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  12. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  13. * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  14. * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  15. * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  16. * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  17. *
  18. * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
  19. ******************************************************************************
  20. */
  21. /* Includes ------------------------------------------------------------------*/
  22. #include "stm32f10x_dac.h"
  23. #include "stm32f10x_rcc.h"
  24. /** @addtogroup STM32F10x_StdPeriph_Driver
  25. * @{
  26. */
  27. /** @defgroup DAC
  28. * @brief DAC driver modules
  29. * @{
  30. */
  31. /** @defgroup DAC_Private_TypesDefinitions
  32. * @{
  33. */
  34. /**
  35. * @}
  36. */
  37. /** @defgroup DAC_Private_Defines
  38. * @{
  39. */
  40. /* CR register Mask */
  41. #define CR_CLEAR_MASK ((uint32_t)0x00000FFE)
  42. /* DAC Dual Channels SWTRIG masks */
  43. #define DUAL_SWTRIG_SET ((uint32_t)0x00000003)
  44. #define DUAL_SWTRIG_RESET ((uint32_t)0xFFFFFFFC)
  45. /* DHR registers offsets */
  46. #define DHR12R1_OFFSET ((uint32_t)0x00000008)
  47. #define DHR12R2_OFFSET ((uint32_t)0x00000014)
  48. #define DHR12RD_OFFSET ((uint32_t)0x00000020)
  49. /* DOR register offset */
  50. #define DOR_OFFSET ((uint32_t)0x0000002C)
  51. /**
  52. * @}
  53. */
  54. /** @defgroup DAC_Private_Macros
  55. * @{
  56. */
  57. /**
  58. * @}
  59. */
  60. /** @defgroup DAC_Private_Variables
  61. * @{
  62. */
  63. /**
  64. * @}
  65. */
  66. /** @defgroup DAC_Private_FunctionPrototypes
  67. * @{
  68. */
  69. /**
  70. * @}
  71. */
  72. /** @defgroup DAC_Private_Functions
  73. * @{
  74. */
  75. /**
  76. * @brief Deinitializes the DAC peripheral registers to their default reset values.
  77. * @param None
  78. * @retval None
  79. */
  80. void DAC_DeInit(void)
  81. {
  82. /* Enable DAC reset state */
  83. RCC_APB1PeriphResetCmd(RCC_APB1Periph_DAC, ENABLE);
  84. /* Release DAC from reset state */
  85. RCC_APB1PeriphResetCmd(RCC_APB1Periph_DAC, DISABLE);
  86. }
  87. /**
  88. * @brief Initializes the DAC peripheral according to the specified
  89. * parameters in the DAC_InitStruct.
  90. * @param DAC_Channel: the selected DAC channel.
  91. * This parameter can be one of the following values:
  92. * @arg DAC_Channel_1: DAC Channel1 selected
  93. * @arg DAC_Channel_2: DAC Channel2 selected
  94. * @param DAC_InitStruct: pointer to a DAC_InitTypeDef structure that
  95. * contains the configuration information for the specified DAC channel.
  96. * @retval None
  97. */
  98. void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef* DAC_InitStruct)
  99. {
  100. uint32_t tmpreg1 = 0, tmpreg2 = 0;
  101. /* Check the DAC parameters */
  102. assert_param(IS_DAC_TRIGGER(DAC_InitStruct->DAC_Trigger));
  103. assert_param(IS_DAC_GENERATE_WAVE(DAC_InitStruct->DAC_WaveGeneration));
  104. assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude));
  105. assert_param(IS_DAC_OUTPUT_BUFFER_STATE(DAC_InitStruct->DAC_OutputBuffer));
  106. /*---------------------------- DAC CR Configuration --------------------------*/
  107. /* Get the DAC CR value */
  108. tmpreg1 = DAC->CR;
  109. /* Clear BOFFx, TENx, TSELx, WAVEx and MAMPx bits */
  110. tmpreg1 &= ~(CR_CLEAR_MASK << DAC_Channel);
  111. /* Configure for the selected DAC channel: buffer output, trigger, wave generation,
  112. mask/amplitude for wave generation */
  113. /* Set TSELx and TENx bits according to DAC_Trigger value */
  114. /* Set WAVEx bits according to DAC_WaveGeneration value */
  115. /* Set MAMPx bits according to DAC_LFSRUnmask_TriangleAmplitude value */
  116. /* Set BOFFx bit according to DAC_OutputBuffer value */
  117. tmpreg2 = (DAC_InitStruct->DAC_Trigger | DAC_InitStruct->DAC_WaveGeneration |
  118. DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude | DAC_InitStruct->DAC_OutputBuffer);
  119. /* Calculate CR register value depending on DAC_Channel */
  120. tmpreg1 |= tmpreg2 << DAC_Channel;
  121. /* Write to DAC CR */
  122. DAC->CR = tmpreg1;
  123. }
  124. /**
  125. * @brief Fills each DAC_InitStruct member with its default value.
  126. * @param DAC_InitStruct : pointer to a DAC_InitTypeDef structure which will
  127. * be initialized.
  128. * @retval None
  129. */
  130. void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct)
  131. {
  132. /*--------------- Reset DAC init structure parameters values -----------------*/
  133. /* Initialize the DAC_Trigger member */
  134. DAC_InitStruct->DAC_Trigger = DAC_Trigger_None;
  135. /* Initialize the DAC_WaveGeneration member */
  136. DAC_InitStruct->DAC_WaveGeneration = DAC_WaveGeneration_None;
  137. /* Initialize the DAC_LFSRUnmask_TriangleAmplitude member */
  138. DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude = DAC_LFSRUnmask_Bit0;
  139. /* Initialize the DAC_OutputBuffer member */
  140. DAC_InitStruct->DAC_OutputBuffer = DAC_OutputBuffer_Enable;
  141. }
  142. /**
  143. * @brief Enables or disables the specified DAC channel.
  144. * @param DAC_Channel: the selected DAC channel.
  145. * This parameter can be one of the following values:
  146. * @arg DAC_Channel_1: DAC Channel1 selected
  147. * @arg DAC_Channel_2: DAC Channel2 selected
  148. * @param NewState: new state of the DAC channel.
  149. * This parameter can be: ENABLE or DISABLE.
  150. * @retval None
  151. */
  152. void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState)
  153. {
  154. /* Check the parameters */
  155. assert_param(IS_DAC_CHANNEL(DAC_Channel));
  156. assert_param(IS_FUNCTIONAL_STATE(NewState));
  157. if (NewState != DISABLE)
  158. {
  159. /* Enable the selected DAC channel */
  160. DAC->CR |= (DAC_CR_EN1 << DAC_Channel);
  161. }
  162. else
  163. {
  164. /* Disable the selected DAC channel */
  165. DAC->CR &= ~(DAC_CR_EN1 << DAC_Channel);
  166. }
  167. }
  168. #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
  169. /**
  170. * @brief Enables or disables the specified DAC interrupts.
  171. * @param DAC_Channel: the selected DAC channel.
  172. * This parameter can be one of the following values:
  173. * @arg DAC_Channel_1: DAC Channel1 selected
  174. * @arg DAC_Channel_2: DAC Channel2 selected
  175. * @param DAC_IT: specifies the DAC interrupt sources to be enabled or disabled.
  176. * This parameter can be the following values:
  177. * @arg DAC_IT_DMAUDR: DMA underrun interrupt mask
  178. * @param NewState: new state of the specified DAC interrupts.
  179. * This parameter can be: ENABLE or DISABLE.
  180. * @retval None
  181. */
  182. void DAC_ITConfig(uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState)
  183. {
  184. /* Check the parameters */
  185. assert_param(IS_DAC_CHANNEL(DAC_Channel));
  186. assert_param(IS_FUNCTIONAL_STATE(NewState));
  187. assert_param(IS_DAC_IT(DAC_IT));
  188. if (NewState != DISABLE)
  189. {
  190. /* Enable the selected DAC interrupts */
  191. DAC->CR |= (DAC_IT << DAC_Channel);
  192. }
  193. else
  194. {
  195. /* Disable the selected DAC interrupts */
  196. DAC->CR &= (~(uint32_t)(DAC_IT << DAC_Channel));
  197. }
  198. }
  199. #endif
  200. /**
  201. * @brief Enables or disables the specified DAC channel DMA request.
  202. * @param DAC_Channel: the selected DAC channel.
  203. * This parameter can be one of the following values:
  204. * @arg DAC_Channel_1: DAC Channel1 selected
  205. * @arg DAC_Channel_2: DAC Channel2 selected
  206. * @param NewState: new state of the selected DAC channel DMA request.
  207. * This parameter can be: ENABLE or DISABLE.
  208. * @retval None
  209. */
  210. void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState)
  211. {
  212. /* Check the parameters */
  213. assert_param(IS_DAC_CHANNEL(DAC_Channel));
  214. assert_param(IS_FUNCTIONAL_STATE(NewState));
  215. if (NewState != DISABLE)
  216. {
  217. /* Enable the selected DAC channel DMA request */
  218. DAC->CR |= (DAC_CR_DMAEN1 << DAC_Channel);
  219. }
  220. else
  221. {
  222. /* Disable the selected DAC channel DMA request */
  223. DAC->CR &= ~(DAC_CR_DMAEN1 << DAC_Channel);
  224. }
  225. }
  226. /**
  227. * @brief Enables or disables the selected DAC channel software trigger.
  228. * @param DAC_Channel: the selected DAC channel.
  229. * This parameter can be one of the following values:
  230. * @arg DAC_Channel_1: DAC Channel1 selected
  231. * @arg DAC_Channel_2: DAC Channel2 selected
  232. * @param NewState: new state of the selected DAC channel software trigger.
  233. * This parameter can be: ENABLE or DISABLE.
  234. * @retval None
  235. */
  236. void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState)
  237. {
  238. /* Check the parameters */
  239. assert_param(IS_DAC_CHANNEL(DAC_Channel));
  240. assert_param(IS_FUNCTIONAL_STATE(NewState));
  241. if (NewState != DISABLE)
  242. {
  243. /* Enable software trigger for the selected DAC channel */
  244. DAC->SWTRIGR |= (uint32_t)DAC_SWTRIGR_SWTRIG1 << (DAC_Channel >> 4);
  245. }
  246. else
  247. {
  248. /* Disable software trigger for the selected DAC channel */
  249. DAC->SWTRIGR &= ~((uint32_t)DAC_SWTRIGR_SWTRIG1 << (DAC_Channel >> 4));
  250. }
  251. }
  252. /**
  253. * @brief Enables or disables simultaneously the two DAC channels software
  254. * triggers.
  255. * @param NewState: new state of the DAC channels software triggers.
  256. * This parameter can be: ENABLE or DISABLE.
  257. * @retval None
  258. */
  259. void DAC_DualSoftwareTriggerCmd(FunctionalState NewState)
  260. {
  261. /* Check the parameters */
  262. assert_param(IS_FUNCTIONAL_STATE(NewState));
  263. if (NewState != DISABLE)
  264. {
  265. /* Enable software trigger for both DAC channels */
  266. DAC->SWTRIGR |= DUAL_SWTRIG_SET ;
  267. }
  268. else
  269. {
  270. /* Disable software trigger for both DAC channels */
  271. DAC->SWTRIGR &= DUAL_SWTRIG_RESET;
  272. }
  273. }
  274. /**
  275. * @brief Enables or disables the selected DAC channel wave generation.
  276. * @param DAC_Channel: the selected DAC channel.
  277. * This parameter can be one of the following values:
  278. * @arg DAC_Channel_1: DAC Channel1 selected
  279. * @arg DAC_Channel_2: DAC Channel2 selected
  280. * @param DAC_Wave: Specifies the wave type to enable or disable.
  281. * This parameter can be one of the following values:
  282. * @arg DAC_Wave_Noise: noise wave generation
  283. * @arg DAC_Wave_Triangle: triangle wave generation
  284. * @param NewState: new state of the selected DAC channel wave generation.
  285. * This parameter can be: ENABLE or DISABLE.
  286. * @retval None
  287. */
  288. void DAC_WaveGenerationCmd(uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState)
  289. {
  290. /* Check the parameters */
  291. assert_param(IS_DAC_CHANNEL(DAC_Channel));
  292. assert_param(IS_DAC_WAVE(DAC_Wave));
  293. assert_param(IS_FUNCTIONAL_STATE(NewState));
  294. if (NewState != DISABLE)
  295. {
  296. /* Enable the selected wave generation for the selected DAC channel */
  297. DAC->CR |= DAC_Wave << DAC_Channel;
  298. }
  299. else
  300. {
  301. /* Disable the selected wave generation for the selected DAC channel */
  302. DAC->CR &= ~(DAC_Wave << DAC_Channel);
  303. }
  304. }
  305. /**
  306. * @brief Set the specified data holding register value for DAC channel1.
  307. * @param DAC_Align: Specifies the data alignment for DAC channel1.
  308. * This parameter can be one of the following values:
  309. * @arg DAC_Align_8b_R: 8bit right data alignment selected
  310. * @arg DAC_Align_12b_L: 12bit left data alignment selected
  311. * @arg DAC_Align_12b_R: 12bit right data alignment selected
  312. * @param Data : Data to be loaded in the selected data holding register.
  313. * @retval None
  314. */
  315. void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data)
  316. {
  317. __IO uint32_t tmp = 0;
  318. /* Check the parameters */
  319. assert_param(IS_DAC_ALIGN(DAC_Align));
  320. assert_param(IS_DAC_DATA(Data));
  321. tmp = (uint32_t)DAC_BASE;
  322. tmp += DHR12R1_OFFSET + DAC_Align;
  323. /* Set the DAC channel1 selected data holding register */
  324. *(__IO uint32_t *) tmp = Data;
  325. }
  326. /**
  327. * @brief Set the specified data holding register value for DAC channel2.
  328. * @param DAC_Align: Specifies the data alignment for DAC channel2.
  329. * This parameter can be one of the following values:
  330. * @arg DAC_Align_8b_R: 8bit right data alignment selected
  331. * @arg DAC_Align_12b_L: 12bit left data alignment selected
  332. * @arg DAC_Align_12b_R: 12bit right data alignment selected
  333. * @param Data : Data to be loaded in the selected data holding register.
  334. * @retval None
  335. */
  336. void DAC_SetChannel2Data(uint32_t DAC_Align, uint16_t Data)
  337. {
  338. __IO uint32_t tmp = 0;
  339. /* Check the parameters */
  340. assert_param(IS_DAC_ALIGN(DAC_Align));
  341. assert_param(IS_DAC_DATA(Data));
  342. tmp = (uint32_t)DAC_BASE;
  343. tmp += DHR12R2_OFFSET + DAC_Align;
  344. /* Set the DAC channel2 selected data holding register */
  345. *(__IO uint32_t *)tmp = Data;
  346. }
  347. /**
  348. * @brief Set the specified data holding register value for dual channel
  349. * DAC.
  350. * @param DAC_Align: Specifies the data alignment for dual channel DAC.
  351. * This parameter can be one of the following values:
  352. * @arg DAC_Align_8b_R: 8bit right data alignment selected
  353. * @arg DAC_Align_12b_L: 12bit left data alignment selected
  354. * @arg DAC_Align_12b_R: 12bit right data alignment selected
  355. * @param Data2: Data for DAC Channel2 to be loaded in the selected data
  356. * holding register.
  357. * @param Data1: Data for DAC Channel1 to be loaded in the selected data
  358. * holding register.
  359. * @retval None
  360. */
  361. void DAC_SetDualChannelData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1)
  362. {
  363. uint32_t data = 0, tmp = 0;
  364. /* Check the parameters */
  365. assert_param(IS_DAC_ALIGN(DAC_Align));
  366. assert_param(IS_DAC_DATA(Data1));
  367. assert_param(IS_DAC_DATA(Data2));
  368. /* Calculate and set dual DAC data holding register value */
  369. if (DAC_Align == DAC_Align_8b_R)
  370. {
  371. data = ((uint32_t)Data2 << 8) | Data1;
  372. }
  373. else
  374. {
  375. data = ((uint32_t)Data2 << 16) | Data1;
  376. }
  377. tmp = (uint32_t)DAC_BASE;
  378. tmp += DHR12RD_OFFSET + DAC_Align;
  379. /* Set the dual DAC selected data holding register */
  380. *(__IO uint32_t *)tmp = data;
  381. }
  382. /**
  383. * @brief Returns the last data output value of the selected DAC channel.
  384. * @param DAC_Channel: the selected DAC channel.
  385. * This parameter can be one of the following values:
  386. * @arg DAC_Channel_1: DAC Channel1 selected
  387. * @arg DAC_Channel_2: DAC Channel2 selected
  388. * @retval The selected DAC channel data output value.
  389. */
  390. uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel)
  391. {
  392. __IO uint32_t tmp = 0;
  393. /* Check the parameters */
  394. assert_param(IS_DAC_CHANNEL(DAC_Channel));
  395. tmp = (uint32_t) DAC_BASE ;
  396. tmp += DOR_OFFSET + ((uint32_t)DAC_Channel >> 2);
  397. /* Returns the DAC channel data output register value */
  398. return (uint16_t) (*(__IO uint32_t*) tmp);
  399. }
  400. #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
  401. /**
  402. * @brief Checks whether the specified DAC flag is set or not.
  403. * @param DAC_Channel: thee selected DAC channel.
  404. * This parameter can be one of the following values:
  405. * @arg DAC_Channel_1: DAC Channel1 selected
  406. * @arg DAC_Channel_2: DAC Channel2 selected
  407. * @param DAC_FLAG: specifies the flag to check.
  408. * This parameter can be only of the following value:
  409. * @arg DAC_FLAG_DMAUDR: DMA underrun flag
  410. * @retval The new state of DAC_FLAG (SET or RESET).
  411. */
  412. FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG)
  413. {
  414. FlagStatus bitstatus = RESET;
  415. /* Check the parameters */
  416. assert_param(IS_DAC_CHANNEL(DAC_Channel));
  417. assert_param(IS_DAC_FLAG(DAC_FLAG));
  418. /* Check the status of the specified DAC flag */
  419. if ((DAC->SR & (DAC_FLAG << DAC_Channel)) != (uint8_t)RESET)
  420. {
  421. /* DAC_FLAG is set */
  422. bitstatus = SET;
  423. }
  424. else
  425. {
  426. /* DAC_FLAG is reset */
  427. bitstatus = RESET;
  428. }
  429. /* Return the DAC_FLAG status */
  430. return bitstatus;
  431. }
  432. /**
  433. * @brief Clears the DAC channelx's pending flags.
  434. * @param DAC_Channel: the selected DAC channel.
  435. * This parameter can be one of the following values:
  436. * @arg DAC_Channel_1: DAC Channel1 selected
  437. * @arg DAC_Channel_2: DAC Channel2 selected
  438. * @param DAC_FLAG: specifies the flag to clear.
  439. * This parameter can be of the following value:
  440. * @arg DAC_FLAG_DMAUDR: DMA underrun flag
  441. * @retval None
  442. */
  443. void DAC_ClearFlag(uint32_t DAC_Channel, uint32_t DAC_FLAG)
  444. {
  445. /* Check the parameters */
  446. assert_param(IS_DAC_CHANNEL(DAC_Channel));
  447. assert_param(IS_DAC_FLAG(DAC_FLAG));
  448. /* Clear the selected DAC flags */
  449. DAC->SR = (DAC_FLAG << DAC_Channel);
  450. }
  451. /**
  452. * @brief Checks whether the specified DAC interrupt has occurred or not.
  453. * @param DAC_Channel: the selected DAC channel.
  454. * This parameter can be one of the following values:
  455. * @arg DAC_Channel_1: DAC Channel1 selected
  456. * @arg DAC_Channel_2: DAC Channel2 selected
  457. * @param DAC_IT: specifies the DAC interrupt source to check.
  458. * This parameter can be the following values:
  459. * @arg DAC_IT_DMAUDR: DMA underrun interrupt mask
  460. * @retval The new state of DAC_IT (SET or RESET).
  461. */
  462. ITStatus DAC_GetITStatus(uint32_t DAC_Channel, uint32_t DAC_IT)
  463. {
  464. ITStatus bitstatus = RESET;
  465. uint32_t enablestatus = 0;
  466. /* Check the parameters */
  467. assert_param(IS_DAC_CHANNEL(DAC_Channel));
  468. assert_param(IS_DAC_IT(DAC_IT));
  469. /* Get the DAC_IT enable bit status */
  470. enablestatus = (DAC->CR & (DAC_IT << DAC_Channel)) ;
  471. /* Check the status of the specified DAC interrupt */
  472. if (((DAC->SR & (DAC_IT << DAC_Channel)) != (uint32_t)RESET) && enablestatus)
  473. {
  474. /* DAC_IT is set */
  475. bitstatus = SET;
  476. }
  477. else
  478. {
  479. /* DAC_IT is reset */
  480. bitstatus = RESET;
  481. }
  482. /* Return the DAC_IT status */
  483. return bitstatus;
  484. }
  485. /**
  486. * @brief Clears the DAC channelx's interrupt pending bits.
  487. * @param DAC_Channel: the selected DAC channel.
  488. * This parameter can be one of the following values:
  489. * @arg DAC_Channel_1: DAC Channel1 selected
  490. * @arg DAC_Channel_2: DAC Channel2 selected
  491. * @param DAC_IT: specifies the DAC interrupt pending bit to clear.
  492. * This parameter can be the following values:
  493. * @arg DAC_IT_DMAUDR: DMA underrun interrupt mask
  494. * @retval None
  495. */
  496. void DAC_ClearITPendingBit(uint32_t DAC_Channel, uint32_t DAC_IT)
  497. {
  498. /* Check the parameters */
  499. assert_param(IS_DAC_CHANNEL(DAC_Channel));
  500. assert_param(IS_DAC_IT(DAC_IT));
  501. /* Clear the selected DAC interrupt pending bits */
  502. DAC->SR = (DAC_IT << DAC_Channel);
  503. }
  504. #endif
  505. /**
  506. * @}
  507. */
  508. /**
  509. * @}
  510. */
  511. /**
  512. * @}
  513. */
  514. /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/