1 /**
2 ******************************************************************************
3 * @file stm32mp1xx_hal_dac_ex.c
4 * @author MCD Application Team
5 * @brief Extended DAC HAL module driver.
6 * This file provides firmware functions to manage the extended
7 * functionalities of DAC peripheral.
8 *
9 *
10 ******************************************************************************
11 * @attention
12 *
13 * Copyright (c) 2019 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
32 (+) HAL_DACEx_SelfCalibrate to calibrate one DAC channel.
33 (+) HAL_DACEx_SetUserTrimming to set user trimming value.
34 (+) HAL_DACEx_GetTrimOffset to retrieve trimming value (factory setting
35 after reset, user setting if HAL_DACEx_SetUserTrimming have been used
36 at least one time after reset).
37
38 @endverbatim
39 ******************************************************************************
40 */
41
42
43 /* Includes ------------------------------------------------------------------*/
44 #include "stm32mp1xx_hal.h"
45
46 /** @addtogroup STM32MP1xx_HAL_Driver
47 * @{
48 */
49
50 /** @defgroup DACEx DACEx
51 * @brief DAC Extended HAL module driver
52 * @{
53 */
54
55 #ifdef HAL_DAC_MODULE_ENABLED
56
57 /* Private typedef -----------------------------------------------------------*/
58 /* Private define ------------------------------------------------------------*/
59 /* Private macro -------------------------------------------------------------*/
60 /* Private variables ---------------------------------------------------------*/
61 /* Private function prototypes -----------------------------------------------*/
62 /* Private functions ---------------------------------------------------------*/
63 /* Exported functions --------------------------------------------------------*/
64 /** @defgroup DACEx_Exported_Functions DACEx Exported Functions
65 * @{
66 */
67
68 /** @defgroup DACEx_Exported_Functions_Group2 IO operation functions
69 * @brief Extended IO operation functions
70 *
71 @verbatim
72 ==============================================================================
73 ##### Extended features functions #####
74 ==============================================================================
75 [..] This section provides functions allowing to:
76 (+) Start conversion with triangle wave generation.
77 (+) Start conversion with noise wave generation.
78 (+) Start self calibration.
79 (+) Set user trimming mode.
80 (+) Get result of dual mode conversion.
81
82 @endverbatim
83 * @{
84 */
85
86
87
88 /**
89 * @brief Enable or disable the selected DAC channel wave generation.
90 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
91 * the configuration information for the specified DAC.
92 * @param Channel: The selected DAC channel.
93 * This parameter can be one of the following values:
94 * @arg DAC_CHANNEL_1: DAC Channel1 selected
95 * @arg DAC_CHANNEL_2: DAC Channel2 selected
96 * @param Amplitude: Select max triangle amplitude.
97 * This parameter can be one of the following values:
98 * @arg DAC_TRIANGLEAMPLITUDE_1: Select max triangle amplitude of 1
99 * @arg DAC_TRIANGLEAMPLITUDE_3: Select max triangle amplitude of 3
100 * @arg DAC_TRIANGLEAMPLITUDE_7: Select max triangle amplitude of 7
101 * @arg DAC_TRIANGLEAMPLITUDE_15: Select max triangle amplitude of 15
102 * @arg DAC_TRIANGLEAMPLITUDE_31: Select max triangle amplitude of 31
103 * @arg DAC_TRIANGLEAMPLITUDE_63: Select max triangle amplitude of 63
104 * @arg DAC_TRIANGLEAMPLITUDE_127: Select max triangle amplitude of 127
105 * @arg DAC_TRIANGLEAMPLITUDE_255: Select max triangle amplitude of 255
106 * @arg DAC_TRIANGLEAMPLITUDE_511: Select max triangle amplitude of 511
107 * @arg DAC_TRIANGLEAMPLITUDE_1023: Select max triangle amplitude of 1023
108 * @arg DAC_TRIANGLEAMPLITUDE_2047: Select max triangle amplitude of 2047
109 * @arg DAC_TRIANGLEAMPLITUDE_4095: Select max triangle amplitude of 4095
110 * @retval HAL status
111 */
HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef * hdac,uint32_t Channel,uint32_t Amplitude)112 HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t Amplitude)
113 {
114 /* Check the parameters */
115 assert_param(IS_DAC_CHANNEL(Channel));
116 assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude));
117
118 /* Process locked */
119 __HAL_LOCK(hdac);
120
121 /* Change DAC state */
122 hdac->State = HAL_DAC_STATE_BUSY;
123
124 /* Enable the triangle wave generation for the selected DAC channel */
125 MODIFY_REG(hdac->Instance->CR, ((DAC_CR_WAVE1) | (DAC_CR_MAMP1)) << Channel, (DAC_CR_WAVE1_1 | Amplitude) << Channel);
126
127 /* Change DAC state */
128 hdac->State = HAL_DAC_STATE_READY;
129
130 /* Process unlocked */
131 __HAL_UNLOCK(hdac);
132
133 /* Return function status */
134 return HAL_OK;
135 }
136
137 /**
138 * @brief Enable or disable the selected DAC channel wave generation.
139 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
140 * the configuration information for the specified DAC.
141 * @param Channel: The selected DAC channel.
142 * This parameter can be one of the following values:
143 * @arg DAC_CHANNEL_1: DAC Channel1 selected
144 * @arg DAC_CHANNEL_2: DAC Channel2 selected
145 * @param Amplitude: Unmask DAC channel LFSR for noise wave generation.
146 * This parameter can be one of the following values:
147 * @arg DAC_LFSRUNMASK_BIT0: Unmask DAC channel LFSR bit0 for noise wave generation
148 * @arg DAC_LFSRUNMASK_BITS1_0: Unmask DAC channel LFSR bit[1:0] for noise wave generation
149 * @arg DAC_LFSRUNMASK_BITS2_0: Unmask DAC channel LFSR bit[2:0] for noise wave generation
150 * @arg DAC_LFSRUNMASK_BITS3_0: Unmask DAC channel LFSR bit[3:0] for noise wave generation
151 * @arg DAC_LFSRUNMASK_BITS4_0: Unmask DAC channel LFSR bit[4:0] for noise wave generation
152 * @arg DAC_LFSRUNMASK_BITS5_0: Unmask DAC channel LFSR bit[5:0] for noise wave generation
153 * @arg DAC_LFSRUNMASK_BITS6_0: Unmask DAC channel LFSR bit[6:0] for noise wave generation
154 * @arg DAC_LFSRUNMASK_BITS7_0: Unmask DAC channel LFSR bit[7:0] for noise wave generation
155 * @arg DAC_LFSRUNMASK_BITS8_0: Unmask DAC channel LFSR bit[8:0] for noise wave generation
156 * @arg DAC_LFSRUNMASK_BITS9_0: Unmask DAC channel LFSR bit[9:0] for noise wave generation
157 * @arg DAC_LFSRUNMASK_BITS10_0: Unmask DAC channel LFSR bit[10:0] for noise wave generation
158 * @arg DAC_LFSRUNMASK_BITS11_0: Unmask DAC channel LFSR bit[11:0] for noise wave generation
159 * @retval HAL status
160 */
HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef * hdac,uint32_t Channel,uint32_t Amplitude)161 HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t Amplitude)
162 {
163 /* Check the parameters */
164 assert_param(IS_DAC_CHANNEL(Channel));
165 assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude));
166
167 /* Process locked */
168 __HAL_LOCK(hdac);
169
170 /* Change DAC state */
171 hdac->State = HAL_DAC_STATE_BUSY;
172
173 /* Enable the noise wave generation for the selected DAC channel */
174 MODIFY_REG(hdac->Instance->CR, ((DAC_CR_WAVE1) | (DAC_CR_MAMP1)) << Channel, (DAC_CR_WAVE1_0 | Amplitude) << Channel);
175
176 /* Change DAC state */
177 hdac->State = HAL_DAC_STATE_READY;
178
179 /* Process unlocked */
180 __HAL_UNLOCK(hdac);
181
182 /* Return function status */
183 return HAL_OK;
184 }
185
186
187
188 /**
189 * @brief Set the specified data holding register value for dual DAC channel.
190 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
191 * the configuration information for the specified DAC.
192 * @param Alignment: Specifies the data alignment for dual channel DAC.
193 * This parameter can be one of the following values:
194 * DAC_ALIGN_8B_R: 8bit right data alignment selected
195 * DAC_ALIGN_12B_L: 12bit left data alignment selected
196 * DAC_ALIGN_12B_R: 12bit right data alignment selected
197 * @param Data1: Data for DAC Channel2 to be loaded in the selected data holding register.
198 * @param Data2: Data for DAC Channel1 to be loaded in the selected data holding register.
199 * @note In dual mode, a unique register access is required to write in both
200 * DAC channels at the same time.
201 * @retval HAL status
202 */
HAL_DACEx_DualSetValue(DAC_HandleTypeDef * hdac,uint32_t Alignment,uint32_t Data1,uint32_t Data2)203 HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef *hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2)
204 {
205 uint32_t data, tmp ;
206
207 /* Check the parameters */
208 assert_param(IS_DAC_ALIGN(Alignment));
209 assert_param(IS_DAC_DATA(Data1));
210 assert_param(IS_DAC_DATA(Data2));
211
212 /* Calculate and set dual DAC data holding register value */
213 if (Alignment == DAC_ALIGN_8B_R)
214 {
215 data = ((uint32_t)Data2 << 8) | Data1;
216 }
217 else
218 {
219 data = ((uint32_t)Data2 << 16) | Data1;
220 }
221
222 tmp = (uint32_t)hdac->Instance;
223 tmp += DAC_DHR12RD_ALIGNMENT(Alignment);
224
225 /* Set the dual DAC selected data holding register */
226 *(__IO uint32_t *)tmp = data;
227
228 /* Return function status */
229 return HAL_OK;
230 }
231
232 /**
233 * @brief Conversion complete callback in non-blocking mode for Channel2.
234 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
235 * the configuration information for the specified DAC.
236 * @retval None
237 */
HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef * hdac)238 __weak void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef *hdac)
239 {
240 /* Prevent unused argument(s) compilation warning */
241 UNUSED(hdac);
242
243 /* NOTE : This function should not be modified, when the callback is needed,
244 the HAL_DACEx_ConvCpltCallbackCh2 could be implemented in the user file
245 */
246 }
247
248 /**
249 * @brief Conversion half DMA transfer callback in non-blocking mode for Channel2.
250 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
251 * the configuration information for the specified DAC.
252 * @retval None
253 */
HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef * hdac)254 __weak void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef *hdac)
255 {
256 /* Prevent unused argument(s) compilation warning */
257 UNUSED(hdac);
258
259 /* NOTE : This function should not be modified, when the callback is needed,
260 the HAL_DACEx_ConvHalfCpltCallbackCh2 could be implemented in the user file
261 */
262 }
263
264 /**
265 * @brief Error DAC callback for Channel2.
266 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
267 * the configuration information for the specified DAC.
268 * @retval None
269 */
HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef * hdac)270 __weak void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef *hdac)
271 {
272 /* Prevent unused argument(s) compilation warning */
273 UNUSED(hdac);
274
275 /* NOTE : This function should not be modified, when the callback is needed,
276 the HAL_DACEx_ErrorCallbackCh2 could be implemented in the user file
277 */
278 }
279
280 /**
281 * @brief DMA underrun DAC callback for channel2.
282 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
283 * the configuration information for the specified DAC.
284 * @retval None
285 */
HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef * hdac)286 __weak void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef *hdac)
287 {
288 /* Prevent unused argument(s) compilation warning */
289 UNUSED(hdac);
290
291 /* NOTE : This function should not be modified, when the callback is needed,
292 the HAL_DACEx_DMAUnderrunCallbackCh2 could be implemented in the user file
293 */
294 }
295
296
297 /**
298 * @brief Run the self calibration of one DAC channel.
299 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
300 * the configuration information for the specified DAC.
301 * @param sConfig: DAC channel configuration structure.
302 * @param Channel: The selected DAC channel.
303 * This parameter can be one of the following values:
304 * @arg DAC_CHANNEL_1: DAC Channel1 selected
305 * @arg DAC_CHANNEL_2: DAC Channel2 selected
306 * @retval Updates DAC_TrimmingValue. , DAC_UserTrimming set to DAC_UserTrimming
307 * @retval HAL status
308 * @note Calibration runs about 7 ms.
309 */
310
HAL_DACEx_SelfCalibrate(DAC_HandleTypeDef * hdac,DAC_ChannelConfTypeDef * sConfig,uint32_t Channel)311 HAL_StatusTypeDef HAL_DACEx_SelfCalibrate(DAC_HandleTypeDef *hdac, DAC_ChannelConfTypeDef *sConfig, uint32_t Channel)
312 {
313 HAL_StatusTypeDef status = HAL_OK;
314
315 __IO uint32_t tmp = 0;
316 uint32_t trimmingvalue ;
317 uint32_t delta;
318
319 /* store/restore channel configuration structure purpose */
320 uint32_t oldmodeconfiguration ;
321
322 /* Check the parameters */
323 assert_param(IS_DAC_CHANNEL(Channel));
324
325 /* Check the DAC handle allocation */
326 if (hdac == NULL)
327 {
328 status = HAL_ERROR;
329 }
330
331 /* Check if DAC running */
332 if (hdac->State == HAL_DAC_STATE_BUSY)
333 {
334 status = HAL_ERROR;
335 }
336 else
337 {
338 /* Process locked */
339 __HAL_LOCK(hdac);
340
341 /* Store configuration */
342 oldmodeconfiguration = (hdac->Instance->MCR & (DAC_MCR_MODE1 << Channel));
343
344 /* Disable the selected DAC channel */
345 CLEAR_BIT((hdac->Instance->CR), (DAC_CR_EN1 << Channel));
346
347 /* Set mode in MCR for calibration */
348 MODIFY_REG(hdac->Instance->MCR, (DAC_MCR_MODE1 << Channel), 0);
349
350 /* Set DAC Channel1 DHR register to the middle value */
351
352 tmp = (uint32_t)hdac->Instance;
353 if (Channel == DAC_CHANNEL_1)
354 {
355 tmp += DAC_DHR12R1_ALIGNMENT(DAC_ALIGN_12B_R);
356 }
357 else
358 {
359 tmp += DAC_DHR12R2_ALIGNMENT(DAC_ALIGN_12B_R);
360 }
361 *(__IO uint32_t *) tmp = 0x0800;
362
363 /* Enable the selected DAC channel calibration */
364 /* i.e. set DAC_CR_CENx bit */
365 SET_BIT((hdac->Instance->CR), (DAC_CR_CEN1 << Channel));
366
367 /* Init trimming counter */
368 /* Medium value */
369 trimmingvalue = 16;
370 delta = 8;
371 while (delta != 0U)
372 {
373 /* Set candidate trimming */
374 MODIFY_REG(hdac->Instance->CCR, (DAC_CCR_OTRIM1 << Channel), (trimmingvalue << Channel));
375
376 /* tOFFTRIMmax delay x ms as per datasheet (electrical characteristics */
377 /* i.e. minimum time needed between two calibration steps */
378 HAL_Delay(1);
379
380 if ((hdac->Instance->SR & (DAC_SR_CAL_FLAG1 << Channel)) == (DAC_SR_CAL_FLAG1 << Channel))
381 {
382 /* DAC_SR_CAL_FLAGx is HIGH try higher trimming */
383 trimmingvalue -= delta;
384 }
385 else
386 {
387 /* DAC_SR_CAL_FLAGx is LOW try lower trimming */
388 trimmingvalue += delta;
389
390 }
391 delta >>= 1;
392 }
393
394 /* Still need to check if right calibration is current value or one step below */
395 /* Indeed the first value that causes the DAC_SR_CAL_FLAGx bit to change from 0 to 1 */
396 /* Set candidate trimming */
397 MODIFY_REG(hdac->Instance->CCR, (DAC_CCR_OTRIM1 << Channel), (trimmingvalue << Channel));
398
399 /* tOFFTRIMmax delay x ms as per datasheet (electrical characteristics */
400 /* i.e. minimum time needed between two calibration steps */
401 HAL_Delay(1);
402
403 if ((hdac->Instance->SR & (DAC_SR_CAL_FLAG1 << Channel)) == 0U)
404 {
405 /* Trimming is actually one value more */
406 trimmingvalue ++;
407 /* Set right trimming */
408 MODIFY_REG(hdac->Instance->CCR, (DAC_CCR_OTRIM1 << Channel), (trimmingvalue << Channel));
409 }
410
411 /* Disable the selected DAC channel calibration */
412 /* i.e. clear DAC_CR_CENx bit */
413 CLEAR_BIT((hdac->Instance->CR), (DAC_CR_CEN1 << Channel));
414
415 sConfig->DAC_TrimmingValue = trimmingvalue;
416 sConfig->DAC_UserTrimming = DAC_TRIMMING_USER;
417
418 /* Restore configuration */
419 MODIFY_REG(hdac->Instance->MCR, (DAC_MCR_MODE1 << Channel), oldmodeconfiguration);
420
421 /* Process unlocked */
422 __HAL_UNLOCK(hdac);
423 }
424
425 return status;
426 }
427
428 /**
429 * @brief Set the trimming mode and trimming value (user trimming mode applied).
430 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
431 * the configuration information for the specified DAC.
432 * @param sConfig: DAC configuration structure updated with new DAC trimming value.
433 * @param Channel: The selected DAC channel.
434 * This parameter can be one of the following values:
435 * @arg DAC_CHANNEL_1: DAC Channel1 selected
436 * @arg DAC_CHANNEL_2: DAC Channel2 selected
437 * @param NewTrimmingValue: DAC new trimming value
438 * @retval HAL status
439 */
440
HAL_DACEx_SetUserTrimming(DAC_HandleTypeDef * hdac,DAC_ChannelConfTypeDef * sConfig,uint32_t Channel,uint32_t NewTrimmingValue)441 HAL_StatusTypeDef HAL_DACEx_SetUserTrimming(DAC_HandleTypeDef *hdac, DAC_ChannelConfTypeDef *sConfig, uint32_t Channel, uint32_t NewTrimmingValue)
442 {
443 HAL_StatusTypeDef status = HAL_OK;
444
445 /* Check the parameters */
446 assert_param(IS_DAC_CHANNEL(Channel));
447 assert_param(IS_DAC_NEWTRIMMINGVALUE(NewTrimmingValue));
448
449 /* Check the DAC handle allocation */
450 if (hdac == NULL)
451 {
452 status = HAL_ERROR;
453 }
454 else
455 {
456
457 /* Process locked */
458 __HAL_LOCK(hdac);
459
460 /* Set new trimming */
461 MODIFY_REG(hdac->Instance->CCR, (DAC_CCR_OTRIM1 << Channel), (NewTrimmingValue << Channel));
462
463 /* Update trimming mode */
464 sConfig->DAC_UserTrimming = DAC_TRIMMING_USER;
465 sConfig->DAC_TrimmingValue = NewTrimmingValue;
466
467 /* Process unlocked */
468 __HAL_UNLOCK(hdac);
469
470 }
471 return status;
472 }
473
474
475 /**
476 * @brief Return the DAC trimming value.
477 * @param hdac : DAC handle
478 * @param Channel: The selected DAC channel.
479 * This parameter can be one of the following values:
480 * @arg DAC_CHANNEL_1: DAC Channel1 selected
481 * @arg DAC_CHANNEL_2: DAC Channel2 selected
482 * @retval Trimming value : range: 0->31
483 *
484 */
485
HAL_DACEx_GetTrimOffset(DAC_HandleTypeDef * hdac,uint32_t Channel)486 uint32_t HAL_DACEx_GetTrimOffset(DAC_HandleTypeDef *hdac, uint32_t Channel)
487 {
488 uint32_t trimmingvalue ;
489
490 /* Check the parameter */
491 assert_param(IS_DAC_CHANNEL(Channel));
492
493 /* Retrieve trimming */
494 trimmingvalue = ((hdac->Instance->CCR & (DAC_CCR_OTRIM1 << Channel)) >> Channel);
495
496 return trimmingvalue;
497 }
498
499 /**
500 * @}
501 */
502
503
504 /** @defgroup DACEx_Exported_Functions_Group3 Peripheral Control functions
505 * @brief Extended Peripheral Control functions
506 *
507 @verbatim
508 ==============================================================================
509 ##### Peripheral Control functions #####
510 ==============================================================================
511 [..] This section provides functions allowing to:
512 (+) Configure channels.
513 (+) Set the specified data holding register value for DAC channel.
514
515 @endverbatim
516 * @{
517 */
518
519 /**
520 * @brief Return the last data output value of the selected DAC channel.
521 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
522 * the configuration information for the specified DAC.
523 * @retval The selected DAC channel data output value.
524 */
HAL_DACEx_DualGetValue(DAC_HandleTypeDef * hdac)525 uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef *hdac)
526 {
527 uint32_t tmp = 0;
528
529 tmp |= hdac->Instance->DOR1;
530
531 tmp |= hdac->Instance->DOR2 << 16;
532
533 /* Returns the DAC channel data output register value */
534 return tmp;
535 }
536
537 /**
538 * @}
539 */
540
541 /**
542 * @}
543 */
544
545 /* Private functions ---------------------------------------------------------*/
546 /** @defgroup DACEx_Private_Functions DACEx private functions
547 * @brief Extended private functions
548 * @{
549 */
550
551 /**
552 * @brief DMA conversion complete callback.
553 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
554 * the configuration information for the specified DMA module.
555 * @retval None
556 */
DAC_DMAConvCpltCh2(DMA_HandleTypeDef * hdma)557 void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma)
558 {
559 DAC_HandleTypeDef *hdac = (DAC_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
560 #if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
561 hdac->ConvCpltCallbackCh2(hdac);
562 #else
563 HAL_DACEx_ConvCpltCallbackCh2(hdac);
564 #endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
565
566 hdac->State = HAL_DAC_STATE_READY;
567 }
568
569 /**
570 * @brief DMA half transfer complete callback.
571 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
572 * the configuration information for the specified DMA module.
573 * @retval None
574 */
DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef * hdma)575 void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma)
576 {
577 DAC_HandleTypeDef *hdac = (DAC_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
578
579 /* Conversion complete callback */
580 #if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
581 hdac->ConvHalfCpltCallbackCh2(hdac);
582 #else
583 HAL_DACEx_ConvHalfCpltCallbackCh2(hdac);
584 #endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
585 }
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 */
DAC_DMAErrorCh2(DMA_HandleTypeDef * hdma)593 void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma)
594 {
595 DAC_HandleTypeDef *hdac = (DAC_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
596
597 /* Set DAC error code to DMA error */
598 hdac->ErrorCode |= HAL_DAC_ERROR_DMA;
599
600 #if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
601 hdac->ErrorCallbackCh2(hdac);
602 #else
603 HAL_DACEx_ErrorCallbackCh2(hdac);
604 #endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
605 hdac->State = HAL_DAC_STATE_READY;
606 }
607
608 /**
609 * @}
610 */
611
612 #endif /* HAL_DAC_MODULE_ENABLED */
613
614 /**
615 * @}
616 */
617
618 /**
619 * @}
620 */
621