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