You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1188 lines
37 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f0xx_hal_dac_ex.c
  4. * @author MCD Application Team
  5. * @brief DAC HAL module driver.
  6. * This file provides firmware functions to manage the extended
  7. * functionalities of the DAC peripheral.
  8. *
  9. *
  10. @verbatim
  11. ==============================================================================
  12. ##### How to use this driver #####
  13. ==============================================================================
  14. [..]
  15. (+) When Dual mode is enabled (i.e. DAC Channel1 and Channel2 are used simultaneously) :
  16. Use HAL_DACEx_DualGetValue() to get digital data to be converted and use
  17. HAL_DACEx_DualSetValue() to set digital value to converted simultaneously in Channel 1 and Channel 2.
  18. (+) Use HAL_DACEx_TriangleWaveGenerate() to generate Triangle signal.
  19. (+) Use HAL_DACEx_NoiseWaveGenerate() to generate Noise signal.
  20. @endverbatim
  21. ******************************************************************************
  22. * @attention
  23. *
  24. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  25. *
  26. * Redistribution and use in source and binary forms, with or without modification,
  27. * are permitted provided that the following conditions are met:
  28. * 1. Redistributions of source code must retain the above copyright notice,
  29. * this list of conditions and the following disclaimer.
  30. * 2. Redistributions in binary form must reproduce the above copyright notice,
  31. * this list of conditions and the following disclaimer in the documentation
  32. * and/or other materials provided with the distribution.
  33. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  34. * may be used to endorse or promote products derived from this software
  35. * without specific prior written permission.
  36. *
  37. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  38. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  39. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  40. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  41. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  42. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  43. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  44. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  45. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  46. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  47. *
  48. ******************************************************************************
  49. */
  50. /* Includes ------------------------------------------------------------------*/
  51. #include "stm32f0xx_hal.h"
  52. /** @addtogroup STM32F0xx_HAL_Driver
  53. * @{
  54. */
  55. #ifdef HAL_DAC_MODULE_ENABLED
  56. /** @addtogroup DAC
  57. * @{
  58. */
  59. #if defined(STM32F051x8) || defined(STM32F058xx) || \
  60. defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
  61. defined(STM32F091xC) || defined(STM32F098xx)
  62. /** @addtogroup DAC_Private_Functions
  63. * @{
  64. */
  65. static void DAC_DMAConvCpltCh1(DMA_HandleTypeDef *hdma);
  66. static void DAC_DMAErrorCh1(DMA_HandleTypeDef *hdma);
  67. static void DAC_DMAHalfConvCpltCh1(DMA_HandleTypeDef *hdma);
  68. /**
  69. * @}
  70. */
  71. #endif /* STM32F051x8 STM32F058xx */
  72. /* STM32F071xB STM32F072xB STM32F078xx */
  73. /* STM32F091xC STM32F098xx */
  74. #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
  75. defined(STM32F091xC) || defined(STM32F098xx)
  76. /** @addtogroup DAC_Private_Functions
  77. * @{
  78. */
  79. /* DAC_DMAConvCpltCh2 / DAC_DMAErrorCh2 / DAC_DMAHalfConvCpltCh2 */
  80. /* are set by HAL_DAC_Start_DMA */
  81. void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma);
  82. void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma);
  83. void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma);
  84. /**
  85. * @}
  86. */
  87. #endif /* STM32F071xB STM32F072xB STM32F078xx */
  88. /* STM32F091xC STM32F098xx */
  89. /** @addtogroup DAC_Exported_Functions
  90. * @{
  91. */
  92. /** @addtogroup DAC_Exported_Functions_Group3
  93. * @{
  94. */
  95. #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
  96. defined(STM32F091xC) || defined(STM32F098xx)
  97. /**
  98. * @brief Configures the selected DAC channel.
  99. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  100. * the configuration information for the specified DAC.
  101. * @param sConfig DAC configuration structure.
  102. * @param Channel The selected DAC channel.
  103. * This parameter can be one of the following values:
  104. * @arg DAC_CHANNEL_1: DAC Channel1 selected
  105. * @arg DAC_CHANNEL_2: DAC Channel2 selected
  106. * @retval HAL status
  107. */
  108. HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef* hdac, DAC_ChannelConfTypeDef* sConfig, uint32_t Channel)
  109. {
  110. uint32_t tmpreg1 = 0U, tmpreg2 = 0U;
  111. /* Check the DAC parameters */
  112. assert_param(IS_DAC_TRIGGER(sConfig->DAC_Trigger));
  113. assert_param(IS_DAC_OUTPUT_BUFFER_STATE(sConfig->DAC_OutputBuffer));
  114. assert_param(IS_DAC_TRIGGER(sConfig->DAC_Trigger));
  115. assert_param(IS_DAC_CHANNEL(Channel));
  116. /* Process locked */
  117. __HAL_LOCK(hdac);
  118. /* Change DAC state */
  119. hdac->State = HAL_DAC_STATE_BUSY;
  120. /* Get the DAC CR value */
  121. tmpreg1 = hdac->Instance->CR;
  122. /* Clear BOFFx, TENx, TSELx, WAVEx and MAMPx bits */
  123. tmpreg1 &= ~(((uint32_t)(DAC_CR_MAMP1 | DAC_CR_WAVE1 | DAC_CR_TSEL1 | DAC_CR_TEN1 | DAC_CR_BOFF1)) << Channel);
  124. /* Configure for the selected DAC channel: buffer output, trigger */
  125. /* Set TSELx and TENx bits according to DAC_Trigger value */
  126. /* Set BOFFx bit according to DAC_OutputBuffer value */
  127. tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputBuffer);
  128. /* Calculate CR register value depending on DAC_Channel */
  129. tmpreg1 |= tmpreg2 << Channel;
  130. /* Write to DAC CR */
  131. hdac->Instance->CR = tmpreg1;
  132. /* Change DAC state */
  133. hdac->State = HAL_DAC_STATE_READY;
  134. /* Process unlocked */
  135. __HAL_UNLOCK(hdac);
  136. /* Return function status */
  137. return HAL_OK;
  138. }
  139. #endif /* STM32F071xB STM32F072xB STM32F078xx */
  140. /* STM32F091xC STM32F098xx */
  141. #if defined (STM32F051x8) || defined (STM32F058xx)
  142. /**
  143. * @brief Configures the selected DAC channel.
  144. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  145. * the configuration information for the specified DAC.
  146. * @param sConfig DAC configuration structure.
  147. * @param Channel The selected DAC channel.
  148. * This parameter can be one of the following values:
  149. * @arg DAC_CHANNEL_1: DAC Channel1 selected
  150. * @retval HAL status
  151. */
  152. HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef* hdac, DAC_ChannelConfTypeDef* sConfig, uint32_t Channel)
  153. {
  154. uint32_t tmpreg1 = 0U, tmpreg2 = 0U;
  155. /* Check the DAC parameters */
  156. assert_param(IS_DAC_TRIGGER(sConfig->DAC_Trigger));
  157. assert_param(IS_DAC_OUTPUT_BUFFER_STATE(sConfig->DAC_OutputBuffer));
  158. assert_param(IS_DAC_TRIGGER(sConfig->DAC_Trigger));
  159. assert_param(IS_DAC_CHANNEL(Channel));
  160. /* Process locked */
  161. __HAL_LOCK(hdac);
  162. /* Change DAC state */
  163. hdac->State = HAL_DAC_STATE_BUSY;
  164. /* Get the DAC CR value */
  165. tmpreg1 = hdac->Instance->CR;
  166. /* Clear BOFFx, TENx, TSELx, WAVEx and MAMPx bits */
  167. tmpreg1 &= ~(((uint32_t)(DAC_CR_TSEL1 | DAC_CR_TEN1 | DAC_CR_BOFF1)) << Channel);
  168. /* Configure for the selected DAC channel: buffer output, trigger */
  169. /* Set TSELx and TENx bits according to DAC_Trigger value */
  170. /* Set BOFFx bit according to DAC_OutputBuffer value */
  171. tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputBuffer);
  172. /* Calculate CR register value depending on DAC_Channel */
  173. tmpreg1 |= tmpreg2 << Channel;
  174. /* Write to DAC CR */
  175. hdac->Instance->CR = tmpreg1;
  176. /* Change DAC state */
  177. hdac->State = HAL_DAC_STATE_READY;
  178. /* Process unlocked */
  179. __HAL_UNLOCK(hdac);
  180. /* Return function status */
  181. return HAL_OK;
  182. }
  183. #endif /* STM32F051x8 STM32F058xx */
  184. #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
  185. defined(STM32F091xC) || defined(STM32F098xx)
  186. /* DAC 1 has 2 channels 1 & 2 */
  187. /**
  188. * @brief Returns the last data output value of the selected DAC channel.
  189. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  190. * the configuration information for the specified DAC.
  191. * @param Channel The selected DAC channel.
  192. * This parameter can be one of the following values:
  193. * @arg DAC_CHANNEL_1: DAC Channel1 selected
  194. * @arg DAC_CHANNEL_2: DAC Channel2 selected
  195. * @retval The selected DAC channel data output value.
  196. */
  197. uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef* hdac, uint32_t Channel)
  198. {
  199. /* Check the parameters */
  200. assert_param(IS_DAC_CHANNEL(Channel));
  201. /* Returns the DAC channel data output register value */
  202. if(Channel == DAC_CHANNEL_1)
  203. {
  204. return hdac->Instance->DOR1;
  205. }
  206. else
  207. {
  208. return hdac->Instance->DOR2;
  209. }
  210. }
  211. #endif /* STM32F071xB STM32F072xB STM32F078xx */
  212. /* STM32F091xC STM32F098xx */
  213. #if defined (STM32F051x8) || defined (STM32F058xx)
  214. /* DAC 1 has 1 channels */
  215. /**
  216. * @brief Returns the last data output value of the selected DAC channel.
  217. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  218. * the configuration information for the specified DAC.
  219. * @param Channel The selected DAC channel.
  220. * This parameter can be one of the following values:
  221. * @arg DAC_CHANNEL_1: DAC Channel1 selected
  222. * @retval The selected DAC channel data output value.
  223. */
  224. uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef* hdac, uint32_t Channel)
  225. {
  226. /* Check the parameters */
  227. assert_param(IS_DAC_CHANNEL(Channel));
  228. /* Returns the DAC channel data output register value */
  229. return hdac->Instance->DOR1;
  230. }
  231. #endif /* STM32F051x8 STM32F058xx */
  232. /**
  233. * @}
  234. */
  235. /** @addtogroup DAC_Exported_Functions_Group2
  236. * @{
  237. */
  238. #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
  239. defined(STM32F091xC) || defined(STM32F098xx)
  240. /**
  241. * @brief Enables DAC and starts conversion of channel.
  242. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  243. * the configuration information for the specified DAC.
  244. * @param Channel The selected DAC channel.
  245. * This parameter can be one of the following values:
  246. * @arg DAC_CHANNEL_1: DAC Channel1 selected
  247. * @arg DAC_CHANNEL_2: DAC Channel2 selected
  248. * @retval HAL status
  249. */
  250. HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef* hdac, uint32_t Channel)
  251. {
  252. /* Check the parameters */
  253. assert_param(IS_DAC_CHANNEL(Channel));
  254. /* Process locked */
  255. __HAL_LOCK(hdac);
  256. /* Change DAC state */
  257. hdac->State = HAL_DAC_STATE_BUSY;
  258. /* Enable the Peripharal */
  259. __HAL_DAC_ENABLE(hdac, Channel);
  260. if(Channel == DAC_CHANNEL_1)
  261. {
  262. /* Check if software trigger enabled */
  263. if((hdac->Instance->CR & (DAC_CR_TEN1 | DAC_CR_TSEL1)) == (DAC_CR_TEN1 | DAC_CR_TSEL1))
  264. {
  265. /* Enable the selected DAC software conversion */
  266. SET_BIT(hdac->Instance->SWTRIGR, DAC_SWTRIGR_SWTRIG1);
  267. }
  268. }
  269. else
  270. {
  271. /* Check if software trigger enabled */
  272. if((hdac->Instance->CR & (DAC_CR_TEN2 | DAC_CR_TSEL2)) == (DAC_CR_TEN2 | DAC_CR_TSEL2))
  273. {
  274. /* Enable the selected DAC software conversion*/
  275. SET_BIT(hdac->Instance->SWTRIGR, DAC_SWTRIGR_SWTRIG2);
  276. }
  277. }
  278. /* Change DAC state */
  279. hdac->State = HAL_DAC_STATE_READY;
  280. /* Process unlocked */
  281. __HAL_UNLOCK(hdac);
  282. /* Return function status */
  283. return HAL_OK;
  284. }
  285. /**
  286. * @brief Enables DAC and starts conversion of channel.
  287. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  288. * the configuration information for the specified DAC.
  289. * @param Channel The selected DAC channel.
  290. * This parameter can be one of the following values:
  291. * @arg DAC_CHANNEL_1: DAC Channel1 selected
  292. * @arg DAC_CHANNEL_2: DAC Channel2 selected
  293. * @param pData The destination peripheral Buffer address.
  294. * @param Length The length of data to be transferred from memory to DAC peripheral
  295. * @param Alignment Specifies the data alignment for DAC channel.
  296. * This parameter can be one of the following values:
  297. * @arg DAC_ALIGN_8B_R: 8bit right data alignment selected
  298. * @arg DAC_ALIGN_12B_L: 12bit left data alignment selected
  299. * @arg DAC_ALIGN_12B_R: 12bit right data alignment selected
  300. * @retval HAL status
  301. */
  302. HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t* pData, uint32_t Length, uint32_t Alignment)
  303. {
  304. uint32_t tmpreg = 0U;
  305. /* Check the parameters */
  306. assert_param(IS_DAC_CHANNEL(Channel));
  307. assert_param(IS_DAC_ALIGN(Alignment));
  308. /* Process locked */
  309. __HAL_LOCK(hdac);
  310. /* Change DAC state */
  311. hdac->State = HAL_DAC_STATE_BUSY;
  312. if(Channel == DAC_CHANNEL_1)
  313. {
  314. /* Set the DMA transfer complete callback for channel1 */
  315. hdac->DMA_Handle1->XferCpltCallback = DAC_DMAConvCpltCh1;
  316. /* Set the DMA half transfer complete callback for channel1 */
  317. hdac->DMA_Handle1->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh1;
  318. /* Set the DMA error callback for channel1 */
  319. hdac->DMA_Handle1->XferErrorCallback = DAC_DMAErrorCh1;
  320. /* Enable the selected DAC channel1 DMA request */
  321. SET_BIT(hdac->Instance->CR, DAC_CR_DMAEN1);
  322. /* Case of use of channel 1 */
  323. switch(Alignment)
  324. {
  325. case DAC_ALIGN_12B_R:
  326. /* Get DHR12R1 address */
  327. tmpreg = (uint32_t)&hdac->Instance->DHR12R1;
  328. break;
  329. case DAC_ALIGN_12B_L:
  330. /* Get DHR12L1 address */
  331. tmpreg = (uint32_t)&hdac->Instance->DHR12L1;
  332. break;
  333. case DAC_ALIGN_8B_R:
  334. /* Get DHR8R1 address */
  335. tmpreg = (uint32_t)&hdac->Instance->DHR8R1;
  336. break;
  337. default:
  338. break;
  339. }
  340. }
  341. else
  342. {
  343. /* Set the DMA transfer complete callback for channel2 */
  344. hdac->DMA_Handle2->XferCpltCallback = DAC_DMAConvCpltCh2;
  345. /* Set the DMA half transfer complete callback for channel2 */
  346. hdac->DMA_Handle2->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh2;
  347. /* Set the DMA error callback for channel2 */
  348. hdac->DMA_Handle2->XferErrorCallback = DAC_DMAErrorCh2;
  349. /* Enable the selected DAC channel2 DMA request */
  350. SET_BIT(hdac->Instance->CR, DAC_CR_DMAEN2);
  351. /* Case of use of channel 2 */
  352. switch(Alignment)
  353. {
  354. case DAC_ALIGN_12B_R:
  355. /* Get DHR12R2 address */
  356. tmpreg = (uint32_t)&hdac->Instance->DHR12R2;
  357. break;
  358. case DAC_ALIGN_12B_L:
  359. /* Get DHR12L2 address */
  360. tmpreg = (uint32_t)&hdac->Instance->DHR12L2;
  361. break;
  362. case DAC_ALIGN_8B_R:
  363. /* Get DHR8R2 address */
  364. tmpreg = (uint32_t)&hdac->Instance->DHR8R2;
  365. break;
  366. default:
  367. break;
  368. }
  369. }
  370. /* Enable the DMA channel */
  371. if(Channel == DAC_CHANNEL_1)
  372. {
  373. /* Enable the DAC DMA underrun interrupt */
  374. __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR1);
  375. /* Enable the DMA channel */
  376. HAL_DMA_Start_IT(hdac->DMA_Handle1, (uint32_t)pData, tmpreg, Length);
  377. }
  378. else
  379. {
  380. /* Enable the DAC DMA underrun interrupt */
  381. __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR2);
  382. /* Enable the DMA channel */
  383. HAL_DMA_Start_IT(hdac->DMA_Handle2, (uint32_t)pData, tmpreg, Length);
  384. }
  385. /* Enable the Peripharal */
  386. __HAL_DAC_ENABLE(hdac, Channel);
  387. /* Process Unlocked */
  388. __HAL_UNLOCK(hdac);
  389. /* Return function status */
  390. return HAL_OK;
  391. }
  392. #endif /* STM32F071xB STM32F072xB STM32F078xx */
  393. /* STM32F091xC STM32F098xx */
  394. #if defined (STM32F051x8) || defined (STM32F058xx)
  395. HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef* hdac, uint32_t Channel)
  396. {
  397. /* Check the parameters */
  398. assert_param(IS_DAC_CHANNEL(Channel));
  399. /* Process locked */
  400. __HAL_LOCK(hdac);
  401. /* Change DAC state */
  402. hdac->State = HAL_DAC_STATE_BUSY;
  403. /* Enable the Peripharal */
  404. __HAL_DAC_ENABLE(hdac, Channel);
  405. if(Channel == DAC_CHANNEL_1)
  406. {
  407. /* Check if software trigger enabled */
  408. if((hdac->Instance->CR & (DAC_CR_TEN1 | DAC_CR_TSEL1)) == (DAC_CR_TEN1 | DAC_CR_TSEL1))
  409. {
  410. /* Enable the selected DAC software conversion */
  411. SET_BIT(hdac->Instance->SWTRIGR, DAC_SWTRIGR_SWTRIG1);
  412. }
  413. }
  414. /* Change DAC state */
  415. hdac->State = HAL_DAC_STATE_READY;
  416. /* Process unlocked */
  417. __HAL_UNLOCK(hdac);
  418. /* Return function status */
  419. return HAL_OK;
  420. }
  421. /**
  422. * @brief Enables DAC and starts conversion of channel.
  423. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  424. * the configuration information for the specified DAC.
  425. * @param Channel The selected DAC channel.
  426. * This parameter can be one of the following values:
  427. * @arg DAC_CHANNEL_1: DAC Channel1 selected
  428. * @param pData The destination peripheral Buffer address.
  429. * @param Length The length of data to be transferred from memory to DAC peripheral
  430. * @param Alignment Specifies the data alignment for DAC channel.
  431. * This parameter can be one of the following values:
  432. * @arg DAC_ALIGN_8B_R: 8bit right data alignment selected
  433. * @arg DAC_ALIGN_12B_L: 12bit left data alignment selected
  434. * @arg DAC_ALIGN_12B_R: 12bit right data alignment selected
  435. * @retval HAL status
  436. */
  437. HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t* pData, uint32_t Length, uint32_t Alignment)
  438. {
  439. uint32_t tmpreg = 0U;
  440. /* Check the parameters */
  441. assert_param(IS_DAC_CHANNEL(Channel));
  442. assert_param(IS_DAC_ALIGN(Alignment));
  443. /* Process locked */
  444. __HAL_LOCK(hdac);
  445. /* Change DAC state */
  446. hdac->State = HAL_DAC_STATE_BUSY;
  447. /* Set the DMA transfer complete callback for channel1 */
  448. hdac->DMA_Handle1->XferCpltCallback = DAC_DMAConvCpltCh1;
  449. /* Set the DMA half transfer complete callback for channel1 */
  450. hdac->DMA_Handle1->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh1;
  451. /* Set the DMA error callback for channel1 */
  452. hdac->DMA_Handle1->XferErrorCallback = DAC_DMAErrorCh1;
  453. /* Enable the selected DAC channel1 DMA request */
  454. SET_BIT(hdac->Instance->CR, DAC_CR_DMAEN1);
  455. /* Case of use of channel 1 */
  456. switch(Alignment)
  457. {
  458. case DAC_ALIGN_12B_R:
  459. /* Get DHR12R1 address */
  460. tmpreg = (uint32_t)&hdac->Instance->DHR12R1;
  461. break;
  462. case DAC_ALIGN_12B_L:
  463. /* Get DHR12L1 address */
  464. tmpreg = (uint32_t)&hdac->Instance->DHR12L1;
  465. break;
  466. case DAC_ALIGN_8B_R:
  467. /* Get DHR8R1 address */
  468. tmpreg = (uint32_t)&hdac->Instance->DHR8R1;
  469. break;
  470. default:
  471. break;
  472. }
  473. /* Enable the DMA channel */
  474. /* Enable the DAC DMA underrun interrupt */
  475. __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR1);
  476. /* Enable the DMA channel */
  477. HAL_DMA_Start_IT(hdac->DMA_Handle1, (uint32_t)pData, tmpreg, Length);
  478. /* Enable the DAC DMA underrun interrupt */
  479. __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR1);
  480. /* Enable the DMA channel */
  481. HAL_DMA_Start_IT(hdac->DMA_Handle1, (uint32_t)pData, tmpreg, Length);
  482. /* Enable the Peripharal */
  483. __HAL_DAC_ENABLE(hdac, Channel);
  484. /* Process Unlocked */
  485. __HAL_UNLOCK(hdac);
  486. /* Return function status */
  487. return HAL_OK;
  488. }
  489. #endif /* STM32F051x8 STM32F058xx */
  490. #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
  491. defined(STM32F091xC) || defined(STM32F098xx)
  492. /* DAC channel 2 is available on top of DAC channel 1 */
  493. /**
  494. * @brief Handles DAC interrupt request
  495. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  496. * the configuration information for the specified DAC.
  497. * @retval None
  498. */
  499. void HAL_DAC_IRQHandler(DAC_HandleTypeDef* hdac)
  500. {
  501. if(__HAL_DAC_GET_IT_SOURCE(hdac, DAC_IT_DMAUDR1))
  502. {
  503. /* Check underrun channel 1 flag */
  504. if(__HAL_DAC_GET_FLAG(hdac, DAC_FLAG_DMAUDR1))
  505. {
  506. /* Change DAC state to error state */
  507. hdac->State = HAL_DAC_STATE_ERROR;
  508. /* Set DAC error code to channel1 DMA underrun error */
  509. hdac->ErrorCode |= HAL_DAC_ERROR_DMAUNDERRUNCH1;
  510. /* Clear the underrun flag */
  511. __HAL_DAC_CLEAR_FLAG(hdac,DAC_FLAG_DMAUDR1);
  512. /* Disable the selected DAC channel1 DMA request */
  513. hdac->Instance->CR &= ~DAC_CR_DMAEN1;
  514. /* Error callback */
  515. HAL_DAC_DMAUnderrunCallbackCh1(hdac);
  516. }
  517. }
  518. if(__HAL_DAC_GET_IT_SOURCE(hdac, DAC_IT_DMAUDR2))
  519. {
  520. /* Check underrun channel 2 flag */
  521. if(__HAL_DAC_GET_FLAG(hdac, DAC_FLAG_DMAUDR2))
  522. {
  523. /* Change DAC state to error state */
  524. hdac->State = HAL_DAC_STATE_ERROR;
  525. /* Set DAC error code to channel2 DMA underrun error */
  526. hdac->ErrorCode |= HAL_DAC_ERROR_DMAUNDERRUNCH2;
  527. /* Clear the underrun flag */
  528. __HAL_DAC_CLEAR_FLAG(hdac,DAC_FLAG_DMAUDR2);
  529. /* Disable the selected DAC channel1 DMA request */
  530. hdac->Instance->CR &= ~DAC_CR_DMAEN2;
  531. /* Error callback */
  532. HAL_DACEx_DMAUnderrunCallbackCh2(hdac);
  533. }
  534. }
  535. }
  536. #endif /* STM32F071xB STM32F072xB STM32F078xx */
  537. /* STM32F091xC STM32F098xx */
  538. #if defined (STM32F051x8) || defined (STM32F058xx)
  539. /* DAC channel 2 is NOT available. Only DAC channel 1 is available */
  540. /**
  541. * @brief Handles DAC interrupt request
  542. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  543. * the configuration information for the specified DAC.
  544. * @retval None
  545. */
  546. void HAL_DAC_IRQHandler(DAC_HandleTypeDef* hdac)
  547. {
  548. if(__HAL_DAC_GET_IT_SOURCE(hdac, DAC_IT_DMAUDR1))
  549. {
  550. /* Check Overrun flag */
  551. if(__HAL_DAC_GET_FLAG(hdac, DAC_FLAG_DMAUDR1))
  552. {
  553. /* Change DAC state to error state */
  554. hdac->State = HAL_DAC_STATE_ERROR;
  555. /* Set DAC error code to chanel1 DMA underrun error */
  556. hdac->ErrorCode |= HAL_DAC_ERROR_DMAUNDERRUNCH1;
  557. /* Clear the underrun flag */
  558. __HAL_DAC_CLEAR_FLAG(hdac,DAC_FLAG_DMAUDR1);
  559. /* Disable the selected DAC channel1 DMA request */
  560. hdac->Instance->CR &= ~DAC_CR_DMAEN1;
  561. /* Error callback */
  562. HAL_DAC_DMAUnderrunCallbackCh1(hdac);
  563. }
  564. }
  565. }
  566. #endif /* STM32F051x8 STM32F058xx */
  567. /**
  568. * @}
  569. */
  570. /**
  571. * @}
  572. */
  573. #if defined(STM32F051x8) || defined(STM32F058xx) || \
  574. defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
  575. defined(STM32F091xC) || defined(STM32F098xx)
  576. /** @addtogroup DAC_Private_Functions
  577. * @{
  578. */
  579. /**
  580. * @brief DMA conversion complete callback.
  581. * @param hdma pointer to a DMA_HandleTypeDef structure that contains
  582. * the configuration information for the specified DMA module.
  583. * @retval None
  584. */
  585. static void DAC_DMAConvCpltCh1(DMA_HandleTypeDef *hdma)
  586. {
  587. DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
  588. HAL_DAC_ConvCpltCallbackCh1(hdac);
  589. hdac->State= HAL_DAC_STATE_READY;
  590. }
  591. /**
  592. * @brief DMA half transfer complete callback.
  593. * @param hdma pointer to a DMA_HandleTypeDef structure that contains
  594. * the configuration information for the specified DMA module.
  595. * @retval None
  596. */
  597. static void DAC_DMAHalfConvCpltCh1(DMA_HandleTypeDef *hdma)
  598. {
  599. DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
  600. /* Conversion complete callback */
  601. HAL_DAC_ConvHalfCpltCallbackCh1(hdac);
  602. }
  603. /**
  604. * @brief DMA error callback
  605. * @param hdma pointer to a DMA_HandleTypeDef structure that contains
  606. * the configuration information for the specified DMA module.
  607. * @retval None
  608. */
  609. static void DAC_DMAErrorCh1(DMA_HandleTypeDef *hdma)
  610. {
  611. DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
  612. /* Set DAC error code to DMA error */
  613. hdac->ErrorCode |= HAL_DAC_ERROR_DMA;
  614. HAL_DAC_ErrorCallbackCh1(hdac);
  615. hdac->State= HAL_DAC_STATE_READY;
  616. }
  617. /**
  618. * @}
  619. */
  620. #endif /* STM32F051x8 STM32F058xx */
  621. /* STM32F071xB STM32F072xB STM32F078xx */
  622. /* STM32F091xC STM32F098xx */
  623. #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
  624. defined(STM32F091xC) || defined(STM32F098xx)
  625. /** @addtogroup DAC_Private_Functions
  626. * @{
  627. */
  628. /**
  629. * @brief DMA conversion complete callback.
  630. * @param hdma pointer to a DMA_HandleTypeDef structure that contains
  631. * the configuration information for the specified DMA module.
  632. * @retval None
  633. */
  634. void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma)
  635. {
  636. DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
  637. HAL_DACEx_ConvCpltCallbackCh2(hdac);
  638. hdac->State= HAL_DAC_STATE_READY;
  639. }
  640. /**
  641. * @brief DMA half transfer complete callback.
  642. * @param hdma pointer to a DMA_HandleTypeDef structure that contains
  643. * the configuration information for the specified DMA module.
  644. * @retval None
  645. */
  646. void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma)
  647. {
  648. DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
  649. /* Conversion complete callback */
  650. HAL_DACEx_ConvHalfCpltCallbackCh2(hdac);
  651. }
  652. /**
  653. * @brief DMA error callback
  654. * @param hdma pointer to a DMA_HandleTypeDef structure that contains
  655. * the configuration information for the specified DMA module.
  656. * @retval None
  657. */
  658. void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma)
  659. {
  660. DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
  661. /* Set DAC error code to DMA error */
  662. hdac->ErrorCode |= HAL_DAC_ERROR_DMA;
  663. HAL_DACEx_ErrorCallbackCh2(hdac);
  664. hdac->State= HAL_DAC_STATE_READY;
  665. }
  666. /**
  667. * @}
  668. */
  669. #endif /* STM32F071xB STM32F072xB STM32F078xx */
  670. /* STM32F091xC STM32F098xx */
  671. /**
  672. * @}
  673. */
  674. /** @defgroup DACEx DACEx
  675. * @brief DACEx driver module
  676. * @{
  677. */
  678. /* Private typedef -----------------------------------------------------------*/
  679. /* Private define ------------------------------------------------------------*/
  680. /* Private macro -------------------------------------------------------------*/
  681. /** @defgroup DACEx_Private_Macros DACEx Private Macros
  682. * @{
  683. */
  684. /**
  685. * @}
  686. */
  687. /* Private variables ---------------------------------------------------------*/
  688. /* Private function prototypes -----------------------------------------------*/
  689. /* Private functions ---------------------------------------------------------*/
  690. /** @defgroup DACEx_Exported_Functions DACEx Exported Functions
  691. * @{
  692. */
  693. /** @defgroup DACEx_Exported_Functions_Group1 Extended features functions
  694. * @brief Extended features functions
  695. *
  696. @verbatim
  697. ==============================================================================
  698. ##### Extended features functions #####
  699. ==============================================================================
  700. [..] This section provides functions allowing to:
  701. (+) Start conversion.
  702. (+) Stop conversion.
  703. (+) Start conversion and enable DMA transfer.
  704. (+) Stop conversion and disable DMA transfer.
  705. (+) Get result of conversion.
  706. (+) Get result of dual mode conversion.
  707. @endverbatim
  708. * @{
  709. */
  710. #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
  711. defined(STM32F091xC) || defined(STM32F098xx)
  712. /**
  713. * @brief Returns the last data output value of the selected DAC channel.
  714. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  715. * the configuration information for the specified DAC.
  716. * @retval The selected DAC channel data output value.
  717. */
  718. uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef* hdac)
  719. {
  720. uint32_t tmp = 0U;
  721. tmp |= hdac->Instance->DOR1;
  722. /* DAC channel 2 is present in DAC 1 */
  723. tmp |= hdac->Instance->DOR2 << 16U;
  724. /* Returns the DAC channel data output register value */
  725. return tmp;
  726. }
  727. #endif /* STM32F071xB STM32F072xB STM32F078xx */
  728. /* STM32F091xC STM32F098xx */
  729. #if defined (STM32F051x8) || defined (STM32F058xx)
  730. /**
  731. * @brief Returns the last data output value of the selected DAC channel.
  732. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  733. * the configuration information for the specified DAC.
  734. * @retval The selected DAC channel data output value.
  735. */
  736. uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef* hdac)
  737. {
  738. uint32_t tmp = 0U;
  739. tmp |= hdac->Instance->DOR1;
  740. /* Returns the DAC channel data output register value */
  741. return tmp;
  742. }
  743. #endif /* STM32F051x8 STM32F058xx */
  744. #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
  745. defined(STM32F091xC) || defined(STM32F098xx)
  746. /**
  747. * @brief Enables or disables the selected DAC channel wave generation.
  748. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  749. * the configuration information for the specified DAC.
  750. * @param Channel The selected DAC channel.
  751. * This parameter can be one of the following values:
  752. * DAC_CHANNEL_1 / DAC_CHANNEL_2
  753. * @param Amplitude Select max triangle amplitude.
  754. * This parameter can be one of the following values:
  755. * @arg DAC_TRIANGLEAMPLITUDE_1: Select max triangle amplitude of 1
  756. * @arg DAC_TRIANGLEAMPLITUDE_3: Select max triangle amplitude of 3
  757. * @arg DAC_TRIANGLEAMPLITUDE_7: Select max triangle amplitude of 7
  758. * @arg DAC_TRIANGLEAMPLITUDE_15: Select max triangle amplitude of 15
  759. * @arg DAC_TRIANGLEAMPLITUDE_31: Select max triangle amplitude of 31
  760. * @arg DAC_TRIANGLEAMPLITUDE_63: Select max triangle amplitude of 63
  761. * @arg DAC_TRIANGLEAMPLITUDE_127: Select max triangle amplitude of 127
  762. * @arg DAC_TRIANGLEAMPLITUDE_255: Select max triangle amplitude of 255
  763. * @arg DAC_TRIANGLEAMPLITUDE_511: Select max triangle amplitude of 511
  764. * @arg DAC_TRIANGLEAMPLITUDE_1023: Select max triangle amplitude of 1023
  765. * @arg DAC_TRIANGLEAMPLITUDE_2047: Select max triangle amplitude of 2047
  766. * @arg DAC_TRIANGLEAMPLITUDE_4095: Select max triangle amplitude of 4095
  767. * @retval HAL status
  768. */
  769. HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude)
  770. {
  771. /* Check the parameters */
  772. assert_param(IS_DAC_CHANNEL(Channel));
  773. assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude));
  774. /* Process locked */
  775. __HAL_LOCK(hdac);
  776. /* Change DAC state */
  777. hdac->State = HAL_DAC_STATE_BUSY;
  778. /* Enable the selected wave generation for the selected DAC channel */
  779. MODIFY_REG(hdac->Instance->CR, ((DAC_CR_WAVE1)|(DAC_CR_MAMP1))<<Channel, (DAC_CR_WAVE1_1 | Amplitude) << Channel);
  780. /* Change DAC state */
  781. hdac->State = HAL_DAC_STATE_READY;
  782. /* Process unlocked */
  783. __HAL_UNLOCK(hdac);
  784. /* Return function status */
  785. return HAL_OK;
  786. }
  787. /**
  788. * @brief Enables or disables the selected DAC channel wave generation.
  789. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  790. * the configuration information for the specified DAC.
  791. * @param Channel The selected DAC channel.
  792. * This parameter can be one of the following values:
  793. * DAC_CHANNEL_1 / DAC_CHANNEL_2
  794. * @param Amplitude Unmask DAC channel LFSR for noise wave generation.
  795. * This parameter can be one of the following values:
  796. * @arg DAC_LFSRUNMASK_BIT0: Unmask DAC channel LFSR bit0 for noise wave generation
  797. * @arg DAC_LFSRUNMASK_BITS1_0: Unmask DAC channel LFSR bit[1:0] for noise wave generation
  798. * @arg DAC_LFSRUNMASK_BITS2_0: Unmask DAC channel LFSR bit[2:0] for noise wave generation
  799. * @arg DAC_LFSRUNMASK_BITS3_0: Unmask DAC channel LFSR bit[3:0] for noise wave generation
  800. * @arg DAC_LFSRUNMASK_BITS4_0: Unmask DAC channel LFSR bit[4:0] for noise wave generation
  801. * @arg DAC_LFSRUNMASK_BITS5_0: Unmask DAC channel LFSR bit[5:0] for noise wave generation
  802. * @arg DAC_LFSRUNMASK_BITS6_0: Unmask DAC channel LFSR bit[6:0] for noise wave generation
  803. * @arg DAC_LFSRUNMASK_BITS7_0: Unmask DAC channel LFSR bit[7:0] for noise wave generation
  804. * @arg DAC_LFSRUNMASK_BITS8_0: Unmask DAC channel LFSR bit[8:0] for noise wave generation
  805. * @arg DAC_LFSRUNMASK_BITS9_0: Unmask DAC channel LFSR bit[9:0] for noise wave generation
  806. * @arg DAC_LFSRUNMASK_BITS10_0: Unmask DAC channel LFSR bit[10:0] for noise wave generation
  807. * @arg DAC_LFSRUNMASK_BITS11_0: Unmask DAC channel LFSR bit[11:0] for noise wave generation
  808. * @retval HAL status
  809. */
  810. HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude)
  811. {
  812. /* Check the parameters */
  813. assert_param(IS_DAC_CHANNEL(Channel));
  814. assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude));
  815. /* Process locked */
  816. __HAL_LOCK(hdac);
  817. /* Change DAC state */
  818. hdac->State = HAL_DAC_STATE_BUSY;
  819. /* Enable the selected wave generation for the selected DAC channel */
  820. MODIFY_REG(hdac->Instance->CR, ((DAC_CR_WAVE1)|(DAC_CR_MAMP1))<<Channel, (DAC_CR_WAVE1_0 | Amplitude) << Channel);
  821. /* Change DAC state */
  822. hdac->State = HAL_DAC_STATE_READY;
  823. /* Process unlocked */
  824. __HAL_UNLOCK(hdac);
  825. /* Return function status */
  826. return HAL_OK;
  827. }
  828. #endif /* STM32F071xB STM32F072xB STM32F078xx */
  829. /* STM32F091xC STM32F098xx */
  830. /**
  831. * @}
  832. */
  833. /**
  834. * @}
  835. */
  836. #if defined(STM32F051x8) || defined(STM32F058xx) || \
  837. defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
  838. defined(STM32F091xC) || defined(STM32F098xx)
  839. /** @addtogroup DACEx_Exported_Functions
  840. * @{
  841. */
  842. /** @addtogroup DACEx_Exported_Functions_Group1
  843. * @brief Extended features functions
  844. * @{
  845. */
  846. /**
  847. * @brief Set the specified data holding register value for dual DAC channel.
  848. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  849. * the configuration information for the specified DAC.
  850. * @param Alignment Specifies the data alignment for dual channel DAC.
  851. * This parameter can be one of the following values:
  852. * DAC_ALIGN_8B_R: 8bit right data alignment selected
  853. * DAC_ALIGN_12B_L: 12bit left data alignment selected
  854. * DAC_ALIGN_12B_R: 12bit right data alignment selected
  855. * @param Data1 Data for DAC Channel2 to be loaded in the selected data holding register.
  856. * @param Data2 Data for DAC Channel1 to be loaded in the selected data holding register.
  857. * @note In dual mode, a unique register access is required to write in both
  858. * DAC channels at the same time.
  859. * @retval HAL status
  860. */
  861. HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef* hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2)
  862. {
  863. uint32_t data = 0U, tmp = 0U;
  864. /* Check the parameters */
  865. assert_param(IS_DAC_ALIGN(Alignment));
  866. assert_param(IS_DAC_DATA(Data1));
  867. assert_param(IS_DAC_DATA(Data2));
  868. /* Calculate and set dual DAC data holding register value */
  869. if (Alignment == DAC_ALIGN_8B_R)
  870. {
  871. data = ((uint32_t)Data2 << 8U) | Data1;
  872. }
  873. else
  874. {
  875. data = ((uint32_t)Data2 << 16U) | Data1;
  876. }
  877. tmp = (uint32_t)hdac->Instance;
  878. tmp += DAC_DHR12RD_ALIGNMENT(Alignment);
  879. /* Set the dual DAC selected data holding register */
  880. *(__IO uint32_t *)tmp = data;
  881. /* Return function status */
  882. return HAL_OK;
  883. }
  884. /**
  885. * @}
  886. */
  887. /**
  888. * @}
  889. */
  890. #endif /* STM32F051x8 STM32F058xx */
  891. /* STM32F071xB STM32F072xB STM32F078xx */
  892. /* STM32F091xC STM32F098xx */
  893. #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
  894. defined(STM32F091xC) || defined(STM32F098xx)
  895. /** @addtogroup DACEx_Exported_Functions
  896. * @{
  897. */
  898. /** @addtogroup DACEx_Exported_Functions_Group1
  899. * @brief Extended features functions
  900. * @{
  901. */
  902. /**
  903. * @brief Conversion complete callback in non blocking mode for Channel2
  904. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  905. * the configuration information for the specified DAC.
  906. * @retval None
  907. */
  908. __weak void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef* hdac)
  909. {
  910. /* Prevent unused argument(s) compilation warning */
  911. UNUSED(hdac);
  912. /* NOTE : This function Should not be modified, when the callback is needed,
  913. the HAL_DAC_ConvCpltCallback could be implemented in the user file
  914. */
  915. }
  916. /**
  917. * @brief Conversion half DMA transfer callback in non blocking mode for Channel2
  918. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  919. * the configuration information for the specified DAC.
  920. * @retval None
  921. */
  922. __weak void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef* hdac)
  923. {
  924. /* Prevent unused argument(s) compilation warning */
  925. UNUSED(hdac);
  926. /* NOTE : This function Should not be modified, when the callback is needed,
  927. the HAL_DAC_ConvHalfCpltCallbackCh2 could be implemented in the user file
  928. */
  929. }
  930. /**
  931. * @brief Error DAC callback for Channel2.
  932. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  933. * the configuration information for the specified DAC.
  934. * @retval None
  935. */
  936. __weak void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef *hdac)
  937. {
  938. /* Prevent unused argument(s) compilation warning */
  939. UNUSED(hdac);
  940. /* NOTE : This function Should not be modified, when the callback is needed,
  941. the HAL_DAC_ErrorCallback could be implemented in the user file
  942. */
  943. }
  944. /**
  945. * @brief DMA underrun DAC callback for channel2.
  946. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  947. * the configuration information for the specified DAC.
  948. * @retval None
  949. */
  950. __weak void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef *hdac)
  951. {
  952. /* Prevent unused argument(s) compilation warning */
  953. UNUSED(hdac);
  954. /* NOTE : This function Should not be modified, when the callback is needed,
  955. the HAL_DAC_DMAUnderrunCallbackCh2 could be implemented in the user file
  956. */
  957. }
  958. /**
  959. * @}
  960. */
  961. /**
  962. * @}
  963. */
  964. #endif /* STM32F071xB STM32F072xB STM32F078xx */
  965. /* STM32F091xC STM32F098xx */
  966. /**
  967. * @}
  968. */
  969. #endif /* HAL_DAC_MODULE_ENABLED */
  970. /**
  971. * @}
  972. */
  973. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/