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