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