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