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