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