TUKS MCU Introductory course / TUKS-COURSE-THERMOMETER

Fork of TUKS-COURSE-TIMER by TUKS MCU Introductory course

Committer:
elmot
Date:
Fri Feb 24 21:13:56 2017 +0000
Revision:
1:d0dfbce63a89
Ready-to-copy

Who changed what in which revision?

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