TEAMUSB / mbed-src

Dependents:   SPI_slave_frdm

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Thu Oct 09 08:15:07 2014 +0100
Revision:
340:28d1f895c6fe
Synchronized with git revision b5a4c8e80393336b2656fb29ab46d405d3068602

Full URL: https://github.com/mbedmicro/mbed/commit/b5a4c8e80393336b2656fb29ab46d405d3068602/

HAL: nrf51822 - Few fixes for PWM and Serial

Who changed what in which revision?

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