]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F3/stm32f3xx_hal_dac.c
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F3 / stm32f3xx_hal_dac.c
1 /**
2   ******************************************************************************
3   * @file    stm32f3xx_hal_dac.c
4   * @author  MCD Application Team
5   * @version V1.1.0
6   * @date    12-Sept-2014
7   * @brief   This file provides firmware functions to manage the following 
8   *          functionalities of the Digital-to-Analog Converter (DAC) peripheral: 
9   *           + DAC channels configuration: trigger, output buffer, data format
10   *           + DMA management      
11   *
12   *
13  @verbatim      
14   ==============================================================================
15                       ##### DAC Peripheral features #####
16   ==============================================================================
17     [..]        
18       *** DAC Channels ***
19       ====================  
20     [..]  
21     The device integrates up to 3 12-bit Digital Analog Converters that can 
22     be used independently or simultaneously (dual mode):
23       (#) DAC1 channel1 with DAC1_OUT1 (PA4) as output
24       (#) DAC1 channel2 with DAC1_OUT2 (PA5) as output 
25           (for STM32F3 devices having 2 channels on DAC1)
26       (#) DAC2 channel1 with DAC2_OUT1 (PA6) as output 
27           (for STM32F3 devices having 2 DAC)
28
29       *** DAC Triggers ***
30       ====================
31     [..]
32     Digital to Analog conversion can be non-triggered using DAC_Trigger_None
33     and DAC1_OUT1/DAC1_OUT2/DAC2_OUT1 is available once writing to DHRx register. 
34     [..] 
35     Digital to Analog conversion can be triggered by:
36       (#) External event: EXTI Line 9 (any GPIOx_Pin9) using DAC_Trigger_Ext_IT9.
37           The used pin (GPIOx_Pin9) must be configured in input mode.
38   
39       (#) Timers TRGO: TIM2, TIM4, TIM5, TIM6, TIM7 and TIM8 
40           (DAC_Trigger_T2_TRGO, DAC_Trigger_T4_TRGO...)
41   
42       (#) Software using DAC_Trigger_Software
43   
44       *** DAC Buffer mode feature ***
45       =============================== 
46       [..] 
47       Each DAC channel integrates an output buffer that can be used to 
48       reduce the output impedance, and to drive external loads directly
49       without having to add an external operational amplifier.
50       To enable, the output buffer use  
51       sConfig.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
52       [..]           
53       (@) Refer to the device datasheet for more details about output 
54           impedance value with and without output buffer.
55             
56        *** DAC wave generation feature ***
57        =================================== 
58        [..]     
59        Both DAC channels of DAC1 can be used to generate
60        note that wave generation is not available in DAC2.
61          (#) Noise wave
62          (#) Triangle wave
63       
64        Wave generation is NOT available in DAC2.
65
66        *** DAC data format ***
67        =======================
68        [..]   
69        The DAC data format can be:
70          (#) 8-bit right alignment using DAC_ALIGN_8B_R
71          (#) 12-bit left alignment using DAC_ALIGN_12B_L
72          (#) 12-bit right alignment using DAC_ALIGN_12B_R
73   
74        *** DAC data value to voltage correspondence ***  
75        ================================================ 
76        [..] 
77        The analog output voltage on each DAC channel pin is determined
78        by the following equation: 
79        DAC_OUTx = VREF+ * DOR / 4095
80        with  DOR is the Data Output Register
81           VEF+ is the input voltage reference (refer to the device datasheet)
82         e.g. To set DAC_OUT1 to 0.7V, use
83           Assuming that VREF+ = 3.3V, DAC_OUT1 = (3.3 * 868) / 4095 = 0.7V
84   
85        *** DMA requests  ***
86        =====================
87        [..]    
88        A DMA1 or DMA2 request can be generated when an external trigger 
89        (but not a software trigger) occurs if DMA1 or DMA2 requests are 
90        enabled using HAL_DAC_Start_DMA()
91        [..]
92        DMA1 requests are mapped as following:
93          (#) DAC1 channel1: mapped either on
94              - DMA1 channel3 
95              - or DMA2 channel3 (for STM32F3 devices having 2 DMA)
96              which must be already configured
97          (#) DAC1 channel2: 
98              (for STM32F3 devices having 2 channels on DAC1)
99              mapped either on
100              - DMA1 channel4 
101              - or DMA2 channel4 (for STM32F3 devices having 2 DMA)
102              which must be already configured
103       
104          (#) DAC2 channel1: mapped either on 
105              (for STM32F3 devices having 2 DAC)
106              - DMA1 channel4 
107              - or DMA2 channel4 (for STM32F3 devices having 2 DMA)
108              which must be already configured
109
110                       ##### How to use this driver #####
111   ==============================================================================
112     [..]          
113       (+) DAC APB clock must be enabled to get write access to DAC
114           registers using HAL_DAC_Init()
115       (+) Configure DAC_OUTx (DAC_OUT1: PA4, DAC_OUT2: PA5) in analog mode.
116       (+) Configure the DAC channel using HAL_DAC_ConfigChannel() function.
117       (+) Enable the DAC channel using HAL_DAC_Start() or HAL_DAC_Start_DMA 
118           functions
119
120      *** Polling mode IO operation ***
121      =================================
122      [..]    
123        (+) Start the DAC peripheral using HAL_DAC_Start() 
124        (+) To read the DAC last data output value value, use the HAL_DAC_GetValue() function.
125        (+) Stop the DAC peripheral using HAL_DAC_Stop()
126        
127      *** DMA mode IO operation ***    
128      ==============================
129      [..]    
130        (+) Start the DAC peripheral using HAL_DAC_Start_DMA(), at this stage the user specify the length 
131            of data to be transfered at each end of conversion 
132        (+) At The end of data transfer HAL_DAC_ConvCpltCallbackCh1()or HAL_DAC_ConvCpltCallbackCh2()  
133            function is executed and user can add his own code by customization of function pointer 
134            HAL_DAC_ConvCpltCallbackCh1 or HAL_DAC_ConvCpltCallbackCh2
135        (+) In case of transfer Error, HAL_DAC_ErrorCallbackCh1() function is executed and user can 
136             add his own code by customization of function pointer HAL_DAC_ErrorCallbackCh1
137        (+) Stop the DAC peripheral using HAL_DAC_Stop_DMA()
138
139      *** Dual mode operation ***    
140      ==============================   
141      [..]
142       (+) When Dual mode is enabled 
143           (i.e DAC1 Channel1 and DAC1 Channel2 are used simultaneously) 
144           (for STM32F3 devices having 2 channels on DAC1).
145           Use HAL_DACEx_DualGetValue() to get digital data to be converted and use
146           HAL_DACEx_DualSetValue() to set digital value to converted simultaneously 
147           in Channel 1 and Channel 2.  
148
149      *** Wave generation operation ***    
150      ==============================   
151      [..]
152       (+) Use HAL_DACEx_TriangleWaveGenerate to generate Triangle signal.
153       (+) Use HAL_DACEx_NoiseWaveGenerate to generate Noise signal.
154    
155           Wave generation is NOT available in DAC2.
156                     
157      *** DAC HAL driver macros list ***
158      ============================================= 
159      [..]
160        Below the list of most used macros in DAC HAL driver.
161        
162       (+) __HAL_DAC_ENABLE : Enable the DAC peripheral
163       (+) __HAL_DAC_DISABLE : Disable the DAC peripheral
164       (+) __HAL_DAC_CLEAR_FLAG: Clear the DAC's pending flags
165       (+) __HAL_DAC_GET_FLAG: Get the selected DAC's flag status 
166       
167      [..]
168       (@) You can refer to the DAC HAL driver header file for more useful macros  
169    
170  @endverbatim    
171   ******************************************************************************
172   * @attention
173   *
174   * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
175   *
176   * Redistribution and use in source and binary forms, with or without modification,
177   * are permitted provided that the following conditions are met:
178   *   1. Redistributions of source code must retain the above copyright notice,
179   *      this list of conditions and the following disclaimer.
180   *   2. Redistributions in binary form must reproduce the above copyright notice,
181   *      this list of conditions and the following disclaimer in the documentation
182   *      and/or other materials provided with the distribution.
183   *   3. Neither the name of STMicroelectronics nor the names of its contributors
184   *      may be used to endorse or promote products derived from this software
185   *      without specific prior written permission.
186   *
187   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
188   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
189   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
190   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
191   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
192   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
193   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
194   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
195   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
196   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
197   *
198   ******************************************************************************
199   */ 
200
201
202 /* Includes ------------------------------------------------------------------*/
203 #include "stm32f3xx_hal.h"
204
205 /** @addtogroup STM32F3xx_HAL_Driver
206   * @{
207   */
208
209 /** @defgroup DAC DAC HAL module driver
210   * @brief DAC HAL module driver
211   * @{
212   */ 
213  
214 #ifdef HAL_DAC_MODULE_ENABLED
215
216 /* Private typedef -----------------------------------------------------------*/
217 /* Private define ------------------------------------------------------------*/
218 /* Private macro -------------------------------------------------------------*/
219 /* Private variables ---------------------------------------------------------*/
220 /* Private function prototypes -----------------------------------------------*/
221     
222 /* Exported functions ---------------------------------------------------------*/
223 /** @defgroup DAC_Exported_Functions DAC Exported Functions
224   * @{
225   */
226
227 /** @defgroup DAC_Exported_Functions_Group1 Initialization and de-initialization functions 
228  *  @brief    Initialization and Configuration functions 
229  *
230 @verbatim    
231   ==============================================================================
232               ##### Initialization and de-initialization functions #####
233   ==============================================================================
234     [..]  This section provides functions allowing to:
235       (+) Initialize and configure the DAC. 
236       (+) De-initialize the DAC. 
237          
238 @endverbatim
239   * @{
240   */
241
242 /**
243   * @brief  Initializes the DAC peripheral according to the specified parameters
244   *         in the DAC_InitStruct.
245   * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
246   *         the configuration information for the specified DAC.
247   * @retval HAL status
248   */
249 HAL_StatusTypeDef HAL_DAC_Init(DAC_HandleTypeDef* hdac)
250
251   /* Check DAC handle */
252   if(hdac == HAL_NULL)
253   {
254      return HAL_ERROR;
255   }
256   /* Check the parameters */
257   assert_param(IS_DAC_ALL_INSTANCE(hdac->Instance));
258   
259   if(hdac->State == HAL_DAC_STATE_RESET)
260   {  
261     /* Init the low level hardware */
262     HAL_DAC_MspInit(hdac);
263   }
264   
265   /* Initialize the DAC state*/
266   hdac->State = HAL_DAC_STATE_BUSY;
267        
268   /* Set DAC error code to none */
269   hdac->ErrorCode = HAL_DAC_ERROR_NONE;
270   
271   /* Initialize the DAC state*/
272   hdac->State = HAL_DAC_STATE_READY;
273   
274   /* Return function status */
275   return HAL_OK;
276 }
277
278 /**
279   * @brief  Deinitializes the DAC peripheral registers to their default reset values.
280   * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
281   *         the configuration information for the specified DAC.
282   * @retval HAL status
283   */
284 HAL_StatusTypeDef HAL_DAC_DeInit(DAC_HandleTypeDef* hdac)
285 {
286   /* Check DAC handle */
287   if(hdac == HAL_NULL)
288   {
289      return HAL_ERROR;
290   }
291
292   /* Check the parameters */
293   assert_param(IS_DAC_ALL_INSTANCE(hdac->Instance));
294
295   /* Change DAC state */
296   hdac->State = HAL_DAC_STATE_BUSY;
297   
298   /* DeInit the low level hardware */
299   HAL_DAC_MspDeInit(hdac);
300   
301   /* Set DAC error code to none */
302   hdac->ErrorCode = HAL_DAC_ERROR_NONE;
303   
304   /* Change DAC state */
305   hdac->State = HAL_DAC_STATE_RESET;
306
307   /* Release Lock */
308   __HAL_UNLOCK(hdac);
309
310   /* Return function status */
311   return HAL_OK;
312 }
313
314 /**
315   * @brief  Initializes the DAC MSP.
316   * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
317   *         the configuration information for the specified DAC.
318   * @retval None
319   */
320 __weak void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac)
321 {
322   /* NOTE : This function Should not be modified, when the callback is needed,
323             the HAL_DAC_MspInit could be implemented in the user file
324    */ 
325 }
326
327 /**
328   * @brief  DeInitializes the DAC MSP.
329   * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
330   *         the configuration information for the specified DAC.  
331   * @retval None
332   */
333 __weak void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac)
334 {
335   /* NOTE : This function Should not be modified, when the callback is needed,
336             the HAL_DAC_MspDeInit could be implemented in the user file
337    */ 
338 }
339
340 /**
341   * @}
342   */
343
344 /** @defgroup DAC_Exported_Functions_Group2 Input and Output operation functions
345  *  @brief    IO operation functions 
346  *
347 @verbatim   
348   ==============================================================================
349              ##### IO operation functions #####
350   ==============================================================================  
351     [..]  This section provides functions allowing to:
352       (+) Start conversion.
353       (+) Stop conversion.
354       (+) Start conversion and enable DMA transfer.
355       (+) Stop conversion and disable DMA transfer.
356       (+) Get result of conversion.
357       (+) Get result of dual mode conversion.
358                      
359 @endverbatim
360   * @{
361   */
362
363 /**
364   * @brief  Enables DAC and starts conversion of channel.
365   * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
366   *         the configuration information for the specified DAC.
367   * @param  channel: The selected DAC channel. 
368   *          This parameter can be one of the following values:
369   *            @arg DAC1_CHANNEL_1: DAC1 Channel1 selected
370   *            @arg DAC1_CHANNEL_2: DAC1 Channel2 selected  
371   *            @arg DAC2_CHANNEL_1: DAC2 Channel1 selected  
372   * @retval HAL status
373   */
374 __weak HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef* hdac, uint32_t channel)
375
376 {
377   /* Note : This function is defined into this file for library reference */
378   /*        Function content is located into file stm32f3xx_hal_dac_ex.c  */
379   
380   /* Return function status */
381   return HAL_ERROR;
382 }
383
384 /**
385   * @brief  Disables DAC and stop conversion of channel.
386   * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
387   *         the configuration information for the specified DAC.
388   * @param  channel: The selected DAC channel. 
389   *          This parameter can be one of the following values:
390   *            @arg DAC1_CHANNEL_1: DAC1 Channel1 selected
391   *            @arg DAC1_CHANNEL_2: DAC1 Channel2 selected  
392   *            @arg DAC2_CHANNEL_1: DAC2 Channel1 selected  
393   * @retval HAL status
394   */
395 HAL_StatusTypeDef HAL_DAC_Stop(DAC_HandleTypeDef* hdac, uint32_t channel)
396 {
397   /* Check the parameters */
398   assert_param(IS_DAC_CHANNEL_INSTANCE(hdac->Instance, channel));
399   
400   /* Disable the Peripheral */
401   __HAL_DAC_DISABLE(hdac, channel);
402   
403   /* Change DAC state */
404   hdac->State = HAL_DAC_STATE_READY;
405   
406   /* Return function status */
407   return HAL_OK;
408 }
409
410 /**
411   * @brief  Disables DAC and stop conversion of channel.
412   * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
413   *         the configuration information for the specified DAC.
414   * @param  channel: The selected DAC channel. 
415   *          This parameter can be one of the following values:
416   *            @arg DAC1_CHANNEL_1: DAC1 Channel1 selected
417   *            @arg DAC1_CHANNEL_2: DAC1 Channel2 selected  
418   *            @arg DAC2_CHANNEL_1: DAC2 Channel1 selected    
419   * @retval HAL status
420   */
421 HAL_StatusTypeDef HAL_DAC_Stop_DMA(DAC_HandleTypeDef* hdac, uint32_t channel)
422 {
423   HAL_StatusTypeDef status = HAL_OK;
424     
425   /* Check the parameters */
426   assert_param(IS_DAC_CHANNEL_INSTANCE(hdac->Instance, channel));
427   
428   /* Disable the selected DAC channel DMA request */
429     hdac->Instance->CR &= ~(DAC_CR_DMAEN1 << channel);
430     
431   /* Disable the Peripheral */
432   __HAL_DAC_DISABLE(hdac, channel);
433   
434   /* Disable the DMA Channel */
435   /* Channel1 is used */
436   if (channel == DAC1_CHANNEL_1)
437   {
438     status = HAL_DMA_Abort(hdac->DMA_Handle1);   
439   }
440   else /* Channel2 is used for */
441   {
442     status = HAL_DMA_Abort(hdac->DMA_Handle2);   
443   }
444  
445   /* Check if DMA Channel effectively disabled */
446   if (status != HAL_OK)
447   {
448     /* Update ADC state machine to error */
449     hdac->State = HAL_DAC_STATE_ERROR;      
450   }
451   else
452   {
453     /* Change DAC state */
454     hdac->State = HAL_DAC_STATE_READY;
455   }
456   
457   /* Return function status */
458   return status;
459 }
460
461 /**
462   * @brief  Returns the last data output value of the selected DAC channel.
463   * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
464   *         the configuration information for the specified DAC.
465   * @param  channel: The selected DAC channel. 
466   *          This parameter can be one of the following values:
467   *            @arg DAC1_CHANNEL_1: DAC1 Channel1 selected
468   *            @arg DAC1_CHANNEL_2: DAC1 Channel2 selected  
469   *            @arg DAC2_CHANNEL_1: DAC2 Channel1 selected 
470   * @retval The selected DAC channel data output value.
471   */
472 __weak uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef* hdac, uint32_t channel)
473
474   /* Note : This function is defined into this file for library reference */
475   /*        Function content is located into file stm32f3xx_hal_dac_ex.c  */
476
477   /* Return function status */
478   return HAL_OK;
479 }
480
481 /**
482   * @brief  Returns the last data output value of the selected DAC channel.
483   * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
484   *         the configuration information for the specified DAC.
485   * @retval The selected DAC channel data output value.
486   */
487 __weak uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef* hdac)
488 {
489
490   /* Note : This function is defined into this file for library reference */
491   /*        Function content is located into file stm32f3xx_hal_dac_ex.c  */
492
493   /* Return function status */
494   return HAL_OK;
495 }
496 }
497
498 /**
499   * @}
500   */
501   
502 /** @defgroup DAC_Exported_Functions_Group3 Peripheral Control functions
503  *  @brief    Peripheral Control functions 
504  *
505 @verbatim   
506   ==============================================================================
507              ##### Peripheral Control functions #####
508   ==============================================================================  
509     [..]  This section provides functions allowing to:
510       (+) Configure channels. 
511       (+) Configure Triangle wave generation.
512       (+) Configure Noise wave generation.
513       (+) Set the specified data holding register value for DAC channel.
514       (+) Set the specified data holding register value for Dual DAC channels.
515       
516 @endverbatim
517   * @{
518   */
519
520 /**
521   * @brief  Configures the selected DAC channel.
522   * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
523   *         the configuration information for the specified DAC.
524   * @param  sConfig: DAC configuration structure.
525   * @param  channel: The selected DAC channel. 
526   *          This parameter can be one of the following values:
527   *            @arg DAC1_CHANNEL_1: DAC1 Channel1 selected
528   *            @arg DAC1_CHANNEL_2: DAC1 Channel2 selected  
529   *            @arg DAC2_CHANNEL_1: DAC2 Channel1 selected 
530   * @retval HAL status
531   */
532 HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef* hdac, DAC_ChannelConfTypeDef* sConfig, uint32_t channel)
533 {
534   uint32_t tmpreg1 = 0, tmpreg2 = 0;
535
536   /* Check the DAC parameters */
537   assert_param(IS_DAC_TRIGGER(sConfig->DAC_Trigger));
538   assert_param(IS_DAC_OUTPUT_BUFFER_STATE(sConfig->DAC_OutputBuffer));
539   assert_param(IS_DAC_CHANNEL(channel));
540   
541   /* Process locked */
542   __HAL_LOCK(hdac);
543   
544   /* Change DAC state */
545   hdac->State = HAL_DAC_STATE_BUSY;
546   
547   /* Get the DAC CR value */
548   tmpreg1 = hdac->Instance->CR;
549   /* Clear BOFFx, TENx, TSELx, WAVEx and MAMPx bits */
550   tmpreg1 &= ~(((uint32_t)(DAC_CR_MAMP1 | DAC_CR_WAVE1 | DAC_CR_TSEL1 | DAC_CR_TEN1 | DAC_CR_BOFF1)) << channel);
551   /* Configure for the selected DAC channel: buffer output, trigger */
552   /* Set TSELx and TENx bits according to DAC_Trigger value */
553   /* Set BOFFx bit according to DAC_OutputBuffer value */   
554   tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputBuffer);
555   /* Calculate CR register value depending on DAC_Channel */
556   tmpreg1 |= tmpreg2 << channel;
557   /* Write to DAC CR */
558   hdac->Instance->CR = tmpreg1;
559   /* Disable wave generation */
560   hdac->Instance->CR &= ~(DAC_CR_WAVE1 << channel);
561
562   /* Change DAC state */
563   hdac->State = HAL_DAC_STATE_READY;
564   
565   /* Process unlocked */
566   __HAL_UNLOCK(hdac);
567   
568   /* Return function status */
569   return HAL_OK;
570 }
571
572 __weak HAL_StatusTypeDef HAL_DAC_SetValue(DAC_HandleTypeDef* hdac, uint32_t channel, uint32_t alignment, uint32_t data)
573
574   /* Note : This function is defined into this file for library reference */
575   /*        Function content is located into file stm32f3xx_hal_dac_ex.c  */
576
577   /* Return function status */
578   return HAL_ERROR;
579 }
580
581 __weak HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef* hdac, uint32_t alignment, uint32_t data1, uint32_t data2)
582
583   /* Note : This function is defined into this file for library reference */
584   /*        Function content is located into file stm32f3xx_hal_dac_ex.c  */
585
586   /* Return function status */
587   return HAL_ERROR;
588 }
589
590 /**
591   * @}
592   */
593
594 /** @defgroup DAC_Exported_Functions_Group4 Peripheral State and Error functions
595  *  @brief   DAC Peripheral State and Error functions 
596  *
597 @verbatim   
598   ==============================================================================
599             ##### DAC Peripheral State and Error functions #####
600   ==============================================================================  
601     [..]
602     This subsection provides functions allowing to
603       (+) Check the DAC state.
604       (+) Check the DAC Errors.
605
606         
607 @endverbatim
608   * @{
609   */
610
611 /**
612   * @brief  return the DAC state
613   * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
614   *         the configuration information for the specified DAC.
615   * @retval HAL state
616   */
617 HAL_DAC_StateTypeDef HAL_DAC_GetState(DAC_HandleTypeDef* hdac)
618 {
619   /* Return DAC state */
620   return hdac->State;
621 }
622
623 /**
624   * @brief  Return the DAC error code
625   * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
626   *         the configuration information for the specified DAC.
627   * @retval DAC Error Code
628   */
629 uint32_t HAL_DAC_GetError(DAC_HandleTypeDef *hdac)
630 {
631   return hdac->ErrorCode;
632 }
633
634 /**
635   * @}
636   */
637
638 /** @addtogroup DAC_Exported_Functions_Group2 Input and Output operation functions
639   * @{
640   */
641
642 /**
643   * @brief  Conversion complete callback in non blocking mode for Channel1 
644   * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
645   *         the configuration information for the specified DAC.
646   * @retval None
647   */
648 __weak void HAL_DAC_ConvCpltCallbackCh1(DAC_HandleTypeDef* hdac)
649 {
650   /* NOTE : This function Should not be modified, when the callback is needed,
651             the HAL_DAC_ConvCpltCallback1 could be implemented in the user file
652    */
653 }
654
655 /**
656   * @brief  Conversion half DMA transfer callback in non blocking mode for Channel1 
657   * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
658   *         the configuration information for the specified DAC.
659   * @retval None
660   */
661 __weak void HAL_DAC_ConvHalfCpltCallbackCh1(DAC_HandleTypeDef* hdac)
662 {
663   /* NOTE : This function Should not be modified, when the callback is needed,
664             the HAL_DAC_ConvHalfCpltCallbackCh1 could be implemented in the user file
665    */
666 }
667
668 /**
669   * @brief  Error DAC callback for Channel1.
670   * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
671   *         the configuration information for the specified DAC.
672   * @retval None
673   */
674 __weak void HAL_DAC_ErrorCallbackCh1(DAC_HandleTypeDef *hdac)
675 {
676   /* NOTE : This function Should not be modified, when the callback is needed,
677             the HAL_DAC_ErrorCallback could be implemented in the user file
678    */
679 }
680
681
682 /**
683   * @brief  DMA underrun DAC callback for Channel1.
684   * @param  hdac: pointer to a DAC_HandleTypeDef structure that contains
685   *         the configuration information for the specified DAC.
686   * @retval None
687   */
688 __weak void HAL_DAC_DMAUnderrunCallbackCh1(DAC_HandleTypeDef *hdac)
689 {
690   /* NOTE : This function Should not be modified, when the callback is needed,
691             the HAL_DAC_DMAUnderrunCallbackCh1 could be implemented in the user file
692    */
693 }
694
695 /**
696   * @}
697   */
698
699 /**
700   * @}
701   */
702
703 #endif /* HAL_DAC_MODULE_ENABLED */
704
705 /**
706   * @}
707   */
708
709 /**
710   * @}
711   */
712
713 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/