stm32f0xx_hal_dac_ex.c 38 KB

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