annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_hal_dac.c @ 74:f2d98ad6f1be

Move font to upper memory
author Ideenmodellierer
date Thu, 04 Oct 2018 20:40:53 +0200
parents 5f11787b4f42
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @file stm32f4xx_hal_dac.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @author MCD Application Team
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @version V1.2.0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @date 26-December-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @brief DAC HAL module driver.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 * This file provides firmware functions to manage the following
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 * functionalities of the Digital to Analog Converter (DAC) peripheral:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 * + Initialization and de-initialization functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 * + IO operation functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 * + Peripheral Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 * + Peripheral State and Errors functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 ##### DAC Peripheral features #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 *** DAC Channels ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 ====================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 The device integrates two 12-bit Digital Analog Converters that can
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 be used independently or simultaneously (dual mode):
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 (#) DAC channel1 with DAC_OUT1 (PA4) as output
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 (#) DAC channel2 with DAC_OUT2 (PA5) as output
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 *** DAC Triggers ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 ====================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 Digital to Analog conversion can be non-triggered using DAC_TRIGGER_NONE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 and DAC_OUT1/DAC_OUT2 is available once writing to DHRx register.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 Digital to Analog conversion can be triggered by:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 (#) External event: EXTI Line 9 (any GPIOx_Pin9) using DAC_TRIGGER_EXT_IT9.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 The used pin (GPIOx_Pin9) must be configured in input mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 (#) Timers TRGO: TIM2, TIM4, TIM5, TIM6, TIM7 and TIM8
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 (DAC_TRIGGER_T2_TRGO, DAC_TRIGGER_T4_TRGO...)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 (#) Software using DAC_TRIGGER_SOFTWARE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 *** DAC Buffer mode feature ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 ===============================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 Each DAC channel integrates an output buffer that can be used to
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 reduce the output impedance, and to drive external loads directly
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 without having to add an external operational amplifier.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 To enable, the output buffer use
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 (@) Refer to the device datasheet for more details about output
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 impedance value with and without output buffer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 *** DAC wave generation feature ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 ===================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 Both DAC channels can be used to generate
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 (#) Noise wave
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 (#) Triangle wave
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 *** DAC data format ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 =======================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 The DAC data format can be:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 (#) 8-bit right alignment using DAC_ALIGN_8B_R
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 (#) 12-bit left alignment using DAC_ALIGN_12B_L
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 (#) 12-bit right alignment using DAC_ALIGN_12B_R
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 *** DAC data value to voltage correspondence ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 ================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 The analog output voltage on each DAC channel pin is determined
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 by the following equation:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 DAC_OUTx = VREF+ * DOR / 4095
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 with DOR is the Data Output Register
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 VEF+ is the input voltage reference (refer to the device datasheet)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 e.g. To set DAC_OUT1 to 0.7V, use
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 Assuming that VREF+ = 3.3V, DAC_OUT1 = (3.3 * 868) / 4095 = 0.7V
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 *** DMA requests ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 =====================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 A DMA1 request can be generated when an external trigger (but not
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 a software trigger) occurs if DMA1 requests are enabled using
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 HAL_DAC_Start_DMA()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 DMA1 requests are mapped as following:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 (#) DAC channel1 : mapped on DMA1 Stream5 channel7 which must be
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 already configured
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 (#) DAC channel2 : mapped on DMA1 Stream6 channel7 which must be
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 already configured
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 -@- For Dual mode and specific signal (Triangle and noise) generation please
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 refer to Extension Features Driver description
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 ##### How to use this driver #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 (+) DAC APB clock must be enabled to get write access to DAC
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 registers using HAL_DAC_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 (+) Configure DAC_OUTx (DAC_OUT1: PA4, DAC_OUT2: PA5) in analog mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 (+) Configure the DAC channel using HAL_DAC_ConfigChannel() function.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 (+) Enable the DAC channel using HAL_DAC_Start() or HAL_DAC_Start_DMA functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 *** Polling mode IO operation ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 =================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 (+) Start the DAC peripheral using HAL_DAC_Start()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 (+) To read the DAC last data output value, use the HAL_DAC_GetValue() function.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 (+) Stop the DAC peripheral using HAL_DAC_Stop()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 *** DMA mode IO operation ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 ==============================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 (+) Start the DAC peripheral using HAL_DAC_Start_DMA(), at this stage the user specify the length
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 of data to be transferred at each end of conversion
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 (+) At The end of data transfer HAL_DAC_ConvCpltCallbackCh1()or HAL_DAC_ConvCpltCallbackCh2()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 function is executed and user can add his own code by customization of function pointer
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 HAL_DAC_ConvCpltCallbackCh1 or HAL_DAC_ConvCpltCallbackCh2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 (+) In case of transfer Error, HAL_DAC_ErrorCallbackCh1() function is executed and user can
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 add his own code by customization of function pointer HAL_DAC_ErrorCallbackCh1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 (+) Stop the DAC peripheral using HAL_DAC_Stop_DMA()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 *** DAC HAL driver macros list ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 =============================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 Below the list of most used macros in DAC HAL driver.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 (+) __HAL_DAC_ENABLE : Enable the DAC peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 (+) __HAL_DAC_DISABLE : Disable the DAC peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 (+) __HAL_DAC_CLEAR_FLAG: Clear the DAC's pending flags
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 (+) __HAL_DAC_GET_FLAG: Get the selected DAC's flag status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 (@) You can refer to the DAC HAL driver header file for more useful macros
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 * Redistribution and use in source and binary forms, with or without modification,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 * are permitted provided that the following conditions are met:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 * 1. Redistributions of source code must retain the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 * this list of conditions and the following disclaimer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 * 2. Redistributions in binary form must reproduce the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 * this list of conditions and the following disclaimer in the documentation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 * and/or other materials provided with the distribution.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 * 3. Neither the name of STMicroelectronics nor the names of its contributors
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 * may be used to endorse or promote products derived from this software
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 * without specific prior written permission.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 /** @addtogroup STM32F4xx_HAL_Driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 /** @defgroup DAC DAC
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 * @brief DAC driver modules
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 #ifdef HAL_DAC_MODULE_ENABLED
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 /* Private typedef -----------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 /* Private define ------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 /* Private macro -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 /** @addtogroup DAC_Private_Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 static void DAC_DMAConvCpltCh1(DMA_HandleTypeDef *hdma);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 static void DAC_DMAErrorCh1(DMA_HandleTypeDef *hdma);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 static void DAC_DMAHalfConvCpltCh1(DMA_HandleTypeDef *hdma);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 /** @defgroup DAC_Exported_Functions DAC Exported Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 /** @defgroup DAC_Exported_Functions_Group1 Initialization and de-initialization functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 * @brief Initialization and Configuration functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 ##### Initialization and de-initialization functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 [..] This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 (+) Initialize and configure the DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 (+) De-initialize the DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 * @brief Initializes the DAC peripheral according to the specified parameters
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 * in the DAC_InitStruct.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 HAL_StatusTypeDef HAL_DAC_Init(DAC_HandleTypeDef* hdac)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 /* Check DAC handle */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 if(hdac == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 assert_param(IS_DAC_ALL_INSTANCE(hdac->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 if(hdac->State == HAL_DAC_STATE_RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 /* Init the low level hardware */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 HAL_DAC_MspInit(hdac);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 /* Initialize the DAC state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 hdac->State = HAL_DAC_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 /* Set DAC error code to none */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 hdac->ErrorCode = HAL_DAC_ERROR_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 /* Initialize the DAC state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 hdac->State = HAL_DAC_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 * @brief Deinitializes the DAC peripheral registers to their default reset values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 HAL_StatusTypeDef HAL_DAC_DeInit(DAC_HandleTypeDef* hdac)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 /* Check DAC handle */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 if(hdac == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 assert_param(IS_DAC_ALL_INSTANCE(hdac->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 /* Change DAC state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 hdac->State = HAL_DAC_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 /* DeInit the low level hardware */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 HAL_DAC_MspDeInit(hdac);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 /* Set DAC error code to none */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 hdac->ErrorCode = HAL_DAC_ERROR_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 /* Change DAC state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 hdac->State = HAL_DAC_STATE_RESET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 /* Release Lock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 __HAL_UNLOCK(hdac);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 * @brief Initializes the DAC MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 __weak void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 the HAL_DAC_MspInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 * @brief DeInitializes the DAC MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 __weak void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 the HAL_DAC_MspDeInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 /** @defgroup DAC_Exported_Functions_Group2 IO operation functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 * @brief IO operation functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 ##### IO operation functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 [..] This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 (+) Start conversion.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 (+) Stop conversion.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 (+) Start conversion and enable DMA transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 (+) Stop conversion and disable DMA transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 (+) Get result of conversion.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 * @brief Enables DAC and starts conversion of channel.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 * @param Channel: The selected DAC channel.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 * @arg DAC_CHANNEL_1: DAC Channel1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 * @arg DAC_CHANNEL_2: DAC Channel2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef* hdac, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 uint32_t tmp1 = 0, tmp2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 assert_param(IS_DAC_CHANNEL(Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 /* Process locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 __HAL_LOCK(hdac);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 /* Change DAC state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 hdac->State = HAL_DAC_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 __HAL_DAC_ENABLE(hdac, Channel);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 if(Channel == DAC_CHANNEL_1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 tmp1 = hdac->Instance->CR & DAC_CR_TEN1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 tmp2 = hdac->Instance->CR & DAC_CR_TSEL1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 /* Check if software trigger enabled */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 if((tmp1 == DAC_CR_TEN1) && (tmp2 == DAC_CR_TSEL1))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 /* Enable the selected DAC software conversion */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 hdac->Instance->SWTRIGR |= (uint32_t)DAC_SWTRIGR_SWTRIG1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 tmp1 = hdac->Instance->CR & DAC_CR_TEN2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 tmp2 = hdac->Instance->CR & DAC_CR_TSEL2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 /* Check if software trigger enabled */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 if((tmp1 == DAC_CR_TEN2) && (tmp2 == DAC_CR_TSEL2))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 /* Enable the selected DAC software conversion*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 hdac->Instance->SWTRIGR |= (uint32_t)DAC_SWTRIGR_SWTRIG2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 /* Change DAC state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 hdac->State = HAL_DAC_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 /* Process unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 __HAL_UNLOCK(hdac);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 * @brief Disables DAC and stop conversion of channel.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 * @param Channel: The selected DAC channel.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 * @arg DAC_CHANNEL_1: DAC Channel1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 * @arg DAC_CHANNEL_2: DAC Channel2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 HAL_StatusTypeDef HAL_DAC_Stop(DAC_HandleTypeDef* hdac, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414 assert_param(IS_DAC_CHANNEL(Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 __HAL_DAC_DISABLE(hdac, Channel);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 /* Change DAC state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 hdac->State = HAL_DAC_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 * @brief Enables DAC and starts conversion of channel.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 * @param Channel: The selected DAC channel.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432 * @arg DAC_CHANNEL_1: DAC Channel1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433 * @arg DAC_CHANNEL_2: DAC Channel2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 * @param pData: The destination peripheral Buffer address.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 * @param Length: The length of data to be transferred from memory to DAC peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 * @param Alignment: Specifies the data alignment for DAC channel.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438 * @arg DAC_ALIGN_8B_R: 8bit right data alignment selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439 * @arg DAC_ALIGN_12B_L: 12bit left data alignment selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440 * @arg DAC_ALIGN_12B_R: 12bit right data alignment selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443 HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t* pData, uint32_t Length, uint32_t Alignment)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445 uint32_t tmpreg = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448 assert_param(IS_DAC_CHANNEL(Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 assert_param(IS_DAC_ALIGN(Alignment));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451 /* Process locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452 __HAL_LOCK(hdac);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454 /* Change DAC state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 hdac->State = HAL_DAC_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 if(Channel == DAC_CHANNEL_1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 /* Set the DMA transfer complete callback for channel1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460 hdac->DMA_Handle1->XferCpltCallback = DAC_DMAConvCpltCh1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 /* Set the DMA half transfer complete callback for channel1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 hdac->DMA_Handle1->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465 /* Set the DMA error callback for channel1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 hdac->DMA_Handle1->XferErrorCallback = DAC_DMAErrorCh1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 /* Enable the selected DAC channel1 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 hdac->Instance->CR |= DAC_CR_DMAEN1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471 /* Case of use of channel 1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472 switch(Alignment)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474 case DAC_ALIGN_12B_R:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 /* Get DHR12R1 address */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 tmpreg = (uint32_t)&hdac->Instance->DHR12R1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 case DAC_ALIGN_12B_L:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 /* Get DHR12L1 address */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480 tmpreg = (uint32_t)&hdac->Instance->DHR12L1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482 case DAC_ALIGN_8B_R:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 /* Get DHR8R1 address */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 tmpreg = (uint32_t)&hdac->Instance->DHR8R1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492 /* Set the DMA transfer complete callback for channel2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493 hdac->DMA_Handle2->XferCpltCallback = DAC_DMAConvCpltCh2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 /* Set the DMA half transfer complete callback for channel2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496 hdac->DMA_Handle2->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 /* Set the DMA error callback for channel2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 hdac->DMA_Handle2->XferErrorCallback = DAC_DMAErrorCh2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 /* Enable the selected DAC channel2 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 hdac->Instance->CR |= DAC_CR_DMAEN2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504 /* Case of use of channel 2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505 switch(Alignment)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 case DAC_ALIGN_12B_R:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 /* Get DHR12R2 address */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 tmpreg = (uint32_t)&hdac->Instance->DHR12R2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511 case DAC_ALIGN_12B_L:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512 /* Get DHR12L2 address */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 tmpreg = (uint32_t)&hdac->Instance->DHR12L2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 case DAC_ALIGN_8B_R:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 /* Get DHR8R2 address */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 tmpreg = (uint32_t)&hdac->Instance->DHR8R2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
522 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525 if(Channel == DAC_CHANNEL_1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527 /* Enable the DAC DMA underrun interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531 HAL_DMA_Start_IT(hdac->DMA_Handle1, (uint32_t)pData, tmpreg, Length);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535 /* Enable the DAC DMA underrun interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536 __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539 HAL_DMA_Start_IT(hdac->DMA_Handle2, (uint32_t)pData, tmpreg, Length);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 __HAL_DAC_ENABLE(hdac, Channel);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546 __HAL_UNLOCK(hdac);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
551
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553 * @brief Disables DAC and stop conversion of channel.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556 * @param Channel: The selected DAC channel.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558 * @arg DAC_CHANNEL_1: DAC Channel1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559 * @arg DAC_CHANNEL_2: DAC Channel2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
560 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
561 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
562 HAL_StatusTypeDef HAL_DAC_Stop_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
563 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
564 HAL_StatusTypeDef status = HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
565
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
567 assert_param(IS_DAC_CHANNEL(Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
569 /* Disable the selected DAC channel DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570 hdac->Instance->CR &= ~(DAC_CR_DMAEN1 << Channel);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
571
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
572 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
573 __HAL_DAC_DISABLE(hdac, Channel);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
574
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
575 /* Disable the DMA Channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
576 /* Channel1 is used */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577 if(Channel == DAC_CHANNEL_1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
578 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
579 status = HAL_DMA_Abort(hdac->DMA_Handle1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
580 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
581 else /* Channel2 is used for */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
582 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
583 status = HAL_DMA_Abort(hdac->DMA_Handle2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
584 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
585
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
586 /* Check if DMA Channel effectively disabled */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
587 if(status != HAL_OK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
588 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
589 /* Update DAC state machine to error */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
590 hdac->State = HAL_DAC_STATE_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
591 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
592 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
593 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
594 /* Change DAC state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
595 hdac->State = HAL_DAC_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
596 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
597
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
598 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
599 return status;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
600 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
601
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
602 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
603 * @brief Returns the last data output value of the selected DAC channel.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
604 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
605 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
606 * @param Channel: The selected DAC channel.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
607 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
608 * @arg DAC_CHANNEL_1: DAC Channel1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
609 * @arg DAC_CHANNEL_2: DAC Channel2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
610 * @retval The selected DAC channel data output value.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
611 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
612 uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef* hdac, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
613 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
614 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
615 assert_param(IS_DAC_CHANNEL(Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
616
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
617 /* Returns the DAC channel data output register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
618 if(Channel == DAC_CHANNEL_1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
619 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
620 return hdac->Instance->DOR1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
621 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
622 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
623 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
624 return hdac->Instance->DOR2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
625 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
626 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
627
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
628 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
629 * @brief Handles DAC interrupt request
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
630 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
631 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
632 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
633 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
634 void HAL_DAC_IRQHandler(DAC_HandleTypeDef* hdac)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
635 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
636 /* Check underrun channel 1 flag */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
637 if(__HAL_DAC_GET_FLAG(hdac, DAC_FLAG_DMAUDR1))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
638 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
639 /* Change DAC state to error state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
640 hdac->State = HAL_DAC_STATE_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
641
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
642 /* Set DAC error code to channel1 DMA underrun error */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
643 hdac->ErrorCode |= HAL_DAC_ERROR_DMAUNDERRUNCH1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
644
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
645 /* Clear the underrun flag */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
646 __HAL_DAC_CLEAR_FLAG(hdac,DAC_FLAG_DMAUDR1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
647
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
648 /* Disable the selected DAC channel1 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
649 hdac->Instance->CR &= ~DAC_CR_DMAEN1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
650
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
651 /* Error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
652 HAL_DAC_DMAUnderrunCallbackCh1(hdac);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
653 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
654 /* Check underrun channel 2 flag */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
655 if(__HAL_DAC_GET_FLAG(hdac, DAC_FLAG_DMAUDR2))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
656 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
657 /* Change DAC state to error state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
658 hdac->State = HAL_DAC_STATE_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
659
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
660 /* Set DAC error code to channel2 DMA underrun error */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
661 hdac->ErrorCode |= HAL_DAC_ERROR_DMAUNDERRUNCH2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
662
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
663 /* Clear the underrun flag */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
664 __HAL_DAC_CLEAR_FLAG(hdac,DAC_FLAG_DMAUDR2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
665
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
666 /* Disable the selected DAC channel1 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
667 hdac->Instance->CR &= ~DAC_CR_DMAEN2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
668
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
669 /* Error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
670 HAL_DACEx_DMAUnderrunCallbackCh2(hdac);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
671 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
672 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
673
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
674 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
675 * @brief Conversion complete callback in non blocking mode for Channel1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
676 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
677 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
678 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
679 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
680 __weak void HAL_DAC_ConvCpltCallbackCh1(DAC_HandleTypeDef* hdac)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
681 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
682 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
683 the HAL_DAC_ConvCpltCallback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
684 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
685 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
686
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
687 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
688 * @brief Conversion half DMA transfer callback in non blocking mode for Channel1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
689 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
690 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
691 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
692 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
693 __weak void HAL_DAC_ConvHalfCpltCallbackCh1(DAC_HandleTypeDef* hdac)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
694 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
695 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
696 the HAL_DAC_ConvHalfCpltCallbackCh1 could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
697 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
698 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
699
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
700 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
701 * @brief Error DAC callback for Channel1.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
702 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
703 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
704 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
705 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
706 __weak void HAL_DAC_ErrorCallbackCh1(DAC_HandleTypeDef *hdac)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
707 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
708 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
709 the HAL_DAC_ErrorCallbackCh1 could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
710 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
711 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
712
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
713 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
714 * @brief DMA underrun DAC callback for channel1.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
715 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
716 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
717 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
718 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
719 __weak void HAL_DAC_DMAUnderrunCallbackCh1(DAC_HandleTypeDef *hdac)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
720 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
721 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
722 the HAL_DAC_DMAUnderrunCallbackCh1 could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
723 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
724 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
725
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
726 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
727 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
728 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
729
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
730 /** @defgroup DAC_Exported_Functions_Group3 Peripheral Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
731 * @brief Peripheral Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
732 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
733 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
734 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
735 ##### Peripheral Control functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
736 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
737 [..] This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
738 (+) Configure channels.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
739 (+) Set the specified data holding register value for DAC channel.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
740
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
741 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
742 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
743 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
744
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
745 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
746 * @brief Configures the selected DAC channel.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
747 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
748 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
749 * @param sConfig: DAC configuration structure.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
750 * @param Channel: The selected DAC channel.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
751 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
752 * @arg DAC_CHANNEL_1: DAC Channel1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
753 * @arg DAC_CHANNEL_2: DAC Channel2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
754 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
755 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
756 HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef* hdac, DAC_ChannelConfTypeDef* sConfig, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
757 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
758 uint32_t tmpreg1 = 0, tmpreg2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
759
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
760 /* Check the DAC parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
761 assert_param(IS_DAC_TRIGGER(sConfig->DAC_Trigger));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
762 assert_param(IS_DAC_OUTPUT_BUFFER_STATE(sConfig->DAC_OutputBuffer));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
763 assert_param(IS_DAC_CHANNEL(Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
764
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
765 /* Process locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
766 __HAL_LOCK(hdac);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
767
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
768 /* Change DAC state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
769 hdac->State = HAL_DAC_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
770
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
771 /* Get the DAC CR value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
772 tmpreg1 = hdac->Instance->CR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
773 /* Clear BOFFx, TENx, TSELx, WAVEx and MAMPx bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
774 tmpreg1 &= ~(((uint32_t)(DAC_CR_MAMP1 | DAC_CR_WAVE1 | DAC_CR_TSEL1 | DAC_CR_TEN1 | DAC_CR_BOFF1)) << Channel);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
775 /* Configure for the selected DAC channel: buffer output, trigger */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
776 /* Set TSELx and TENx bits according to DAC_Trigger value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
777 /* Set BOFFx bit according to DAC_OutputBuffer value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
778 tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputBuffer);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
779 /* Calculate CR register value depending on DAC_Channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
780 tmpreg1 |= tmpreg2 << Channel;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
781 /* Write to DAC CR */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
782 hdac->Instance->CR = tmpreg1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
783 /* Disable wave generation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
784 hdac->Instance->CR &= ~(DAC_CR_WAVE1 << Channel);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
785
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
786 /* Change DAC state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
787 hdac->State = HAL_DAC_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
788
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
789 /* Process unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
790 __HAL_UNLOCK(hdac);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
791
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
792 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
793 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
794 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
795
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
796 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
797 * @brief Set the specified data holding register value for DAC channel.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
798 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
799 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
800 * @param Channel: The selected DAC channel.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
801 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
802 * @arg DAC_CHANNEL_1: DAC Channel1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
803 * @arg DAC_CHANNEL_2: DAC Channel2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
804 * @param Alignment: Specifies the data alignment.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
805 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
806 * @arg DAC_ALIGN_8B_R: 8bit right data alignment selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
807 * @arg DAC_ALIGN_12B_L: 12bit left data alignment selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
808 * @arg DAC_ALIGN_12B_R: 12bit right data alignment selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
809 * @param Data: Data to be loaded in the selected data holding register.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
810 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
811 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
812 HAL_StatusTypeDef HAL_DAC_SetValue(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Alignment, uint32_t Data)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
813 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
814 __IO uint32_t tmp = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
815
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
816 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
817 assert_param(IS_DAC_CHANNEL(Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
818 assert_param(IS_DAC_ALIGN(Alignment));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
819 assert_param(IS_DAC_DATA(Data));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
820
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
821 tmp = (uint32_t)hdac->Instance;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
822 if(Channel == DAC_CHANNEL_1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
823 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
824 tmp += DAC_DHR12R1_ALIGNMENT(Alignment);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
825 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
826 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
827 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
828 tmp += DAC_DHR12R2_ALIGNMENT(Alignment);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
829 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
830
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
831 /* Set the DAC channel1 selected data holding register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
832 *(__IO uint32_t *) tmp = Data;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
833
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
834 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
835 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
836 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
837
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
838 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
839 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
840 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
841
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
842 /** @defgroup DAC_Exported_Functions_Group4 Peripheral State and Errors functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
843 * @brief Peripheral State and Errors functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
844 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
845 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
846 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
847 ##### Peripheral State and Errors functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
848 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
849 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
850 This subsection provides functions allowing to
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
851 (+) Check the DAC state.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
852 (+) Check the DAC Errors.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
853
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
854 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
855 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
856 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
857
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
858 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
859 * @brief return the DAC state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
860 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
861 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
862 * @retval HAL state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
863 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
864 HAL_DAC_StateTypeDef HAL_DAC_GetState(DAC_HandleTypeDef* hdac)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
865 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
866 /* Return DAC state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
867 return hdac->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
868 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
869
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
870
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
871 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
872 * @brief Return the DAC error code
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
873 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
874 * the configuration information for the specified DAC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
875 * @retval DAC Error Code
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
876 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
877 uint32_t HAL_DAC_GetError(DAC_HandleTypeDef *hdac)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
878 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
879 return hdac->ErrorCode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
880 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
881
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
882 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
883 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
884 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
885
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
886 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
887 * @brief DMA conversion complete callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
888 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
889 * the configuration information for the specified DMA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
890 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
891 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
892 static void DAC_DMAConvCpltCh1(DMA_HandleTypeDef *hdma)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
893 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
894 DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
895
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
896 HAL_DAC_ConvCpltCallbackCh1(hdac);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
897
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
898 hdac->State= HAL_DAC_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
899 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
900
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
901 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
902 * @brief DMA half transfer complete callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
903 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
904 * the configuration information for the specified DMA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
905 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
906 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
907 static void DAC_DMAHalfConvCpltCh1(DMA_HandleTypeDef *hdma)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
908 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
909 DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
910 /* Conversion complete callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
911 HAL_DAC_ConvHalfCpltCallbackCh1(hdac);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
912 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
913
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
914 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
915 * @brief DMA error callback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
916 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
917 * the configuration information for the specified DMA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
918 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
919 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
920 static void DAC_DMAErrorCh1(DMA_HandleTypeDef *hdma)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
921 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
922 DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
923
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
924 /* Set DAC error code to DMA error */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
925 hdac->ErrorCode |= HAL_DAC_ERROR_DMA;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
926
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
927 HAL_DAC_ErrorCallbackCh1(hdac);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
928
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
929 hdac->State= HAL_DAC_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
930 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
931
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
932 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
933 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
934 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
935 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
936 #endif /* HAL_DAC_MODULE_ENABLED */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
937
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
938 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
939 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
940 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
941
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
942 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
943 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
944 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
945
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
946 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/