inport from local

Dependents:   Hobbyking_Cheetah_0511

Committer:
NYX
Date:
Mon Mar 16 06:35:48 2020 +0000
Revision:
0:85b3fd62ea1a
reinport to mbed;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
NYX 0:85b3fd62ea1a 1 /**
NYX 0:85b3fd62ea1a 2 ******************************************************************************
NYX 0:85b3fd62ea1a 3 * @file stm32f4xx_hal_dac_ex.c
NYX 0:85b3fd62ea1a 4 * @author MCD Application Team
NYX 0:85b3fd62ea1a 5 * @version V1.7.1
NYX 0:85b3fd62ea1a 6 * @date 14-April-2017
NYX 0:85b3fd62ea1a 7 * @brief DAC HAL module driver.
NYX 0:85b3fd62ea1a 8 * This file provides firmware functions to manage the following
NYX 0:85b3fd62ea1a 9 * functionalities of DAC extension peripheral:
NYX 0:85b3fd62ea1a 10 * + Extended features functions
NYX 0:85b3fd62ea1a 11 *
NYX 0:85b3fd62ea1a 12 *
NYX 0:85b3fd62ea1a 13 @verbatim
NYX 0:85b3fd62ea1a 14 ==============================================================================
NYX 0:85b3fd62ea1a 15 ##### How to use this driver #####
NYX 0:85b3fd62ea1a 16 ==============================================================================
NYX 0:85b3fd62ea1a 17 [..]
NYX 0:85b3fd62ea1a 18 (+) When Dual mode is enabled (i.e DAC Channel1 and Channel2 are used simultaneously) :
NYX 0:85b3fd62ea1a 19 Use HAL_DACEx_DualGetValue() to get digital data to be converted and use
NYX 0:85b3fd62ea1a 20 HAL_DACEx_DualSetValue() to set digital value to converted simultaneously in Channel 1 and Channel 2.
NYX 0:85b3fd62ea1a 21 (+) Use HAL_DACEx_TriangleWaveGenerate() to generate Triangle signal.
NYX 0:85b3fd62ea1a 22 (+) Use HAL_DACEx_NoiseWaveGenerate() to generate Noise signal.
NYX 0:85b3fd62ea1a 23
NYX 0:85b3fd62ea1a 24 @endverbatim
NYX 0:85b3fd62ea1a 25 ******************************************************************************
NYX 0:85b3fd62ea1a 26 * @attention
NYX 0:85b3fd62ea1a 27 *
NYX 0:85b3fd62ea1a 28 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
NYX 0:85b3fd62ea1a 29 *
NYX 0:85b3fd62ea1a 30 * Redistribution and use in source and binary forms, with or without modification,
NYX 0:85b3fd62ea1a 31 * are permitted provided that the following conditions are met:
NYX 0:85b3fd62ea1a 32 * 1. Redistributions of source code must retain the above copyright notice,
NYX 0:85b3fd62ea1a 33 * this list of conditions and the following disclaimer.
NYX 0:85b3fd62ea1a 34 * 2. Redistributions in binary form must reproduce the above copyright notice,
NYX 0:85b3fd62ea1a 35 * this list of conditions and the following disclaimer in the documentation
NYX 0:85b3fd62ea1a 36 * and/or other materials provided with the distribution.
NYX 0:85b3fd62ea1a 37 * 3. Neither the name of STMicroelectronics nor the names of its contributors
NYX 0:85b3fd62ea1a 38 * may be used to endorse or promote products derived from this software
NYX 0:85b3fd62ea1a 39 * without specific prior written permission.
NYX 0:85b3fd62ea1a 40 *
NYX 0:85b3fd62ea1a 41 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
NYX 0:85b3fd62ea1a 42 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
NYX 0:85b3fd62ea1a 43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
NYX 0:85b3fd62ea1a 44 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
NYX 0:85b3fd62ea1a 45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
NYX 0:85b3fd62ea1a 46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
NYX 0:85b3fd62ea1a 47 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
NYX 0:85b3fd62ea1a 48 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
NYX 0:85b3fd62ea1a 49 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
NYX 0:85b3fd62ea1a 50 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NYX 0:85b3fd62ea1a 51 *
NYX 0:85b3fd62ea1a 52 ******************************************************************************
NYX 0:85b3fd62ea1a 53 */
NYX 0:85b3fd62ea1a 54
NYX 0:85b3fd62ea1a 55
NYX 0:85b3fd62ea1a 56 /* Includes ------------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 57 #include "stm32f4xx_hal.h"
NYX 0:85b3fd62ea1a 58
NYX 0:85b3fd62ea1a 59 /** @addtogroup STM32F4xx_HAL_Driver
NYX 0:85b3fd62ea1a 60 * @{
NYX 0:85b3fd62ea1a 61 */
NYX 0:85b3fd62ea1a 62
NYX 0:85b3fd62ea1a 63 /** @defgroup DACEx DACEx
NYX 0:85b3fd62ea1a 64 * @brief DAC driver modules
NYX 0:85b3fd62ea1a 65 * @{
NYX 0:85b3fd62ea1a 66 */
NYX 0:85b3fd62ea1a 67
NYX 0:85b3fd62ea1a 68 #ifdef HAL_DAC_MODULE_ENABLED
NYX 0:85b3fd62ea1a 69
NYX 0:85b3fd62ea1a 70 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
NYX 0:85b3fd62ea1a 71 defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
NYX 0:85b3fd62ea1a 72 defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F446xx) ||\
NYX 0:85b3fd62ea1a 73 defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F413xx) || defined(STM32F423xx)
NYX 0:85b3fd62ea1a 74 /* Private typedef -----------------------------------------------------------*/
NYX 0:85b3fd62ea1a 75 /* Private define ------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 76 /* Private macro -------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 77 /* Private variables ---------------------------------------------------------*/
NYX 0:85b3fd62ea1a 78 /* Private function prototypes -----------------------------------------------*/
NYX 0:85b3fd62ea1a 79 /* Private functions ---------------------------------------------------------*/
NYX 0:85b3fd62ea1a 80 /* Exported functions --------------------------------------------------------*/
NYX 0:85b3fd62ea1a 81 /** @defgroup DACEx_Exported_Functions DAC Exported Functions
NYX 0:85b3fd62ea1a 82 * @{
NYX 0:85b3fd62ea1a 83 */
NYX 0:85b3fd62ea1a 84
NYX 0:85b3fd62ea1a 85 /** @defgroup DACEx_Exported_Functions_Group1 Extended features functions
NYX 0:85b3fd62ea1a 86 * @brief Extended features functions
NYX 0:85b3fd62ea1a 87 *
NYX 0:85b3fd62ea1a 88 @verbatim
NYX 0:85b3fd62ea1a 89 ==============================================================================
NYX 0:85b3fd62ea1a 90 ##### Extended features functions #####
NYX 0:85b3fd62ea1a 91 ==============================================================================
NYX 0:85b3fd62ea1a 92 [..] This section provides functions allowing to:
NYX 0:85b3fd62ea1a 93 (+) Start conversion.
NYX 0:85b3fd62ea1a 94 (+) Stop conversion.
NYX 0:85b3fd62ea1a 95 (+) Start conversion and enable DMA transfer.
NYX 0:85b3fd62ea1a 96 (+) Stop conversion and disable DMA transfer.
NYX 0:85b3fd62ea1a 97 (+) Get result of conversion.
NYX 0:85b3fd62ea1a 98 (+) Get result of dual mode conversion.
NYX 0:85b3fd62ea1a 99
NYX 0:85b3fd62ea1a 100 @endverbatim
NYX 0:85b3fd62ea1a 101 * @{
NYX 0:85b3fd62ea1a 102 */
NYX 0:85b3fd62ea1a 103
NYX 0:85b3fd62ea1a 104 /**
NYX 0:85b3fd62ea1a 105 * @brief Returns the last data output value of the selected DAC channel.
NYX 0:85b3fd62ea1a 106 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 107 * the configuration information for the specified DAC.
NYX 0:85b3fd62ea1a 108 * @retval The selected DAC channel data output value.
NYX 0:85b3fd62ea1a 109 */
NYX 0:85b3fd62ea1a 110 uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef* hdac)
NYX 0:85b3fd62ea1a 111 {
NYX 0:85b3fd62ea1a 112 uint32_t tmp = 0U;
NYX 0:85b3fd62ea1a 113
NYX 0:85b3fd62ea1a 114 tmp |= hdac->Instance->DOR1;
NYX 0:85b3fd62ea1a 115
NYX 0:85b3fd62ea1a 116 tmp |= hdac->Instance->DOR2 << 16U;
NYX 0:85b3fd62ea1a 117
NYX 0:85b3fd62ea1a 118 /* Returns the DAC channel data output register value */
NYX 0:85b3fd62ea1a 119 return tmp;
NYX 0:85b3fd62ea1a 120 }
NYX 0:85b3fd62ea1a 121
NYX 0:85b3fd62ea1a 122 /**
NYX 0:85b3fd62ea1a 123 * @brief Enables or disables the selected DAC channel wave generation.
NYX 0:85b3fd62ea1a 124 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 125 * the configuration information for the specified DAC.
NYX 0:85b3fd62ea1a 126 * @param Channel: The selected DAC channel.
NYX 0:85b3fd62ea1a 127 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 128 * DAC_CHANNEL_1 / DAC_CHANNEL_2
NYX 0:85b3fd62ea1a 129 * @param Amplitude: Select max triangle amplitude.
NYX 0:85b3fd62ea1a 130 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 131 * @arg DAC_TRIANGLEAMPLITUDE_1: Select max triangle amplitude of 1
NYX 0:85b3fd62ea1a 132 * @arg DAC_TRIANGLEAMPLITUDE_3: Select max triangle amplitude of 3
NYX 0:85b3fd62ea1a 133 * @arg DAC_TRIANGLEAMPLITUDE_7: Select max triangle amplitude of 7
NYX 0:85b3fd62ea1a 134 * @arg DAC_TRIANGLEAMPLITUDE_15: Select max triangle amplitude of 15
NYX 0:85b3fd62ea1a 135 * @arg DAC_TRIANGLEAMPLITUDE_31: Select max triangle amplitude of 31
NYX 0:85b3fd62ea1a 136 * @arg DAC_TRIANGLEAMPLITUDE_63: Select max triangle amplitude of 63
NYX 0:85b3fd62ea1a 137 * @arg DAC_TRIANGLEAMPLITUDE_127: Select max triangle amplitude of 127
NYX 0:85b3fd62ea1a 138 * @arg DAC_TRIANGLEAMPLITUDE_255: Select max triangle amplitude of 255
NYX 0:85b3fd62ea1a 139 * @arg DAC_TRIANGLEAMPLITUDE_511: Select max triangle amplitude of 511
NYX 0:85b3fd62ea1a 140 * @arg DAC_TRIANGLEAMPLITUDE_1023: Select max triangle amplitude of 1023
NYX 0:85b3fd62ea1a 141 * @arg DAC_TRIANGLEAMPLITUDE_2047: Select max triangle amplitude of 2047
NYX 0:85b3fd62ea1a 142 * @arg DAC_TRIANGLEAMPLITUDE_4095: Select max triangle amplitude of 4095
NYX 0:85b3fd62ea1a 143 * @retval HAL status
NYX 0:85b3fd62ea1a 144 */
NYX 0:85b3fd62ea1a 145 HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude)
NYX 0:85b3fd62ea1a 146 {
NYX 0:85b3fd62ea1a 147 /* Check the parameters */
NYX 0:85b3fd62ea1a 148 assert_param(IS_DAC_CHANNEL(Channel));
NYX 0:85b3fd62ea1a 149 assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude));
NYX 0:85b3fd62ea1a 150
NYX 0:85b3fd62ea1a 151 /* Process locked */
NYX 0:85b3fd62ea1a 152 __HAL_LOCK(hdac);
NYX 0:85b3fd62ea1a 153
NYX 0:85b3fd62ea1a 154 /* Change DAC state */
NYX 0:85b3fd62ea1a 155 hdac->State = HAL_DAC_STATE_BUSY;
NYX 0:85b3fd62ea1a 156
NYX 0:85b3fd62ea1a 157 /* Enable the selected wave generation for the selected DAC channel */
NYX 0:85b3fd62ea1a 158 MODIFY_REG(hdac->Instance->CR, (DAC_CR_WAVE1 | DAC_CR_MAMP1) << Channel, (DAC_CR_WAVE1_1 | Amplitude) << Channel);
NYX 0:85b3fd62ea1a 159
NYX 0:85b3fd62ea1a 160 /* Change DAC state */
NYX 0:85b3fd62ea1a 161 hdac->State = HAL_DAC_STATE_READY;
NYX 0:85b3fd62ea1a 162
NYX 0:85b3fd62ea1a 163 /* Process unlocked */
NYX 0:85b3fd62ea1a 164 __HAL_UNLOCK(hdac);
NYX 0:85b3fd62ea1a 165
NYX 0:85b3fd62ea1a 166 /* Return function status */
NYX 0:85b3fd62ea1a 167 return HAL_OK;
NYX 0:85b3fd62ea1a 168 }
NYX 0:85b3fd62ea1a 169
NYX 0:85b3fd62ea1a 170 /**
NYX 0:85b3fd62ea1a 171 * @brief Enables or disables the selected DAC channel wave generation.
NYX 0:85b3fd62ea1a 172 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 173 * the configuration information for the specified DAC.
NYX 0:85b3fd62ea1a 174 * @param Channel: The selected DAC channel.
NYX 0:85b3fd62ea1a 175 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 176 * DAC_CHANNEL_1 / DAC_CHANNEL_2
NYX 0:85b3fd62ea1a 177 * @param Amplitude: Unmask DAC channel LFSR for noise wave generation.
NYX 0:85b3fd62ea1a 178 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 179 * @arg DAC_LFSRUNMASK_BIT0: Unmask DAC channel LFSR bit0 for noise wave generation
NYX 0:85b3fd62ea1a 180 * @arg DAC_LFSRUNMASK_BITS1_0: Unmask DAC channel LFSR bit[1:0] for noise wave generation
NYX 0:85b3fd62ea1a 181 * @arg DAC_LFSRUNMASK_BITS2_0: Unmask DAC channel LFSR bit[2:0] for noise wave generation
NYX 0:85b3fd62ea1a 182 * @arg DAC_LFSRUNMASK_BITS3_0: Unmask DAC channel LFSR bit[3:0] for noise wave generation
NYX 0:85b3fd62ea1a 183 * @arg DAC_LFSRUNMASK_BITS4_0: Unmask DAC channel LFSR bit[4:0] for noise wave generation
NYX 0:85b3fd62ea1a 184 * @arg DAC_LFSRUNMASK_BITS5_0: Unmask DAC channel LFSR bit[5:0] for noise wave generation
NYX 0:85b3fd62ea1a 185 * @arg DAC_LFSRUNMASK_BITS6_0: Unmask DAC channel LFSR bit[6:0] for noise wave generation
NYX 0:85b3fd62ea1a 186 * @arg DAC_LFSRUNMASK_BITS7_0: Unmask DAC channel LFSR bit[7:0] for noise wave generation
NYX 0:85b3fd62ea1a 187 * @arg DAC_LFSRUNMASK_BITS8_0: Unmask DAC channel LFSR bit[8:0] for noise wave generation
NYX 0:85b3fd62ea1a 188 * @arg DAC_LFSRUNMASK_BITS9_0: Unmask DAC channel LFSR bit[9:0] for noise wave generation
NYX 0:85b3fd62ea1a 189 * @arg DAC_LFSRUNMASK_BITS10_0: Unmask DAC channel LFSR bit[10:0] for noise wave generation
NYX 0:85b3fd62ea1a 190 * @arg DAC_LFSRUNMASK_BITS11_0: Unmask DAC channel LFSR bit[11:0] for noise wave generation
NYX 0:85b3fd62ea1a 191 * @retval HAL status
NYX 0:85b3fd62ea1a 192 */
NYX 0:85b3fd62ea1a 193 HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude)
NYX 0:85b3fd62ea1a 194 {
NYX 0:85b3fd62ea1a 195 /* Check the parameters */
NYX 0:85b3fd62ea1a 196 assert_param(IS_DAC_CHANNEL(Channel));
NYX 0:85b3fd62ea1a 197 assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude));
NYX 0:85b3fd62ea1a 198
NYX 0:85b3fd62ea1a 199 /* Process locked */
NYX 0:85b3fd62ea1a 200 __HAL_LOCK(hdac);
NYX 0:85b3fd62ea1a 201
NYX 0:85b3fd62ea1a 202 /* Change DAC state */
NYX 0:85b3fd62ea1a 203 hdac->State = HAL_DAC_STATE_BUSY;
NYX 0:85b3fd62ea1a 204
NYX 0:85b3fd62ea1a 205 /* Enable the selected wave generation for the selected DAC channel */
NYX 0:85b3fd62ea1a 206 MODIFY_REG(hdac->Instance->CR, (DAC_CR_WAVE1 | DAC_CR_MAMP1) << Channel, (DAC_CR_WAVE1_0 | Amplitude) << Channel);
NYX 0:85b3fd62ea1a 207
NYX 0:85b3fd62ea1a 208 /* Change DAC state */
NYX 0:85b3fd62ea1a 209 hdac->State = HAL_DAC_STATE_READY;
NYX 0:85b3fd62ea1a 210
NYX 0:85b3fd62ea1a 211 /* Process unlocked */
NYX 0:85b3fd62ea1a 212 __HAL_UNLOCK(hdac);
NYX 0:85b3fd62ea1a 213
NYX 0:85b3fd62ea1a 214 /* Return function status */
NYX 0:85b3fd62ea1a 215 return HAL_OK;
NYX 0:85b3fd62ea1a 216 }
NYX 0:85b3fd62ea1a 217
NYX 0:85b3fd62ea1a 218 /**
NYX 0:85b3fd62ea1a 219 * @brief Set the specified data holding register value for dual DAC channel.
NYX 0:85b3fd62ea1a 220 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 221 * the configuration information for the specified DAC.
NYX 0:85b3fd62ea1a 222 * @param Alignment: Specifies the data alignment for dual channel DAC.
NYX 0:85b3fd62ea1a 223 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 224 * DAC_ALIGN_8B_R: 8bit right data alignment selected
NYX 0:85b3fd62ea1a 225 * DAC_ALIGN_12B_L: 12bit left data alignment selected
NYX 0:85b3fd62ea1a 226 * DAC_ALIGN_12B_R: 12bit right data alignment selected
NYX 0:85b3fd62ea1a 227 * @param Data1: Data for DAC Channel2 to be loaded in the selected data holding register.
NYX 0:85b3fd62ea1a 228 * @param Data2: Data for DAC Channel1 to be loaded in the selected data holding register.
NYX 0:85b3fd62ea1a 229 * @note In dual mode, a unique register access is required to write in both
NYX 0:85b3fd62ea1a 230 * DAC channels at the same time.
NYX 0:85b3fd62ea1a 231 * @retval HAL status
NYX 0:85b3fd62ea1a 232 */
NYX 0:85b3fd62ea1a 233 HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef* hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2)
NYX 0:85b3fd62ea1a 234 {
NYX 0:85b3fd62ea1a 235 uint32_t data = 0U, tmp = 0U;
NYX 0:85b3fd62ea1a 236
NYX 0:85b3fd62ea1a 237 /* Check the parameters */
NYX 0:85b3fd62ea1a 238 assert_param(IS_DAC_ALIGN(Alignment));
NYX 0:85b3fd62ea1a 239 assert_param(IS_DAC_DATA(Data1));
NYX 0:85b3fd62ea1a 240 assert_param(IS_DAC_DATA(Data2));
NYX 0:85b3fd62ea1a 241
NYX 0:85b3fd62ea1a 242 /* Calculate and set dual DAC data holding register value */
NYX 0:85b3fd62ea1a 243 if (Alignment == DAC_ALIGN_8B_R)
NYX 0:85b3fd62ea1a 244 {
NYX 0:85b3fd62ea1a 245 data = ((uint32_t)Data2 << 8U) | Data1;
NYX 0:85b3fd62ea1a 246 }
NYX 0:85b3fd62ea1a 247 else
NYX 0:85b3fd62ea1a 248 {
NYX 0:85b3fd62ea1a 249 data = ((uint32_t)Data2 << 16U) | Data1;
NYX 0:85b3fd62ea1a 250 }
NYX 0:85b3fd62ea1a 251
NYX 0:85b3fd62ea1a 252 tmp = (uint32_t)hdac->Instance;
NYX 0:85b3fd62ea1a 253 tmp += DAC_DHR12RD_ALIGNMENT(Alignment);
NYX 0:85b3fd62ea1a 254
NYX 0:85b3fd62ea1a 255 /* Set the dual DAC selected data holding register */
NYX 0:85b3fd62ea1a 256 *(__IO uint32_t *)tmp = data;
NYX 0:85b3fd62ea1a 257
NYX 0:85b3fd62ea1a 258 /* Return function status */
NYX 0:85b3fd62ea1a 259 return HAL_OK;
NYX 0:85b3fd62ea1a 260 }
NYX 0:85b3fd62ea1a 261
NYX 0:85b3fd62ea1a 262 /**
NYX 0:85b3fd62ea1a 263 * @}
NYX 0:85b3fd62ea1a 264 */
NYX 0:85b3fd62ea1a 265
NYX 0:85b3fd62ea1a 266 /**
NYX 0:85b3fd62ea1a 267 * @brief Conversion complete callback in non blocking mode for Channel2
NYX 0:85b3fd62ea1a 268 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 269 * the configuration information for the specified DAC.
NYX 0:85b3fd62ea1a 270 * @retval None
NYX 0:85b3fd62ea1a 271 */
NYX 0:85b3fd62ea1a 272 __weak void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef* hdac)
NYX 0:85b3fd62ea1a 273 {
NYX 0:85b3fd62ea1a 274 /* Prevent unused argument(s) compilation warning */
NYX 0:85b3fd62ea1a 275 UNUSED(hdac);
NYX 0:85b3fd62ea1a 276 /* NOTE : This function Should not be modified, when the callback is needed,
NYX 0:85b3fd62ea1a 277 the HAL_DAC_ConvCpltCallback could be implemented in the user file
NYX 0:85b3fd62ea1a 278 */
NYX 0:85b3fd62ea1a 279 }
NYX 0:85b3fd62ea1a 280
NYX 0:85b3fd62ea1a 281 /**
NYX 0:85b3fd62ea1a 282 * @brief Conversion half DMA transfer callback in non blocking mode for Channel2
NYX 0:85b3fd62ea1a 283 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 284 * the configuration information for the specified DAC.
NYX 0:85b3fd62ea1a 285 * @retval None
NYX 0:85b3fd62ea1a 286 */
NYX 0:85b3fd62ea1a 287 __weak void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef* hdac)
NYX 0:85b3fd62ea1a 288 {
NYX 0:85b3fd62ea1a 289 /* Prevent unused argument(s) compilation warning */
NYX 0:85b3fd62ea1a 290 UNUSED(hdac);
NYX 0:85b3fd62ea1a 291 /* NOTE : This function Should not be modified, when the callback is needed,
NYX 0:85b3fd62ea1a 292 the HAL_DAC_ConvHalfCpltCallbackCh2 could be implemented in the user file
NYX 0:85b3fd62ea1a 293 */
NYX 0:85b3fd62ea1a 294 }
NYX 0:85b3fd62ea1a 295
NYX 0:85b3fd62ea1a 296 /**
NYX 0:85b3fd62ea1a 297 * @brief Error DAC callback for Channel2.
NYX 0:85b3fd62ea1a 298 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 299 * the configuration information for the specified DAC.
NYX 0:85b3fd62ea1a 300 * @retval None
NYX 0:85b3fd62ea1a 301 */
NYX 0:85b3fd62ea1a 302 __weak void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef *hdac)
NYX 0:85b3fd62ea1a 303 {
NYX 0:85b3fd62ea1a 304 /* Prevent unused argument(s) compilation warning */
NYX 0:85b3fd62ea1a 305 UNUSED(hdac);
NYX 0:85b3fd62ea1a 306 /* NOTE : This function Should not be modified, when the callback is needed,
NYX 0:85b3fd62ea1a 307 the HAL_DAC_ErrorCallback could be implemented in the user file
NYX 0:85b3fd62ea1a 308 */
NYX 0:85b3fd62ea1a 309 }
NYX 0:85b3fd62ea1a 310
NYX 0:85b3fd62ea1a 311 /**
NYX 0:85b3fd62ea1a 312 * @brief DMA underrun DAC callback for channel2.
NYX 0:85b3fd62ea1a 313 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 314 * the configuration information for the specified DAC.
NYX 0:85b3fd62ea1a 315 * @retval None
NYX 0:85b3fd62ea1a 316 */
NYX 0:85b3fd62ea1a 317 __weak void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef *hdac)
NYX 0:85b3fd62ea1a 318 {
NYX 0:85b3fd62ea1a 319 /* Prevent unused argument(s) compilation warning */
NYX 0:85b3fd62ea1a 320 UNUSED(hdac);
NYX 0:85b3fd62ea1a 321 /* NOTE : This function Should not be modified, when the callback is needed,
NYX 0:85b3fd62ea1a 322 the HAL_DAC_DMAUnderrunCallbackCh2 could be implemented in the user file
NYX 0:85b3fd62ea1a 323 */
NYX 0:85b3fd62ea1a 324 }
NYX 0:85b3fd62ea1a 325
NYX 0:85b3fd62ea1a 326 /**
NYX 0:85b3fd62ea1a 327 * @brief DMA conversion complete callback.
NYX 0:85b3fd62ea1a 328 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 329 * the configuration information for the specified DMA module.
NYX 0:85b3fd62ea1a 330 * @retval None
NYX 0:85b3fd62ea1a 331 */
NYX 0:85b3fd62ea1a 332 void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma)
NYX 0:85b3fd62ea1a 333 {
NYX 0:85b3fd62ea1a 334 DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
NYX 0:85b3fd62ea1a 335
NYX 0:85b3fd62ea1a 336 HAL_DACEx_ConvCpltCallbackCh2(hdac);
NYX 0:85b3fd62ea1a 337
NYX 0:85b3fd62ea1a 338 hdac->State= HAL_DAC_STATE_READY;
NYX 0:85b3fd62ea1a 339 }
NYX 0:85b3fd62ea1a 340
NYX 0:85b3fd62ea1a 341 /**
NYX 0:85b3fd62ea1a 342 * @brief DMA half transfer complete callback.
NYX 0:85b3fd62ea1a 343 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 344 * the configuration information for the specified DMA module.
NYX 0:85b3fd62ea1a 345 * @retval None
NYX 0:85b3fd62ea1a 346 */
NYX 0:85b3fd62ea1a 347 void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma)
NYX 0:85b3fd62ea1a 348 {
NYX 0:85b3fd62ea1a 349 DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
NYX 0:85b3fd62ea1a 350 /* Conversion complete callback */
NYX 0:85b3fd62ea1a 351 HAL_DACEx_ConvHalfCpltCallbackCh2(hdac);
NYX 0:85b3fd62ea1a 352 }
NYX 0:85b3fd62ea1a 353
NYX 0:85b3fd62ea1a 354 /**
NYX 0:85b3fd62ea1a 355 * @brief DMA error callback
NYX 0:85b3fd62ea1a 356 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 357 * the configuration information for the specified DMA module.
NYX 0:85b3fd62ea1a 358 * @retval None
NYX 0:85b3fd62ea1a 359 */
NYX 0:85b3fd62ea1a 360 void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma)
NYX 0:85b3fd62ea1a 361 {
NYX 0:85b3fd62ea1a 362 DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
NYX 0:85b3fd62ea1a 363
NYX 0:85b3fd62ea1a 364 /* Set DAC error code to DMA error */
NYX 0:85b3fd62ea1a 365 hdac->ErrorCode |= HAL_DAC_ERROR_DMA;
NYX 0:85b3fd62ea1a 366
NYX 0:85b3fd62ea1a 367 HAL_DACEx_ErrorCallbackCh2(hdac);
NYX 0:85b3fd62ea1a 368
NYX 0:85b3fd62ea1a 369 hdac->State= HAL_DAC_STATE_READY;
NYX 0:85b3fd62ea1a 370 }
NYX 0:85b3fd62ea1a 371
NYX 0:85b3fd62ea1a 372 /**
NYX 0:85b3fd62ea1a 373 * @}
NYX 0:85b3fd62ea1a 374 */
NYX 0:85b3fd62ea1a 375
NYX 0:85b3fd62ea1a 376 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx ||\
NYX 0:85b3fd62ea1a 377 STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||\
NYX 0:85b3fd62ea1a 378 STM32F410xx || STM32F446xx || STM32F469xx || STM32F479xx ||\
NYX 0:85b3fd62ea1a 379 STM32F413xx || STM32F423xx */
NYX 0:85b3fd62ea1a 380
NYX 0:85b3fd62ea1a 381 #endif /* HAL_DAC_MODULE_ENABLED */
NYX 0:85b3fd62ea1a 382
NYX 0:85b3fd62ea1a 383 /**
NYX 0:85b3fd62ea1a 384 * @}
NYX 0:85b3fd62ea1a 385 */
NYX 0:85b3fd62ea1a 386
NYX 0:85b3fd62ea1a 387 /**
NYX 0:85b3fd62ea1a 388 * @}
NYX 0:85b3fd62ea1a 389 */
NYX 0:85b3fd62ea1a 390
NYX 0:85b3fd62ea1a 391 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/