mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
180:96ed750bd169
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 144:ef7eb2e8f9f7 1 /**
<> 144:ef7eb2e8f9f7 2 ******************************************************************************
<> 144:ef7eb2e8f9f7 3 * @file stm32f0xx_hal_dac.c
<> 144:ef7eb2e8f9f7 4 * @author MCD Application Team
<> 144:ef7eb2e8f9f7 5 * @brief DAC HAL module driver.
<> 144:ef7eb2e8f9f7 6 * This file provides firmware functions to manage the following
<> 144:ef7eb2e8f9f7 7 * functionalities of the Digital to Analog Converter (DAC) peripheral:
<> 144:ef7eb2e8f9f7 8 * + Initialization and de-initialization functions
<> 144:ef7eb2e8f9f7 9 * + IO operation functions
<> 144:ef7eb2e8f9f7 10 * + Peripheral Control functions
<> 144:ef7eb2e8f9f7 11 * + Peripheral State and Errors functions
<> 144:ef7eb2e8f9f7 12 *
<> 144:ef7eb2e8f9f7 13 *
<> 144:ef7eb2e8f9f7 14 @verbatim
<> 144:ef7eb2e8f9f7 15 ==============================================================================
<> 144:ef7eb2e8f9f7 16 ##### DAC Peripheral features #####
<> 144:ef7eb2e8f9f7 17 ==============================================================================
<> 144:ef7eb2e8f9f7 18 [..]
<> 144:ef7eb2e8f9f7 19 *** DAC Channels ***
<> 144:ef7eb2e8f9f7 20 ====================
<> 144:ef7eb2e8f9f7 21 [..]
<> 144:ef7eb2e8f9f7 22 STM32F0 devices integrates no, one or two 12-bit Digital Analog Converters.
<> 144:ef7eb2e8f9f7 23 STM32F05x devices have one converter (channel1)
<> 144:ef7eb2e8f9f7 24 STM32F07x & STM32F09x devices have two converters (i.e. channel1 & channel2)
<> 144:ef7eb2e8f9f7 25
<> 144:ef7eb2e8f9f7 26 When 2 converters are present (i.e. channel1 & channel2) they
<> 144:ef7eb2e8f9f7 27 can be used independently or simultaneously (dual mode):
<> 144:ef7eb2e8f9f7 28 (#) DAC channel1 with DAC_OUT1 (PA4) as output
<> 144:ef7eb2e8f9f7 29 (#) DAC channel2 with DAC_OUT2 (PA5) as output
<> 144:ef7eb2e8f9f7 30
<> 144:ef7eb2e8f9f7 31 *** DAC Triggers ***
<> 144:ef7eb2e8f9f7 32 ====================
<> 144:ef7eb2e8f9f7 33 [..]
<> 144:ef7eb2e8f9f7 34 Digital to Analog conversion can be non-triggered using DAC_TRIGGER_NONE
<> 144:ef7eb2e8f9f7 35 and DAC_OUT1/DAC_OUT2 is available once writing to DHRx register.
<> 144:ef7eb2e8f9f7 36 [..]
<> 144:ef7eb2e8f9f7 37 Digital to Analog conversion can be triggered by:
<> 144:ef7eb2e8f9f7 38 (#) External event: EXTI Line 9 (any GPIOx_PIN_9) using DAC_TRIGGER_EXT_IT9.
<> 144:ef7eb2e8f9f7 39 The used pin (GPIOx_PIN_9) must be configured in input mode.
<> 144:ef7eb2e8f9f7 40
<> 144:ef7eb2e8f9f7 41 (#) Timers TRGO: TIM2, TIM3, TIM6, and TIM15
<> 144:ef7eb2e8f9f7 42 (DAC_TRIGGER_T2_TRGO, DAC_TRIGGER_T3_TRGO...)
<> 144:ef7eb2e8f9f7 43
<> 144:ef7eb2e8f9f7 44 (#) Software using DAC_TRIGGER_SOFTWARE
<> 144:ef7eb2e8f9f7 45
<> 144:ef7eb2e8f9f7 46 *** DAC Buffer mode feature ***
<> 144:ef7eb2e8f9f7 47 ===============================
<> 144:ef7eb2e8f9f7 48 [..]
<> 144:ef7eb2e8f9f7 49 Each DAC channel integrates an output buffer that can be used to
<> 144:ef7eb2e8f9f7 50 reduce the output impedance, and to drive external loads directly
<> 144:ef7eb2e8f9f7 51 without having to add an external operational amplifier.
<> 144:ef7eb2e8f9f7 52 To enable, the output buffer use
<> 144:ef7eb2e8f9f7 53 sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
<> 144:ef7eb2e8f9f7 54 [..]
<> 144:ef7eb2e8f9f7 55 (@) Refer to the device datasheet for more details about output
<> 144:ef7eb2e8f9f7 56 impedance value with and without output buffer.
<> 144:ef7eb2e8f9f7 57
<> 144:ef7eb2e8f9f7 58 *** GPIO configurations guidelines ***
<> 144:ef7eb2e8f9f7 59 =====================
<> 144:ef7eb2e8f9f7 60 [..]
<> 144:ef7eb2e8f9f7 61 When a DAC channel is used (ex channel1 on PA4) and the other is not
<> 144:ef7eb2e8f9f7 62 (ex channel1 on PA5 is configured in Analog and disabled).
<> 144:ef7eb2e8f9f7 63 Channel1 may disturb channel2 as coupling effect.
<> 144:ef7eb2e8f9f7 64 Note that there is no coupling on channel2 as soon as channel2 is turned on.
<> 144:ef7eb2e8f9f7 65 Coupling on adjacent channel could be avoided as follows:
<> 144:ef7eb2e8f9f7 66 when unused PA5 is configured as INPUT PULL-UP or DOWN.
<> 144:ef7eb2e8f9f7 67 PA5 is configured in ANALOG just before it is turned on.
<> 144:ef7eb2e8f9f7 68
<> 144:ef7eb2e8f9f7 69 *** DAC wave generation feature ***
<> 144:ef7eb2e8f9f7 70 ===================================
<> 144:ef7eb2e8f9f7 71 [..]
<> 144:ef7eb2e8f9f7 72 Both DAC channels can be used to generate
<> 144:ef7eb2e8f9f7 73 (#) Noise wave
<> 144:ef7eb2e8f9f7 74 (#) Triangle wave
<> 144:ef7eb2e8f9f7 75
<> 144:ef7eb2e8f9f7 76 *** DAC data format ***
<> 144:ef7eb2e8f9f7 77 =======================
<> 144:ef7eb2e8f9f7 78 [..]
<> 144:ef7eb2e8f9f7 79 The DAC data format can be:
<> 144:ef7eb2e8f9f7 80 (#) 8-bit right alignment using DAC_ALIGN_8B_R
<> 144:ef7eb2e8f9f7 81 (#) 12-bit left alignment using DAC_ALIGN_12B_L
<> 144:ef7eb2e8f9f7 82 (#) 12-bit right alignment using DAC_ALIGN_12B_R
<> 144:ef7eb2e8f9f7 83
<> 144:ef7eb2e8f9f7 84 *** DAC data value to voltage correspondance ***
<> 144:ef7eb2e8f9f7 85 ================================================
<> 144:ef7eb2e8f9f7 86 [..]
<> 144:ef7eb2e8f9f7 87 The analog output voltage on each DAC channel pin is determined
<> 144:ef7eb2e8f9f7 88 by the following equation:
<> 144:ef7eb2e8f9f7 89 [..]
<> 144:ef7eb2e8f9f7 90 DAC_OUTx = VREF+ * DOR / 4095
<> 144:ef7eb2e8f9f7 91 (+) with DOR is the Data Output Register
<> 144:ef7eb2e8f9f7 92 [..]
<> 144:ef7eb2e8f9f7 93 VEF+ is the input voltage reference (refer to the device datasheet)
<> 144:ef7eb2e8f9f7 94 [..]
<> 144:ef7eb2e8f9f7 95 e.g. To set DAC_OUT1 to 0.7V, use
<> 144:ef7eb2e8f9f7 96 (+) Assuming that VREF+ = 3.3V, DAC_OUT1 = (3.3 * 868) / 4095 = 0.7V
<> 144:ef7eb2e8f9f7 97
<> 144:ef7eb2e8f9f7 98 *** DMA requests ***
<> 144:ef7eb2e8f9f7 99 =====================
<> 144:ef7eb2e8f9f7 100 [..]
<> 144:ef7eb2e8f9f7 101 A DMA1 request can be generated when an external trigger (but not
<> 144:ef7eb2e8f9f7 102 a software trigger) occurs if DMA1 requests are enabled using
<> 144:ef7eb2e8f9f7 103 HAL_DAC_Start_DMA()
<> 144:ef7eb2e8f9f7 104 [..]
<> 144:ef7eb2e8f9f7 105 DMA1 requests are mapped as following:
<> 144:ef7eb2e8f9f7 106 (#) DAC channel1 : mapped on DMA1 channel3 which must be
<> 144:ef7eb2e8f9f7 107 already configured
<> 144:ef7eb2e8f9f7 108 (#) DAC channel2 : mapped on DMA1 channel4 which must be
<> 144:ef7eb2e8f9f7 109 already configured
<> 144:ef7eb2e8f9f7 110
<> 144:ef7eb2e8f9f7 111 (@) For Dual mode and specific signal (Triangle and noise) generation please
<> 144:ef7eb2e8f9f7 112 refer to Extended Features Driver description
<> 144:ef7eb2e8f9f7 113 STM32F0 devices with one channel (one converting capability) does not
<> 144:ef7eb2e8f9f7 114 support Dual mode and specific signal (Triangle and noise) generation.
<> 144:ef7eb2e8f9f7 115
<> 144:ef7eb2e8f9f7 116 ##### How to use this driver #####
<> 144:ef7eb2e8f9f7 117 ==============================================================================
<> 144:ef7eb2e8f9f7 118 [..]
<> 144:ef7eb2e8f9f7 119 (+) DAC APB clock must be enabled to get write access to DAC
<> 144:ef7eb2e8f9f7 120 registers using HAL_DAC_Init()
<> 144:ef7eb2e8f9f7 121 (+) Configure DAC_OUTx (DAC_OUT1: PA4, DAC_OUT2: PA5) in analog mode.
<> 144:ef7eb2e8f9f7 122 (+) Configure the DAC channel using HAL_DAC_ConfigChannel() function.
<> 144:ef7eb2e8f9f7 123 (+) Enable the DAC channel using HAL_DAC_Start() or HAL_DAC_Start_DMA() functions.
<> 144:ef7eb2e8f9f7 124
<> 144:ef7eb2e8f9f7 125 *** Polling mode IO operation ***
<> 144:ef7eb2e8f9f7 126 =================================
<> 144:ef7eb2e8f9f7 127 [..]
<> 144:ef7eb2e8f9f7 128 (+) Start the DAC peripheral using HAL_DAC_Start()
<> 144:ef7eb2e8f9f7 129 (+) To read the DAC last data output value, use the HAL_DAC_GetValue() function.
<> 144:ef7eb2e8f9f7 130 (+) Stop the DAC peripheral using HAL_DAC_Stop()
<> 144:ef7eb2e8f9f7 131
<> 144:ef7eb2e8f9f7 132 *** DMA mode IO operation ***
<> 144:ef7eb2e8f9f7 133 ==============================
<> 144:ef7eb2e8f9f7 134 [..]
<> 144:ef7eb2e8f9f7 135 (+) Start the DAC peripheral using HAL_DAC_Start_DMA(), at this stage the user specify the length
<> 144:ef7eb2e8f9f7 136 of data to be transferred at each end of conversion
<> 144:ef7eb2e8f9f7 137 (+) At the middle of data transfer HAL_DAC_ConvHalfCpltCallbackCh1() or HAL_DACEx_ConvHalfCpltCallbackCh2()
<> 144:ef7eb2e8f9f7 138 function is executed and user can add his own code by customization of function pointer
<> 144:ef7eb2e8f9f7 139 HAL_DAC_ConvHalfCpltCallbackCh1() or HAL_DACEx_ConvHalfCpltCallbackCh2()
<> 144:ef7eb2e8f9f7 140 (+) At The end of data transfer HAL_DAC_ConvCpltCallbackCh1() or HAL_DACEx_ConvHalfCpltCallbackCh2()
<> 144:ef7eb2e8f9f7 141 function is executed and user can add his own code by customization of function pointer
<> 144:ef7eb2e8f9f7 142 HAL_DAC_ConvCpltCallbackCh1() or HAL_DACEx_ConvHalfCpltCallbackCh2()
<> 144:ef7eb2e8f9f7 143 (+) In case of transfer Error, HAL_DAC_ErrorCallbackCh1() function is executed and user can
<> 144:ef7eb2e8f9f7 144 add his own code by customization of function pointer HAL_DAC_ErrorCallbackCh1
<> 144:ef7eb2e8f9f7 145 (+) In case of DMA underrun, DAC interruption triggers and execute internal function HAL_DAC_IRQHandler.
<> 144:ef7eb2e8f9f7 146 HAL_DAC_DMAUnderrunCallbackCh1() or HAL_DACEx_DMAUnderrunCallbackCh2()
<> 144:ef7eb2e8f9f7 147 function is executed and user can add his own code by customization of function pointer
<> 144:ef7eb2e8f9f7 148 HAL_DAC_DMAUnderrunCallbackCh1() or HAL_DACEx_DMAUnderrunCallbackCh2() and
<> 144:ef7eb2e8f9f7 149 add his own code by customization of function pointer HAL_DAC_ErrorCallbackCh1()
<> 144:ef7eb2e8f9f7 150 (+) Stop the DAC peripheral using HAL_DAC_Stop_DMA()
<> 144:ef7eb2e8f9f7 151
<> 144:ef7eb2e8f9f7 152 *** DAC HAL driver macros list ***
<> 144:ef7eb2e8f9f7 153 =============================================
<> 144:ef7eb2e8f9f7 154 [..]
<> 144:ef7eb2e8f9f7 155 Below the list of most used macros in DAC HAL driver.
<> 144:ef7eb2e8f9f7 156
<> 144:ef7eb2e8f9f7 157 (+) __HAL_DAC_ENABLE : Enable the DAC peripheral
<> 144:ef7eb2e8f9f7 158 (+) __HAL_DAC_DISABLE : Disable the DAC peripheral
<> 144:ef7eb2e8f9f7 159 (+) __HAL_DAC_CLEAR_FLAG: Clear the DAC's pending flags
<> 144:ef7eb2e8f9f7 160 (+) __HAL_DAC_GET_FLAG: Get the selected DAC's flag status
<> 144:ef7eb2e8f9f7 161
<> 144:ef7eb2e8f9f7 162 [..]
<> 144:ef7eb2e8f9f7 163 (@) You can refer to the DAC HAL driver header file for more useful macros
<> 144:ef7eb2e8f9f7 164
<> 144:ef7eb2e8f9f7 165 @endverbatim
<> 144:ef7eb2e8f9f7 166 ******************************************************************************
<> 144:ef7eb2e8f9f7 167 * @attention
<> 144:ef7eb2e8f9f7 168 *
<> 144:ef7eb2e8f9f7 169 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
<> 144:ef7eb2e8f9f7 170 *
<> 144:ef7eb2e8f9f7 171 * Redistribution and use in source and binary forms, with or without modification,
<> 144:ef7eb2e8f9f7 172 * are permitted provided that the following conditions are met:
<> 144:ef7eb2e8f9f7 173 * 1. Redistributions of source code must retain the above copyright notice,
<> 144:ef7eb2e8f9f7 174 * this list of conditions and the following disclaimer.
<> 144:ef7eb2e8f9f7 175 * 2. Redistributions in binary form must reproduce the above copyright notice,
<> 144:ef7eb2e8f9f7 176 * this list of conditions and the following disclaimer in the documentation
<> 144:ef7eb2e8f9f7 177 * and/or other materials provided with the distribution.
<> 144:ef7eb2e8f9f7 178 * 3. Neither the name of STMicroelectronics nor the names of its contributors
<> 144:ef7eb2e8f9f7 179 * may be used to endorse or promote products derived from this software
<> 144:ef7eb2e8f9f7 180 * without specific prior written permission.
<> 144:ef7eb2e8f9f7 181 *
<> 144:ef7eb2e8f9f7 182 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
<> 144:ef7eb2e8f9f7 183 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
<> 144:ef7eb2e8f9f7 184 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
<> 144:ef7eb2e8f9f7 185 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
<> 144:ef7eb2e8f9f7 186 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
<> 144:ef7eb2e8f9f7 187 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
<> 144:ef7eb2e8f9f7 188 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
<> 144:ef7eb2e8f9f7 189 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
<> 144:ef7eb2e8f9f7 190 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
<> 144:ef7eb2e8f9f7 191 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<> 144:ef7eb2e8f9f7 192 *
<> 144:ef7eb2e8f9f7 193 ******************************************************************************
<> 144:ef7eb2e8f9f7 194 */
<> 144:ef7eb2e8f9f7 195
<> 144:ef7eb2e8f9f7 196
<> 144:ef7eb2e8f9f7 197 /* Includes ------------------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 198 #include "stm32f0xx_hal.h"
<> 144:ef7eb2e8f9f7 199
<> 144:ef7eb2e8f9f7 200 /** @addtogroup STM32F0xx_HAL_Driver
<> 144:ef7eb2e8f9f7 201 * @{
<> 144:ef7eb2e8f9f7 202 */
<> 144:ef7eb2e8f9f7 203
<> 144:ef7eb2e8f9f7 204 #ifdef HAL_DAC_MODULE_ENABLED
<> 144:ef7eb2e8f9f7 205
<> 144:ef7eb2e8f9f7 206 #if defined(STM32F051x8) || defined(STM32F058xx) || \
<> 144:ef7eb2e8f9f7 207 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
<> 144:ef7eb2e8f9f7 208 defined(STM32F091xC) || defined (STM32F098xx)
<> 144:ef7eb2e8f9f7 209
<> 144:ef7eb2e8f9f7 210 /** @defgroup DAC DAC
<> 144:ef7eb2e8f9f7 211 * @brief DAC driver modules
<> 144:ef7eb2e8f9f7 212 * @{
<> 144:ef7eb2e8f9f7 213 */
<> 144:ef7eb2e8f9f7 214
<> 144:ef7eb2e8f9f7 215 /* Private typedef -----------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 216 /* Private define ------------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 217 /* Private macro -------------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 218 /** @defgroup DAC_Private_Macros DAC Private Macros
<> 144:ef7eb2e8f9f7 219 * @{
<> 144:ef7eb2e8f9f7 220 */
<> 144:ef7eb2e8f9f7 221 /**
<> 144:ef7eb2e8f9f7 222 * @}
<> 144:ef7eb2e8f9f7 223 */
<> 144:ef7eb2e8f9f7 224
<> 144:ef7eb2e8f9f7 225 /* Private variables ---------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 226 /* Private function prototypes -----------------------------------------------*/
<> 144:ef7eb2e8f9f7 227 /** @defgroup DAC_Private_Functions DAC Private Functions
<> 144:ef7eb2e8f9f7 228 * @{
<> 144:ef7eb2e8f9f7 229 */
<> 144:ef7eb2e8f9f7 230 /**
<> 144:ef7eb2e8f9f7 231 * @}
<> 144:ef7eb2e8f9f7 232 */
<> 144:ef7eb2e8f9f7 233
<> 144:ef7eb2e8f9f7 234 /* Exported functions -------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 235
<> 144:ef7eb2e8f9f7 236 /** @defgroup DAC_Exported_Functions DAC Exported Functions
<> 144:ef7eb2e8f9f7 237 * @{
<> 144:ef7eb2e8f9f7 238 */
<> 144:ef7eb2e8f9f7 239
<> 144:ef7eb2e8f9f7 240 /** @defgroup DAC_Exported_Functions_Group1 Initialization and de-initialization functions
<> 144:ef7eb2e8f9f7 241 * @brief Initialization and Configuration functions
<> 144:ef7eb2e8f9f7 242 *
<> 144:ef7eb2e8f9f7 243 @verbatim
<> 144:ef7eb2e8f9f7 244 ==============================================================================
<> 144:ef7eb2e8f9f7 245 ##### Initialization and de-initialization functions #####
<> 144:ef7eb2e8f9f7 246 ==============================================================================
<> 144:ef7eb2e8f9f7 247 [..] This section provides functions allowing to:
<> 144:ef7eb2e8f9f7 248 (+) Initialize and configure the DAC.
<> 144:ef7eb2e8f9f7 249 (+) De-initialize the DAC.
<> 144:ef7eb2e8f9f7 250
<> 144:ef7eb2e8f9f7 251 @endverbatim
<> 144:ef7eb2e8f9f7 252 * @{
<> 144:ef7eb2e8f9f7 253 */
<> 144:ef7eb2e8f9f7 254
<> 144:ef7eb2e8f9f7 255 /**
<> 144:ef7eb2e8f9f7 256 * @brief Initialize the DAC peripheral according to the specified parameters
<> 144:ef7eb2e8f9f7 257 * in the DAC_InitStruct and initialize the associated handle.
Anna Bridge 180:96ed750bd169 258 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 259 * the configuration information for the specified DAC.
<> 144:ef7eb2e8f9f7 260 * @retval HAL status
<> 144:ef7eb2e8f9f7 261 */
<> 144:ef7eb2e8f9f7 262 HAL_StatusTypeDef HAL_DAC_Init(DAC_HandleTypeDef* hdac)
<> 144:ef7eb2e8f9f7 263 {
<> 144:ef7eb2e8f9f7 264 /* Check DAC handle */
<> 144:ef7eb2e8f9f7 265 if(hdac == NULL)
<> 144:ef7eb2e8f9f7 266 {
<> 144:ef7eb2e8f9f7 267 return HAL_ERROR;
<> 144:ef7eb2e8f9f7 268 }
<> 144:ef7eb2e8f9f7 269 /* Check the parameters */
<> 144:ef7eb2e8f9f7 270 assert_param(IS_DAC_ALL_INSTANCE(hdac->Instance));
<> 144:ef7eb2e8f9f7 271
<> 144:ef7eb2e8f9f7 272 if(hdac->State == HAL_DAC_STATE_RESET)
<> 144:ef7eb2e8f9f7 273 {
<> 144:ef7eb2e8f9f7 274 /* Allocate lock resource and initialize it */
<> 144:ef7eb2e8f9f7 275 hdac->Lock = HAL_UNLOCKED;
<> 144:ef7eb2e8f9f7 276
<> 144:ef7eb2e8f9f7 277 /* Init the low level hardware */
<> 144:ef7eb2e8f9f7 278 HAL_DAC_MspInit(hdac);
<> 144:ef7eb2e8f9f7 279 }
<> 144:ef7eb2e8f9f7 280
<> 144:ef7eb2e8f9f7 281 /* Initialize the DAC state*/
<> 144:ef7eb2e8f9f7 282 hdac->State = HAL_DAC_STATE_BUSY;
<> 144:ef7eb2e8f9f7 283
<> 144:ef7eb2e8f9f7 284 /* Set DAC error code to none */
<> 144:ef7eb2e8f9f7 285 hdac->ErrorCode = HAL_DAC_ERROR_NONE;
<> 144:ef7eb2e8f9f7 286
<> 144:ef7eb2e8f9f7 287 /* Initialize the DAC state*/
<> 144:ef7eb2e8f9f7 288 hdac->State = HAL_DAC_STATE_READY;
<> 144:ef7eb2e8f9f7 289
<> 144:ef7eb2e8f9f7 290 /* Return function status */
<> 144:ef7eb2e8f9f7 291 return HAL_OK;
<> 144:ef7eb2e8f9f7 292 }
<> 144:ef7eb2e8f9f7 293
<> 144:ef7eb2e8f9f7 294 /**
<> 144:ef7eb2e8f9f7 295 * @brief Deinitialize the DAC peripheral registers to their default reset values.
Anna Bridge 180:96ed750bd169 296 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 297 * the configuration information for the specified DAC.
<> 144:ef7eb2e8f9f7 298 * @retval HAL status
<> 144:ef7eb2e8f9f7 299 */
<> 144:ef7eb2e8f9f7 300 HAL_StatusTypeDef HAL_DAC_DeInit(DAC_HandleTypeDef* hdac)
<> 144:ef7eb2e8f9f7 301 {
<> 144:ef7eb2e8f9f7 302 /* Check DAC handle */
<> 144:ef7eb2e8f9f7 303 if(hdac == NULL)
<> 144:ef7eb2e8f9f7 304 {
<> 144:ef7eb2e8f9f7 305 return HAL_ERROR;
<> 144:ef7eb2e8f9f7 306 }
<> 144:ef7eb2e8f9f7 307
<> 144:ef7eb2e8f9f7 308 /* Check the parameters */
<> 144:ef7eb2e8f9f7 309 assert_param(IS_DAC_ALL_INSTANCE(hdac->Instance));
<> 144:ef7eb2e8f9f7 310
<> 144:ef7eb2e8f9f7 311 /* Change DAC state */
<> 144:ef7eb2e8f9f7 312 hdac->State = HAL_DAC_STATE_BUSY;
<> 144:ef7eb2e8f9f7 313
<> 144:ef7eb2e8f9f7 314 /* DeInit the low level hardware */
<> 144:ef7eb2e8f9f7 315 HAL_DAC_MspDeInit(hdac);
<> 144:ef7eb2e8f9f7 316
<> 144:ef7eb2e8f9f7 317 /* Set DAC error code to none */
<> 144:ef7eb2e8f9f7 318 hdac->ErrorCode = HAL_DAC_ERROR_NONE;
<> 144:ef7eb2e8f9f7 319
<> 144:ef7eb2e8f9f7 320 /* Change DAC state */
<> 144:ef7eb2e8f9f7 321 hdac->State = HAL_DAC_STATE_RESET;
<> 144:ef7eb2e8f9f7 322
<> 144:ef7eb2e8f9f7 323 /* Release Lock */
<> 144:ef7eb2e8f9f7 324 __HAL_UNLOCK(hdac);
<> 144:ef7eb2e8f9f7 325
<> 144:ef7eb2e8f9f7 326 /* Return function status */
<> 144:ef7eb2e8f9f7 327 return HAL_OK;
<> 144:ef7eb2e8f9f7 328 }
<> 144:ef7eb2e8f9f7 329
<> 144:ef7eb2e8f9f7 330 /**
<> 144:ef7eb2e8f9f7 331 * @brief Initialize the DAC MSP.
Anna Bridge 180:96ed750bd169 332 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 333 * the configuration information for the specified DAC.
<> 144:ef7eb2e8f9f7 334 * @retval None
<> 144:ef7eb2e8f9f7 335 */
<> 144:ef7eb2e8f9f7 336 __weak void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac)
<> 144:ef7eb2e8f9f7 337 {
<> 144:ef7eb2e8f9f7 338 /* Prevent unused argument(s) compilation warning */
<> 144:ef7eb2e8f9f7 339 UNUSED(hdac);
<> 144:ef7eb2e8f9f7 340
<> 144:ef7eb2e8f9f7 341 /* NOTE : This function should not be modified, when the callback is needed,
<> 144:ef7eb2e8f9f7 342 the HAL_DAC_MspInit could be implemented in the user file
<> 144:ef7eb2e8f9f7 343 */
<> 144:ef7eb2e8f9f7 344 }
<> 144:ef7eb2e8f9f7 345
<> 144:ef7eb2e8f9f7 346 /**
<> 144:ef7eb2e8f9f7 347 * @brief DeInitialize the DAC MSP.
Anna Bridge 180:96ed750bd169 348 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 349 * the configuration information for the specified DAC.
<> 144:ef7eb2e8f9f7 350 * @retval None
<> 144:ef7eb2e8f9f7 351 */
<> 144:ef7eb2e8f9f7 352 __weak void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac)
<> 144:ef7eb2e8f9f7 353 {
<> 144:ef7eb2e8f9f7 354 /* Prevent unused argument(s) compilation warning */
<> 144:ef7eb2e8f9f7 355 UNUSED(hdac);
<> 144:ef7eb2e8f9f7 356
<> 144:ef7eb2e8f9f7 357 /* NOTE : This function should not be modified, when the callback is needed,
<> 144:ef7eb2e8f9f7 358 the HAL_DAC_MspDeInit could be implemented in the user file
<> 144:ef7eb2e8f9f7 359 */
<> 144:ef7eb2e8f9f7 360 }
<> 144:ef7eb2e8f9f7 361
<> 144:ef7eb2e8f9f7 362 /**
<> 144:ef7eb2e8f9f7 363 * @}
<> 144:ef7eb2e8f9f7 364 */
<> 144:ef7eb2e8f9f7 365
<> 144:ef7eb2e8f9f7 366 /** @defgroup DAC_Exported_Functions_Group2 IO operation functions
<> 144:ef7eb2e8f9f7 367 * @brief IO operation functions
<> 144:ef7eb2e8f9f7 368 *
<> 144:ef7eb2e8f9f7 369 @verbatim
<> 144:ef7eb2e8f9f7 370 ==============================================================================
<> 144:ef7eb2e8f9f7 371 ##### IO operation functions #####
<> 144:ef7eb2e8f9f7 372 ==============================================================================
<> 144:ef7eb2e8f9f7 373 [..] This section provides functions allowing to:
<> 144:ef7eb2e8f9f7 374 (+) Start conversion.
<> 144:ef7eb2e8f9f7 375 (+) Stop conversion.
<> 144:ef7eb2e8f9f7 376 (+) Start conversion and enable DMA transfer.
<> 144:ef7eb2e8f9f7 377 (+) Stop conversion and disable DMA transfer.
<> 144:ef7eb2e8f9f7 378 (+) Set the specified data holding register value for DAC channel.
<> 144:ef7eb2e8f9f7 379
<> 144:ef7eb2e8f9f7 380 @endverbatim
<> 144:ef7eb2e8f9f7 381 * @{
<> 144:ef7eb2e8f9f7 382 */
<> 144:ef7eb2e8f9f7 383
<> 144:ef7eb2e8f9f7 384 /**
<> 144:ef7eb2e8f9f7 385 * @brief Enables DAC and starts conversion of channel.
Anna Bridge 180:96ed750bd169 386 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 387 * the configuration information for the specified DAC.
Anna Bridge 180:96ed750bd169 388 * @param Channel The selected DAC channel.
<> 144:ef7eb2e8f9f7 389 * This parameter can be one of the following values:
<> 144:ef7eb2e8f9f7 390 * @arg DAC_CHANNEL_1: DAC Channel1 selected
<> 144:ef7eb2e8f9f7 391 * @arg DAC_CHANNEL_2: DAC Channel2 selected
<> 144:ef7eb2e8f9f7 392 * @retval HAL status
<> 144:ef7eb2e8f9f7 393 */
<> 144:ef7eb2e8f9f7 394 __weak HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef* hdac, uint32_t Channel)
<> 144:ef7eb2e8f9f7 395 {
<> 144:ef7eb2e8f9f7 396 /* Prevent unused argument(s) compilation warning */
<> 144:ef7eb2e8f9f7 397 UNUSED(hdac);
<> 144:ef7eb2e8f9f7 398 UNUSED(Channel);
<> 144:ef7eb2e8f9f7 399
<> 144:ef7eb2e8f9f7 400 /* Note : This function is defined into this file for library reference. */
<> 144:ef7eb2e8f9f7 401 /* Function content is located into file stm32f0xx_hal_dac_ex.c */
<> 144:ef7eb2e8f9f7 402
<> 144:ef7eb2e8f9f7 403 /* Return error status as not implemented here */
<> 144:ef7eb2e8f9f7 404 return HAL_ERROR;
<> 144:ef7eb2e8f9f7 405 }
<> 144:ef7eb2e8f9f7 406
<> 144:ef7eb2e8f9f7 407 /**
<> 144:ef7eb2e8f9f7 408 * @brief Disables DAC and stop conversion of channel.
Anna Bridge 180:96ed750bd169 409 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 410 * the configuration information for the specified DAC.
Anna Bridge 180:96ed750bd169 411 * @param Channel The selected DAC channel.
<> 144:ef7eb2e8f9f7 412 * This parameter can be one of the following values:
<> 144:ef7eb2e8f9f7 413 * @arg DAC_CHANNEL_1: DAC Channel1 selected
<> 144:ef7eb2e8f9f7 414 * @arg DAC_CHANNEL_2: DAC Channel2 selected
<> 144:ef7eb2e8f9f7 415 * @retval HAL status
<> 144:ef7eb2e8f9f7 416 */
<> 144:ef7eb2e8f9f7 417 HAL_StatusTypeDef HAL_DAC_Stop(DAC_HandleTypeDef* hdac, uint32_t Channel)
<> 144:ef7eb2e8f9f7 418 {
<> 144:ef7eb2e8f9f7 419 /* Check the parameters */
<> 144:ef7eb2e8f9f7 420 assert_param(IS_DAC_CHANNEL(Channel));
<> 144:ef7eb2e8f9f7 421
<> 144:ef7eb2e8f9f7 422 /* Disable the Peripheral */
<> 144:ef7eb2e8f9f7 423 __HAL_DAC_DISABLE(hdac, Channel);
<> 144:ef7eb2e8f9f7 424
<> 144:ef7eb2e8f9f7 425 /* Change DAC state */
<> 144:ef7eb2e8f9f7 426 hdac->State = HAL_DAC_STATE_READY;
<> 144:ef7eb2e8f9f7 427
<> 144:ef7eb2e8f9f7 428 /* Return function status */
<> 144:ef7eb2e8f9f7 429 return HAL_OK;
<> 144:ef7eb2e8f9f7 430 }
<> 144:ef7eb2e8f9f7 431
<> 144:ef7eb2e8f9f7 432 /**
<> 144:ef7eb2e8f9f7 433 * @brief Enables DAC and starts conversion of channel.
Anna Bridge 180:96ed750bd169 434 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 435 * the configuration information for the specified DAC.
Anna Bridge 180:96ed750bd169 436 * @param Channel The selected DAC channel.
<> 144:ef7eb2e8f9f7 437 * This parameter can be one of the following values:
<> 144:ef7eb2e8f9f7 438 * @arg DAC_CHANNEL_1: DAC Channel1 selected
<> 144:ef7eb2e8f9f7 439 * @arg DAC_CHANNEL_2: DAC Channel2 selected
Anna Bridge 180:96ed750bd169 440 * @param pData The destination peripheral Buffer address.
Anna Bridge 180:96ed750bd169 441 * @param Length The length of data to be transferred from memory to DAC peripheral
Anna Bridge 180:96ed750bd169 442 * @param Alignment Specifies the data alignment for DAC channel.
<> 144:ef7eb2e8f9f7 443 * This parameter can be one of the following values:
<> 144:ef7eb2e8f9f7 444 * @arg DAC_ALIGN_8B_R: 8bit right data alignment selected
<> 144:ef7eb2e8f9f7 445 * @arg DAC_ALIGN_12B_L: 12bit left data alignment selected
<> 144:ef7eb2e8f9f7 446 * @arg DAC_ALIGN_12B_R: 12bit right data alignment selected
<> 144:ef7eb2e8f9f7 447 * @retval HAL status
<> 144:ef7eb2e8f9f7 448 */
<> 144:ef7eb2e8f9f7 449 __weak HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t* pData, uint32_t Length, uint32_t Alignment)
<> 144:ef7eb2e8f9f7 450 {
<> 144:ef7eb2e8f9f7 451 /* Prevent unused argument(s) compilation warning */
<> 144:ef7eb2e8f9f7 452 UNUSED(hdac);
<> 144:ef7eb2e8f9f7 453 UNUSED(Channel);
<> 144:ef7eb2e8f9f7 454 UNUSED(pData);
<> 144:ef7eb2e8f9f7 455 UNUSED(Length);
<> 144:ef7eb2e8f9f7 456 UNUSED(Alignment);
<> 144:ef7eb2e8f9f7 457
<> 144:ef7eb2e8f9f7 458 /* Note : This function is defined into this file for library reference. */
<> 144:ef7eb2e8f9f7 459 /* Function content is located into file stm32f0xx_hal_dac_ex.c */
<> 144:ef7eb2e8f9f7 460
<> 144:ef7eb2e8f9f7 461 /* Return error status as not implemented here */
<> 144:ef7eb2e8f9f7 462 return HAL_ERROR;
<> 144:ef7eb2e8f9f7 463 }
<> 144:ef7eb2e8f9f7 464
<> 144:ef7eb2e8f9f7 465 /**
<> 144:ef7eb2e8f9f7 466 * @brief Disables DAC and stop conversion of channel.
Anna Bridge 180:96ed750bd169 467 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 468 * the configuration information for the specified DAC.
Anna Bridge 180:96ed750bd169 469 * @param Channel The selected DAC channel.
<> 144:ef7eb2e8f9f7 470 * This parameter can be one of the following values:
<> 144:ef7eb2e8f9f7 471 * @arg DAC_CHANNEL_1: DAC Channel1 selected
<> 144:ef7eb2e8f9f7 472 * @arg DAC_CHANNEL_2: DAC Channel2 selected
<> 144:ef7eb2e8f9f7 473 * @retval HAL status
<> 144:ef7eb2e8f9f7 474 */
<> 144:ef7eb2e8f9f7 475 HAL_StatusTypeDef HAL_DAC_Stop_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel)
<> 144:ef7eb2e8f9f7 476 {
<> 144:ef7eb2e8f9f7 477 HAL_StatusTypeDef status = HAL_OK;
<> 144:ef7eb2e8f9f7 478
<> 144:ef7eb2e8f9f7 479 /* Check the parameters */
<> 144:ef7eb2e8f9f7 480 assert_param(IS_DAC_CHANNEL(Channel));
<> 144:ef7eb2e8f9f7 481
<> 144:ef7eb2e8f9f7 482 /* Disable the selected DAC channel DMA request */
<> 144:ef7eb2e8f9f7 483 hdac->Instance->CR &= ~(DAC_CR_DMAEN1 << Channel);
<> 144:ef7eb2e8f9f7 484
<> 144:ef7eb2e8f9f7 485 /* Disable the Peripheral */
<> 144:ef7eb2e8f9f7 486 __HAL_DAC_DISABLE(hdac, Channel);
<> 144:ef7eb2e8f9f7 487
<> 144:ef7eb2e8f9f7 488 /* Disable the DMA channel */
<> 144:ef7eb2e8f9f7 489 /* Channel1 is used */
<> 144:ef7eb2e8f9f7 490 if (Channel == DAC_CHANNEL_1)
<> 144:ef7eb2e8f9f7 491 {
<> 144:ef7eb2e8f9f7 492 /* Disable the DMA channel */
<> 144:ef7eb2e8f9f7 493 status = HAL_DMA_Abort(hdac->DMA_Handle1);
<> 144:ef7eb2e8f9f7 494
<> 144:ef7eb2e8f9f7 495 /* Disable the DAC DMA underrun interrupt */
<> 144:ef7eb2e8f9f7 496 __HAL_DAC_DISABLE_IT(hdac, DAC_IT_DMAUDR1);
<> 144:ef7eb2e8f9f7 497 }
<> 144:ef7eb2e8f9f7 498
<> 144:ef7eb2e8f9f7 499 #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
<> 144:ef7eb2e8f9f7 500 defined(STM32F091xC) || defined (STM32F098xx)
<> 144:ef7eb2e8f9f7 501 /* Does not apply to STM32F051x8 & STM32F058xx */
<> 144:ef7eb2e8f9f7 502
<> 144:ef7eb2e8f9f7 503 else /* Channel2 is used for */
<> 144:ef7eb2e8f9f7 504 {
<> 144:ef7eb2e8f9f7 505 /* Disable the DMA channel */
<> 144:ef7eb2e8f9f7 506 status = HAL_DMA_Abort(hdac->DMA_Handle2);
<> 144:ef7eb2e8f9f7 507
<> 144:ef7eb2e8f9f7 508 /* Disable the DAC DMA underrun interrupt */
<> 144:ef7eb2e8f9f7 509 __HAL_DAC_DISABLE_IT(hdac, DAC_IT_DMAUDR2);
<> 144:ef7eb2e8f9f7 510 }
<> 144:ef7eb2e8f9f7 511 #endif /* STM32F071xB || STM32F072xB || STM32F078xx || */
<> 144:ef7eb2e8f9f7 512 /* STM32F091xC || STM32F098xx */
<> 144:ef7eb2e8f9f7 513
<> 144:ef7eb2e8f9f7 514 /* Check if DMA Channel effectively disabled */
<> 144:ef7eb2e8f9f7 515 if (status != HAL_OK)
<> 144:ef7eb2e8f9f7 516 {
<> 144:ef7eb2e8f9f7 517 /* Update DAC state machine to error */
<> 144:ef7eb2e8f9f7 518 hdac->State = HAL_DAC_STATE_ERROR;
<> 144:ef7eb2e8f9f7 519 }
<> 144:ef7eb2e8f9f7 520 else
<> 144:ef7eb2e8f9f7 521 {
<> 144:ef7eb2e8f9f7 522 /* Change DAC state */
<> 144:ef7eb2e8f9f7 523 hdac->State = HAL_DAC_STATE_READY;
<> 144:ef7eb2e8f9f7 524 }
<> 144:ef7eb2e8f9f7 525
<> 144:ef7eb2e8f9f7 526 /* Return function status */
<> 144:ef7eb2e8f9f7 527 return status;
<> 144:ef7eb2e8f9f7 528 }
<> 144:ef7eb2e8f9f7 529
<> 144:ef7eb2e8f9f7 530 /**
<> 144:ef7eb2e8f9f7 531 * @brief Handles DAC interrupt request
Anna Bridge 180:96ed750bd169 532 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 533 * the configuration information for the specified DAC.
<> 144:ef7eb2e8f9f7 534 * @retval None
<> 144:ef7eb2e8f9f7 535 */
<> 144:ef7eb2e8f9f7 536 __weak void HAL_DAC_IRQHandler(DAC_HandleTypeDef* hdac)
<> 144:ef7eb2e8f9f7 537 {
<> 144:ef7eb2e8f9f7 538 /* Prevent unused argument(s) compilation warning */
<> 144:ef7eb2e8f9f7 539 UNUSED(hdac);
<> 144:ef7eb2e8f9f7 540
<> 144:ef7eb2e8f9f7 541 /* Note : This function is defined into this file for library reference. */
<> 144:ef7eb2e8f9f7 542 /* Function content is located into file stm32f0xx_hal_dac_ex.c */
<> 144:ef7eb2e8f9f7 543 }
<> 144:ef7eb2e8f9f7 544
<> 144:ef7eb2e8f9f7 545 /**
<> 144:ef7eb2e8f9f7 546 * @brief Set the specified data holding register value for DAC channel.
Anna Bridge 180:96ed750bd169 547 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 548 * the configuration information for the specified DAC.
Anna Bridge 180:96ed750bd169 549 * @param Channel The selected DAC channel.
<> 144:ef7eb2e8f9f7 550 * This parameter can be one of the following values:
<> 144:ef7eb2e8f9f7 551 * @arg DAC_CHANNEL_1: DAC Channel1 selected
<> 144:ef7eb2e8f9f7 552 * @arg DAC_CHANNEL_2: DAC Channel2 selected
Anna Bridge 180:96ed750bd169 553 * @param Alignment Specifies the data alignment.
<> 144:ef7eb2e8f9f7 554 * This parameter can be one of the following values:
<> 144:ef7eb2e8f9f7 555 * @arg DAC_ALIGN_8B_R: 8bit right data alignment selected
<> 144:ef7eb2e8f9f7 556 * @arg DAC_ALIGN_12B_L: 12bit left data alignment selected
<> 144:ef7eb2e8f9f7 557 * @arg DAC_ALIGN_12B_R: 12bit right data alignment selected
Anna Bridge 180:96ed750bd169 558 * @param Data Data to be loaded in the selected data holding register.
<> 144:ef7eb2e8f9f7 559 * @retval HAL status
<> 144:ef7eb2e8f9f7 560 */
<> 144:ef7eb2e8f9f7 561 HAL_StatusTypeDef HAL_DAC_SetValue(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Alignment, uint32_t Data)
<> 144:ef7eb2e8f9f7 562 {
<> 144:ef7eb2e8f9f7 563 __IO uint32_t tmp = 0;
<> 144:ef7eb2e8f9f7 564
<> 144:ef7eb2e8f9f7 565 /* Check the parameters */
<> 144:ef7eb2e8f9f7 566 assert_param(IS_DAC_CHANNEL(Channel));
<> 144:ef7eb2e8f9f7 567 assert_param(IS_DAC_ALIGN(Alignment));
<> 144:ef7eb2e8f9f7 568 assert_param(IS_DAC_DATA(Data));
<> 144:ef7eb2e8f9f7 569
<> 144:ef7eb2e8f9f7 570 tmp = (uint32_t)hdac->Instance;
<> 144:ef7eb2e8f9f7 571 if(Channel == DAC_CHANNEL_1)
<> 144:ef7eb2e8f9f7 572 {
<> 144:ef7eb2e8f9f7 573 tmp += DAC_DHR12R1_ALIGNMENT(Alignment);
<> 144:ef7eb2e8f9f7 574 }
<> 144:ef7eb2e8f9f7 575 else
<> 144:ef7eb2e8f9f7 576 {
<> 144:ef7eb2e8f9f7 577 tmp += DAC_DHR12R2_ALIGNMENT(Alignment);
<> 144:ef7eb2e8f9f7 578 }
<> 144:ef7eb2e8f9f7 579
<> 144:ef7eb2e8f9f7 580 /* Set the DAC channel1 selected data holding register */
<> 144:ef7eb2e8f9f7 581 *(__IO uint32_t *) tmp = Data;
<> 144:ef7eb2e8f9f7 582
<> 144:ef7eb2e8f9f7 583 /* Return function status */
<> 144:ef7eb2e8f9f7 584 return HAL_OK;
<> 144:ef7eb2e8f9f7 585 }
<> 144:ef7eb2e8f9f7 586
<> 144:ef7eb2e8f9f7 587 /**
<> 144:ef7eb2e8f9f7 588 * @brief Conversion complete callback in non blocking mode for Channel1
Anna Bridge 180:96ed750bd169 589 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 590 * the configuration information for the specified DAC.
<> 144:ef7eb2e8f9f7 591 * @retval None
<> 144:ef7eb2e8f9f7 592 */
<> 144:ef7eb2e8f9f7 593 __weak void HAL_DAC_ConvCpltCallbackCh1(DAC_HandleTypeDef* hdac)
<> 144:ef7eb2e8f9f7 594 {
<> 144:ef7eb2e8f9f7 595 /* Prevent unused argument(s) compilation warning */
<> 144:ef7eb2e8f9f7 596 UNUSED(hdac);
<> 144:ef7eb2e8f9f7 597
<> 144:ef7eb2e8f9f7 598 /* NOTE : This function should not be modified, when the callback is needed,
<> 144:ef7eb2e8f9f7 599 the HAL_DAC_ConvCpltCallbackCh1 could be implemented in the user file
<> 144:ef7eb2e8f9f7 600 */
<> 144:ef7eb2e8f9f7 601 }
<> 144:ef7eb2e8f9f7 602
<> 144:ef7eb2e8f9f7 603 /**
<> 144:ef7eb2e8f9f7 604 * @brief Conversion half DMA transfer callback in non-blocking mode for Channel1
Anna Bridge 180:96ed750bd169 605 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 606 * the configuration information for the specified DAC.
<> 144:ef7eb2e8f9f7 607 * @retval None
<> 144:ef7eb2e8f9f7 608 */
<> 144:ef7eb2e8f9f7 609 __weak void HAL_DAC_ConvHalfCpltCallbackCh1(DAC_HandleTypeDef* hdac)
<> 144:ef7eb2e8f9f7 610 {
<> 144:ef7eb2e8f9f7 611 /* Prevent unused argument(s) compilation warning */
<> 144:ef7eb2e8f9f7 612 UNUSED(hdac);
<> 144:ef7eb2e8f9f7 613
<> 144:ef7eb2e8f9f7 614 /* NOTE : This function should not be modified, when the callback is needed,
<> 144:ef7eb2e8f9f7 615 the HAL_DAC_ConvHalfCpltCallbackCh1 could be implemented in the user file
<> 144:ef7eb2e8f9f7 616 */
<> 144:ef7eb2e8f9f7 617 }
<> 144:ef7eb2e8f9f7 618
<> 144:ef7eb2e8f9f7 619 /**
<> 144:ef7eb2e8f9f7 620 * @brief Error DAC callback for Channel1.
Anna Bridge 180:96ed750bd169 621 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 622 * the configuration information for the specified DAC.
<> 144:ef7eb2e8f9f7 623 * @retval None
<> 144:ef7eb2e8f9f7 624 */
<> 144:ef7eb2e8f9f7 625 __weak void HAL_DAC_ErrorCallbackCh1(DAC_HandleTypeDef *hdac)
<> 144:ef7eb2e8f9f7 626 {
<> 144:ef7eb2e8f9f7 627 /* Prevent unused argument(s) compilation warning */
<> 144:ef7eb2e8f9f7 628 UNUSED(hdac);
<> 144:ef7eb2e8f9f7 629
<> 144:ef7eb2e8f9f7 630 /* NOTE : This function should not be modified, when the callback is needed,
<> 144:ef7eb2e8f9f7 631 the HAL_DAC_ErrorCallbackCh1 could be implemented in the user file
<> 144:ef7eb2e8f9f7 632 */
<> 144:ef7eb2e8f9f7 633 }
<> 144:ef7eb2e8f9f7 634
<> 144:ef7eb2e8f9f7 635 /**
<> 144:ef7eb2e8f9f7 636 * @brief DMA underrun DAC callback for channel1.
Anna Bridge 180:96ed750bd169 637 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 638 * the configuration information for the specified DAC.
<> 144:ef7eb2e8f9f7 639 * @retval None
<> 144:ef7eb2e8f9f7 640 */
<> 144:ef7eb2e8f9f7 641 __weak void HAL_DAC_DMAUnderrunCallbackCh1(DAC_HandleTypeDef *hdac)
<> 144:ef7eb2e8f9f7 642 {
<> 144:ef7eb2e8f9f7 643 /* Prevent unused argument(s) compilation warning */
<> 144:ef7eb2e8f9f7 644 UNUSED(hdac);
<> 144:ef7eb2e8f9f7 645
<> 144:ef7eb2e8f9f7 646 /* NOTE : This function should not be modified, when the callback is needed,
<> 144:ef7eb2e8f9f7 647 the HAL_DAC_DMAUnderrunCallbackCh1 could be implemented in the user file
<> 144:ef7eb2e8f9f7 648 */
<> 144:ef7eb2e8f9f7 649 }
<> 144:ef7eb2e8f9f7 650
<> 144:ef7eb2e8f9f7 651 /**
<> 144:ef7eb2e8f9f7 652 * @}
<> 144:ef7eb2e8f9f7 653 */
<> 144:ef7eb2e8f9f7 654
<> 144:ef7eb2e8f9f7 655 /** @defgroup DAC_Exported_Functions_Group3 Peripheral Control functions
<> 144:ef7eb2e8f9f7 656 * @brief Peripheral Control functions
<> 144:ef7eb2e8f9f7 657 *
<> 144:ef7eb2e8f9f7 658 @verbatim
<> 144:ef7eb2e8f9f7 659 ==============================================================================
<> 144:ef7eb2e8f9f7 660 ##### Peripheral Control functions #####
<> 144:ef7eb2e8f9f7 661 ==============================================================================
<> 144:ef7eb2e8f9f7 662 [..] This section provides functions allowing to:
<> 144:ef7eb2e8f9f7 663 (+) Configure channels.
<> 144:ef7eb2e8f9f7 664 (+) Get result of conversion.
<> 144:ef7eb2e8f9f7 665
<> 144:ef7eb2e8f9f7 666 @endverbatim
<> 144:ef7eb2e8f9f7 667 * @{
<> 144:ef7eb2e8f9f7 668 */
<> 144:ef7eb2e8f9f7 669
<> 144:ef7eb2e8f9f7 670 /**
<> 144:ef7eb2e8f9f7 671 * @brief Returns the last data output value of the selected DAC channel.
Anna Bridge 180:96ed750bd169 672 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 673 * the configuration information for the specified DAC.
Anna Bridge 180:96ed750bd169 674 * @param Channel The selected DAC channel.
<> 144:ef7eb2e8f9f7 675 * This parameter can be one of the following values:
<> 144:ef7eb2e8f9f7 676 * @arg DAC_CHANNEL_1: DAC Channel1 selected
<> 144:ef7eb2e8f9f7 677 * @arg DAC_CHANNEL_2: DAC Channel2 selected
<> 144:ef7eb2e8f9f7 678 * @retval The selected DAC channel data output value.
<> 144:ef7eb2e8f9f7 679 */
<> 144:ef7eb2e8f9f7 680 __weak uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef* hdac, uint32_t Channel)
<> 144:ef7eb2e8f9f7 681 {
<> 144:ef7eb2e8f9f7 682 /* Prevent unused argument(s) compilation warning */
<> 144:ef7eb2e8f9f7 683 UNUSED(hdac);
<> 144:ef7eb2e8f9f7 684 UNUSED(Channel);
<> 144:ef7eb2e8f9f7 685
<> 144:ef7eb2e8f9f7 686 /* Note : This function is defined into this file for library reference. */
<> 144:ef7eb2e8f9f7 687 /* Function content is located into file stm32f0xx_hal_dac_ex.c */
<> 144:ef7eb2e8f9f7 688
<> 144:ef7eb2e8f9f7 689 /* Return error status as not implemented here */
<> 144:ef7eb2e8f9f7 690 return HAL_ERROR;
<> 144:ef7eb2e8f9f7 691 }
<> 144:ef7eb2e8f9f7 692
<> 144:ef7eb2e8f9f7 693 /**
<> 144:ef7eb2e8f9f7 694 * @brief Configures the selected DAC channel.
Anna Bridge 180:96ed750bd169 695 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 696 * the configuration information for the specified DAC.
Anna Bridge 180:96ed750bd169 697 * @param sConfig DAC configuration structure.
Anna Bridge 180:96ed750bd169 698 * @param Channel The selected DAC channel.
<> 144:ef7eb2e8f9f7 699 * This parameter can be one of the following values:
<> 144:ef7eb2e8f9f7 700 * @arg DAC_CHANNEL_1: DAC Channel1 selected
<> 144:ef7eb2e8f9f7 701 * @arg DAC_CHANNEL_2: DAC Channel2 selected
<> 144:ef7eb2e8f9f7 702 * @retval HAL status
<> 144:ef7eb2e8f9f7 703 */
<> 144:ef7eb2e8f9f7 704 __weak HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef* hdac, DAC_ChannelConfTypeDef* sConfig, uint32_t Channel)
<> 144:ef7eb2e8f9f7 705 {
<> 144:ef7eb2e8f9f7 706 /* Prevent unused argument(s) compilation warning */
<> 144:ef7eb2e8f9f7 707 UNUSED(hdac);
<> 144:ef7eb2e8f9f7 708 UNUSED(sConfig);
<> 144:ef7eb2e8f9f7 709 UNUSED(Channel);
<> 144:ef7eb2e8f9f7 710
<> 144:ef7eb2e8f9f7 711 /* Note : This function is defined into this file for library reference. */
<> 144:ef7eb2e8f9f7 712 /* Function content is located into file stm32f0xx_hal_dac_ex.c */
<> 144:ef7eb2e8f9f7 713
<> 144:ef7eb2e8f9f7 714 /* Return error status as not implemented here */
<> 144:ef7eb2e8f9f7 715 return HAL_ERROR;
<> 144:ef7eb2e8f9f7 716 }
<> 144:ef7eb2e8f9f7 717
<> 144:ef7eb2e8f9f7 718 /**
<> 144:ef7eb2e8f9f7 719 * @}
<> 144:ef7eb2e8f9f7 720 */
<> 144:ef7eb2e8f9f7 721
<> 144:ef7eb2e8f9f7 722 /** @defgroup DAC_Exported_Functions_Group4 Peripheral State and Errors functions
<> 144:ef7eb2e8f9f7 723 * @brief Peripheral State and Errors functions
<> 144:ef7eb2e8f9f7 724 *
<> 144:ef7eb2e8f9f7 725 @verbatim
<> 144:ef7eb2e8f9f7 726 ==============================================================================
<> 144:ef7eb2e8f9f7 727 ##### Peripheral State and Errors functions #####
<> 144:ef7eb2e8f9f7 728 ==============================================================================
<> 144:ef7eb2e8f9f7 729 [..]
<> 144:ef7eb2e8f9f7 730 This subsection provides functions allowing to
<> 144:ef7eb2e8f9f7 731 (+) Check the DAC state.
<> 144:ef7eb2e8f9f7 732 (+) Check the DAC Errors.
<> 144:ef7eb2e8f9f7 733
<> 144:ef7eb2e8f9f7 734 @endverbatim
<> 144:ef7eb2e8f9f7 735 * @{
<> 144:ef7eb2e8f9f7 736 */
<> 144:ef7eb2e8f9f7 737
<> 144:ef7eb2e8f9f7 738 /**
<> 144:ef7eb2e8f9f7 739 * @brief return the DAC handle state
Anna Bridge 180:96ed750bd169 740 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 741 * the configuration information for the specified DAC.
<> 144:ef7eb2e8f9f7 742 * @retval HAL state
<> 144:ef7eb2e8f9f7 743 */
<> 144:ef7eb2e8f9f7 744 HAL_DAC_StateTypeDef HAL_DAC_GetState(DAC_HandleTypeDef* hdac)
<> 144:ef7eb2e8f9f7 745 {
<> 144:ef7eb2e8f9f7 746 /* Return DAC handle state */
<> 144:ef7eb2e8f9f7 747 return hdac->State;
<> 144:ef7eb2e8f9f7 748 }
<> 144:ef7eb2e8f9f7 749
<> 144:ef7eb2e8f9f7 750
<> 144:ef7eb2e8f9f7 751 /**
<> 144:ef7eb2e8f9f7 752 * @brief Return the DAC error code
Anna Bridge 180:96ed750bd169 753 * @param hdac pointer to a DAC_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 754 * the configuration information for the specified DAC.
<> 144:ef7eb2e8f9f7 755 * @retval DAC Error Code
<> 144:ef7eb2e8f9f7 756 */
<> 144:ef7eb2e8f9f7 757 uint32_t HAL_DAC_GetError(DAC_HandleTypeDef *hdac)
<> 144:ef7eb2e8f9f7 758 {
<> 144:ef7eb2e8f9f7 759 return hdac->ErrorCode;
<> 144:ef7eb2e8f9f7 760 }
<> 144:ef7eb2e8f9f7 761
<> 144:ef7eb2e8f9f7 762 /**
<> 144:ef7eb2e8f9f7 763 * @}
<> 144:ef7eb2e8f9f7 764 */
<> 144:ef7eb2e8f9f7 765
<> 144:ef7eb2e8f9f7 766
<> 144:ef7eb2e8f9f7 767 /**
<> 144:ef7eb2e8f9f7 768 * @}
<> 144:ef7eb2e8f9f7 769 */
<> 144:ef7eb2e8f9f7 770
<> 144:ef7eb2e8f9f7 771 /**
<> 144:ef7eb2e8f9f7 772 * @}
<> 144:ef7eb2e8f9f7 773 */
<> 144:ef7eb2e8f9f7 774 #endif /* STM32F051x8 || STM32F058xx || */
<> 144:ef7eb2e8f9f7 775 /* STM32F071xB || STM32F072xB || STM32F078xx || */
<> 144:ef7eb2e8f9f7 776 /* STM32F091xC || STM32F098xx */
<> 144:ef7eb2e8f9f7 777
<> 144:ef7eb2e8f9f7 778 #endif /* HAL_DAC_MODULE_ENABLED */
<> 144:ef7eb2e8f9f7 779
<> 144:ef7eb2e8f9f7 780 /**
<> 144:ef7eb2e8f9f7 781 * @}
<> 144:ef7eb2e8f9f7 782 */
<> 144:ef7eb2e8f9f7 783
<> 144:ef7eb2e8f9f7 784
<> 144:ef7eb2e8f9f7 785 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/