mbed library sources

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Tue Jun 24 14:45:08 2014 +0100
Revision:
237:f3da66175598
Child:
375:3d36234a1087
Synchronized with git revision 8ef659bca81f12dfc896b5a7af7c2abbd1a1b8b7

Full URL: https://github.com/mbedmicro/mbed/commit/8ef659bca81f12dfc896b5a7af7c2abbd1a1b8b7/

[NUCLEO_F334R8] Add platform files

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 237:f3da66175598 1 /**
mbed_official 237:f3da66175598 2 ******************************************************************************
mbed_official 237:f3da66175598 3 * @file stm32f3xx_hal_dac_ex.c
mbed_official 237:f3da66175598 4 * @author MCD Application Team
mbed_official 237:f3da66175598 5 * @version V1.0.1
mbed_official 237:f3da66175598 6 * @date 18-June-2014
mbed_official 237:f3da66175598 7 * @brief Extended DAC HAL module driver.
mbed_official 237:f3da66175598 8 *
mbed_official 237:f3da66175598 9 * This file provides firmware functions to manage the following
mbed_official 237:f3da66175598 10 * functionalities of the Power Controller (DAC) peripheral:
mbed_official 237:f3da66175598 11 * + Initialization and de-initialization functions
mbed_official 237:f3da66175598 12 * + Peripheral Control functions
mbed_official 237:f3da66175598 13 @verbatim
mbed_official 237:f3da66175598 14
mbed_official 237:f3da66175598 15 @endverbatim
mbed_official 237:f3da66175598 16 ******************************************************************************
mbed_official 237:f3da66175598 17 * @attention
mbed_official 237:f3da66175598 18 *
mbed_official 237:f3da66175598 19 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 237:f3da66175598 20 *
mbed_official 237:f3da66175598 21 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 237:f3da66175598 22 * are permitted provided that the following conditions are met:
mbed_official 237:f3da66175598 23 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 237:f3da66175598 24 * this list of conditions and the following disclaimer.
mbed_official 237:f3da66175598 25 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 237:f3da66175598 26 * this list of conditions and the following disclaimer in the documentation
mbed_official 237:f3da66175598 27 * and/or other materials provided with the distribution.
mbed_official 237:f3da66175598 28 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 237:f3da66175598 29 * may be used to endorse or promote products derived from this software
mbed_official 237:f3da66175598 30 * without specific prior written permission.
mbed_official 237:f3da66175598 31 *
mbed_official 237:f3da66175598 32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 237:f3da66175598 33 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 237:f3da66175598 34 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 237:f3da66175598 35 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 237:f3da66175598 36 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 237:f3da66175598 37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 237:f3da66175598 38 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 237:f3da66175598 39 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 237:f3da66175598 40 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 237:f3da66175598 41 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 237:f3da66175598 42 *
mbed_official 237:f3da66175598 43 ******************************************************************************
mbed_official 237:f3da66175598 44 */
mbed_official 237:f3da66175598 45
mbed_official 237:f3da66175598 46 /* Includes ------------------------------------------------------------------*/
mbed_official 237:f3da66175598 47 #include "stm32f3xx_hal.h"
mbed_official 237:f3da66175598 48
mbed_official 237:f3da66175598 49 /** @addtogroup STM32F3xx_HAL_Driver
mbed_official 237:f3da66175598 50 * @{
mbed_official 237:f3da66175598 51 */
mbed_official 237:f3da66175598 52
mbed_official 237:f3da66175598 53 /** @addtogroup DAC
mbed_official 237:f3da66175598 54 * @brief DAC HAL module driver
mbed_official 237:f3da66175598 55 * @{
mbed_official 237:f3da66175598 56 */
mbed_official 237:f3da66175598 57
mbed_official 237:f3da66175598 58 #ifdef HAL_DAC_MODULE_ENABLED
mbed_official 237:f3da66175598 59
mbed_official 237:f3da66175598 60 /* Private typedef -----------------------------------------------------------*/
mbed_official 237:f3da66175598 61 /* Private define ------------------------------------------------------------*/
mbed_official 237:f3da66175598 62 /* Private macro -------------------------------------------------------------*/
mbed_official 237:f3da66175598 63 /* Private variables ---------------------------------------------------------*/
mbed_official 237:f3da66175598 64 /* Private function prototypes -----------------------------------------------*/
mbed_official 237:f3da66175598 65
mbed_official 237:f3da66175598 66 static void DAC_DMAConvCpltCh1(DMA_HandleTypeDef *hdma);
mbed_official 237:f3da66175598 67 static void DAC_DMAErrorCh1(DMA_HandleTypeDef *hdma);
mbed_official 237:f3da66175598 68 static void DAC_DMAHalfConvCpltCh1(DMA_HandleTypeDef *hdma);
mbed_official 237:f3da66175598 69
mbed_official 237:f3da66175598 70 #if defined(STM32F303xC) || defined(STM32F358xx) || defined(STM32F303x8) || defined(STM32F328xx) || defined(STM32F334x8) || defined(STM32F373xC) || defined(STM32F378xx)
mbed_official 237:f3da66175598 71 /* DAC channel 2 is available on top of DAC channel 1 */
mbed_official 237:f3da66175598 72 static void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma);
mbed_official 237:f3da66175598 73 static void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma);
mbed_official 237:f3da66175598 74 static void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma);
mbed_official 237:f3da66175598 75 #endif /* STM32F303xC STM32F358xx STM32F303x8 STM32F328xx STM32F302xC STM32F334x8 STM32F373xC STM32F378xx */
mbed_official 237:f3da66175598 76
mbed_official 237:f3da66175598 77 /* Private functions ---------------------------------------------------------*/
mbed_official 237:f3da66175598 78
mbed_official 237:f3da66175598 79 /** @addtogroup DAC_Private_Functions
mbed_official 237:f3da66175598 80 * @{
mbed_official 237:f3da66175598 81 */
mbed_official 237:f3da66175598 82
mbed_official 237:f3da66175598 83 /** @defgroup DAC_Group3 Peripheral Control functions
mbed_official 237:f3da66175598 84 * @brief Peripheral Control functions
mbed_official 237:f3da66175598 85 *
mbed_official 237:f3da66175598 86 @verbatim
mbed_official 237:f3da66175598 87 ==============================================================================
mbed_official 237:f3da66175598 88 ##### Peripheral Control functions #####
mbed_official 237:f3da66175598 89 ==============================================================================
mbed_official 237:f3da66175598 90 [..] This section provides functions allowing to:
mbed_official 237:f3da66175598 91 (+) Set the specified data holding register value for DAC channel.
mbed_official 237:f3da66175598 92
mbed_official 237:f3da66175598 93 @endverbatim
mbed_official 237:f3da66175598 94 * @{
mbed_official 237:f3da66175598 95 */
mbed_official 237:f3da66175598 96
mbed_official 237:f3da66175598 97 /**
mbed_official 237:f3da66175598 98 * @brief Set the specified data holding register value for DAC channel.
mbed_official 237:f3da66175598 99 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 100 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 101 * @param channel: The selected DAC channel.
mbed_official 237:f3da66175598 102 * @param alignment: Specifies the data alignment for DAC channel.
mbed_official 237:f3da66175598 103 * This parameter can be one of the following values:
mbed_official 237:f3da66175598 104 * @arg DAC_ALIGN_8B_R: 8bit right data alignment selected
mbed_official 237:f3da66175598 105 * @arg DAC_ALIGN_12B_L: 12bit left data alignment selected
mbed_official 237:f3da66175598 106 * @arg DAC_ALIGN_12B_R: 12bit right data alignment selected
mbed_official 237:f3da66175598 107 * @param data: Data to be loaded in the selected data holding register.
mbed_official 237:f3da66175598 108 * @retval HAL status
mbed_official 237:f3da66175598 109 */
mbed_official 237:f3da66175598 110 HAL_StatusTypeDef HAL_DAC_SetValue(DAC_HandleTypeDef* hdac, uint32_t channel, uint32_t alignment, uint32_t data)
mbed_official 237:f3da66175598 111 {
mbed_official 237:f3da66175598 112 __IO uint32_t tmp = 0;
mbed_official 237:f3da66175598 113
mbed_official 237:f3da66175598 114 /* Check the parameters */
mbed_official 237:f3da66175598 115 assert_param(IS_DAC_CHANNEL(channel));
mbed_official 237:f3da66175598 116 assert_param(IS_DAC_ALIGN(alignment));
mbed_official 237:f3da66175598 117 assert_param(IS_DAC_DATA(data));
mbed_official 237:f3da66175598 118
mbed_official 237:f3da66175598 119 tmp = (uint32_t) (hdac->Instance);
mbed_official 237:f3da66175598 120
mbed_official 237:f3da66175598 121 /* DAC 1 has 1 or 2 channels - no DAC2 */
mbed_official 237:f3da66175598 122 #if defined(STM32F302xC) || defined(STM32F302x8) || defined(STM32F301x8) || defined(STM32F318xx) || defined(STM32F303xC) || defined(STM32F358xx) || defined(STM32F328xx) || \
mbed_official 237:f3da66175598 123 defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F373xC) || defined(STM32F378xx)
mbed_official 237:f3da66175598 124 /* DAC 1 has 2 channels 1 & 2 - DAC 2 has one channel 1 */
mbed_official 237:f3da66175598 125
mbed_official 237:f3da66175598 126 if(channel == DAC_CHANNEL_1)
mbed_official 237:f3da66175598 127 {
mbed_official 237:f3da66175598 128 tmp += __HAL_DHR12R1_ALIGNEMENT(alignment);
mbed_official 237:f3da66175598 129 }
mbed_official 237:f3da66175598 130
mbed_official 237:f3da66175598 131 #endif
mbed_official 237:f3da66175598 132
mbed_official 237:f3da66175598 133 else /* channel = DAC_CHANNEL_2 */
mbed_official 237:f3da66175598 134 {
mbed_official 237:f3da66175598 135 tmp += __HAL_DHR12R2_ALIGNEMENT(alignment);
mbed_official 237:f3da66175598 136 }
mbed_official 237:f3da66175598 137
mbed_official 237:f3da66175598 138 /* Set the DAC channel1 selected data holding register */
mbed_official 237:f3da66175598 139 *(__IO uint32_t *) tmp = data;
mbed_official 237:f3da66175598 140
mbed_official 237:f3da66175598 141 /* Return function status */
mbed_official 237:f3da66175598 142 return HAL_OK;
mbed_official 237:f3da66175598 143 }
mbed_official 237:f3da66175598 144
mbed_official 237:f3da66175598 145 /**
mbed_official 237:f3da66175598 146 * @}
mbed_official 237:f3da66175598 147 */
mbed_official 237:f3da66175598 148
mbed_official 237:f3da66175598 149 /** @defgroup DAC_Group2 IO operation functions
mbed_official 237:f3da66175598 150 * @brief IO operation functions
mbed_official 237:f3da66175598 151 *
mbed_official 237:f3da66175598 152 @verbatim
mbed_official 237:f3da66175598 153 ==============================================================================
mbed_official 237:f3da66175598 154 ##### IO operation functions #####
mbed_official 237:f3da66175598 155 ==============================================================================
mbed_official 237:f3da66175598 156 [..] This section provides functions allowing to:
mbed_official 237:f3da66175598 157 (+) Start conversion.
mbed_official 237:f3da66175598 158 (+) Stop conversion.
mbed_official 237:f3da66175598 159 (+) Start conversion and enable DMA transfer.
mbed_official 237:f3da66175598 160 (+) Stop conversion and disable DMA transfer.
mbed_official 237:f3da66175598 161 (+) Get result of conversion.
mbed_official 237:f3da66175598 162
mbed_official 237:f3da66175598 163 @endverbatim
mbed_official 237:f3da66175598 164 * @{
mbed_official 237:f3da66175598 165 */
mbed_official 237:f3da66175598 166
mbed_official 237:f3da66175598 167 /* DAC 1 has 2 channels 1 & 2 - DAC 2 has one channel 1 */
mbed_official 237:f3da66175598 168 #if defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F373xC) || defined(STM32F378xx) || \
mbed_official 237:f3da66175598 169 defined(STM32F303xC) || defined(STM32F358xx)
mbed_official 237:f3da66175598 170 /* DAC 1 has 2 channels 1 & 2 */
mbed_official 237:f3da66175598 171
mbed_official 237:f3da66175598 172 /**
mbed_official 237:f3da66175598 173 * @brief Enables DAC and starts conversion of channel.
mbed_official 237:f3da66175598 174 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 175 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 176 * @param channel: The selected DAC channel.
mbed_official 237:f3da66175598 177 * This parameter can be one of the following values:
mbed_official 237:f3da66175598 178 * @arg DAC_CHANNEL_1: DAC1 Channel1 or DAC2 Channel1 selected
mbed_official 237:f3da66175598 179 * @arg DAC_CHANNEL_2: DAC1 Channel2 selected
mbed_official 237:f3da66175598 180 * @retval HAL status
mbed_official 237:f3da66175598 181 */
mbed_official 237:f3da66175598 182
mbed_official 237:f3da66175598 183 /**
mbed_official 237:f3da66175598 184 * @brief Enables DAC and starts conversion of channel.
mbed_official 237:f3da66175598 185 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 186 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 187 * @param channel: The selected DAC channel.
mbed_official 237:f3da66175598 188 * This parameter can be one of the following values:
mbed_official 237:f3da66175598 189 * @arg DAC_CHANNEL_1: DAC1 Channel1 selected
mbed_official 237:f3da66175598 190 * @arg DAC_CHANNEL_2: DAC1 Channel2 selected
mbed_official 237:f3da66175598 191 * @retval HAL status
mbed_official 237:f3da66175598 192 */
mbed_official 237:f3da66175598 193 HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef* hdac, uint32_t channel)
mbed_official 237:f3da66175598 194 {
mbed_official 237:f3da66175598 195 /* Check the parameters */
mbed_official 237:f3da66175598 196 assert_param(IS_DAC_CHANNEL_INSTANCE(hdac->Instance, channel));
mbed_official 237:f3da66175598 197
mbed_official 237:f3da66175598 198 /* Process locked */
mbed_official 237:f3da66175598 199 __HAL_LOCK(hdac);
mbed_official 237:f3da66175598 200
mbed_official 237:f3da66175598 201 /* Change DAC state */
mbed_official 237:f3da66175598 202 hdac->State = HAL_DAC_STATE_BUSY;
mbed_official 237:f3da66175598 203
mbed_official 237:f3da66175598 204 /* Enable the Peripharal */
mbed_official 237:f3da66175598 205 __HAL_DAC_ENABLE(hdac, channel);
mbed_official 237:f3da66175598 206
mbed_official 237:f3da66175598 207 if(channel == DAC_CHANNEL_1)
mbed_official 237:f3da66175598 208 {
mbed_official 237:f3da66175598 209 /* Check if software trigger enabled */
mbed_official 237:f3da66175598 210 if(((hdac->Instance->CR & DAC_CR_TEN1) == DAC_CR_TEN1) && ((hdac->Instance->CR & DAC_CR_TSEL1) == DAC_CR_TSEL1))
mbed_official 237:f3da66175598 211 {
mbed_official 237:f3da66175598 212 /* Enable the selected DAC software conversion */
mbed_official 237:f3da66175598 213 hdac->Instance->SWTRIGR |= (uint32_t)DAC_SWTRIGR_SWTRIG1;
mbed_official 237:f3da66175598 214 }
mbed_official 237:f3da66175598 215 }
mbed_official 237:f3da66175598 216 else
mbed_official 237:f3da66175598 217 {
mbed_official 237:f3da66175598 218 /* Check if software trigger enabled */
mbed_official 237:f3da66175598 219 if(((hdac->Instance->CR & DAC_CR_TEN2) == DAC_CR_TEN2) && ((hdac->Instance->CR & DAC_CR_TSEL2) == DAC_CR_TSEL2))
mbed_official 237:f3da66175598 220 {
mbed_official 237:f3da66175598 221 /* Enable the selected DAC software conversion*/
mbed_official 237:f3da66175598 222 hdac->Instance->SWTRIGR |= (uint32_t)DAC_SWTRIGR_SWTRIG2;
mbed_official 237:f3da66175598 223 }
mbed_official 237:f3da66175598 224 }
mbed_official 237:f3da66175598 225
mbed_official 237:f3da66175598 226 /* Change DAC state */
mbed_official 237:f3da66175598 227 hdac->State = HAL_DAC_STATE_READY;
mbed_official 237:f3da66175598 228
mbed_official 237:f3da66175598 229 /* Process unlocked */
mbed_official 237:f3da66175598 230 __HAL_UNLOCK(hdac);
mbed_official 237:f3da66175598 231
mbed_official 237:f3da66175598 232 /* Return function status */
mbed_official 237:f3da66175598 233 return HAL_OK;
mbed_official 237:f3da66175598 234 }
mbed_official 237:f3da66175598 235 #endif
mbed_official 237:f3da66175598 236
mbed_official 237:f3da66175598 237 #if defined(STM32F302xC) || defined(STM32F302x8) || defined(STM32F301x8) || defined(STM32F318xx)
mbed_official 237:f3da66175598 238 /* DAC 1 has 1 channels 1 */
mbed_official 237:f3da66175598 239 HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef* hdac, uint32_t channel)
mbed_official 237:f3da66175598 240 {
mbed_official 237:f3da66175598 241 /* Check the parameters */
mbed_official 237:f3da66175598 242 assert_param(IS_DAC_CHANNEL_INSTANCE(hdac->Instance, channel));
mbed_official 237:f3da66175598 243
mbed_official 237:f3da66175598 244 /* Process locked */
mbed_official 237:f3da66175598 245 __HAL_LOCK(hdac);
mbed_official 237:f3da66175598 246
mbed_official 237:f3da66175598 247 /* Change DAC state */
mbed_official 237:f3da66175598 248 hdac->State = HAL_DAC_STATE_BUSY;
mbed_official 237:f3da66175598 249
mbed_official 237:f3da66175598 250 /* Enable the Peripharal */
mbed_official 237:f3da66175598 251 __HAL_DAC_ENABLE(hdac, channel);
mbed_official 237:f3da66175598 252
mbed_official 237:f3da66175598 253 /* Check if software trigger enabled */
mbed_official 237:f3da66175598 254 if(((hdac->Instance->CR & DAC_CR_TEN1) == DAC_CR_TEN1) && ((hdac->Instance->CR & DAC_CR_TSEL1) == DAC_CR_TSEL1))
mbed_official 237:f3da66175598 255 {
mbed_official 237:f3da66175598 256 /* Enable the selected DAC software conversion */
mbed_official 237:f3da66175598 257 hdac->Instance->SWTRIGR |= (uint32_t)DAC_SWTRIGR_SWTRIG1;
mbed_official 237:f3da66175598 258 }
mbed_official 237:f3da66175598 259
mbed_official 237:f3da66175598 260 /* Change DAC state */
mbed_official 237:f3da66175598 261 hdac->State = HAL_DAC_STATE_READY;
mbed_official 237:f3da66175598 262
mbed_official 237:f3da66175598 263 /* Process unlocked */
mbed_official 237:f3da66175598 264 __HAL_UNLOCK(hdac);
mbed_official 237:f3da66175598 265
mbed_official 237:f3da66175598 266 /* Return function status */
mbed_official 237:f3da66175598 267 return HAL_OK;
mbed_official 237:f3da66175598 268 }
mbed_official 237:f3da66175598 269 #endif
mbed_official 237:f3da66175598 270
mbed_official 237:f3da66175598 271 /* DAC 1 has 2 channels 1 & 2 - DAC 2 has one channel 1 */
mbed_official 237:f3da66175598 272 #if defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F373xC) || defined(STM32F378xx) || defined(STM32F328xx) || \
mbed_official 237:f3da66175598 273 defined(STM32F303xC) || defined(STM32F358xx)
mbed_official 237:f3da66175598 274 /* DAC 1 has 2 channels 1 & 2 */
mbed_official 237:f3da66175598 275
mbed_official 237:f3da66175598 276 /**
mbed_official 237:f3da66175598 277 * @brief Enables DAC and starts conversion of channel.
mbed_official 237:f3da66175598 278 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 279 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 280 * @param channel: The selected DAC channel.
mbed_official 237:f3da66175598 281 * This parameter can be one of the following values:
mbed_official 237:f3da66175598 282 * @arg DAC_CHANNEL_1: DAC1 Channel1 selected
mbed_official 237:f3da66175598 283 * @arg DAC_CHANNEL_2: DAC1 Channel2 selected
mbed_official 237:f3da66175598 284 * @param pData: The destination peripheral Buffer address.
mbed_official 237:f3da66175598 285 * @param Length: The length of data to be transferred from memory to DAC peripheral
mbed_official 237:f3da66175598 286 * @param alignment: Specifies the data alignment for DAC channel.
mbed_official 237:f3da66175598 287 * This parameter can be one of the following values:
mbed_official 237:f3da66175598 288 * @arg DAC_Align_8b_R: 8bit right data alignment selected
mbed_official 237:f3da66175598 289 * @arg DAC_Align_12b_L: 12bit left data alignment selected
mbed_official 237:f3da66175598 290 * @arg DAC_Align_12b_R: 12bit right data alignment selected
mbed_official 237:f3da66175598 291 * @retval HAL status
mbed_official 237:f3da66175598 292 */
mbed_official 237:f3da66175598 293
mbed_official 237:f3da66175598 294 HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t channel, uint32_t* pData, uint32_t Length, uint32_t alignment)
mbed_official 237:f3da66175598 295 {
mbed_official 237:f3da66175598 296 uint32_t tmpreg = 0;
mbed_official 237:f3da66175598 297
mbed_official 237:f3da66175598 298 /* Check the parameters */
mbed_official 237:f3da66175598 299 assert_param(IS_DAC_CHANNEL_INSTANCE(hdac->Instance, channel));
mbed_official 237:f3da66175598 300 assert_param(IS_DAC_ALIGN(alignment));
mbed_official 237:f3da66175598 301
mbed_official 237:f3da66175598 302 /* Process locked */
mbed_official 237:f3da66175598 303 __HAL_LOCK(hdac);
mbed_official 237:f3da66175598 304
mbed_official 237:f3da66175598 305 /* Change DAC state */
mbed_official 237:f3da66175598 306 hdac->State = HAL_DAC_STATE_BUSY;
mbed_official 237:f3da66175598 307
mbed_official 237:f3da66175598 308 if(channel == DAC_CHANNEL_1)
mbed_official 237:f3da66175598 309 {
mbed_official 237:f3da66175598 310 /* Set the DMA transfer complete callback for channel1 */
mbed_official 237:f3da66175598 311 hdac->DMA_Handle1->XferCpltCallback = DAC_DMAConvCpltCh1;
mbed_official 237:f3da66175598 312
mbed_official 237:f3da66175598 313 /* Set the DMA half transfer complete callback for channel1 */
mbed_official 237:f3da66175598 314 hdac->DMA_Handle1->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh1;
mbed_official 237:f3da66175598 315
mbed_official 237:f3da66175598 316 /* Set the DMA error callback for channel1 */
mbed_official 237:f3da66175598 317 hdac->DMA_Handle1->XferErrorCallback = DAC_DMAErrorCh1;
mbed_official 237:f3da66175598 318 }
mbed_official 237:f3da66175598 319 else
mbed_official 237:f3da66175598 320 {
mbed_official 237:f3da66175598 321 /* Set the DMA transfer complete callback for channel2 */
mbed_official 237:f3da66175598 322 hdac->DMA_Handle2->XferCpltCallback = DAC_DMAConvCpltCh2;
mbed_official 237:f3da66175598 323
mbed_official 237:f3da66175598 324 /* Set the DMA half transfer complete callback for channel2 */
mbed_official 237:f3da66175598 325 hdac->DMA_Handle2->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh2;
mbed_official 237:f3da66175598 326
mbed_official 237:f3da66175598 327 /* Set the DMA error callback for channel2 */
mbed_official 237:f3da66175598 328 hdac->DMA_Handle2->XferErrorCallback = DAC_DMAErrorCh2;
mbed_official 237:f3da66175598 329 }
mbed_official 237:f3da66175598 330
mbed_official 237:f3da66175598 331 if(channel == DAC_CHANNEL_1)
mbed_official 237:f3da66175598 332 {
mbed_official 237:f3da66175598 333 /* Enable the selected DAC channel1 DMA request */
mbed_official 237:f3da66175598 334 hdac->Instance->CR |= DAC_CR_DMAEN1;
mbed_official 237:f3da66175598 335
mbed_official 237:f3da66175598 336 /* Case of use of channel 1 */
mbed_official 237:f3da66175598 337 switch(alignment)
mbed_official 237:f3da66175598 338 {
mbed_official 237:f3da66175598 339 case DAC_ALIGN_12B_R:
mbed_official 237:f3da66175598 340 /* Get DHR12R1 address */
mbed_official 237:f3da66175598 341 tmpreg = (uint32_t)&hdac->Instance->DHR12R1;
mbed_official 237:f3da66175598 342 break;
mbed_official 237:f3da66175598 343 case DAC_ALIGN_12B_L:
mbed_official 237:f3da66175598 344 /* Get DHR12L1 address */
mbed_official 237:f3da66175598 345 tmpreg = (uint32_t)&hdac->Instance->DHR12L1;
mbed_official 237:f3da66175598 346 break;
mbed_official 237:f3da66175598 347 case DAC_ALIGN_8B_R:
mbed_official 237:f3da66175598 348 /* Get DHR8R1 address */
mbed_official 237:f3da66175598 349 tmpreg = (uint32_t)&hdac->Instance->DHR8R1;
mbed_official 237:f3da66175598 350 break;
mbed_official 237:f3da66175598 351 default:
mbed_official 237:f3da66175598 352 break;
mbed_official 237:f3da66175598 353 }
mbed_official 237:f3da66175598 354 }
mbed_official 237:f3da66175598 355 else
mbed_official 237:f3da66175598 356 {
mbed_official 237:f3da66175598 357 /* Enable the selected DAC channel2 DMA request */
mbed_official 237:f3da66175598 358 hdac->Instance->CR |= DAC_CR_DMAEN2;
mbed_official 237:f3da66175598 359
mbed_official 237:f3da66175598 360 /* Case of use of channel 2 */
mbed_official 237:f3da66175598 361 switch(alignment)
mbed_official 237:f3da66175598 362 {
mbed_official 237:f3da66175598 363 case DAC_ALIGN_12B_R:
mbed_official 237:f3da66175598 364 /* Get DHR12R2 address */
mbed_official 237:f3da66175598 365 tmpreg = (uint32_t)&hdac->Instance->DHR12R2;
mbed_official 237:f3da66175598 366 break;
mbed_official 237:f3da66175598 367 case DAC_ALIGN_12B_L:
mbed_official 237:f3da66175598 368 /* Get DHR12L2 address */
mbed_official 237:f3da66175598 369 tmpreg = (uint32_t)&hdac->Instance->DHR12L2;
mbed_official 237:f3da66175598 370 break;
mbed_official 237:f3da66175598 371 case DAC_ALIGN_8B_R:
mbed_official 237:f3da66175598 372 /* Get DHR8R2 address */
mbed_official 237:f3da66175598 373 tmpreg = (uint32_t)&hdac->Instance->DHR8R2;
mbed_official 237:f3da66175598 374 break;
mbed_official 237:f3da66175598 375 default:
mbed_official 237:f3da66175598 376 break;
mbed_official 237:f3da66175598 377 }
mbed_official 237:f3da66175598 378 }
mbed_official 237:f3da66175598 379
mbed_official 237:f3da66175598 380 /* Enable the DMA Channel */
mbed_official 237:f3da66175598 381 if(channel == DAC_CHANNEL_1)
mbed_official 237:f3da66175598 382 {
mbed_official 237:f3da66175598 383 /* Enable the DAC DMA underrun interrupt */
mbed_official 237:f3da66175598 384 __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR1);
mbed_official 237:f3da66175598 385
mbed_official 237:f3da66175598 386 /* Enable the DMA Channel */
mbed_official 237:f3da66175598 387 HAL_DMA_Start_IT(hdac->DMA_Handle1, (uint32_t)pData, tmpreg, Length);
mbed_official 237:f3da66175598 388 }
mbed_official 237:f3da66175598 389 else
mbed_official 237:f3da66175598 390 {
mbed_official 237:f3da66175598 391 /* Enable the DAC DMA underrun interrupt */
mbed_official 237:f3da66175598 392 __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR2);
mbed_official 237:f3da66175598 393
mbed_official 237:f3da66175598 394 /* Enable the DMA Channel */
mbed_official 237:f3da66175598 395 HAL_DMA_Start_IT(hdac->DMA_Handle2, (uint32_t)pData, tmpreg, Length);
mbed_official 237:f3da66175598 396 }
mbed_official 237:f3da66175598 397
mbed_official 237:f3da66175598 398 /* Enable the Peripheral */
mbed_official 237:f3da66175598 399 __HAL_DAC_ENABLE(hdac, channel);
mbed_official 237:f3da66175598 400
mbed_official 237:f3da66175598 401 /* Process Unlocked */
mbed_official 237:f3da66175598 402 __HAL_UNLOCK(hdac);
mbed_official 237:f3da66175598 403
mbed_official 237:f3da66175598 404 /* Return function status */
mbed_official 237:f3da66175598 405 return HAL_OK;
mbed_official 237:f3da66175598 406 }
mbed_official 237:f3da66175598 407
mbed_official 237:f3da66175598 408 #endif
mbed_official 237:f3da66175598 409
mbed_official 237:f3da66175598 410 #if defined(STM32F302xC) || defined(STM32F302x8) || defined(STM32F301x8) || defined(STM32F318xx)
mbed_official 237:f3da66175598 411 /* DAC 1 has 1 channels 1 */
mbed_official 237:f3da66175598 412
mbed_official 237:f3da66175598 413 /**
mbed_official 237:f3da66175598 414 * @brief Enables DAC and starts conversion of channel.
mbed_official 237:f3da66175598 415 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 416 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 417 * @param channel: The selected DAC channel.
mbed_official 237:f3da66175598 418 * This parameter can be one of the following values:
mbed_official 237:f3da66175598 419 * @arg DAC_CHANNEL_1: DAC1 Channel1 selected
mbed_official 237:f3da66175598 420 * @param pData: The destination peripheral Buffer address.
mbed_official 237:f3da66175598 421 * @param Length: The length of data to be transferred from memory to DAC peripheral
mbed_official 237:f3da66175598 422 * @param alignment: Specifies the data alignment for DAC channel.
mbed_official 237:f3da66175598 423 * This parameter can be one of the following values:
mbed_official 237:f3da66175598 424 * @arg DAC_Align_8b_R: 8bit right data alignment selected
mbed_official 237:f3da66175598 425 * @arg DAC_Align_12b_L: 12bit left data alignment selected
mbed_official 237:f3da66175598 426 * @arg DAC_Align_12b_R: 12bit right data alignment selected
mbed_official 237:f3da66175598 427 * @retval HAL status
mbed_official 237:f3da66175598 428 */
mbed_official 237:f3da66175598 429
mbed_official 237:f3da66175598 430 HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t channel, uint32_t* pData, uint32_t Length, uint32_t alignment)
mbed_official 237:f3da66175598 431 {
mbed_official 237:f3da66175598 432 uint32_t tmpreg = 0;
mbed_official 237:f3da66175598 433
mbed_official 237:f3da66175598 434 /* Check the parameters */
mbed_official 237:f3da66175598 435 assert_param(IS_DAC_CHANNEL_INSTANCE(hdac->Instance, channel));
mbed_official 237:f3da66175598 436 assert_param(IS_DAC_ALIGN(alignment));
mbed_official 237:f3da66175598 437
mbed_official 237:f3da66175598 438 /* Process locked */
mbed_official 237:f3da66175598 439 __HAL_LOCK(hdac);
mbed_official 237:f3da66175598 440
mbed_official 237:f3da66175598 441 /* Change DAC state */
mbed_official 237:f3da66175598 442 hdac->State = HAL_DAC_STATE_BUSY;
mbed_official 237:f3da66175598 443
mbed_official 237:f3da66175598 444 /* Set the DMA transfer complete callback for channel1 */
mbed_official 237:f3da66175598 445 hdac->DMA_Handle1->XferCpltCallback = DAC_DMAConvCpltCh1;
mbed_official 237:f3da66175598 446
mbed_official 237:f3da66175598 447 /* Set the DMA half transfer complete callback for channel1 */
mbed_official 237:f3da66175598 448 hdac->DMA_Handle1->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh1;
mbed_official 237:f3da66175598 449
mbed_official 237:f3da66175598 450 /* Set the DMA error callback for channel1 */
mbed_official 237:f3da66175598 451 hdac->DMA_Handle1->XferErrorCallback = DAC_DMAErrorCh1;
mbed_official 237:f3da66175598 452
mbed_official 237:f3da66175598 453 /* Enable the selected DAC channel1 DMA request */
mbed_official 237:f3da66175598 454 hdac->Instance->CR |= DAC_CR_DMAEN1;
mbed_official 237:f3da66175598 455
mbed_official 237:f3da66175598 456 /* Case of use of channel 1 */
mbed_official 237:f3da66175598 457 switch(alignment)
mbed_official 237:f3da66175598 458 {
mbed_official 237:f3da66175598 459 case DAC_ALIGN_12B_R:
mbed_official 237:f3da66175598 460 /* Get DHR12R1 address */
mbed_official 237:f3da66175598 461 tmpreg = (uint32_t)&hdac->Instance->DHR12R1;
mbed_official 237:f3da66175598 462 break;
mbed_official 237:f3da66175598 463 case DAC_ALIGN_12B_L:
mbed_official 237:f3da66175598 464 /* Get DHR12L1 address */
mbed_official 237:f3da66175598 465 tmpreg = (uint32_t)&hdac->Instance->DHR12L1;
mbed_official 237:f3da66175598 466 break;
mbed_official 237:f3da66175598 467 case DAC_ALIGN_8B_R:
mbed_official 237:f3da66175598 468 /* Get DHR8R1 address */
mbed_official 237:f3da66175598 469 tmpreg = (uint32_t)&hdac->Instance->DHR8R1;
mbed_official 237:f3da66175598 470 break;
mbed_official 237:f3da66175598 471 default:
mbed_official 237:f3da66175598 472 break;
mbed_official 237:f3da66175598 473 }
mbed_official 237:f3da66175598 474
mbed_official 237:f3da66175598 475 /* Enable the DMA Channel */
mbed_official 237:f3da66175598 476 /* Enable the DAC DMA underrun interrupt */
mbed_official 237:f3da66175598 477 __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR1);
mbed_official 237:f3da66175598 478
mbed_official 237:f3da66175598 479 /* Enable the DMA Channel */
mbed_official 237:f3da66175598 480 HAL_DMA_Start_IT(hdac->DMA_Handle1, (uint32_t)pData, tmpreg, Length);
mbed_official 237:f3da66175598 481
mbed_official 237:f3da66175598 482 /* Enable the Peripheral */
mbed_official 237:f3da66175598 483 __HAL_DAC_ENABLE(hdac, channel);
mbed_official 237:f3da66175598 484
mbed_official 237:f3da66175598 485 /* Process Unlocked */
mbed_official 237:f3da66175598 486 __HAL_UNLOCK(hdac);
mbed_official 237:f3da66175598 487
mbed_official 237:f3da66175598 488 /* Return function status */
mbed_official 237:f3da66175598 489 return HAL_OK;
mbed_official 237:f3da66175598 490 }
mbed_official 237:f3da66175598 491 #endif
mbed_official 237:f3da66175598 492
mbed_official 237:f3da66175598 493 /* DAC 1 has 2 channels 1 & 2 - DAC 2 has one channel 1 */
mbed_official 237:f3da66175598 494 #if defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F373xC) || defined(STM32F378xx) || \
mbed_official 237:f3da66175598 495 defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx)
mbed_official 237:f3da66175598 496 /* DAC 1 has 2 channels 1 & 2 */
mbed_official 237:f3da66175598 497
mbed_official 237:f3da66175598 498 /**
mbed_official 237:f3da66175598 499 * @brief Returns the last data output value of the selected DAC channel.
mbed_official 237:f3da66175598 500 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 501 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 502 * @param channel: The selected DAC channel.
mbed_official 237:f3da66175598 503 * This parameter can be one of the following values:
mbed_official 237:f3da66175598 504 * @arg DAC_CHANNEL_1: DAC1 Channel1 or DAC2 Channel1 selected
mbed_official 237:f3da66175598 505 * @arg DAC_CHANNEL_2: DAC1 Channel2 selected
mbed_official 237:f3da66175598 506 * @retval The selected DAC channel data output value.
mbed_official 237:f3da66175598 507 */
mbed_official 237:f3da66175598 508
mbed_official 237:f3da66175598 509
mbed_official 237:f3da66175598 510 /**
mbed_official 237:f3da66175598 511 * @brief Returns the last data output value of the selected DAC channel.
mbed_official 237:f3da66175598 512 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 513 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 514 * @param channel: The selected DAC channel.
mbed_official 237:f3da66175598 515 * This parameter can be one of the following values:
mbed_official 237:f3da66175598 516 * @arg DAC_CHANNEL_1: DAC1 Channel1 selected
mbed_official 237:f3da66175598 517 * @arg DAC_CHANNEL_2: DAC1 Channel2 selected
mbed_official 237:f3da66175598 518 * @retval The selected DAC channel data output value.
mbed_official 237:f3da66175598 519 */
mbed_official 237:f3da66175598 520 uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef* hdac, uint32_t channel)
mbed_official 237:f3da66175598 521 {
mbed_official 237:f3da66175598 522 /* Check the parameters */
mbed_official 237:f3da66175598 523 assert_param(IS_DAC_CHANNEL_INSTANCE(hdac->Instance, channel));
mbed_official 237:f3da66175598 524
mbed_official 237:f3da66175598 525 /* Returns the DAC channel data output register value */
mbed_official 237:f3da66175598 526 if(channel == DAC_CHANNEL_1)
mbed_official 237:f3da66175598 527 {
mbed_official 237:f3da66175598 528 return hdac->Instance->DOR1;
mbed_official 237:f3da66175598 529 }
mbed_official 237:f3da66175598 530 else /* channel = DAC_CHANNEL_2 */
mbed_official 237:f3da66175598 531 {
mbed_official 237:f3da66175598 532 return hdac->Instance->DOR2;
mbed_official 237:f3da66175598 533 }
mbed_official 237:f3da66175598 534 }
mbed_official 237:f3da66175598 535
mbed_official 237:f3da66175598 536 #endif
mbed_official 237:f3da66175598 537
mbed_official 237:f3da66175598 538 #if defined(STM32F302x8) || defined(STM32F301x8) || defined(STM32F318xx)
mbed_official 237:f3da66175598 539 /* DAC 1 has 1 channel (channel 1) */
mbed_official 237:f3da66175598 540 /**
mbed_official 237:f3da66175598 541 * @brief Returns the last data output value of the selected DAC channel.
mbed_official 237:f3da66175598 542 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 543 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 544 * @param channel: The selected DAC channel.
mbed_official 237:f3da66175598 545 * This parameter can be one of the following values:
mbed_official 237:f3da66175598 546 * @arg DAC_CHANNEL_1: DAC1 Channel1 selected
mbed_official 237:f3da66175598 547 * @retval The selected DAC channel data output value.
mbed_official 237:f3da66175598 548 */
mbed_official 237:f3da66175598 549 uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef* hdac, uint32_t channel)
mbed_official 237:f3da66175598 550 {
mbed_official 237:f3da66175598 551 /* Check the parameters */
mbed_official 237:f3da66175598 552 assert_param(IS_DAC_CHANNEL_INSTANCE(hdac->Instance, channel));
mbed_official 237:f3da66175598 553
mbed_official 237:f3da66175598 554 /* Returns the DAC channel data output register value */
mbed_official 237:f3da66175598 555 return hdac->Instance->DOR1;
mbed_official 237:f3da66175598 556 }
mbed_official 237:f3da66175598 557 #endif
mbed_official 237:f3da66175598 558
mbed_official 237:f3da66175598 559 #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
mbed_official 237:f3da66175598 560 /* DAC channel 2 is NOT available. Only DAC channel 1 is available */
mbed_official 237:f3da66175598 561
mbed_official 237:f3da66175598 562 /**
mbed_official 237:f3da66175598 563 * @brief Handles DAC interrupt request
mbed_official 237:f3da66175598 564 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 565 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 566 * @retval None
mbed_official 237:f3da66175598 567 */
mbed_official 237:f3da66175598 568
mbed_official 237:f3da66175598 569 void HAL_DAC_IRQHandler(struct __DAC_HandleTypeDef* hdac)
mbed_official 237:f3da66175598 570 {
mbed_official 237:f3da66175598 571 /* Check Overrun flag */
mbed_official 237:f3da66175598 572 if(__HAL_DAC_GET_FLAG(hdac, DAC_FLAG_DMAUDR1))
mbed_official 237:f3da66175598 573 {
mbed_official 237:f3da66175598 574 /* Change DAC state to error state */
mbed_official 237:f3da66175598 575 hdac->State = HAL_DAC_STATE_ERROR;
mbed_official 237:f3da66175598 576
mbed_official 237:f3da66175598 577 /* Set DAC error code to chanel1 DMA underrun error */
mbed_official 237:f3da66175598 578 hdac->ErrorCode |= HAL_DAC_ERROR_DMAUNDERRUNCH1;
mbed_official 237:f3da66175598 579
mbed_official 237:f3da66175598 580 /* Clear the underrun flag */
mbed_official 237:f3da66175598 581 __HAL_DAC_CLEAR_FLAG(hdac,DAC_FLAG_DMAUDR1);
mbed_official 237:f3da66175598 582
mbed_official 237:f3da66175598 583 /* Disable the selected DAC channel1 DMA request */
mbed_official 237:f3da66175598 584 hdac->Instance->CR &= ~DAC_CR_DMAEN1;
mbed_official 237:f3da66175598 585
mbed_official 237:f3da66175598 586 /* Error callback */
mbed_official 237:f3da66175598 587 HAL_DAC_DMAUnderrunCallbackCh1(hdac);
mbed_official 237:f3da66175598 588 }
mbed_official 237:f3da66175598 589 }
mbed_official 237:f3da66175598 590 #endif /* STM32F301x8 STM32F302x8 STM32F318xx */
mbed_official 237:f3da66175598 591
mbed_official 237:f3da66175598 592 #if defined(STM32F303xC) || defined(STM32F358xx) || defined(STM32F303x8) || defined(STM32F328xx)|| defined(STM32F302xC) || defined(STM32F334x8) || defined(STM32F373xC) || defined(STM32F378xx)
mbed_official 237:f3da66175598 593 /* DAC channel 2 is available on top of DAC channel 1 */
mbed_official 237:f3da66175598 594
mbed_official 237:f3da66175598 595 /**
mbed_official 237:f3da66175598 596 * @brief Handles DAC interrupt request
mbed_official 237:f3da66175598 597 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 598 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 599 * @retval None
mbed_official 237:f3da66175598 600 */
mbed_official 237:f3da66175598 601 void HAL_DAC_IRQHandler(struct __DAC_HandleTypeDef* hdac)
mbed_official 237:f3da66175598 602 {
mbed_official 237:f3da66175598 603 /* Check Overrun flag */
mbed_official 237:f3da66175598 604 if(__HAL_DAC_GET_FLAG(hdac, DAC_FLAG_DMAUDR1))
mbed_official 237:f3da66175598 605 {
mbed_official 237:f3da66175598 606 /* Change DAC state to error state */
mbed_official 237:f3da66175598 607 hdac->State = HAL_DAC_STATE_ERROR;
mbed_official 237:f3da66175598 608
mbed_official 237:f3da66175598 609 /* Set DAC error code to chanel1 DMA underrun error */
mbed_official 237:f3da66175598 610 hdac->ErrorCode |= HAL_DAC_ERROR_DMAUNDERRUNCH1;
mbed_official 237:f3da66175598 611
mbed_official 237:f3da66175598 612 /* Clear the underrun flag */
mbed_official 237:f3da66175598 613 __HAL_DAC_CLEAR_FLAG(hdac,DAC_FLAG_DMAUDR1);
mbed_official 237:f3da66175598 614
mbed_official 237:f3da66175598 615 /* Disable the selected DAC channel1 DMA request */
mbed_official 237:f3da66175598 616 hdac->Instance->CR &= ~DAC_CR_DMAEN1;
mbed_official 237:f3da66175598 617
mbed_official 237:f3da66175598 618 /* Error callback */
mbed_official 237:f3da66175598 619 HAL_DAC_DMAUnderrunCallbackCh1(hdac);
mbed_official 237:f3da66175598 620 }
mbed_official 237:f3da66175598 621 else
mbed_official 237:f3da66175598 622 {
mbed_official 237:f3da66175598 623 if (__HAL_DAC_GET_FLAG(hdac, DAC_FLAG_DMAUDR2))
mbed_official 237:f3da66175598 624 {
mbed_official 237:f3da66175598 625 /* Change DAC state to error state */
mbed_official 237:f3da66175598 626 hdac->State = HAL_DAC_STATE_ERROR;
mbed_official 237:f3da66175598 627
mbed_official 237:f3da66175598 628 /* Set DAC error code to channel2 DMA underrun error */
mbed_official 237:f3da66175598 629 hdac->ErrorCode |= HAL_DAC_ERROR_DMAUNDERRUNCH2;
mbed_official 237:f3da66175598 630
mbed_official 237:f3da66175598 631 /* Clear the underrun flag */
mbed_official 237:f3da66175598 632 __HAL_DAC_CLEAR_FLAG(hdac,DAC_FLAG_DMAUDR2);
mbed_official 237:f3da66175598 633
mbed_official 237:f3da66175598 634 /* Disable the selected DAC channel1 DMA request */
mbed_official 237:f3da66175598 635 hdac->Instance->CR &= ~DAC_CR_DMAEN2;
mbed_official 237:f3da66175598 636
mbed_official 237:f3da66175598 637 /* Error callback */
mbed_official 237:f3da66175598 638 HAL_DACEx_DMAUnderrunCallbackCh2(hdac);
mbed_official 237:f3da66175598 639 }
mbed_official 237:f3da66175598 640 }
mbed_official 237:f3da66175598 641 }
mbed_official 237:f3da66175598 642
mbed_official 237:f3da66175598 643 #endif /* STM32F303xC STM32F358xx STM32F303x8 STM32F328xx STM32F302xC STM32F334x8 STM32F373xC STM32F378xx */
mbed_official 237:f3da66175598 644
mbed_official 237:f3da66175598 645 /**
mbed_official 237:f3da66175598 646 * @}
mbed_official 237:f3da66175598 647 */
mbed_official 237:f3da66175598 648
mbed_official 237:f3da66175598 649 /**
mbed_official 237:f3da66175598 650 * @}
mbed_official 237:f3da66175598 651 */
mbed_official 237:f3da66175598 652
mbed_official 237:f3da66175598 653 /** @defgroup DACEx
mbed_official 237:f3da66175598 654 * @brief DACEx Extended HAL module driver
mbed_official 237:f3da66175598 655 * @{
mbed_official 237:f3da66175598 656 */
mbed_official 237:f3da66175598 657
mbed_official 237:f3da66175598 658 /** @defgroup DACEx_Private_Functions
mbed_official 237:f3da66175598 659 * @{
mbed_official 237:f3da66175598 660 */
mbed_official 237:f3da66175598 661
mbed_official 237:f3da66175598 662 #if defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F373xC) || defined(STM32F378xx) || defined(STM32F303xC) || defined(STM32F358xx)
mbed_official 237:f3da66175598 663 /* DAC channel 2 is present in DAC 1 */
mbed_official 237:f3da66175598 664 /**
mbed_official 237:f3da66175598 665 * @brief Set the specified data holding register value for dual DAC channel.
mbed_official 237:f3da66175598 666 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 667 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 668 * @param alignment: Specifies the data alignment for dual channel DAC.
mbed_official 237:f3da66175598 669 * This parameter can be one of the following values:
mbed_official 237:f3da66175598 670 * @arg DAC_Align_8b_R: 8bit right data alignment selected
mbed_official 237:f3da66175598 671 * @arg DAC_Align_12b_L: 12bit left data alignment selected
mbed_official 237:f3da66175598 672 * @arg DAC_Align_12b_R: 12bit right data alignment selected
mbed_official 237:f3da66175598 673 * @param data2: Data for DAC Channel2 to be loaded in the selected data holding register.
mbed_official 237:f3da66175598 674 * @param data1: Data for DAC Channel1 to be loaded in the selected data holding register.
mbed_official 237:f3da66175598 675 * @note In dual mode, a unique register access is required to write in both
mbed_official 237:f3da66175598 676 * DAC channels at the same time.
mbed_official 237:f3da66175598 677 * @retval HAL status
mbed_official 237:f3da66175598 678 */
mbed_official 237:f3da66175598 679 HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef* hdac, uint32_t alignment, uint32_t data1, uint32_t data2)
mbed_official 237:f3da66175598 680 {
mbed_official 237:f3da66175598 681 uint32_t data = 0, tmp = 0;
mbed_official 237:f3da66175598 682
mbed_official 237:f3da66175598 683 /* Check the parameters */
mbed_official 237:f3da66175598 684 assert_param(IS_DAC_ALIGN(alignment));
mbed_official 237:f3da66175598 685 assert_param(IS_DAC_DATA(data1));
mbed_official 237:f3da66175598 686 assert_param(IS_DAC_DATA(data2));
mbed_official 237:f3da66175598 687
mbed_official 237:f3da66175598 688 /* Calculate and set dual DAC data holding register value */
mbed_official 237:f3da66175598 689 if (alignment == DAC_ALIGN_8B_R)
mbed_official 237:f3da66175598 690 {
mbed_official 237:f3da66175598 691 data = ((uint32_t)data2 << 8) | data1;
mbed_official 237:f3da66175598 692 }
mbed_official 237:f3da66175598 693 else
mbed_official 237:f3da66175598 694 {
mbed_official 237:f3da66175598 695 data = ((uint32_t)data2 << 16) | data1;
mbed_official 237:f3da66175598 696 }
mbed_official 237:f3da66175598 697
mbed_official 237:f3da66175598 698 tmp = (uint32_t) (hdac->Instance);
mbed_official 237:f3da66175598 699 tmp += __HAL_DHR12RD_ALIGNEMENT(alignment);
mbed_official 237:f3da66175598 700
mbed_official 237:f3da66175598 701 /* Set the dual DAC selected data holding register */
mbed_official 237:f3da66175598 702 *(__IO uint32_t *)tmp = data;
mbed_official 237:f3da66175598 703
mbed_official 237:f3da66175598 704 /* Return function status */
mbed_official 237:f3da66175598 705 return HAL_OK;
mbed_official 237:f3da66175598 706 }
mbed_official 237:f3da66175598 707 #endif
mbed_official 237:f3da66175598 708
mbed_official 237:f3da66175598 709 /**
mbed_official 237:f3da66175598 710 * @brief Returns the last data output value of the selected DAC channel.
mbed_official 237:f3da66175598 711 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 712 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 713 * @retval The selected DAC channel data output value.
mbed_official 237:f3da66175598 714 */
mbed_official 237:f3da66175598 715 uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef* hdac)
mbed_official 237:f3da66175598 716 {
mbed_official 237:f3da66175598 717 uint32_t tmp = 0;
mbed_official 237:f3da66175598 718
mbed_official 237:f3da66175598 719 tmp |= hdac->Instance->DOR1;
mbed_official 237:f3da66175598 720
mbed_official 237:f3da66175598 721 #if defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F373xC) || defined(STM32F378xx) || defined(STM32F303xC) || defined(STM32F358xx)
mbed_official 237:f3da66175598 722 /* DAC channel 2 is present in DAC 1 */
mbed_official 237:f3da66175598 723 tmp |= hdac->Instance->DOR2 << 16;
mbed_official 237:f3da66175598 724 #endif
mbed_official 237:f3da66175598 725 /* Returns the DAC channel data output register value */
mbed_official 237:f3da66175598 726 return tmp;
mbed_official 237:f3da66175598 727 }
mbed_official 237:f3da66175598 728
mbed_official 237:f3da66175598 729 /**
mbed_official 237:f3da66175598 730 * @brief Enables or disables the selected DAC channel wave generation.
mbed_official 237:f3da66175598 731 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 732 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 733 * @param channel: The selected DAC channel.
mbed_official 237:f3da66175598 734 * This parameter can be one of the following values:
mbed_official 237:f3da66175598 735 * @arg DAC_CHANNEL_1: DAC1 Channel1 selected
mbed_official 237:f3da66175598 736 * @arg DAC_CHANNEL_2: DAC1 Channel2 selected
mbed_official 237:f3da66175598 737 * @param Amplitude: Select max triangle amplitude.
mbed_official 237:f3da66175598 738 * This parameter can be one of the following values:
mbed_official 237:f3da66175598 739 * @arg DAC_TRIANGLEAMPLITUDE_1: Select max triangle amplitude of 1
mbed_official 237:f3da66175598 740 * @arg DAC_TRIANGLEAMPLITUDE_3: Select max triangle amplitude of 3
mbed_official 237:f3da66175598 741 * @arg DAC_TRIANGLEAMPLITUDE_7: Select max triangle amplitude of 7
mbed_official 237:f3da66175598 742 * @arg DAC_TRIANGLEAMPLITUDE_15: Select max triangle amplitude of 15
mbed_official 237:f3da66175598 743 * @arg DAC_TRIANGLEAMPLITUDE_31: Select max triangle amplitude of 31
mbed_official 237:f3da66175598 744 * @arg DAC_TRIANGLEAMPLITUDE_63: Select max triangle amplitude of 63
mbed_official 237:f3da66175598 745 * @arg DAC_TRIANGLEAMPLITUDE_127: Select max triangle amplitude of 127
mbed_official 237:f3da66175598 746 * @arg DAC_TRIANGLEAMPLITUDE_255: Select max triangle amplitude of 255
mbed_official 237:f3da66175598 747 * @arg DAC_TRIANGLEAMPLITUDE_511: Select max triangle amplitude of 511
mbed_official 237:f3da66175598 748 * @arg DAC_TRIANGLEAMPLITUDE_1023: Select max triangle amplitude of 1023
mbed_official 237:f3da66175598 749 * @arg DAC_TRIANGLEAMPLITUDE_2047: Select max triangle amplitude of 2047
mbed_official 237:f3da66175598 750 * @arg DAC_TRIANGLEAMPLITUDE_4095: Select max triangle amplitude of 4095
mbed_official 237:f3da66175598 751 * @note Wave generation is not available in DAC2.
mbed_official 237:f3da66175598 752 * @retval HAL status
mbed_official 237:f3da66175598 753 */
mbed_official 237:f3da66175598 754 HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t channel, uint32_t Amplitude)
mbed_official 237:f3da66175598 755 {
mbed_official 237:f3da66175598 756 /* Check the parameters */
mbed_official 237:f3da66175598 757 assert_param(IS_DAC_CHANNEL(channel));
mbed_official 237:f3da66175598 758 assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude));
mbed_official 237:f3da66175598 759
mbed_official 237:f3da66175598 760 /* Process locked */
mbed_official 237:f3da66175598 761 __HAL_LOCK(hdac);
mbed_official 237:f3da66175598 762
mbed_official 237:f3da66175598 763 /* Change DAC state */
mbed_official 237:f3da66175598 764 hdac->State = HAL_DAC_STATE_BUSY;
mbed_official 237:f3da66175598 765
mbed_official 237:f3da66175598 766 /* Enable the selected wave generation for the selected DAC channel */
mbed_official 237:f3da66175598 767 hdac->Instance->CR |= (DAC_WAVE_TRIANGLE | Amplitude) << channel;
mbed_official 237:f3da66175598 768
mbed_official 237:f3da66175598 769 /* Change DAC state */
mbed_official 237:f3da66175598 770 hdac->State = HAL_DAC_STATE_READY;
mbed_official 237:f3da66175598 771
mbed_official 237:f3da66175598 772 /* Process unlocked */
mbed_official 237:f3da66175598 773 __HAL_UNLOCK(hdac);
mbed_official 237:f3da66175598 774
mbed_official 237:f3da66175598 775 /* Return function status */
mbed_official 237:f3da66175598 776 return HAL_OK;
mbed_official 237:f3da66175598 777 }
mbed_official 237:f3da66175598 778
mbed_official 237:f3da66175598 779 /**
mbed_official 237:f3da66175598 780 * @brief Enables or disables the selected DAC channel wave generation.
mbed_official 237:f3da66175598 781 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 782 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 783 * @param channel: The selected DAC channel.
mbed_official 237:f3da66175598 784 * This parameter can be one of the following values:
mbed_official 237:f3da66175598 785 * @arg DAC_CHANNEL_1: DAC1 Channel1 selected
mbed_official 237:f3da66175598 786 * @arg DAC_CHANNEL_2: DAC1 Channel2 selected
mbed_official 237:f3da66175598 787 * @param Amplitude: Unmask DAC channel LFSR for noise wave generation.
mbed_official 237:f3da66175598 788 * This parameter can be one of the following values:
mbed_official 237:f3da66175598 789 * @arg DAC_LFSRUNMASK_BIT0: Unmask DAC channel LFSR bit0 for noise wave generation
mbed_official 237:f3da66175598 790 * @arg DAC_LFSRUNMASK_BITS1_0: Unmask DAC channel LFSR bit[1:0] for noise wave generation
mbed_official 237:f3da66175598 791 * @arg DAC_LFSRUNMASK_BITS2_0: Unmask DAC channel LFSR bit[2:0] for noise wave generation
mbed_official 237:f3da66175598 792 * @arg DAC_LFSRUNMASK_BITS3_0: Unmask DAC channel LFSR bit[3:0] for noise wave generation
mbed_official 237:f3da66175598 793 * @arg DAC_LFSRUNMASK_BITS4_0: Unmask DAC channel LFSR bit[4:0] for noise wave generation
mbed_official 237:f3da66175598 794 * @arg DAC_LFSRUNMASK_BITS5_0: Unmask DAC channel LFSR bit[5:0] for noise wave generation
mbed_official 237:f3da66175598 795 * @arg DAC_LFSRUNMASK_BITS6_0: Unmask DAC channel LFSR bit[6:0] for noise wave generation
mbed_official 237:f3da66175598 796 * @arg DAC_LFSRUNMASK_BITS7_0: Unmask DAC channel LFSR bit[7:0] for noise wave generation
mbed_official 237:f3da66175598 797 * @arg DAC_LFSRUNMASK_BITS8_0: Unmask DAC channel LFSR bit[8:0] for noise wave generation
mbed_official 237:f3da66175598 798 * @arg DAC_LFSRUNMASK_BITS9_0: Unmask DAC channel LFSR bit[9:0] for noise wave generation
mbed_official 237:f3da66175598 799 * @arg DAC_LFSRUNMASK_BITS10_0: Unmask DAC channel LFSR bit[10:0] for noise wave generation
mbed_official 237:f3da66175598 800 * @arg DAC_LFSRUNMASK_BITS11_0: Unmask DAC channel LFSR bit[11:0] for noise wave generation
mbed_official 237:f3da66175598 801 * @retval HAL status
mbed_official 237:f3da66175598 802 */
mbed_official 237:f3da66175598 803 HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t channel, uint32_t Amplitude)
mbed_official 237:f3da66175598 804 {
mbed_official 237:f3da66175598 805 /* Check the parameters */
mbed_official 237:f3da66175598 806 assert_param(IS_DAC_CHANNEL(channel));
mbed_official 237:f3da66175598 807 assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude));
mbed_official 237:f3da66175598 808
mbed_official 237:f3da66175598 809 /* Process locked */
mbed_official 237:f3da66175598 810 __HAL_LOCK(hdac);
mbed_official 237:f3da66175598 811
mbed_official 237:f3da66175598 812 /* Change DAC state */
mbed_official 237:f3da66175598 813 hdac->State = HAL_DAC_STATE_BUSY;
mbed_official 237:f3da66175598 814
mbed_official 237:f3da66175598 815 /* Enable the selected wave generation for the selected DAC channel */
mbed_official 237:f3da66175598 816 hdac->Instance->CR |= (DAC_WAVE_NOISE | Amplitude) << channel;
mbed_official 237:f3da66175598 817
mbed_official 237:f3da66175598 818 /* Change DAC state */
mbed_official 237:f3da66175598 819 hdac->State = HAL_DAC_STATE_READY;
mbed_official 237:f3da66175598 820
mbed_official 237:f3da66175598 821 /* Process unlocked */
mbed_official 237:f3da66175598 822 __HAL_UNLOCK(hdac);
mbed_official 237:f3da66175598 823
mbed_official 237:f3da66175598 824 /* Return function status */
mbed_official 237:f3da66175598 825 return HAL_OK;
mbed_official 237:f3da66175598 826 }
mbed_official 237:f3da66175598 827
mbed_official 237:f3da66175598 828 /**
mbed_official 237:f3da66175598 829 * @brief Conversion complete callback in non blocking mode for Channel2
mbed_official 237:f3da66175598 830 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 831 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 832 * @retval None
mbed_official 237:f3da66175598 833 */
mbed_official 237:f3da66175598 834 __weak void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef* hdac)
mbed_official 237:f3da66175598 835 {
mbed_official 237:f3da66175598 836 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 237:f3da66175598 837 the HAL_DACEx_ConvCpltCallbackCh2 could be implemented in the user file
mbed_official 237:f3da66175598 838 */
mbed_official 237:f3da66175598 839 }
mbed_official 237:f3da66175598 840
mbed_official 237:f3da66175598 841 /**
mbed_official 237:f3da66175598 842 * @brief Conversion half DMA transfer callback in non blocking mode for Channel2
mbed_official 237:f3da66175598 843 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 844 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 845 * @retval None
mbed_official 237:f3da66175598 846 */
mbed_official 237:f3da66175598 847 __weak void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef* hdac)
mbed_official 237:f3da66175598 848 {
mbed_official 237:f3da66175598 849 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 237:f3da66175598 850 the HAL_DACEx_ConvHalfCpltCallbackCh2 could be implemented in the user file
mbed_official 237:f3da66175598 851 */
mbed_official 237:f3da66175598 852 }
mbed_official 237:f3da66175598 853
mbed_official 237:f3da66175598 854 /**
mbed_official 237:f3da66175598 855 * @brief Error DAC callback for Channel2.
mbed_official 237:f3da66175598 856 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 857 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 858 * @retval None
mbed_official 237:f3da66175598 859 */
mbed_official 237:f3da66175598 860 __weak void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef *hdac)
mbed_official 237:f3da66175598 861 {
mbed_official 237:f3da66175598 862 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 237:f3da66175598 863 the HAL_DACEx_ErrorCallbackCh2 could be implemented in the user file
mbed_official 237:f3da66175598 864 */
mbed_official 237:f3da66175598 865 }
mbed_official 237:f3da66175598 866
mbed_official 237:f3da66175598 867 /**
mbed_official 237:f3da66175598 868 * @brief DMA underrun DAC callback for channel2.
mbed_official 237:f3da66175598 869 * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 870 * the configuration information for the specified DAC.
mbed_official 237:f3da66175598 871 * @retval None
mbed_official 237:f3da66175598 872 */
mbed_official 237:f3da66175598 873 __weak void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef *hdac)
mbed_official 237:f3da66175598 874 {
mbed_official 237:f3da66175598 875 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 237:f3da66175598 876 the HAL_DACEx_DMAUnderrunCallbackCh2 could be implemented in the user file
mbed_official 237:f3da66175598 877 */
mbed_official 237:f3da66175598 878 }
mbed_official 237:f3da66175598 879
mbed_official 237:f3da66175598 880 /**
mbed_official 237:f3da66175598 881 * @brief DMA conversion complete callback.
mbed_official 237:f3da66175598 882 * @param hdma: pointer to DMA handle.
mbed_official 237:f3da66175598 883 * @retval None
mbed_official 237:f3da66175598 884 */
mbed_official 237:f3da66175598 885 static void DAC_DMAConvCpltCh1(DMA_HandleTypeDef *hdma)
mbed_official 237:f3da66175598 886 {
mbed_official 237:f3da66175598 887 DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
mbed_official 237:f3da66175598 888
mbed_official 237:f3da66175598 889 HAL_DAC_ConvCpltCallbackCh1(hdac);
mbed_official 237:f3da66175598 890
mbed_official 237:f3da66175598 891 hdac->State= HAL_DAC_STATE_READY;
mbed_official 237:f3da66175598 892 }
mbed_official 237:f3da66175598 893
mbed_official 237:f3da66175598 894 /**
mbed_official 237:f3da66175598 895 * @brief DMA half transfer complete callback.
mbed_official 237:f3da66175598 896 * @param hdma: pointer to DMA handle.
mbed_official 237:f3da66175598 897 * @retval None
mbed_official 237:f3da66175598 898 */
mbed_official 237:f3da66175598 899 static void DAC_DMAHalfConvCpltCh1(DMA_HandleTypeDef *hdma)
mbed_official 237:f3da66175598 900 {
mbed_official 237:f3da66175598 901 DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
mbed_official 237:f3da66175598 902 /* Conversion complete callback */
mbed_official 237:f3da66175598 903 HAL_DAC_ConvHalfCpltCallbackCh1(hdac);
mbed_official 237:f3da66175598 904 }
mbed_official 237:f3da66175598 905
mbed_official 237:f3da66175598 906 /**
mbed_official 237:f3da66175598 907 * @brief DMA error callback
mbed_official 237:f3da66175598 908 * @param hdma: pointer to DMA handle.
mbed_official 237:f3da66175598 909 * @retval None
mbed_official 237:f3da66175598 910 */
mbed_official 237:f3da66175598 911 static void DAC_DMAErrorCh1(DMA_HandleTypeDef *hdma)
mbed_official 237:f3da66175598 912 {
mbed_official 237:f3da66175598 913 DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
mbed_official 237:f3da66175598 914
mbed_official 237:f3da66175598 915 /* Set DAC error code to DMA error */
mbed_official 237:f3da66175598 916 hdac->ErrorCode |= HAL_DAC_ERROR_DMA;
mbed_official 237:f3da66175598 917
mbed_official 237:f3da66175598 918 HAL_DAC_ErrorCallbackCh1(hdac);
mbed_official 237:f3da66175598 919
mbed_official 237:f3da66175598 920 hdac->State= HAL_DAC_STATE_READY;
mbed_official 237:f3da66175598 921 }
mbed_official 237:f3da66175598 922
mbed_official 237:f3da66175598 923 #if defined(STM32F303xC) || defined(STM32F358xx) || defined(STM32F303x8) || defined(STM32F328xx) || defined(STM32F334x8) || defined(STM32F373xC) || defined(STM32F378xx)
mbed_official 237:f3da66175598 924 /* DAC channel 2 is available on top of DAC channel 1 */
mbed_official 237:f3da66175598 925
mbed_official 237:f3da66175598 926 /**
mbed_official 237:f3da66175598 927 * @brief DMA conversion complete callback.
mbed_official 237:f3da66175598 928 * @param hdma: pointer to DMA handle.
mbed_official 237:f3da66175598 929 * @retval None
mbed_official 237:f3da66175598 930 */
mbed_official 237:f3da66175598 931 static void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma)
mbed_official 237:f3da66175598 932 {
mbed_official 237:f3da66175598 933 DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
mbed_official 237:f3da66175598 934
mbed_official 237:f3da66175598 935 HAL_DACEx_ConvCpltCallbackCh2(hdac);
mbed_official 237:f3da66175598 936
mbed_official 237:f3da66175598 937 hdac->State= HAL_DAC_STATE_READY;
mbed_official 237:f3da66175598 938 }
mbed_official 237:f3da66175598 939
mbed_official 237:f3da66175598 940 /**
mbed_official 237:f3da66175598 941 * @brief DMA half transfer complete callback.
mbed_official 237:f3da66175598 942 * @param hdma: pointer to DMA handle.
mbed_official 237:f3da66175598 943 * @retval None
mbed_official 237:f3da66175598 944 */
mbed_official 237:f3da66175598 945 static void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma)
mbed_official 237:f3da66175598 946 {
mbed_official 237:f3da66175598 947 DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
mbed_official 237:f3da66175598 948 /* Conversion complete callback */
mbed_official 237:f3da66175598 949 HAL_DACEx_ConvHalfCpltCallbackCh2(hdac);
mbed_official 237:f3da66175598 950 }
mbed_official 237:f3da66175598 951
mbed_official 237:f3da66175598 952 /**
mbed_official 237:f3da66175598 953 * @brief DMA error callback
mbed_official 237:f3da66175598 954 * @param hdma: pointer to DMA handle.
mbed_official 237:f3da66175598 955 * @retval None
mbed_official 237:f3da66175598 956 */
mbed_official 237:f3da66175598 957 static void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma)
mbed_official 237:f3da66175598 958 {
mbed_official 237:f3da66175598 959 DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
mbed_official 237:f3da66175598 960
mbed_official 237:f3da66175598 961 /* Set DAC error code to DMA error */
mbed_official 237:f3da66175598 962 hdac->ErrorCode |= HAL_DAC_ERROR_DMA;
mbed_official 237:f3da66175598 963
mbed_official 237:f3da66175598 964 HAL_DACEx_ErrorCallbackCh2(hdac);
mbed_official 237:f3da66175598 965
mbed_official 237:f3da66175598 966 hdac->State= HAL_DAC_STATE_READY;
mbed_official 237:f3da66175598 967 }
mbed_official 237:f3da66175598 968 #endif /* STM32F303xC STM32F358xx STM32F303x8 STM32F328xx STM32F334x8 STM32F373xC STM32F378xx */
mbed_official 237:f3da66175598 969
mbed_official 237:f3da66175598 970 /**
mbed_official 237:f3da66175598 971 * @}
mbed_official 237:f3da66175598 972 */
mbed_official 237:f3da66175598 973
mbed_official 237:f3da66175598 974 /**
mbed_official 237:f3da66175598 975 * @}
mbed_official 237:f3da66175598 976 */
mbed_official 237:f3da66175598 977
mbed_official 237:f3da66175598 978 #endif /* HAL_DAC_MODULE_ENABLED */
mbed_official 237:f3da66175598 979 /**
mbed_official 237:f3da66175598 980 * @}
mbed_official 237:f3da66175598 981 */
mbed_official 237:f3da66175598 982
mbed_official 237:f3da66175598 983 /**
mbed_official 237:f3da66175598 984 * @}
mbed_official 237:f3da66175598 985 */
mbed_official 237:f3da66175598 986
mbed_official 237:f3da66175598 987 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/