mbed w/ spi bug fig

Dependents:   display-puck

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Thu May 22 20:00:09 2014 +0100
Revision:
205:c41fc65bcfb4
Child:
218:44081b78fdc2
Synchronized with git revision ea4b6f76efab17a3f7d7777b0cc1ef05fec6d1cb

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

[NUCLEO_F072RB] cmsis files

Who changed what in which revision?

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