mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
186:707f6e361f3e
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 158:b23ee177fd68 1 /**
Kojto 158:b23ee177fd68 2 ******************************************************************************
Kojto 158:b23ee177fd68 3 * @file stm32l0xx_ll_dac.h
Kojto 158:b23ee177fd68 4 * @author MCD Application Team
Kojto 158:b23ee177fd68 5 * @brief Header file of DAC LL module.
Kojto 158:b23ee177fd68 6 ******************************************************************************
Kojto 158:b23ee177fd68 7 * @attention
Kojto 158:b23ee177fd68 8 *
Kojto 158:b23ee177fd68 9 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 158:b23ee177fd68 10 *
Kojto 158:b23ee177fd68 11 * Redistribution and use in source and binary forms, with or without modification,
Kojto 158:b23ee177fd68 12 * are permitted provided that the following conditions are met:
Kojto 158:b23ee177fd68 13 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 158:b23ee177fd68 14 * this list of conditions and the following disclaimer.
Kojto 158:b23ee177fd68 15 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 158:b23ee177fd68 16 * this list of conditions and the following disclaimer in the documentation
Kojto 158:b23ee177fd68 17 * and/or other materials provided with the distribution.
Kojto 158:b23ee177fd68 18 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 158:b23ee177fd68 19 * may be used to endorse or promote products derived from this software
Kojto 158:b23ee177fd68 20 * without specific prior written permission.
Kojto 158:b23ee177fd68 21 *
Kojto 158:b23ee177fd68 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 158:b23ee177fd68 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 158:b23ee177fd68 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 158:b23ee177fd68 25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 158:b23ee177fd68 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 158:b23ee177fd68 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 158:b23ee177fd68 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 158:b23ee177fd68 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 158:b23ee177fd68 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 158:b23ee177fd68 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 158:b23ee177fd68 32 *
Kojto 158:b23ee177fd68 33 ******************************************************************************
Kojto 158:b23ee177fd68 34 */
Kojto 158:b23ee177fd68 35
Kojto 158:b23ee177fd68 36 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 158:b23ee177fd68 37 #ifndef __STM32L0xx_LL_DAC_H
Kojto 158:b23ee177fd68 38 #define __STM32L0xx_LL_DAC_H
Kojto 158:b23ee177fd68 39
Kojto 158:b23ee177fd68 40 #ifdef __cplusplus
Kojto 158:b23ee177fd68 41 extern "C" {
Kojto 158:b23ee177fd68 42 #endif
Kojto 158:b23ee177fd68 43
Kojto 158:b23ee177fd68 44 /* Includes ------------------------------------------------------------------*/
Kojto 158:b23ee177fd68 45 #include "stm32l0xx.h"
Kojto 158:b23ee177fd68 46
Kojto 158:b23ee177fd68 47 /** @addtogroup STM32L0xx_LL_Driver
Kojto 158:b23ee177fd68 48 * @{
Kojto 158:b23ee177fd68 49 */
Kojto 158:b23ee177fd68 50
Kojto 158:b23ee177fd68 51 #if defined (DAC1)
Kojto 158:b23ee177fd68 52
Kojto 158:b23ee177fd68 53 /** @defgroup DAC_LL DAC
Kojto 158:b23ee177fd68 54 * @{
Kojto 158:b23ee177fd68 55 */
Kojto 158:b23ee177fd68 56
Kojto 158:b23ee177fd68 57 /* Private types -------------------------------------------------------------*/
Kojto 158:b23ee177fd68 58 /* Private variables ---------------------------------------------------------*/
Kojto 158:b23ee177fd68 59
Kojto 158:b23ee177fd68 60 /* Private constants ---------------------------------------------------------*/
Kojto 158:b23ee177fd68 61 /** @defgroup DAC_LL_Private_Constants DAC Private Constants
Kojto 158:b23ee177fd68 62 * @{
Kojto 158:b23ee177fd68 63 */
Kojto 158:b23ee177fd68 64
Kojto 158:b23ee177fd68 65 /* Internal masks for DAC channels definition */
Kojto 158:b23ee177fd68 66 /* To select into literal LL_DAC_CHANNEL_x the relevant bits for: */
Kojto 158:b23ee177fd68 67 /* - channel bits position into register CR */
Kojto 158:b23ee177fd68 68 /* - channel bits position into register SWTRIG */
Kojto 158:b23ee177fd68 69 /* - channel register offset of data holding register DHRx */
Kojto 158:b23ee177fd68 70 /* - channel register offset of data output register DORx */
Anna Bridge 186:707f6e361f3e 71 #define DAC_CR_CH1_BITOFFSET 0U /* Position of channel bits into registers CR, MCR, CCR, SHHR, SHRR of channel 1 */
Anna Bridge 186:707f6e361f3e 72 #define DAC_CR_CH2_BITOFFSET 16U /* Position of channel bits into registers CR, MCR, CCR, SHHR, SHRR of channel 2 */
Kojto 158:b23ee177fd68 73 #define DAC_CR_CHX_BITOFFSET_MASK (DAC_CR_CH1_BITOFFSET | DAC_CR_CH2_BITOFFSET)
Kojto 158:b23ee177fd68 74
Kojto 158:b23ee177fd68 75 #define DAC_SWTR_CH1 (DAC_SWTRIGR_SWTRIG1) /* Channel bit into register SWTRIGR of channel 1. This bit is into area of LL_DAC_CR_CHx_BITOFFSET but excluded by mask DAC_CR_CHX_BITOFFSET_MASK (done to be enable to trig SW start of both DAC channels simultaneously). */
Kojto 158:b23ee177fd68 76 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 158:b23ee177fd68 77 #define DAC_SWTR_CH2 (DAC_SWTRIGR_SWTRIG2) /* Channel bit into register SWTRIGR of channel 2. This bit is into area of LL_DAC_CR_CHx_BITOFFSET but excluded by mask DAC_CR_CHX_BITOFFSET_MASK (done to be enable to trig SW start of both DAC channels simultaneously). */
Kojto 158:b23ee177fd68 78 #define DAC_SWTR_CHX_MASK (DAC_SWTR_CH1 | DAC_SWTR_CH2)
Kojto 158:b23ee177fd68 79 #else
Kojto 158:b23ee177fd68 80 #define DAC_SWTR_CHX_MASK (DAC_SWTR_CH1)
Kojto 158:b23ee177fd68 81 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 158:b23ee177fd68 82
Anna Bridge 186:707f6e361f3e 83 #define DAC_REG_DHR12R1_REGOFFSET 0x00000000U /* Register DHR12Rx channel 1 taken as reference */
Anna Bridge 186:707f6e361f3e 84 #define DAC_REG_DHR12L1_REGOFFSET 0x00100000U /* Register offset of DHR12Lx channel 1 versus DHR12Rx channel 1 (shifted left of 20 bits) */
Anna Bridge 186:707f6e361f3e 85 #define DAC_REG_DHR8R1_REGOFFSET 0x02000000U /* Register offset of DHR8Rx channel 1 versus DHR12Rx channel 1 (shifted left of 24 bits) */
Kojto 158:b23ee177fd68 86 #if defined(DAC_CHANNEL2_SUPPORT)
Anna Bridge 186:707f6e361f3e 87 #define DAC_REG_DHR12R2_REGOFFSET 0x00030000U /* Register offset of DHR12Rx channel 2 versus DHR12Rx channel 1 (shifted left of 16 bits) */
Anna Bridge 186:707f6e361f3e 88 #define DAC_REG_DHR12L2_REGOFFSET 0x00400000U /* Register offset of DHR12Lx channel 2 versus DHR12Rx channel 1 (shifted left of 20 bits) */
Anna Bridge 186:707f6e361f3e 89 #define DAC_REG_DHR8R2_REGOFFSET 0x05000000U /* Register offset of DHR8Rx channel 2 versus DHR12Rx channel 1 (shifted left of 24 bits) */
Kojto 158:b23ee177fd68 90 #endif /* DAC_CHANNEL2_SUPPORT */
Anna Bridge 186:707f6e361f3e 91 #define DAC_REG_DHR12RX_REGOFFSET_MASK 0x000F0000U
Anna Bridge 186:707f6e361f3e 92 #define DAC_REG_DHR12LX_REGOFFSET_MASK 0x00F00000U
Anna Bridge 186:707f6e361f3e 93 #define DAC_REG_DHR8RX_REGOFFSET_MASK 0x0F000000U
Kojto 158:b23ee177fd68 94 #define DAC_REG_DHRX_REGOFFSET_MASK (DAC_REG_DHR12RX_REGOFFSET_MASK | DAC_REG_DHR12LX_REGOFFSET_MASK | DAC_REG_DHR8RX_REGOFFSET_MASK)
Kojto 158:b23ee177fd68 95
Anna Bridge 186:707f6e361f3e 96 #define DAC_REG_DOR1_REGOFFSET 0x00000000U /* Register DORx channel 1 taken as reference */
Kojto 158:b23ee177fd68 97 #if defined(DAC_CHANNEL2_SUPPORT)
Anna Bridge 186:707f6e361f3e 98 #define DAC_REG_DOR2_REGOFFSET 0x10000000U /* Register offset of DORx channel 1 versus DORx channel 2 (shifted left of 28 bits) */
Kojto 158:b23ee177fd68 99 #define DAC_REG_DORX_REGOFFSET_MASK (DAC_REG_DOR1_REGOFFSET | DAC_REG_DOR2_REGOFFSET)
Kojto 158:b23ee177fd68 100 #else
Kojto 158:b23ee177fd68 101 #define DAC_REG_DORX_REGOFFSET_MASK (DAC_REG_DOR1_REGOFFSET)
Kojto 158:b23ee177fd68 102 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 158:b23ee177fd68 103
Anna Bridge 186:707f6e361f3e 104 #define DAC_REG_REGOFFSET_MASK_POSBIT0 0x0000000FU /* Mask of registers offset (DHR12Rx, DHR12Lx, DHR8Rx, DORx, ...) when shifted to position 0 */
Kojto 158:b23ee177fd68 105
Anna Bridge 186:707f6e361f3e 106 #define DAC_REG_DHR12RX_REGOFFSET_BITOFFSET_POS 16U /* Position of bits register offset of DHR12Rx channel 1 or 2 versus DHR12Rx channel 1 (shifted left of 16 bits) */
Anna Bridge 186:707f6e361f3e 107 #define DAC_REG_DHR12LX_REGOFFSET_BITOFFSET_POS 20U /* Position of bits register offset of DHR12Lx channel 1 or 2 versus DHR12Rx channel 1 (shifted left of 20 bits) */
Anna Bridge 186:707f6e361f3e 108 #define DAC_REG_DHR8RX_REGOFFSET_BITOFFSET_POS 24U /* Position of bits register offset of DHR8Rx channel 1 or 2 versus DHR12Rx channel 1 (shifted left of 24 bits) */
Anna Bridge 186:707f6e361f3e 109 #define DAC_REG_DORX_REGOFFSET_BITOFFSET_POS 28U /* Position of bits register offset of DORx channel 1 or 2 versus DORx channel 1 (shifted left of 28 bits) */
Kojto 158:b23ee177fd68 110
Kojto 158:b23ee177fd68 111 /* DAC registers bits positions */
Kojto 158:b23ee177fd68 112 #if defined(DAC_CHANNEL2_SUPPORT)
Anna Bridge 186:707f6e361f3e 113 #define DAC_DHR12RD_DACC2DHR_BITOFFSET_POS 16U /* Value equivalent to POSITION_VAL(DAC_DHR12RD_DACC2DHR) */
Anna Bridge 186:707f6e361f3e 114 #define DAC_DHR12LD_DACC2DHR_BITOFFSET_POS 20U /* Value equivalent to POSITION_VAL(DAC_DHR12LD_DACC2DHR) */
Anna Bridge 186:707f6e361f3e 115 #define DAC_DHR8RD_DACC2DHR_BITOFFSET_POS 8U /* Value equivalent to POSITION_VAL(DAC_DHR8RD_DACC2DHR) */
Kojto 158:b23ee177fd68 116 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 158:b23ee177fd68 117
Kojto 158:b23ee177fd68 118 /* Miscellaneous data */
Anna Bridge 186:707f6e361f3e 119 #define DAC_DIGITAL_SCALE_12BITS 4095U /* Full-scale digital value with a resolution of 12 bits (voltage range determined by analog voltage references Vref+ and Vref-, refer to reference manual) */
Kojto 158:b23ee177fd68 120
Kojto 158:b23ee177fd68 121 /**
Kojto 158:b23ee177fd68 122 * @}
Kojto 158:b23ee177fd68 123 */
Kojto 158:b23ee177fd68 124
Kojto 158:b23ee177fd68 125
Kojto 158:b23ee177fd68 126 /* Private macros ------------------------------------------------------------*/
Kojto 158:b23ee177fd68 127 /** @defgroup DAC_LL_Private_Macros DAC Private Macros
Kojto 158:b23ee177fd68 128 * @{
Kojto 158:b23ee177fd68 129 */
Kojto 158:b23ee177fd68 130
Kojto 158:b23ee177fd68 131 /**
Kojto 158:b23ee177fd68 132 * @brief Driver macro reserved for internal use: set a pointer to
Kojto 158:b23ee177fd68 133 * a register from a register basis from which an offset
Kojto 158:b23ee177fd68 134 * is applied.
Kojto 158:b23ee177fd68 135 * @param __REG__ Register basis from which the offset is applied.
Kojto 158:b23ee177fd68 136 * @param __REG_OFFFSET__ Offset to be applied (unit: number of registers).
Kojto 158:b23ee177fd68 137 * @retval Pointer to register address
Kojto 158:b23ee177fd68 138 */
Kojto 158:b23ee177fd68 139 #define __DAC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__) \
Kojto 158:b23ee177fd68 140 ((uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2U))))
Kojto 158:b23ee177fd68 141
Kojto 158:b23ee177fd68 142 /**
Kojto 158:b23ee177fd68 143 * @}
Kojto 158:b23ee177fd68 144 */
Kojto 158:b23ee177fd68 145
Kojto 158:b23ee177fd68 146
Kojto 158:b23ee177fd68 147 /* Exported types ------------------------------------------------------------*/
Kojto 158:b23ee177fd68 148 #if defined(USE_FULL_LL_DRIVER)
Kojto 158:b23ee177fd68 149 /** @defgroup DAC_LL_ES_INIT DAC Exported Init structure
Kojto 158:b23ee177fd68 150 * @{
Kojto 158:b23ee177fd68 151 */
Kojto 158:b23ee177fd68 152
Kojto 158:b23ee177fd68 153 /**
Kojto 158:b23ee177fd68 154 * @brief Structure definition of some features of DAC instance.
Kojto 158:b23ee177fd68 155 */
Kojto 158:b23ee177fd68 156 typedef struct
Kojto 158:b23ee177fd68 157 {
Kojto 158:b23ee177fd68 158 uint32_t TriggerSource; /*!< Set the conversion trigger source for the selected DAC channel: internal (SW start) or from external IP (timer event, external interrupt line).
Kojto 158:b23ee177fd68 159 This parameter can be a value of @ref DAC_LL_EC_TRIGGER_SOURCE
Kojto 158:b23ee177fd68 160
Kojto 158:b23ee177fd68 161 This feature can be modified afterwards using unitary function @ref LL_DAC_SetTriggerSource(). */
Kojto 158:b23ee177fd68 162
Kojto 158:b23ee177fd68 163 uint32_t WaveAutoGeneration; /*!< Set the waveform automatic generation mode for the selected DAC channel.
Kojto 158:b23ee177fd68 164 This parameter can be a value of @ref DAC_LL_EC_WAVE_AUTO_GENERATION_MODE
Kojto 158:b23ee177fd68 165
Kojto 158:b23ee177fd68 166 This feature can be modified afterwards using unitary function @ref LL_DAC_SetWaveAutoGeneration(). */
Kojto 158:b23ee177fd68 167
Kojto 158:b23ee177fd68 168 uint32_t WaveAutoGenerationConfig; /*!< Set the waveform automatic generation mode for the selected DAC channel.
Kojto 158:b23ee177fd68 169 If waveform automatic generation mode is set to noise, this parameter can be a value of @ref DAC_LL_EC_WAVE_NOISE_LFSR_UNMASK_BITS
Kojto 158:b23ee177fd68 170 If waveform automatic generation mode is set to triangle, this parameter can be a value of @ref DAC_LL_EC_WAVE_TRIANGLE_AMPLITUDE
Kojto 158:b23ee177fd68 171 @note If waveform automatic generation mode is disabled, this parameter is discarded.
Kojto 158:b23ee177fd68 172
Kojto 158:b23ee177fd68 173 This feature can be modified afterwards using unitary function @ref LL_DAC_SetWaveNoiseLFSR() or @ref LL_DAC_SetWaveTriangleAmplitude(), depending on the wave automatic generation selected. */
Kojto 158:b23ee177fd68 174
Kojto 158:b23ee177fd68 175 uint32_t OutputBuffer; /*!< Set the output buffer for the selected DAC channel.
Kojto 158:b23ee177fd68 176 This parameter can be a value of @ref DAC_LL_EC_OUTPUT_BUFFER
Kojto 158:b23ee177fd68 177
Kojto 158:b23ee177fd68 178 This feature can be modified afterwards using unitary function @ref LL_DAC_SetOutputBuffer(). */
Kojto 158:b23ee177fd68 179
Kojto 158:b23ee177fd68 180 } LL_DAC_InitTypeDef;
Kojto 158:b23ee177fd68 181
Kojto 158:b23ee177fd68 182 /**
Kojto 158:b23ee177fd68 183 * @}
Kojto 158:b23ee177fd68 184 */
Kojto 158:b23ee177fd68 185 #endif /* USE_FULL_LL_DRIVER */
Kojto 158:b23ee177fd68 186
Kojto 158:b23ee177fd68 187 /* Exported constants --------------------------------------------------------*/
Kojto 158:b23ee177fd68 188 /** @defgroup DAC_LL_Exported_Constants DAC Exported Constants
Kojto 158:b23ee177fd68 189 * @{
Kojto 158:b23ee177fd68 190 */
Kojto 158:b23ee177fd68 191
Kojto 158:b23ee177fd68 192 /** @defgroup DAC_LL_EC_GET_FLAG DAC flags
Kojto 158:b23ee177fd68 193 * @brief Flags defines which can be used with LL_DAC_ReadReg function
Kojto 158:b23ee177fd68 194 * @{
Kojto 158:b23ee177fd68 195 */
Kojto 158:b23ee177fd68 196 /* DAC channel 1 flags */
Kojto 158:b23ee177fd68 197 #define LL_DAC_FLAG_DMAUDR1 (DAC_SR_DMAUDR1) /*!< DAC channel 1 flag DMA underrun */
Kojto 158:b23ee177fd68 198
Kojto 158:b23ee177fd68 199 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 158:b23ee177fd68 200 /* DAC channel 2 flags */
Kojto 158:b23ee177fd68 201 #define LL_DAC_FLAG_DMAUDR2 (DAC_SR_DMAUDR2) /*!< DAC channel 2 flag DMA underrun */
Kojto 158:b23ee177fd68 202 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 158:b23ee177fd68 203 /**
Kojto 158:b23ee177fd68 204 * @}
Kojto 158:b23ee177fd68 205 */
Kojto 158:b23ee177fd68 206
Kojto 158:b23ee177fd68 207 /** @defgroup DAC_LL_EC_IT DAC interruptions
Kojto 158:b23ee177fd68 208 * @brief IT defines which can be used with LL_DAC_ReadReg and LL_DAC_WriteReg functions
Kojto 158:b23ee177fd68 209 * @{
Kojto 158:b23ee177fd68 210 */
Kojto 158:b23ee177fd68 211 #define LL_DAC_IT_DMAUDRIE1 (DAC_CR_DMAUDRIE1) /*!< DAC channel 1 interruption DMA underrun */
Kojto 158:b23ee177fd68 212 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 158:b23ee177fd68 213 #define LL_DAC_IT_DMAUDRIE2 (DAC_CR_DMAUDRIE2) /*!< DAC channel 2 interruption DMA underrun */
Kojto 158:b23ee177fd68 214 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 158:b23ee177fd68 215 /**
Kojto 158:b23ee177fd68 216 * @}
Kojto 158:b23ee177fd68 217 */
Kojto 158:b23ee177fd68 218
Kojto 158:b23ee177fd68 219 /** @defgroup DAC_LL_EC_CHANNEL DAC channels
Kojto 158:b23ee177fd68 220 * @{
Kojto 158:b23ee177fd68 221 */
Kojto 158:b23ee177fd68 222 #define LL_DAC_CHANNEL_1 (DAC_REG_DOR1_REGOFFSET | DAC_REG_DHR12R1_REGOFFSET | DAC_REG_DHR12L1_REGOFFSET | DAC_REG_DHR8R1_REGOFFSET | DAC_CR_CH1_BITOFFSET | DAC_SWTR_CH1) /*!< DAC channel 1 */
Kojto 158:b23ee177fd68 223 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 158:b23ee177fd68 224 #define LL_DAC_CHANNEL_2 (DAC_REG_DOR2_REGOFFSET | DAC_REG_DHR12R2_REGOFFSET | DAC_REG_DHR12L2_REGOFFSET | DAC_REG_DHR8R2_REGOFFSET | DAC_CR_CH2_BITOFFSET | DAC_SWTR_CH2) /*!< DAC channel 2 */
Kojto 158:b23ee177fd68 225 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 158:b23ee177fd68 226 /**
Kojto 158:b23ee177fd68 227 * @}
Kojto 158:b23ee177fd68 228 */
Kojto 158:b23ee177fd68 229
Kojto 158:b23ee177fd68 230 /** @defgroup DAC_LL_EC_TRIGGER_SOURCE DAC trigger source
Kojto 158:b23ee177fd68 231 * @{
Kojto 158:b23ee177fd68 232 */
Kojto 158:b23ee177fd68 233 #define LL_DAC_TRIG_SOFTWARE (DAC_CR_TSEL1_2 | DAC_CR_TSEL1_1 | DAC_CR_TSEL1_0) /*!< DAC channel conversion trigger internal (SW start) */
Kojto 158:b23ee177fd68 234 #define LL_DAC_TRIG_EXT_TIM2_TRGO (DAC_CR_TSEL1_2 ) /*!< DAC channel conversion trigger from external IP: TIM2 TRGO. */
Kojto 158:b23ee177fd68 235 #define LL_DAC_TRIG_EXT_TIM3_TRGO ( DAC_CR_TSEL1_0) /*!< DAC channel conversion trigger from external IP: TIM3 TRGO. */
Kojto 158:b23ee177fd68 236 #define LL_DAC_TRIG_EXT_TIM3_CH3 ( DAC_CR_TSEL1_1 ) /*!< DAC channel conversion trigger from external IP: TIM3 CH3 event. */
Anna Bridge 186:707f6e361f3e 237 #define LL_DAC_TRIG_EXT_TIM6_TRGO 0x00000000U /*!< DAC channel conversion trigger from external IP: TIM6 TRGO. */
Kojto 158:b23ee177fd68 238 #define LL_DAC_TRIG_EXT_TIM7_TRGO (DAC_CR_TSEL1_2 | DAC_CR_TSEL1_0) /*!< DAC channel conversion trigger from external IP: TIM7 TRGO. */
Kojto 158:b23ee177fd68 239 #define LL_DAC_TRIG_EXT_TIM21_TRGO ( DAC_CR_TSEL1_1 | DAC_CR_TSEL1_0) /*!< DAC channel conversion trigger from external IP: TIM21 TRGO. */
Kojto 158:b23ee177fd68 240 #define LL_DAC_TRIG_EXT_EXTI_LINE9 (DAC_CR_TSEL1_2 | DAC_CR_TSEL1_1 ) /*!< DAC channel conversion trigger from external IP: external interrupt line 9. */
Kojto 158:b23ee177fd68 241 /**
Kojto 158:b23ee177fd68 242 * @}
Kojto 158:b23ee177fd68 243 */
Kojto 158:b23ee177fd68 244
Kojto 158:b23ee177fd68 245 /** @defgroup DAC_LL_EC_WAVE_AUTO_GENERATION_MODE DAC waveform automatic generation mode
Kojto 158:b23ee177fd68 246 * @{
Kojto 158:b23ee177fd68 247 */
Anna Bridge 186:707f6e361f3e 248 #define LL_DAC_WAVE_AUTO_GENERATION_NONE 0x00000000U /*!< DAC channel wave auto generation mode disabled. */
Kojto 158:b23ee177fd68 249 #define LL_DAC_WAVE_AUTO_GENERATION_NOISE (DAC_CR_WAVE1_0) /*!< DAC channel wave auto generation mode enabled, set generated noise waveform. */
Kojto 158:b23ee177fd68 250 #define LL_DAC_WAVE_AUTO_GENERATION_TRIANGLE (DAC_CR_WAVE1_1) /*!< DAC channel wave auto generation mode enabled, set generated triangle waveform. */
Kojto 158:b23ee177fd68 251 /**
Kojto 158:b23ee177fd68 252 * @}
Kojto 158:b23ee177fd68 253 */
Kojto 158:b23ee177fd68 254
Kojto 158:b23ee177fd68 255 /** @defgroup DAC_LL_EC_WAVE_NOISE_LFSR_UNMASK_BITS DAC wave generation - Noise LFSR unmask bits
Kojto 158:b23ee177fd68 256 * @{
Kojto 158:b23ee177fd68 257 */
Anna Bridge 186:707f6e361f3e 258 #define LL_DAC_NOISE_LFSR_UNMASK_BIT0 0x00000000U /*!< Noise wave generation, unmask LFSR bit0, for the selected DAC channel */
Kojto 158:b23ee177fd68 259 #define LL_DAC_NOISE_LFSR_UNMASK_BITS1_0 ( DAC_CR_MAMP1_0) /*!< Noise wave generation, unmask LFSR bits[1:0], for the selected DAC channel */
Kojto 158:b23ee177fd68 260 #define LL_DAC_NOISE_LFSR_UNMASK_BITS2_0 ( DAC_CR_MAMP1_1 ) /*!< Noise wave generation, unmask LFSR bits[2:0], for the selected DAC channel */
Kojto 158:b23ee177fd68 261 #define LL_DAC_NOISE_LFSR_UNMASK_BITS3_0 ( DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Noise wave generation, unmask LFSR bits[3:0], for the selected DAC channel */
Kojto 158:b23ee177fd68 262 #define LL_DAC_NOISE_LFSR_UNMASK_BITS4_0 ( DAC_CR_MAMP1_2 ) /*!< Noise wave generation, unmask LFSR bits[4:0], for the selected DAC channel */
Kojto 158:b23ee177fd68 263 #define LL_DAC_NOISE_LFSR_UNMASK_BITS5_0 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_0) /*!< Noise wave generation, unmask LFSR bits[5:0], for the selected DAC channel */
Kojto 158:b23ee177fd68 264 #define LL_DAC_NOISE_LFSR_UNMASK_BITS6_0 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1 ) /*!< Noise wave generation, unmask LFSR bits[6:0], for the selected DAC channel */
Kojto 158:b23ee177fd68 265 #define LL_DAC_NOISE_LFSR_UNMASK_BITS7_0 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Noise wave generation, unmask LFSR bits[7:0], for the selected DAC channel */
Kojto 158:b23ee177fd68 266 #define LL_DAC_NOISE_LFSR_UNMASK_BITS8_0 (DAC_CR_MAMP1_3 ) /*!< Noise wave generation, unmask LFSR bits[8:0], for the selected DAC channel */
Kojto 158:b23ee177fd68 267 #define LL_DAC_NOISE_LFSR_UNMASK_BITS9_0 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_0) /*!< Noise wave generation, unmask LFSR bits[9:0], for the selected DAC channel */
Kojto 158:b23ee177fd68 268 #define LL_DAC_NOISE_LFSR_UNMASK_BITS10_0 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1 ) /*!< Noise wave generation, unmask LFSR bits[10:0], for the selected DAC channel */
Kojto 158:b23ee177fd68 269 #define LL_DAC_NOISE_LFSR_UNMASK_BITS11_0 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Noise wave generation, unmask LFSR bits[11:0], for the selected DAC channel */
Kojto 158:b23ee177fd68 270 /**
Kojto 158:b23ee177fd68 271 * @}
Kojto 158:b23ee177fd68 272 */
Kojto 158:b23ee177fd68 273
Kojto 158:b23ee177fd68 274 /** @defgroup DAC_LL_EC_WAVE_TRIANGLE_AMPLITUDE DAC wave generation - Triangle amplitude
Kojto 158:b23ee177fd68 275 * @{
Kojto 158:b23ee177fd68 276 */
Anna Bridge 186:707f6e361f3e 277 #define LL_DAC_TRIANGLE_AMPLITUDE_1 0x00000000U /*!< Triangle wave generation, amplitude of 1 LSB of DAC output range, for the selected DAC channel */
Kojto 158:b23ee177fd68 278 #define LL_DAC_TRIANGLE_AMPLITUDE_3 ( DAC_CR_MAMP1_0) /*!< Triangle wave generation, amplitude of 3 LSB of DAC output range, for the selected DAC channel */
Kojto 158:b23ee177fd68 279 #define LL_DAC_TRIANGLE_AMPLITUDE_7 ( DAC_CR_MAMP1_1 ) /*!< Triangle wave generation, amplitude of 7 LSB of DAC output range, for the selected DAC channel */
Kojto 158:b23ee177fd68 280 #define LL_DAC_TRIANGLE_AMPLITUDE_15 ( DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Triangle wave generation, amplitude of 15 LSB of DAC output range, for the selected DAC channel */
Kojto 158:b23ee177fd68 281 #define LL_DAC_TRIANGLE_AMPLITUDE_31 ( DAC_CR_MAMP1_2 ) /*!< Triangle wave generation, amplitude of 31 LSB of DAC output range, for the selected DAC channel */
Kojto 158:b23ee177fd68 282 #define LL_DAC_TRIANGLE_AMPLITUDE_63 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_0) /*!< Triangle wave generation, amplitude of 63 LSB of DAC output range, for the selected DAC channel */
Kojto 158:b23ee177fd68 283 #define LL_DAC_TRIANGLE_AMPLITUDE_127 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1 ) /*!< Triangle wave generation, amplitude of 127 LSB of DAC output range, for the selected DAC channel */
Kojto 158:b23ee177fd68 284 #define LL_DAC_TRIANGLE_AMPLITUDE_255 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Triangle wave generation, amplitude of 255 LSB of DAC output range, for the selected DAC channel */
Kojto 158:b23ee177fd68 285 #define LL_DAC_TRIANGLE_AMPLITUDE_511 (DAC_CR_MAMP1_3 ) /*!< Triangle wave generation, amplitude of 512 LSB of DAC output range, for the selected DAC channel */
Kojto 158:b23ee177fd68 286 #define LL_DAC_TRIANGLE_AMPLITUDE_1023 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_0) /*!< Triangle wave generation, amplitude of 1023 LSB of DAC output range, for the selected DAC channel */
Kojto 158:b23ee177fd68 287 #define LL_DAC_TRIANGLE_AMPLITUDE_2047 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1 ) /*!< Triangle wave generation, amplitude of 2047 LSB of DAC output range, for the selected DAC channel */
Kojto 158:b23ee177fd68 288 #define LL_DAC_TRIANGLE_AMPLITUDE_4095 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Triangle wave generation, amplitude of 4095 LSB of DAC output range, for the selected DAC channel */
Kojto 158:b23ee177fd68 289 /**
Kojto 158:b23ee177fd68 290 * @}
Kojto 158:b23ee177fd68 291 */
Kojto 158:b23ee177fd68 292
Kojto 158:b23ee177fd68 293 /** @defgroup DAC_LL_EC_OUTPUT_BUFFER DAC channel output buffer
Kojto 158:b23ee177fd68 294 * @{
Kojto 158:b23ee177fd68 295 */
Anna Bridge 186:707f6e361f3e 296 #define LL_DAC_OUTPUT_BUFFER_ENABLE 0x00000000U /*!< The selected DAC channel output is buffered: higher drive current capability, but also higher current consumption */
Kojto 158:b23ee177fd68 297 #define LL_DAC_OUTPUT_BUFFER_DISABLE (DAC_CR_BOFF1) /*!< The selected DAC channel output is not buffered: lower drive current capability, but also lower current consumption */
Kojto 158:b23ee177fd68 298 /**
Kojto 158:b23ee177fd68 299 * @}
Kojto 158:b23ee177fd68 300 */
Kojto 158:b23ee177fd68 301
Kojto 158:b23ee177fd68 302
Kojto 158:b23ee177fd68 303 /** @defgroup DAC_LL_EC_RESOLUTION DAC channel output resolution
Kojto 158:b23ee177fd68 304 * @{
Kojto 158:b23ee177fd68 305 */
Anna Bridge 186:707f6e361f3e 306 #define LL_DAC_RESOLUTION_12B 0x00000000U /*!< DAC channel resolution 12 bits */
Anna Bridge 186:707f6e361f3e 307 #define LL_DAC_RESOLUTION_8B 0x00000002U /*!< DAC channel resolution 8 bits */
Kojto 158:b23ee177fd68 308 /**
Kojto 158:b23ee177fd68 309 * @}
Kojto 158:b23ee177fd68 310 */
Kojto 158:b23ee177fd68 311
Kojto 158:b23ee177fd68 312 /** @defgroup DAC_LL_EC_REGISTERS DAC registers compliant with specific purpose
Kojto 158:b23ee177fd68 313 * @{
Kojto 158:b23ee177fd68 314 */
Kojto 158:b23ee177fd68 315 /* List of DAC registers intended to be used (most commonly) with */
Kojto 158:b23ee177fd68 316 /* DMA transfer. */
Kojto 158:b23ee177fd68 317 /* Refer to function @ref LL_DAC_DMA_GetRegAddr(). */
Kojto 158:b23ee177fd68 318 #define LL_DAC_DMA_REG_DATA_12BITS_RIGHT_ALIGNED DAC_REG_DHR12RX_REGOFFSET_BITOFFSET_POS /*!< DAC channel data holding register 12 bits right aligned */
Kojto 158:b23ee177fd68 319 #define LL_DAC_DMA_REG_DATA_12BITS_LEFT_ALIGNED DAC_REG_DHR12LX_REGOFFSET_BITOFFSET_POS /*!< DAC channel data holding register 12 bits left aligned */
Kojto 158:b23ee177fd68 320 #define LL_DAC_DMA_REG_DATA_8BITS_RIGHT_ALIGNED DAC_REG_DHR8RX_REGOFFSET_BITOFFSET_POS /*!< DAC channel data holding register 8 bits right aligned */
Kojto 158:b23ee177fd68 321 /**
Kojto 158:b23ee177fd68 322 * @}
Kojto 158:b23ee177fd68 323 */
Kojto 158:b23ee177fd68 324
Kojto 158:b23ee177fd68 325 /** @defgroup DAC_LL_EC_HW_DELAYS Definitions of DAC hardware constraints delays
Kojto 158:b23ee177fd68 326 * @note Only DAC IP HW delays are defined in DAC LL driver driver,
Kojto 158:b23ee177fd68 327 * not timeout values.
Kojto 158:b23ee177fd68 328 * For details on delays values, refer to descriptions in source code
Kojto 158:b23ee177fd68 329 * above each literal definition.
Kojto 158:b23ee177fd68 330 * @{
Kojto 158:b23ee177fd68 331 */
Kojto 158:b23ee177fd68 332
Kojto 158:b23ee177fd68 333 /* Delay for DAC channel voltage settling time from DAC channel startup */
Kojto 158:b23ee177fd68 334 /* (transition from disable to enable). */
Kojto 158:b23ee177fd68 335 /* Note: DAC channel startup time depends on board application environment: */
Kojto 158:b23ee177fd68 336 /* impedance connected to DAC channel output. */
Kojto 158:b23ee177fd68 337 /* The delay below is specified under conditions: */
Kojto 158:b23ee177fd68 338 /* - voltage maximum transition (lowest to highest value) */
Kojto 158:b23ee177fd68 339 /* - until voltage reaches final value +-1LSB */
Kojto 158:b23ee177fd68 340 /* - DAC channel output buffer enabled */
Kojto 158:b23ee177fd68 341 /* - load impedance of 5kOhm (min), 50pF (max) */
Kojto 158:b23ee177fd68 342 /* Literal set to maximum value (refer to device datasheet, */
Kojto 158:b23ee177fd68 343 /* parameter "tWAKEUP"). */
Kojto 158:b23ee177fd68 344 /* Unit: us */
Anna Bridge 186:707f6e361f3e 345 #define LL_DAC_DELAY_STARTUP_VOLTAGE_SETTLING_US 15U /*!< Delay for DAC channel voltage settling time from DAC channel startup (transition from disable to enable) */
Kojto 158:b23ee177fd68 346
Kojto 158:b23ee177fd68 347 /* Delay for DAC channel voltage settling time. */
Kojto 158:b23ee177fd68 348 /* Note: DAC channel startup time depends on board application environment: */
Kojto 158:b23ee177fd68 349 /* impedance connected to DAC channel output. */
Kojto 158:b23ee177fd68 350 /* The delay below is specified under conditions: */
Kojto 158:b23ee177fd68 351 /* - voltage maximum transition (lowest to highest value) */
Kojto 158:b23ee177fd68 352 /* - until voltage reaches final value +-1LSB */
Kojto 158:b23ee177fd68 353 /* - DAC channel output buffer enabled */
Kojto 158:b23ee177fd68 354 /* - load impedance of 5kOhm min, 50pF max */
Kojto 158:b23ee177fd68 355 /* Literal set to maximum value (refer to device datasheet, */
Kojto 158:b23ee177fd68 356 /* parameter "tSETTLING"). */
Kojto 158:b23ee177fd68 357 /* Unit: us */
Anna Bridge 186:707f6e361f3e 358 #define LL_DAC_DELAY_VOLTAGE_SETTLING_US 12U /*!< Delay for DAC channel voltage settling time */
Kojto 158:b23ee177fd68 359 /**
Kojto 158:b23ee177fd68 360 * @}
Kojto 158:b23ee177fd68 361 */
Kojto 158:b23ee177fd68 362
Kojto 158:b23ee177fd68 363 /**
Kojto 158:b23ee177fd68 364 * @}
Kojto 158:b23ee177fd68 365 */
Kojto 158:b23ee177fd68 366
Kojto 158:b23ee177fd68 367 /* Exported macro ------------------------------------------------------------*/
Kojto 158:b23ee177fd68 368 /** @defgroup DAC_LL_Exported_Macros DAC Exported Macros
Kojto 158:b23ee177fd68 369 * @{
Kojto 158:b23ee177fd68 370 */
Kojto 158:b23ee177fd68 371
Kojto 158:b23ee177fd68 372 /** @defgroup DAC_LL_EM_WRITE_READ Common write and read registers macros
Kojto 158:b23ee177fd68 373 * @{
Kojto 158:b23ee177fd68 374 */
Kojto 158:b23ee177fd68 375
Kojto 158:b23ee177fd68 376 /**
Kojto 158:b23ee177fd68 377 * @brief Write a value in DAC register
Kojto 158:b23ee177fd68 378 * @param __INSTANCE__ DAC Instance
Kojto 158:b23ee177fd68 379 * @param __REG__ Register to be written
Kojto 158:b23ee177fd68 380 * @param __VALUE__ Value to be written in the register
Kojto 158:b23ee177fd68 381 * @retval None
Kojto 158:b23ee177fd68 382 */
Kojto 158:b23ee177fd68 383 #define LL_DAC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
Kojto 158:b23ee177fd68 384
Kojto 158:b23ee177fd68 385 /**
Kojto 158:b23ee177fd68 386 * @brief Read a value in DAC register
Kojto 158:b23ee177fd68 387 * @param __INSTANCE__ DAC Instance
Kojto 158:b23ee177fd68 388 * @param __REG__ Register to be read
Kojto 158:b23ee177fd68 389 * @retval Register value
Kojto 158:b23ee177fd68 390 */
Kojto 158:b23ee177fd68 391 #define LL_DAC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
Kojto 158:b23ee177fd68 392
Kojto 158:b23ee177fd68 393 /**
Kojto 158:b23ee177fd68 394 * @}
Kojto 158:b23ee177fd68 395 */
Kojto 158:b23ee177fd68 396
Kojto 158:b23ee177fd68 397 /** @defgroup DAC_LL_EM_HELPER_MACRO DAC helper macro
Kojto 158:b23ee177fd68 398 * @{
Kojto 158:b23ee177fd68 399 */
Kojto 158:b23ee177fd68 400
Kojto 158:b23ee177fd68 401 /**
Kojto 158:b23ee177fd68 402 * @brief Helper macro to get DAC channel number in decimal format
Kojto 158:b23ee177fd68 403 * from literals LL_DAC_CHANNEL_x.
Kojto 158:b23ee177fd68 404 * Example:
Kojto 158:b23ee177fd68 405 * __LL_DAC_CHANNEL_TO_DECIMAL_NB(LL_DAC_CHANNEL_1)
Kojto 158:b23ee177fd68 406 * will return decimal number "1".
Kojto 158:b23ee177fd68 407 * @note The input can be a value from functions where a channel
Kojto 158:b23ee177fd68 408 * number is returned.
Kojto 158:b23ee177fd68 409 * @param __CHANNEL__ This parameter can be one of the following values:
Kojto 158:b23ee177fd68 410 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 411 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 412 *
Kojto 158:b23ee177fd68 413 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 414 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 415 * @retval 1...2 (value "2" depending on DAC channel 2 availability)
Kojto 158:b23ee177fd68 416 */
Kojto 158:b23ee177fd68 417 #define __LL_DAC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
Kojto 158:b23ee177fd68 418 ((__CHANNEL__) & DAC_SWTR_CHX_MASK)
Kojto 158:b23ee177fd68 419
Kojto 158:b23ee177fd68 420 /**
Kojto 158:b23ee177fd68 421 * @brief Helper macro to get DAC channel in literal format LL_DAC_CHANNEL_x
Kojto 158:b23ee177fd68 422 * from number in decimal format.
Kojto 158:b23ee177fd68 423 * Example:
Kojto 158:b23ee177fd68 424 * __LL_DAC_DECIMAL_NB_TO_CHANNEL(1)
Kojto 158:b23ee177fd68 425 * will return a data equivalent to "LL_DAC_CHANNEL_1".
Kojto 158:b23ee177fd68 426 * @note If the input parameter does not correspond to a DAC channel,
Kojto 158:b23ee177fd68 427 * this macro returns value '0'.
Kojto 158:b23ee177fd68 428 * @param __DECIMAL_NB__ 1...2 (value "2" depending on DAC channel 2 availability)
Kojto 158:b23ee177fd68 429 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 430 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 431 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 432 *
Kojto 158:b23ee177fd68 433 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 434 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 435 */
Kojto 158:b23ee177fd68 436 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 158:b23ee177fd68 437 #define __LL_DAC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
Kojto 158:b23ee177fd68 438 (((__DECIMAL_NB__) == 1U) \
Kojto 158:b23ee177fd68 439 ? ( \
Kojto 158:b23ee177fd68 440 LL_DAC_CHANNEL_1 \
Kojto 158:b23ee177fd68 441 ) \
Kojto 158:b23ee177fd68 442 : \
Kojto 158:b23ee177fd68 443 (((__DECIMAL_NB__) == 2U) \
Kojto 158:b23ee177fd68 444 ? ( \
Kojto 158:b23ee177fd68 445 LL_DAC_CHANNEL_2 \
Kojto 158:b23ee177fd68 446 ) \
Kojto 158:b23ee177fd68 447 : \
Kojto 158:b23ee177fd68 448 ( \
Kojto 158:b23ee177fd68 449 0 \
Kojto 158:b23ee177fd68 450 ) \
Kojto 158:b23ee177fd68 451 ) \
Kojto 158:b23ee177fd68 452 )
Kojto 158:b23ee177fd68 453 #else
Kojto 158:b23ee177fd68 454 #define __LL_DAC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
Kojto 158:b23ee177fd68 455 (((__DECIMAL_NB__) == 1U) \
Kojto 158:b23ee177fd68 456 ? ( \
Kojto 158:b23ee177fd68 457 LL_DAC_CHANNEL_1 \
Kojto 158:b23ee177fd68 458 ) \
Kojto 158:b23ee177fd68 459 : \
Kojto 158:b23ee177fd68 460 ( \
Kojto 158:b23ee177fd68 461 0 \
Kojto 158:b23ee177fd68 462 ) \
Kojto 158:b23ee177fd68 463 )
Kojto 158:b23ee177fd68 464 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 158:b23ee177fd68 465
Kojto 158:b23ee177fd68 466 /**
Kojto 158:b23ee177fd68 467 * @brief Helper macro to define the DAC conversion data full-scale digital
Kojto 158:b23ee177fd68 468 * value corresponding to the selected DAC resolution.
Kojto 158:b23ee177fd68 469 * @note DAC conversion data full-scale corresponds to voltage range
Kojto 158:b23ee177fd68 470 * determined by analog voltage references Vref+ and Vref-
Kojto 158:b23ee177fd68 471 * (refer to reference manual).
Kojto 158:b23ee177fd68 472 * @param __DAC_RESOLUTION__ This parameter can be one of the following values:
Kojto 158:b23ee177fd68 473 * @arg @ref LL_DAC_RESOLUTION_12B
Kojto 158:b23ee177fd68 474 * @arg @ref LL_DAC_RESOLUTION_8B
Kojto 158:b23ee177fd68 475 * @retval ADC conversion data equivalent voltage value (unit: mVolt)
Kojto 158:b23ee177fd68 476 */
Kojto 158:b23ee177fd68 477 #define __LL_DAC_DIGITAL_SCALE(__DAC_RESOLUTION__) \
Anna Bridge 186:707f6e361f3e 478 ((0x00000FFFU) >> ((__DAC_RESOLUTION__) << 1U))
Kojto 158:b23ee177fd68 479
Kojto 158:b23ee177fd68 480 /**
Kojto 158:b23ee177fd68 481 * @brief Helper macro to calculate the DAC conversion data (unit: digital
Kojto 158:b23ee177fd68 482 * value) corresponding to a voltage (unit: mVolt).
Kojto 158:b23ee177fd68 483 * @note This helper macro is intended to provide input data in voltage
Kojto 158:b23ee177fd68 484 * rather than digital value,
Kojto 158:b23ee177fd68 485 * to be used with LL DAC functions such as
Kojto 158:b23ee177fd68 486 * @ref LL_DAC_ConvertData12RightAligned().
Kojto 158:b23ee177fd68 487 * @note Analog reference voltage (Vref+) must be either known from
Kojto 158:b23ee177fd68 488 * user board environment or can be calculated using ADC measurement
Kojto 158:b23ee177fd68 489 * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
Kojto 158:b23ee177fd68 490 * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
Kojto 158:b23ee177fd68 491 * @param __DAC_VOLTAGE__ Voltage to be generated by DAC channel
Kojto 158:b23ee177fd68 492 * (unit: mVolt).
Kojto 158:b23ee177fd68 493 * @param __DAC_RESOLUTION__ This parameter can be one of the following values:
Kojto 158:b23ee177fd68 494 * @arg @ref LL_DAC_RESOLUTION_12B
Kojto 158:b23ee177fd68 495 * @arg @ref LL_DAC_RESOLUTION_8B
Kojto 158:b23ee177fd68 496 * @retval DAC conversion data (unit: digital value)
Kojto 158:b23ee177fd68 497 */
Kojto 158:b23ee177fd68 498 #define __LL_DAC_CALC_VOLTAGE_TO_DATA(__VREFANALOG_VOLTAGE__,\
Kojto 158:b23ee177fd68 499 __DAC_VOLTAGE__,\
Kojto 158:b23ee177fd68 500 __DAC_RESOLUTION__) \
Kojto 158:b23ee177fd68 501 ((__DAC_VOLTAGE__) * __LL_DAC_DIGITAL_SCALE(__DAC_RESOLUTION__) \
Kojto 158:b23ee177fd68 502 / (__VREFANALOG_VOLTAGE__) \
Kojto 158:b23ee177fd68 503 )
Kojto 158:b23ee177fd68 504
Kojto 158:b23ee177fd68 505 /**
Kojto 158:b23ee177fd68 506 * @}
Kojto 158:b23ee177fd68 507 */
Kojto 158:b23ee177fd68 508
Kojto 158:b23ee177fd68 509 /**
Kojto 158:b23ee177fd68 510 * @}
Kojto 158:b23ee177fd68 511 */
Kojto 158:b23ee177fd68 512
Kojto 158:b23ee177fd68 513
Kojto 158:b23ee177fd68 514 /* Exported functions --------------------------------------------------------*/
Kojto 158:b23ee177fd68 515 /** @defgroup DAC_LL_Exported_Functions DAC Exported Functions
Kojto 158:b23ee177fd68 516 * @{
Kojto 158:b23ee177fd68 517 */
Kojto 158:b23ee177fd68 518 /** @defgroup DAC_LL_EF_Configuration Configuration of DAC channels
Kojto 158:b23ee177fd68 519 * @{
Kojto 158:b23ee177fd68 520 */
Kojto 158:b23ee177fd68 521
Kojto 158:b23ee177fd68 522 /**
Kojto 158:b23ee177fd68 523 * @brief Set the conversion trigger source for the selected DAC channel.
Kojto 158:b23ee177fd68 524 * @note For conversion trigger source to be effective, DAC trigger
Kojto 158:b23ee177fd68 525 * must be enabled using function @ref LL_DAC_EnableTrigger().
Kojto 158:b23ee177fd68 526 * @note To set conversion trigger source, DAC channel must be disabled.
Kojto 158:b23ee177fd68 527 * Otherwise, the setting is discarded.
Kojto 158:b23ee177fd68 528 * @note Availability of parameters of trigger sources from timer
Kojto 158:b23ee177fd68 529 * depends on timers availability on the selected device.
Kojto 158:b23ee177fd68 530 * @rmtoll CR TSEL1 LL_DAC_SetTriggerSource\n
Kojto 158:b23ee177fd68 531 * CR TSEL2 LL_DAC_SetTriggerSource
Kojto 158:b23ee177fd68 532 * @param DACx DAC instance
Kojto 158:b23ee177fd68 533 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 534 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 535 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 536 *
Kojto 158:b23ee177fd68 537 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 538 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 539 * @param TriggerSource This parameter can be one of the following values:
Kojto 158:b23ee177fd68 540 * @arg @ref LL_DAC_TRIG_SOFTWARE
Kojto 158:b23ee177fd68 541 * @arg @ref LL_DAC_TRIG_EXT_TIM2_TRGO
Kojto 158:b23ee177fd68 542 * @arg @ref LL_DAC_TRIG_EXT_TIM3_TRGO
Kojto 158:b23ee177fd68 543 * @arg @ref LL_DAC_TRIG_EXT_TIM3_CH3
Kojto 158:b23ee177fd68 544 * @arg @ref LL_DAC_TRIG_EXT_TIM6_TRGO
Kojto 158:b23ee177fd68 545 * @arg @ref LL_DAC_TRIG_EXT_TIM7_TRGO
Kojto 158:b23ee177fd68 546 * @arg @ref LL_DAC_TRIG_EXT_TIM21_TRGO
Kojto 158:b23ee177fd68 547 * @arg @ref LL_DAC_TRIG_EXT_EXTI_LINE9
Kojto 158:b23ee177fd68 548 * @retval None
Kojto 158:b23ee177fd68 549 */
Kojto 158:b23ee177fd68 550 __STATIC_INLINE void LL_DAC_SetTriggerSource(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t TriggerSource)
Kojto 158:b23ee177fd68 551 {
Kojto 158:b23ee177fd68 552 MODIFY_REG(DACx->CR,
Kojto 158:b23ee177fd68 553 DAC_CR_TSEL1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
Kojto 158:b23ee177fd68 554 TriggerSource << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 158:b23ee177fd68 555 }
Kojto 158:b23ee177fd68 556
Kojto 158:b23ee177fd68 557 /**
Kojto 158:b23ee177fd68 558 * @brief Get the conversion trigger source for the selected DAC channel.
Kojto 158:b23ee177fd68 559 * @note For conversion trigger source to be effective, DAC trigger
Kojto 158:b23ee177fd68 560 * must be enabled using function @ref LL_DAC_EnableTrigger().
Kojto 158:b23ee177fd68 561 * @note Availability of parameters of trigger sources from timer
Kojto 158:b23ee177fd68 562 * depends on timers availability on the selected device.
Kojto 158:b23ee177fd68 563 * @rmtoll CR TSEL1 LL_DAC_GetTriggerSource\n
Kojto 158:b23ee177fd68 564 * CR TSEL2 LL_DAC_GetTriggerSource
Kojto 158:b23ee177fd68 565 * @param DACx DAC instance
Kojto 158:b23ee177fd68 566 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 567 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 568 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 569 *
Kojto 158:b23ee177fd68 570 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 571 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 572 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 573 * @arg @ref LL_DAC_TRIG_SOFTWARE
Kojto 158:b23ee177fd68 574 * @arg @ref LL_DAC_TRIG_EXT_TIM2_TRGO
Kojto 158:b23ee177fd68 575 * @arg @ref LL_DAC_TRIG_EXT_TIM3_TRGO
Kojto 158:b23ee177fd68 576 * @arg @ref LL_DAC_TRIG_EXT_TIM3_CH3
Kojto 158:b23ee177fd68 577 * @arg @ref LL_DAC_TRIG_EXT_TIM6_TRGO
Kojto 158:b23ee177fd68 578 * @arg @ref LL_DAC_TRIG_EXT_TIM7_TRGO
Kojto 158:b23ee177fd68 579 * @arg @ref LL_DAC_TRIG_EXT_TIM21_TRGO
Kojto 158:b23ee177fd68 580 * @arg @ref LL_DAC_TRIG_EXT_EXTI_LINE9
Kojto 158:b23ee177fd68 581 */
Kojto 158:b23ee177fd68 582 __STATIC_INLINE uint32_t LL_DAC_GetTriggerSource(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 158:b23ee177fd68 583 {
Kojto 158:b23ee177fd68 584 return (uint32_t)(READ_BIT(DACx->CR, DAC_CR_TSEL1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 158:b23ee177fd68 585 >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
Kojto 158:b23ee177fd68 586 );
Kojto 158:b23ee177fd68 587 }
Kojto 158:b23ee177fd68 588
Kojto 158:b23ee177fd68 589 /**
Kojto 158:b23ee177fd68 590 * @brief Set the waveform automatic generation mode
Kojto 158:b23ee177fd68 591 * for the selected DAC channel.
Kojto 158:b23ee177fd68 592 * @rmtoll CR WAVE1 LL_DAC_SetWaveAutoGeneration\n
Kojto 158:b23ee177fd68 593 * CR WAVE2 LL_DAC_SetWaveAutoGeneration
Kojto 158:b23ee177fd68 594 * @param DACx DAC instance
Kojto 158:b23ee177fd68 595 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 596 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 597 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 598 *
Kojto 158:b23ee177fd68 599 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 600 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 601 * @param WaveAutoGeneration This parameter can be one of the following values:
Kojto 158:b23ee177fd68 602 * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_NONE
Kojto 158:b23ee177fd68 603 * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_NOISE
Kojto 158:b23ee177fd68 604 * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_TRIANGLE
Kojto 158:b23ee177fd68 605 * @retval None
Kojto 158:b23ee177fd68 606 */
Kojto 158:b23ee177fd68 607 __STATIC_INLINE void LL_DAC_SetWaveAutoGeneration(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t WaveAutoGeneration)
Kojto 158:b23ee177fd68 608 {
Kojto 158:b23ee177fd68 609 MODIFY_REG(DACx->CR,
Kojto 158:b23ee177fd68 610 DAC_CR_WAVE1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
Kojto 158:b23ee177fd68 611 WaveAutoGeneration << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 158:b23ee177fd68 612 }
Kojto 158:b23ee177fd68 613
Kojto 158:b23ee177fd68 614 /**
Kojto 158:b23ee177fd68 615 * @brief Get the waveform automatic generation mode
Kojto 158:b23ee177fd68 616 * for the selected DAC channel.
Kojto 158:b23ee177fd68 617 * @rmtoll CR WAVE1 LL_DAC_GetWaveAutoGeneration\n
Kojto 158:b23ee177fd68 618 * CR WAVE2 LL_DAC_GetWaveAutoGeneration
Kojto 158:b23ee177fd68 619 * @param DACx DAC instance
Kojto 158:b23ee177fd68 620 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 621 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 622 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 623 *
Kojto 158:b23ee177fd68 624 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 625 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 626 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 627 * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_NONE
Kojto 158:b23ee177fd68 628 * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_NOISE
Kojto 158:b23ee177fd68 629 * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_TRIANGLE
Kojto 158:b23ee177fd68 630 */
Kojto 158:b23ee177fd68 631 __STATIC_INLINE uint32_t LL_DAC_GetWaveAutoGeneration(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 158:b23ee177fd68 632 {
Kojto 158:b23ee177fd68 633 return (uint32_t)(READ_BIT(DACx->CR, DAC_CR_WAVE1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 158:b23ee177fd68 634 >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
Kojto 158:b23ee177fd68 635 );
Kojto 158:b23ee177fd68 636 }
Kojto 158:b23ee177fd68 637
Kojto 158:b23ee177fd68 638 /**
Kojto 158:b23ee177fd68 639 * @brief Set the noise waveform generation for the selected DAC channel:
Kojto 158:b23ee177fd68 640 * Noise mode and parameters LFSR (linear feedback shift register).
Kojto 158:b23ee177fd68 641 * @note For wave generation to be effective, DAC channel
Kojto 158:b23ee177fd68 642 * wave generation mode must be enabled using
Kojto 158:b23ee177fd68 643 * function @ref LL_DAC_SetWaveAutoGeneration().
Kojto 158:b23ee177fd68 644 * @note This setting can be set when the selected DAC channel is disabled
Kojto 158:b23ee177fd68 645 * (otherwise, the setting operation is ignored).
Kojto 158:b23ee177fd68 646 * @rmtoll CR MAMP1 LL_DAC_SetWaveNoiseLFSR\n
Kojto 158:b23ee177fd68 647 * CR MAMP2 LL_DAC_SetWaveNoiseLFSR
Kojto 158:b23ee177fd68 648 * @param DACx DAC instance
Kojto 158:b23ee177fd68 649 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 650 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 651 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 652 *
Kojto 158:b23ee177fd68 653 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 654 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 655 * @param NoiseLFSRMask This parameter can be one of the following values:
Kojto 158:b23ee177fd68 656 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BIT0
Kojto 158:b23ee177fd68 657 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS1_0
Kojto 158:b23ee177fd68 658 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS2_0
Kojto 158:b23ee177fd68 659 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS3_0
Kojto 158:b23ee177fd68 660 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS4_0
Kojto 158:b23ee177fd68 661 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS5_0
Kojto 158:b23ee177fd68 662 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS6_0
Kojto 158:b23ee177fd68 663 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS7_0
Kojto 158:b23ee177fd68 664 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS8_0
Kojto 158:b23ee177fd68 665 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS9_0
Kojto 158:b23ee177fd68 666 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS10_0
Kojto 158:b23ee177fd68 667 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS11_0
Kojto 158:b23ee177fd68 668 * @retval None
Kojto 158:b23ee177fd68 669 */
Kojto 158:b23ee177fd68 670 __STATIC_INLINE void LL_DAC_SetWaveNoiseLFSR(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t NoiseLFSRMask)
Kojto 158:b23ee177fd68 671 {
Kojto 158:b23ee177fd68 672 MODIFY_REG(DACx->CR,
Kojto 158:b23ee177fd68 673 DAC_CR_MAMP1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
Kojto 158:b23ee177fd68 674 NoiseLFSRMask << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 158:b23ee177fd68 675 }
Kojto 158:b23ee177fd68 676
Kojto 158:b23ee177fd68 677 /**
Kojto 158:b23ee177fd68 678 * @brief Set the noise waveform generation for the selected DAC channel:
Kojto 158:b23ee177fd68 679 * Noise mode and parameters LFSR (linear feedback shift register).
Kojto 158:b23ee177fd68 680 * @rmtoll CR MAMP1 LL_DAC_GetWaveNoiseLFSR\n
Kojto 158:b23ee177fd68 681 * CR MAMP2 LL_DAC_GetWaveNoiseLFSR
Kojto 158:b23ee177fd68 682 * @param DACx DAC instance
Kojto 158:b23ee177fd68 683 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 684 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 685 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 686 *
Kojto 158:b23ee177fd68 687 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 688 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 689 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 690 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BIT0
Kojto 158:b23ee177fd68 691 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS1_0
Kojto 158:b23ee177fd68 692 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS2_0
Kojto 158:b23ee177fd68 693 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS3_0
Kojto 158:b23ee177fd68 694 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS4_0
Kojto 158:b23ee177fd68 695 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS5_0
Kojto 158:b23ee177fd68 696 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS6_0
Kojto 158:b23ee177fd68 697 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS7_0
Kojto 158:b23ee177fd68 698 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS8_0
Kojto 158:b23ee177fd68 699 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS9_0
Kojto 158:b23ee177fd68 700 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS10_0
Kojto 158:b23ee177fd68 701 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS11_0
Kojto 158:b23ee177fd68 702 */
Kojto 158:b23ee177fd68 703 __STATIC_INLINE uint32_t LL_DAC_GetWaveNoiseLFSR(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 158:b23ee177fd68 704 {
Kojto 158:b23ee177fd68 705 return (uint32_t)(READ_BIT(DACx->CR, DAC_CR_MAMP1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 158:b23ee177fd68 706 >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
Kojto 158:b23ee177fd68 707 );
Kojto 158:b23ee177fd68 708 }
Kojto 158:b23ee177fd68 709
Kojto 158:b23ee177fd68 710 /**
Kojto 158:b23ee177fd68 711 * @brief Set the triangle waveform generation for the selected DAC channel:
Kojto 158:b23ee177fd68 712 * triangle mode and amplitude.
Kojto 158:b23ee177fd68 713 * @note For wave generation to be effective, DAC channel
Kojto 158:b23ee177fd68 714 * wave generation mode must be enabled using
Kojto 158:b23ee177fd68 715 * function @ref LL_DAC_SetWaveAutoGeneration().
Kojto 158:b23ee177fd68 716 * @note This setting can be set when the selected DAC channel is disabled
Kojto 158:b23ee177fd68 717 * (otherwise, the setting operation is ignored).
Kojto 158:b23ee177fd68 718 * @rmtoll CR MAMP1 LL_DAC_SetWaveTriangleAmplitude\n
Kojto 158:b23ee177fd68 719 * CR MAMP2 LL_DAC_SetWaveTriangleAmplitude
Kojto 158:b23ee177fd68 720 * @param DACx DAC instance
Kojto 158:b23ee177fd68 721 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 722 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 723 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 724 *
Kojto 158:b23ee177fd68 725 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 726 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 727 * @param TriangleAmplitude This parameter can be one of the following values:
Kojto 158:b23ee177fd68 728 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_1
Kojto 158:b23ee177fd68 729 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_3
Kojto 158:b23ee177fd68 730 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_7
Kojto 158:b23ee177fd68 731 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_15
Kojto 158:b23ee177fd68 732 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_31
Kojto 158:b23ee177fd68 733 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_63
Kojto 158:b23ee177fd68 734 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_127
Kojto 158:b23ee177fd68 735 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_255
Kojto 158:b23ee177fd68 736 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_511
Kojto 158:b23ee177fd68 737 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_1023
Kojto 158:b23ee177fd68 738 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_2047
Kojto 158:b23ee177fd68 739 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_4095
Kojto 158:b23ee177fd68 740 * @retval None
Kojto 158:b23ee177fd68 741 */
Kojto 158:b23ee177fd68 742 __STATIC_INLINE void LL_DAC_SetWaveTriangleAmplitude(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t TriangleAmplitude)
Kojto 158:b23ee177fd68 743 {
Kojto 158:b23ee177fd68 744 MODIFY_REG(DACx->CR,
Kojto 158:b23ee177fd68 745 DAC_CR_MAMP1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
Kojto 158:b23ee177fd68 746 TriangleAmplitude << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 158:b23ee177fd68 747 }
Kojto 158:b23ee177fd68 748
Kojto 158:b23ee177fd68 749 /**
Kojto 158:b23ee177fd68 750 * @brief Set the triangle waveform generation for the selected DAC channel:
Kojto 158:b23ee177fd68 751 * triangle mode and amplitude.
Kojto 158:b23ee177fd68 752 * @rmtoll CR MAMP1 LL_DAC_GetWaveTriangleAmplitude\n
Kojto 158:b23ee177fd68 753 * CR MAMP2 LL_DAC_GetWaveTriangleAmplitude
Kojto 158:b23ee177fd68 754 * @param DACx DAC instance
Kojto 158:b23ee177fd68 755 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 756 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 757 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 758 *
Kojto 158:b23ee177fd68 759 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 760 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 761 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 762 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_1
Kojto 158:b23ee177fd68 763 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_3
Kojto 158:b23ee177fd68 764 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_7
Kojto 158:b23ee177fd68 765 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_15
Kojto 158:b23ee177fd68 766 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_31
Kojto 158:b23ee177fd68 767 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_63
Kojto 158:b23ee177fd68 768 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_127
Kojto 158:b23ee177fd68 769 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_255
Kojto 158:b23ee177fd68 770 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_511
Kojto 158:b23ee177fd68 771 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_1023
Kojto 158:b23ee177fd68 772 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_2047
Kojto 158:b23ee177fd68 773 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_4095
Kojto 158:b23ee177fd68 774 */
Kojto 158:b23ee177fd68 775 __STATIC_INLINE uint32_t LL_DAC_GetWaveTriangleAmplitude(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 158:b23ee177fd68 776 {
Kojto 158:b23ee177fd68 777 return (uint32_t)(READ_BIT(DACx->CR, DAC_CR_MAMP1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 158:b23ee177fd68 778 >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
Kojto 158:b23ee177fd68 779 );
Kojto 158:b23ee177fd68 780 }
Kojto 158:b23ee177fd68 781
Kojto 158:b23ee177fd68 782 /**
Kojto 158:b23ee177fd68 783 * @brief Set the output buffer for the selected DAC channel.
Kojto 158:b23ee177fd68 784 * @rmtoll CR BOFF1 LL_DAC_SetOutputBuffer\n
Kojto 158:b23ee177fd68 785 * CR BOFF2 LL_DAC_SetOutputBuffer
Kojto 158:b23ee177fd68 786 * @param DACx DAC instance
Kojto 158:b23ee177fd68 787 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 788 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 789 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 790 *
Kojto 158:b23ee177fd68 791 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 792 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 793 * @param OutputBuffer This parameter can be one of the following values:
Kojto 158:b23ee177fd68 794 * @arg @ref LL_DAC_OUTPUT_BUFFER_ENABLE
Kojto 158:b23ee177fd68 795 * @arg @ref LL_DAC_OUTPUT_BUFFER_DISABLE
Kojto 158:b23ee177fd68 796 * @retval None
Kojto 158:b23ee177fd68 797 */
Kojto 158:b23ee177fd68 798 __STATIC_INLINE void LL_DAC_SetOutputBuffer(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t OutputBuffer)
Kojto 158:b23ee177fd68 799 {
Kojto 158:b23ee177fd68 800 MODIFY_REG(DACx->CR,
Kojto 158:b23ee177fd68 801 DAC_CR_BOFF1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
Kojto 158:b23ee177fd68 802 OutputBuffer << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 158:b23ee177fd68 803 }
Kojto 158:b23ee177fd68 804
Kojto 158:b23ee177fd68 805 /**
Kojto 158:b23ee177fd68 806 * @brief Get the output buffer state for the selected DAC channel.
Kojto 158:b23ee177fd68 807 * @rmtoll CR BOFF1 LL_DAC_GetOutputBuffer\n
Kojto 158:b23ee177fd68 808 * CR BOFF2 LL_DAC_GetOutputBuffer
Kojto 158:b23ee177fd68 809 * @param DACx DAC instance
Kojto 158:b23ee177fd68 810 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 811 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 812 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 813 *
Kojto 158:b23ee177fd68 814 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 815 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 816 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 817 * @arg @ref LL_DAC_OUTPUT_BUFFER_ENABLE
Kojto 158:b23ee177fd68 818 * @arg @ref LL_DAC_OUTPUT_BUFFER_DISABLE
Kojto 158:b23ee177fd68 819 */
Kojto 158:b23ee177fd68 820 __STATIC_INLINE uint32_t LL_DAC_GetOutputBuffer(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 158:b23ee177fd68 821 {
Kojto 158:b23ee177fd68 822 return (uint32_t)(READ_BIT(DACx->CR, DAC_CR_BOFF1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 158:b23ee177fd68 823 >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
Kojto 158:b23ee177fd68 824 );
Kojto 158:b23ee177fd68 825 }
Kojto 158:b23ee177fd68 826
Kojto 158:b23ee177fd68 827 /**
Kojto 158:b23ee177fd68 828 * @}
Kojto 158:b23ee177fd68 829 */
Kojto 158:b23ee177fd68 830
Kojto 158:b23ee177fd68 831 /** @defgroup DAC_LL_EF_DMA_Management DMA Management
Kojto 158:b23ee177fd68 832 * @{
Kojto 158:b23ee177fd68 833 */
Kojto 158:b23ee177fd68 834
Kojto 158:b23ee177fd68 835 /**
Kojto 158:b23ee177fd68 836 * @brief Enable DAC DMA transfer request of the selected channel.
Kojto 158:b23ee177fd68 837 * @note To configure DMA source address (peripheral address),
Kojto 158:b23ee177fd68 838 * use function @ref LL_DAC_DMA_GetRegAddr().
Kojto 158:b23ee177fd68 839 * @rmtoll CR DMAEN1 LL_DAC_EnableDMAReq\n
Kojto 158:b23ee177fd68 840 * CR DMAEN2 LL_DAC_EnableDMAReq
Kojto 158:b23ee177fd68 841 * @param DACx DAC instance
Kojto 158:b23ee177fd68 842 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 843 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 844 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 845 *
Kojto 158:b23ee177fd68 846 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 847 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 848 * @retval None
Kojto 158:b23ee177fd68 849 */
Kojto 158:b23ee177fd68 850 __STATIC_INLINE void LL_DAC_EnableDMAReq(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 158:b23ee177fd68 851 {
Kojto 158:b23ee177fd68 852 SET_BIT(DACx->CR,
Kojto 158:b23ee177fd68 853 DAC_CR_DMAEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 158:b23ee177fd68 854 }
Kojto 158:b23ee177fd68 855
Kojto 158:b23ee177fd68 856 /**
Kojto 158:b23ee177fd68 857 * @brief Disable DAC DMA transfer request of the selected channel.
Kojto 158:b23ee177fd68 858 * @note To configure DMA source address (peripheral address),
Kojto 158:b23ee177fd68 859 * use function @ref LL_DAC_DMA_GetRegAddr().
Kojto 158:b23ee177fd68 860 * @rmtoll CR DMAEN1 LL_DAC_DisableDMAReq\n
Kojto 158:b23ee177fd68 861 * CR DMAEN2 LL_DAC_DisableDMAReq
Kojto 158:b23ee177fd68 862 * @param DACx DAC instance
Kojto 158:b23ee177fd68 863 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 864 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 865 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 866 *
Kojto 158:b23ee177fd68 867 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 868 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 869 * @retval None
Kojto 158:b23ee177fd68 870 */
Kojto 158:b23ee177fd68 871 __STATIC_INLINE void LL_DAC_DisableDMAReq(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 158:b23ee177fd68 872 {
Kojto 158:b23ee177fd68 873 CLEAR_BIT(DACx->CR,
Kojto 158:b23ee177fd68 874 DAC_CR_DMAEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 158:b23ee177fd68 875 }
Kojto 158:b23ee177fd68 876
Kojto 158:b23ee177fd68 877 /**
Kojto 158:b23ee177fd68 878 * @brief Get DAC DMA transfer request state of the selected channel.
Kojto 158:b23ee177fd68 879 * (0: DAC DMA transfer request is disabled, 1: DAC DMA transfer request is enabled)
Kojto 158:b23ee177fd68 880 * @rmtoll CR DMAEN1 LL_DAC_IsDMAReqEnabled\n
Kojto 158:b23ee177fd68 881 * CR DMAEN2 LL_DAC_IsDMAReqEnabled
Kojto 158:b23ee177fd68 882 * @param DACx DAC instance
Kojto 158:b23ee177fd68 883 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 884 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 885 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 886 *
Kojto 158:b23ee177fd68 887 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 888 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 889 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 890 */
Kojto 158:b23ee177fd68 891 __STATIC_INLINE uint32_t LL_DAC_IsDMAReqEnabled(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 158:b23ee177fd68 892 {
Kojto 158:b23ee177fd68 893 return (READ_BIT(DACx->CR,
Kojto 158:b23ee177fd68 894 DAC_CR_DMAEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 158:b23ee177fd68 895 == (DAC_CR_DMAEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)));
Kojto 158:b23ee177fd68 896 }
Kojto 158:b23ee177fd68 897
Kojto 158:b23ee177fd68 898 /**
Kojto 158:b23ee177fd68 899 * @brief Function to help to configure DMA transfer to DAC: retrieve the
Kojto 158:b23ee177fd68 900 * DAC register address from DAC instance and a list of DAC registers
Kojto 158:b23ee177fd68 901 * intended to be used (most commonly) with DMA transfer.
Kojto 158:b23ee177fd68 902 * @note These DAC registers are data holding registers:
Kojto 158:b23ee177fd68 903 * when DAC conversion is requested, DAC generates a DMA transfer
Kojto 158:b23ee177fd68 904 * request to have data available in DAC data holding registers.
Kojto 158:b23ee177fd68 905 * @note This macro is intended to be used with LL DMA driver, refer to
Kojto 158:b23ee177fd68 906 * function "LL_DMA_ConfigAddresses()".
Kojto 158:b23ee177fd68 907 * Example:
Kojto 158:b23ee177fd68 908 * LL_DMA_ConfigAddresses(DMA1,
Kojto 158:b23ee177fd68 909 * LL_DMA_CHANNEL_1,
Kojto 158:b23ee177fd68 910 * (uint32_t)&< array or variable >,
Kojto 158:b23ee177fd68 911 * LL_DAC_DMA_GetRegAddr(DAC1, LL_DAC_CHANNEL_1, LL_DAC_DMA_REG_DATA_12BITS_RIGHT_ALIGNED),
Kojto 158:b23ee177fd68 912 * LL_DMA_DIRECTION_MEMORY_TO_PERIPH);
Kojto 158:b23ee177fd68 913 * @rmtoll DHR12R1 DACC1DHR LL_DAC_DMA_GetRegAddr\n
Kojto 158:b23ee177fd68 914 * DHR12L1 DACC1DHR LL_DAC_DMA_GetRegAddr\n
Kojto 158:b23ee177fd68 915 * DHR8R1 DACC1DHR LL_DAC_DMA_GetRegAddr\n
Kojto 158:b23ee177fd68 916 * DHR12R2 DACC2DHR LL_DAC_DMA_GetRegAddr\n
Kojto 158:b23ee177fd68 917 * DHR12L2 DACC2DHR LL_DAC_DMA_GetRegAddr\n
Kojto 158:b23ee177fd68 918 * DHR8R2 DACC2DHR LL_DAC_DMA_GetRegAddr
Kojto 158:b23ee177fd68 919 * @param DACx DAC instance
Kojto 158:b23ee177fd68 920 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 921 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 922 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 923 *
Kojto 158:b23ee177fd68 924 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 925 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 926 * @param Register This parameter can be one of the following values:
Kojto 158:b23ee177fd68 927 * @arg @ref LL_DAC_DMA_REG_DATA_12BITS_RIGHT_ALIGNED
Kojto 158:b23ee177fd68 928 * @arg @ref LL_DAC_DMA_REG_DATA_12BITS_LEFT_ALIGNED
Kojto 158:b23ee177fd68 929 * @arg @ref LL_DAC_DMA_REG_DATA_8BITS_RIGHT_ALIGNED
Kojto 158:b23ee177fd68 930 * @retval DAC register address
Kojto 158:b23ee177fd68 931 */
Kojto 158:b23ee177fd68 932 __STATIC_INLINE uint32_t LL_DAC_DMA_GetRegAddr(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t Register)
Kojto 158:b23ee177fd68 933 {
Kojto 158:b23ee177fd68 934 /* Retrieve address of register DHR12Rx, DHR12Lx or DHR8Rx depending on */
Kojto 158:b23ee177fd68 935 /* DAC channel selected. */
Kojto 158:b23ee177fd68 936 return ((uint32_t)(__DAC_PTR_REG_OFFSET((DACx)->DHR12R1, ((DAC_Channel >> Register) & DAC_REG_REGOFFSET_MASK_POSBIT0))));
Kojto 158:b23ee177fd68 937 }
Kojto 158:b23ee177fd68 938 /**
Kojto 158:b23ee177fd68 939 * @}
Kojto 158:b23ee177fd68 940 */
Kojto 158:b23ee177fd68 941
Kojto 158:b23ee177fd68 942 /** @defgroup DAC_LL_EF_Operation Operation on DAC channels
Kojto 158:b23ee177fd68 943 * @{
Kojto 158:b23ee177fd68 944 */
Kojto 158:b23ee177fd68 945
Kojto 158:b23ee177fd68 946 /**
Kojto 158:b23ee177fd68 947 * @brief Enable DAC selected channel.
Kojto 158:b23ee177fd68 948 * @rmtoll CR EN1 LL_DAC_Enable\n
Kojto 158:b23ee177fd68 949 * CR EN2 LL_DAC_Enable
Kojto 158:b23ee177fd68 950 * @note After enable from off state, DAC channel requires a delay
Kojto 158:b23ee177fd68 951 * for output voltage to reach accuracy +/- 1 LSB.
Kojto 158:b23ee177fd68 952 * Refer to device datasheet, parameter "tWAKEUP".
Kojto 158:b23ee177fd68 953 * @param DACx DAC instance
Kojto 158:b23ee177fd68 954 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 955 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 956 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 957 *
Kojto 158:b23ee177fd68 958 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 959 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 960 * @retval None
Kojto 158:b23ee177fd68 961 */
Kojto 158:b23ee177fd68 962 __STATIC_INLINE void LL_DAC_Enable(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 158:b23ee177fd68 963 {
Kojto 158:b23ee177fd68 964 SET_BIT(DACx->CR,
Kojto 158:b23ee177fd68 965 DAC_CR_EN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 158:b23ee177fd68 966 }
Kojto 158:b23ee177fd68 967
Kojto 158:b23ee177fd68 968 /**
Kojto 158:b23ee177fd68 969 * @brief Disable DAC selected channel.
Kojto 158:b23ee177fd68 970 * @rmtoll CR EN1 LL_DAC_Disable\n
Kojto 158:b23ee177fd68 971 * CR EN2 LL_DAC_Disable
Kojto 158:b23ee177fd68 972 * @param DACx DAC instance
Kojto 158:b23ee177fd68 973 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 974 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 975 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 976 *
Kojto 158:b23ee177fd68 977 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 978 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 979 * @retval None
Kojto 158:b23ee177fd68 980 */
Kojto 158:b23ee177fd68 981 __STATIC_INLINE void LL_DAC_Disable(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 158:b23ee177fd68 982 {
Kojto 158:b23ee177fd68 983 CLEAR_BIT(DACx->CR,
Kojto 158:b23ee177fd68 984 DAC_CR_EN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 158:b23ee177fd68 985 }
Kojto 158:b23ee177fd68 986
Kojto 158:b23ee177fd68 987 /**
Kojto 158:b23ee177fd68 988 * @brief Get DAC enable state of the selected channel.
Kojto 158:b23ee177fd68 989 * (0: DAC channel is disabled, 1: DAC channel is enabled)
Kojto 158:b23ee177fd68 990 * @rmtoll CR EN1 LL_DAC_IsEnabled\n
Kojto 158:b23ee177fd68 991 * CR EN2 LL_DAC_IsEnabled
Kojto 158:b23ee177fd68 992 * @param DACx DAC instance
Kojto 158:b23ee177fd68 993 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 994 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 995 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 996 *
Kojto 158:b23ee177fd68 997 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 998 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 999 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1000 */
Kojto 158:b23ee177fd68 1001 __STATIC_INLINE uint32_t LL_DAC_IsEnabled(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 158:b23ee177fd68 1002 {
Kojto 158:b23ee177fd68 1003 return (READ_BIT(DACx->CR,
Kojto 158:b23ee177fd68 1004 DAC_CR_EN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 158:b23ee177fd68 1005 == (DAC_CR_EN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)));
Kojto 158:b23ee177fd68 1006 }
Kojto 158:b23ee177fd68 1007
Kojto 158:b23ee177fd68 1008 /**
Kojto 158:b23ee177fd68 1009 * @brief Enable DAC trigger of the selected channel.
Kojto 158:b23ee177fd68 1010 * @note - If DAC trigger is disabled, DAC conversion is performed
Kojto 158:b23ee177fd68 1011 * automatically once the data holding register is updated,
Kojto 158:b23ee177fd68 1012 * using functions "LL_DAC_ConvertData{8; 12}{Right; Left} Aligned()":
Kojto 158:b23ee177fd68 1013 * @ref LL_DAC_ConvertData12RightAligned(), ...
Kojto 158:b23ee177fd68 1014 * - If DAC trigger is enabled, DAC conversion is performed
Kojto 158:b23ee177fd68 1015 * only when a hardware of software trigger event is occurring.
Kojto 158:b23ee177fd68 1016 * Select trigger source using
Kojto 158:b23ee177fd68 1017 * function @ref LL_DAC_SetTriggerSource().
Kojto 158:b23ee177fd68 1018 * @rmtoll CR TEN1 LL_DAC_EnableTrigger\n
Kojto 158:b23ee177fd68 1019 * CR TEN2 LL_DAC_EnableTrigger
Kojto 158:b23ee177fd68 1020 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1021 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1022 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 1023 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 1024 *
Kojto 158:b23ee177fd68 1025 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 1026 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 1027 * @retval None
Kojto 158:b23ee177fd68 1028 */
Kojto 158:b23ee177fd68 1029 __STATIC_INLINE void LL_DAC_EnableTrigger(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 158:b23ee177fd68 1030 {
Kojto 158:b23ee177fd68 1031 SET_BIT(DACx->CR,
Kojto 158:b23ee177fd68 1032 DAC_CR_TEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 158:b23ee177fd68 1033 }
Kojto 158:b23ee177fd68 1034
Kojto 158:b23ee177fd68 1035 /**
Kojto 158:b23ee177fd68 1036 * @brief Disable DAC trigger of the selected channel.
Kojto 158:b23ee177fd68 1037 * @rmtoll CR TEN1 LL_DAC_DisableTrigger\n
Kojto 158:b23ee177fd68 1038 * CR TEN2 LL_DAC_DisableTrigger
Kojto 158:b23ee177fd68 1039 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1040 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1041 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 1042 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 1043 *
Kojto 158:b23ee177fd68 1044 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 1045 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 1046 * @retval None
Kojto 158:b23ee177fd68 1047 */
Kojto 158:b23ee177fd68 1048 __STATIC_INLINE void LL_DAC_DisableTrigger(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 158:b23ee177fd68 1049 {
Kojto 158:b23ee177fd68 1050 CLEAR_BIT(DACx->CR,
Kojto 158:b23ee177fd68 1051 DAC_CR_TEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 158:b23ee177fd68 1052 }
Kojto 158:b23ee177fd68 1053
Kojto 158:b23ee177fd68 1054 /**
Kojto 158:b23ee177fd68 1055 * @brief Get DAC trigger state of the selected channel.
Kojto 158:b23ee177fd68 1056 * (0: DAC trigger is disabled, 1: DAC trigger is enabled)
Kojto 158:b23ee177fd68 1057 * @rmtoll CR TEN1 LL_DAC_IsTriggerEnabled\n
Kojto 158:b23ee177fd68 1058 * CR TEN2 LL_DAC_IsTriggerEnabled
Kojto 158:b23ee177fd68 1059 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1060 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1061 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 1062 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 1063 *
Kojto 158:b23ee177fd68 1064 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 1065 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 1066 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1067 */
Kojto 158:b23ee177fd68 1068 __STATIC_INLINE uint32_t LL_DAC_IsTriggerEnabled(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 158:b23ee177fd68 1069 {
Kojto 158:b23ee177fd68 1070 return (READ_BIT(DACx->CR,
Kojto 158:b23ee177fd68 1071 DAC_CR_TEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 158:b23ee177fd68 1072 == (DAC_CR_TEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)));
Kojto 158:b23ee177fd68 1073 }
Kojto 158:b23ee177fd68 1074
Kojto 158:b23ee177fd68 1075 /**
Kojto 158:b23ee177fd68 1076 * @brief Trig DAC conversion by software for the selected DAC channel.
Kojto 158:b23ee177fd68 1077 * @note Preliminarily, DAC trigger must be set to software trigger
Kojto 158:b23ee177fd68 1078 * using function @ref LL_DAC_SetTriggerSource()
Kojto 158:b23ee177fd68 1079 * with parameter "LL_DAC_TRIGGER_SOFTWARE".
Kojto 158:b23ee177fd68 1080 * and DAC trigger must be enabled using
Kojto 158:b23ee177fd68 1081 * function @ref LL_DAC_EnableTrigger().
Kojto 158:b23ee177fd68 1082 * @note For devices featuring DAC with 2 channels: this function
Kojto 158:b23ee177fd68 1083 * can perform a SW start of both DAC channels simultaneously.
Kojto 158:b23ee177fd68 1084 * Two channels can be selected as parameter.
Kojto 158:b23ee177fd68 1085 * Example: (LL_DAC_CHANNEL_1 | LL_DAC_CHANNEL_2)
Kojto 158:b23ee177fd68 1086 * @rmtoll SWTRIGR SWTRIG1 LL_DAC_TrigSWConversion\n
Kojto 158:b23ee177fd68 1087 * SWTRIGR SWTRIG2 LL_DAC_TrigSWConversion
Kojto 158:b23ee177fd68 1088 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1089 * @param DAC_Channel This parameter can a combination of the following values:
Kojto 158:b23ee177fd68 1090 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 1091 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 1092 *
Kojto 158:b23ee177fd68 1093 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 1094 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 1095 * @retval None
Kojto 158:b23ee177fd68 1096 */
Kojto 158:b23ee177fd68 1097 __STATIC_INLINE void LL_DAC_TrigSWConversion(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 158:b23ee177fd68 1098 {
Kojto 158:b23ee177fd68 1099 SET_BIT(DACx->SWTRIGR,
Kojto 158:b23ee177fd68 1100 (DAC_Channel & DAC_SWTR_CHX_MASK));
Kojto 158:b23ee177fd68 1101 }
Kojto 158:b23ee177fd68 1102
Kojto 158:b23ee177fd68 1103 /**
Kojto 158:b23ee177fd68 1104 * @brief Set the data to be loaded in the data holding register
Kojto 158:b23ee177fd68 1105 * in format 12 bits left alignment (LSB aligned on bit 0),
Kojto 158:b23ee177fd68 1106 * for the selected DAC channel.
Kojto 158:b23ee177fd68 1107 * @rmtoll DHR12R1 DACC1DHR LL_DAC_ConvertData12RightAligned\n
Kojto 158:b23ee177fd68 1108 * DHR12R2 DACC2DHR LL_DAC_ConvertData12RightAligned
Kojto 158:b23ee177fd68 1109 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1110 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1111 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 1112 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 1113 *
Kojto 158:b23ee177fd68 1114 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 1115 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 1116 * @param Data Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 1117 * @retval None
Kojto 158:b23ee177fd68 1118 */
Kojto 158:b23ee177fd68 1119 __STATIC_INLINE void LL_DAC_ConvertData12RightAligned(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t Data)
Kojto 158:b23ee177fd68 1120 {
Kojto 158:b23ee177fd68 1121 register uint32_t *preg = __DAC_PTR_REG_OFFSET(DACx->DHR12R1, (DAC_Channel >> DAC_REG_DHR12RX_REGOFFSET_BITOFFSET_POS) & DAC_REG_REGOFFSET_MASK_POSBIT0);
Kojto 158:b23ee177fd68 1122
Kojto 158:b23ee177fd68 1123 MODIFY_REG(*preg,
Kojto 158:b23ee177fd68 1124 DAC_DHR12R1_DACC1DHR,
Kojto 158:b23ee177fd68 1125 Data);
Kojto 158:b23ee177fd68 1126 }
Kojto 158:b23ee177fd68 1127
Kojto 158:b23ee177fd68 1128 /**
Kojto 158:b23ee177fd68 1129 * @brief Set the data to be loaded in the data holding register
Kojto 158:b23ee177fd68 1130 * in format 12 bits left alignment (MSB aligned on bit 15),
Kojto 158:b23ee177fd68 1131 * for the selected DAC channel.
Kojto 158:b23ee177fd68 1132 * @rmtoll DHR12L1 DACC1DHR LL_DAC_ConvertData12LeftAligned\n
Kojto 158:b23ee177fd68 1133 * DHR12L2 DACC2DHR LL_DAC_ConvertData12LeftAligned
Kojto 158:b23ee177fd68 1134 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1135 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1136 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 1137 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 1138 *
Kojto 158:b23ee177fd68 1139 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 1140 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 1141 * @param Data Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 1142 * @retval None
Kojto 158:b23ee177fd68 1143 */
Kojto 158:b23ee177fd68 1144 __STATIC_INLINE void LL_DAC_ConvertData12LeftAligned(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t Data)
Kojto 158:b23ee177fd68 1145 {
Kojto 158:b23ee177fd68 1146 register uint32_t *preg = __DAC_PTR_REG_OFFSET(DACx->DHR12R1, (DAC_Channel >> DAC_REG_DHR12LX_REGOFFSET_BITOFFSET_POS) & DAC_REG_REGOFFSET_MASK_POSBIT0);
Kojto 158:b23ee177fd68 1147
Kojto 158:b23ee177fd68 1148 MODIFY_REG(*preg,
Kojto 158:b23ee177fd68 1149 DAC_DHR12L1_DACC1DHR,
Kojto 158:b23ee177fd68 1150 Data);
Kojto 158:b23ee177fd68 1151 }
Kojto 158:b23ee177fd68 1152
Kojto 158:b23ee177fd68 1153 /**
Kojto 158:b23ee177fd68 1154 * @brief Set the data to be loaded in the data holding register
Kojto 158:b23ee177fd68 1155 * in format 8 bits left alignment (LSB aligned on bit 0),
Kojto 158:b23ee177fd68 1156 * for the selected DAC channel.
Kojto 158:b23ee177fd68 1157 * @rmtoll DHR8R1 DACC1DHR LL_DAC_ConvertData8RightAligned\n
Kojto 158:b23ee177fd68 1158 * DHR8R2 DACC2DHR LL_DAC_ConvertData8RightAligned
Kojto 158:b23ee177fd68 1159 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1160 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1161 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 1162 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 1163 *
Kojto 158:b23ee177fd68 1164 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 1165 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 1166 * @param Data Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 158:b23ee177fd68 1167 * @retval None
Kojto 158:b23ee177fd68 1168 */
Kojto 158:b23ee177fd68 1169 __STATIC_INLINE void LL_DAC_ConvertData8RightAligned(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t Data)
Kojto 158:b23ee177fd68 1170 {
Kojto 158:b23ee177fd68 1171 register uint32_t *preg = __DAC_PTR_REG_OFFSET(DACx->DHR12R1, (DAC_Channel >> DAC_REG_DHR8RX_REGOFFSET_BITOFFSET_POS) & DAC_REG_REGOFFSET_MASK_POSBIT0);
Kojto 158:b23ee177fd68 1172
Kojto 158:b23ee177fd68 1173 MODIFY_REG(*preg,
Kojto 158:b23ee177fd68 1174 DAC_DHR8R1_DACC1DHR,
Kojto 158:b23ee177fd68 1175 Data);
Kojto 158:b23ee177fd68 1176 }
Kojto 158:b23ee177fd68 1177
Kojto 158:b23ee177fd68 1178 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 158:b23ee177fd68 1179 /**
Kojto 158:b23ee177fd68 1180 * @brief Set the data to be loaded in the data holding register
Kojto 158:b23ee177fd68 1181 * in format 12 bits left alignment (LSB aligned on bit 0),
Kojto 158:b23ee177fd68 1182 * for both DAC channels.
Kojto 158:b23ee177fd68 1183 * @rmtoll DHR12RD DACC1DHR LL_DAC_ConvertDualData12RightAligned\n
Kojto 158:b23ee177fd68 1184 * DHR12RD DACC2DHR LL_DAC_ConvertDualData12RightAligned
Kojto 158:b23ee177fd68 1185 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1186 * @param DataChannel1 Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 1187 * @param DataChannel2 Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 1188 * @retval None
Kojto 158:b23ee177fd68 1189 */
Kojto 158:b23ee177fd68 1190 __STATIC_INLINE void LL_DAC_ConvertDualData12RightAligned(DAC_TypeDef *DACx, uint32_t DataChannel1, uint32_t DataChannel2)
Kojto 158:b23ee177fd68 1191 {
Kojto 158:b23ee177fd68 1192 MODIFY_REG(DACx->DHR12RD,
Kojto 158:b23ee177fd68 1193 (DAC_DHR12RD_DACC2DHR | DAC_DHR12RD_DACC1DHR),
Kojto 158:b23ee177fd68 1194 ((DataChannel2 << DAC_DHR12RD_DACC2DHR_BITOFFSET_POS) | DataChannel1));
Kojto 158:b23ee177fd68 1195 }
Kojto 158:b23ee177fd68 1196
Kojto 158:b23ee177fd68 1197 /**
Kojto 158:b23ee177fd68 1198 * @brief Set the data to be loaded in the data holding register
Kojto 158:b23ee177fd68 1199 * in format 12 bits left alignment (MSB aligned on bit 15),
Kojto 158:b23ee177fd68 1200 * for both DAC channels.
Kojto 158:b23ee177fd68 1201 * @rmtoll DHR12LD DACC1DHR LL_DAC_ConvertDualData12LeftAligned\n
Kojto 158:b23ee177fd68 1202 * DHR12LD DACC2DHR LL_DAC_ConvertDualData12LeftAligned
Kojto 158:b23ee177fd68 1203 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1204 * @param DataChannel1 Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 1205 * @param DataChannel2 Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 1206 * @retval None
Kojto 158:b23ee177fd68 1207 */
Kojto 158:b23ee177fd68 1208 __STATIC_INLINE void LL_DAC_ConvertDualData12LeftAligned(DAC_TypeDef *DACx, uint32_t DataChannel1, uint32_t DataChannel2)
Kojto 158:b23ee177fd68 1209 {
Kojto 158:b23ee177fd68 1210 /* Note: Data of DAC channel 2 shift value subtracted of 4 because */
Kojto 158:b23ee177fd68 1211 /* data on 16 bits and DAC channel 2 bits field is on the 12 MSB, */
Kojto 158:b23ee177fd68 1212 /* the 4 LSB must be taken into account for the shift value. */
Kojto 158:b23ee177fd68 1213 MODIFY_REG(DACx->DHR12LD,
Kojto 158:b23ee177fd68 1214 (DAC_DHR12LD_DACC2DHR | DAC_DHR12LD_DACC1DHR),
Kojto 158:b23ee177fd68 1215 ((DataChannel2 << (DAC_DHR12LD_DACC2DHR_BITOFFSET_POS - 4U)) | DataChannel1));
Kojto 158:b23ee177fd68 1216 }
Kojto 158:b23ee177fd68 1217
Kojto 158:b23ee177fd68 1218 /**
Kojto 158:b23ee177fd68 1219 * @brief Set the data to be loaded in the data holding register
Kojto 158:b23ee177fd68 1220 * in format 8 bits left alignment (LSB aligned on bit 0),
Kojto 158:b23ee177fd68 1221 * for both DAC channels.
Kojto 158:b23ee177fd68 1222 * @rmtoll DHR8RD DACC1DHR LL_DAC_ConvertDualData8RightAligned\n
Kojto 158:b23ee177fd68 1223 * DHR8RD DACC2DHR LL_DAC_ConvertDualData8RightAligned
Kojto 158:b23ee177fd68 1224 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1225 * @param DataChannel1 Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 158:b23ee177fd68 1226 * @param DataChannel2 Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 158:b23ee177fd68 1227 * @retval None
Kojto 158:b23ee177fd68 1228 */
Kojto 158:b23ee177fd68 1229 __STATIC_INLINE void LL_DAC_ConvertDualData8RightAligned(DAC_TypeDef *DACx, uint32_t DataChannel1, uint32_t DataChannel2)
Kojto 158:b23ee177fd68 1230 {
Kojto 158:b23ee177fd68 1231 MODIFY_REG(DACx->DHR8RD,
Kojto 158:b23ee177fd68 1232 (DAC_DHR8RD_DACC2DHR | DAC_DHR8RD_DACC1DHR),
Kojto 158:b23ee177fd68 1233 ((DataChannel2 << DAC_DHR8RD_DACC2DHR_BITOFFSET_POS) | DataChannel1));
Kojto 158:b23ee177fd68 1234 }
Kojto 158:b23ee177fd68 1235
Kojto 158:b23ee177fd68 1236 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 158:b23ee177fd68 1237 /**
Kojto 158:b23ee177fd68 1238 * @brief Retrieve output data currently generated for the selected DAC channel.
Kojto 158:b23ee177fd68 1239 * @note Whatever alignment and resolution settings
Kojto 158:b23ee177fd68 1240 * (using functions "LL_DAC_ConvertData{8; 12}{Right; Left} Aligned()":
Kojto 158:b23ee177fd68 1241 * @ref LL_DAC_ConvertData12RightAligned(), ...),
Kojto 158:b23ee177fd68 1242 * output data format is 12 bits right aligned (LSB aligned on bit 0).
Kojto 158:b23ee177fd68 1243 * @rmtoll DOR1 DACC1DOR LL_DAC_RetrieveOutputData\n
Kojto 158:b23ee177fd68 1244 * DOR2 DACC2DOR LL_DAC_RetrieveOutputData
Kojto 158:b23ee177fd68 1245 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1246 * @param DAC_Channel This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1247 * @arg @ref LL_DAC_CHANNEL_1
Kojto 158:b23ee177fd68 1248 * @arg @ref LL_DAC_CHANNEL_2 (1)
Kojto 158:b23ee177fd68 1249 *
Kojto 158:b23ee177fd68 1250 * (1) On this STM32 serie, parameter not available on all devices.
Kojto 158:b23ee177fd68 1251 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 1252 * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 1253 */
Kojto 158:b23ee177fd68 1254 __STATIC_INLINE uint32_t LL_DAC_RetrieveOutputData(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 158:b23ee177fd68 1255 {
Kojto 158:b23ee177fd68 1256 register uint32_t *preg = __DAC_PTR_REG_OFFSET(DACx->DOR1, (DAC_Channel >> DAC_REG_DORX_REGOFFSET_BITOFFSET_POS) & DAC_REG_REGOFFSET_MASK_POSBIT0);
Kojto 158:b23ee177fd68 1257
Kojto 158:b23ee177fd68 1258 return (uint16_t) READ_BIT(*preg, DAC_DOR1_DACC1DOR);
Kojto 158:b23ee177fd68 1259 }
Kojto 158:b23ee177fd68 1260
Kojto 158:b23ee177fd68 1261 /**
Kojto 158:b23ee177fd68 1262 * @}
Kojto 158:b23ee177fd68 1263 */
Kojto 158:b23ee177fd68 1264
Kojto 158:b23ee177fd68 1265 /** @defgroup DAC_LL_EF_FLAG_Management FLAG Management
Kojto 158:b23ee177fd68 1266 * @{
Kojto 158:b23ee177fd68 1267 */
Kojto 158:b23ee177fd68 1268 /**
Kojto 158:b23ee177fd68 1269 * @brief Get DAC underrun flag for DAC channel 1
Kojto 158:b23ee177fd68 1270 * @rmtoll SR DMAUDR1 LL_DAC_IsActiveFlag_DMAUDR1
Kojto 158:b23ee177fd68 1271 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1272 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1273 */
Kojto 158:b23ee177fd68 1274 __STATIC_INLINE uint32_t LL_DAC_IsActiveFlag_DMAUDR1(DAC_TypeDef *DACx)
Kojto 158:b23ee177fd68 1275 {
Kojto 158:b23ee177fd68 1276 return (READ_BIT(DACx->SR, LL_DAC_FLAG_DMAUDR1) == (LL_DAC_FLAG_DMAUDR1));
Kojto 158:b23ee177fd68 1277 }
Kojto 158:b23ee177fd68 1278
Kojto 158:b23ee177fd68 1279 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 158:b23ee177fd68 1280 /**
Kojto 158:b23ee177fd68 1281 * @brief Get DAC underrun flag for DAC channel 2
Kojto 158:b23ee177fd68 1282 * @rmtoll SR DMAUDR2 LL_DAC_IsActiveFlag_DMAUDR2
Kojto 158:b23ee177fd68 1283 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1284 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1285 */
Kojto 158:b23ee177fd68 1286 __STATIC_INLINE uint32_t LL_DAC_IsActiveFlag_DMAUDR2(DAC_TypeDef *DACx)
Kojto 158:b23ee177fd68 1287 {
Kojto 158:b23ee177fd68 1288 return (READ_BIT(DACx->SR, LL_DAC_FLAG_DMAUDR2) == (LL_DAC_FLAG_DMAUDR2));
Kojto 158:b23ee177fd68 1289 }
Kojto 158:b23ee177fd68 1290 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 158:b23ee177fd68 1291
Kojto 158:b23ee177fd68 1292 /**
Kojto 158:b23ee177fd68 1293 * @brief Clear DAC underrun flag for DAC channel 1
Kojto 158:b23ee177fd68 1294 * @rmtoll SR DMAUDR1 LL_DAC_ClearFlag_DMAUDR1
Kojto 158:b23ee177fd68 1295 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1296 * @retval None
Kojto 158:b23ee177fd68 1297 */
Kojto 158:b23ee177fd68 1298 __STATIC_INLINE void LL_DAC_ClearFlag_DMAUDR1(DAC_TypeDef *DACx)
Kojto 158:b23ee177fd68 1299 {
Kojto 158:b23ee177fd68 1300 WRITE_REG(DACx->SR, LL_DAC_FLAG_DMAUDR1);
Kojto 158:b23ee177fd68 1301 }
Kojto 158:b23ee177fd68 1302
Kojto 158:b23ee177fd68 1303 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 158:b23ee177fd68 1304 /**
Kojto 158:b23ee177fd68 1305 * @brief Clear DAC underrun flag for DAC channel 2
Kojto 158:b23ee177fd68 1306 * @rmtoll SR DMAUDR2 LL_DAC_ClearFlag_DMAUDR2
Kojto 158:b23ee177fd68 1307 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1308 * @retval None
Kojto 158:b23ee177fd68 1309 */
Kojto 158:b23ee177fd68 1310 __STATIC_INLINE void LL_DAC_ClearFlag_DMAUDR2(DAC_TypeDef *DACx)
Kojto 158:b23ee177fd68 1311 {
Kojto 158:b23ee177fd68 1312 WRITE_REG(DACx->SR, LL_DAC_FLAG_DMAUDR2);
Kojto 158:b23ee177fd68 1313 }
Kojto 158:b23ee177fd68 1314 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 158:b23ee177fd68 1315
Kojto 158:b23ee177fd68 1316 /**
Kojto 158:b23ee177fd68 1317 * @}
Kojto 158:b23ee177fd68 1318 */
Kojto 158:b23ee177fd68 1319
Kojto 158:b23ee177fd68 1320 /** @defgroup DAC_LL_EF_IT_Management IT management
Kojto 158:b23ee177fd68 1321 * @{
Kojto 158:b23ee177fd68 1322 */
Kojto 158:b23ee177fd68 1323
Kojto 158:b23ee177fd68 1324 /**
Kojto 158:b23ee177fd68 1325 * @brief Enable DMA underrun interrupt for DAC channel 1
Kojto 158:b23ee177fd68 1326 * @rmtoll CR DMAUDRIE1 LL_DAC_EnableIT_DMAUDR1
Kojto 158:b23ee177fd68 1327 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1328 * @retval None
Kojto 158:b23ee177fd68 1329 */
Kojto 158:b23ee177fd68 1330 __STATIC_INLINE void LL_DAC_EnableIT_DMAUDR1(DAC_TypeDef *DACx)
Kojto 158:b23ee177fd68 1331 {
Kojto 158:b23ee177fd68 1332 SET_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE1);
Kojto 158:b23ee177fd68 1333 }
Kojto 158:b23ee177fd68 1334
Kojto 158:b23ee177fd68 1335 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 158:b23ee177fd68 1336 /**
Kojto 158:b23ee177fd68 1337 * @brief Enable DMA underrun interrupt for DAC channel 2
Kojto 158:b23ee177fd68 1338 * @rmtoll CR DMAUDRIE2 LL_DAC_EnableIT_DMAUDR2
Kojto 158:b23ee177fd68 1339 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1340 * @retval None
Kojto 158:b23ee177fd68 1341 */
Kojto 158:b23ee177fd68 1342 __STATIC_INLINE void LL_DAC_EnableIT_DMAUDR2(DAC_TypeDef *DACx)
Kojto 158:b23ee177fd68 1343 {
Kojto 158:b23ee177fd68 1344 SET_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE2);
Kojto 158:b23ee177fd68 1345 }
Kojto 158:b23ee177fd68 1346 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 158:b23ee177fd68 1347
Kojto 158:b23ee177fd68 1348 /**
Kojto 158:b23ee177fd68 1349 * @brief Disable DMA underrun interrupt for DAC channel 1
Kojto 158:b23ee177fd68 1350 * @rmtoll CR DMAUDRIE1 LL_DAC_DisableIT_DMAUDR1
Kojto 158:b23ee177fd68 1351 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1352 * @retval None
Kojto 158:b23ee177fd68 1353 */
Kojto 158:b23ee177fd68 1354 __STATIC_INLINE void LL_DAC_DisableIT_DMAUDR1(DAC_TypeDef *DACx)
Kojto 158:b23ee177fd68 1355 {
Kojto 158:b23ee177fd68 1356 CLEAR_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE1);
Kojto 158:b23ee177fd68 1357 }
Kojto 158:b23ee177fd68 1358
Kojto 158:b23ee177fd68 1359 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 158:b23ee177fd68 1360 /**
Kojto 158:b23ee177fd68 1361 * @brief Disable DMA underrun interrupt for DAC channel 2
Kojto 158:b23ee177fd68 1362 * @rmtoll CR DMAUDRIE2 LL_DAC_DisableIT_DMAUDR2
Kojto 158:b23ee177fd68 1363 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1364 * @retval None
Kojto 158:b23ee177fd68 1365 */
Kojto 158:b23ee177fd68 1366 __STATIC_INLINE void LL_DAC_DisableIT_DMAUDR2(DAC_TypeDef *DACx)
Kojto 158:b23ee177fd68 1367 {
Kojto 158:b23ee177fd68 1368 CLEAR_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE2);
Kojto 158:b23ee177fd68 1369 }
Kojto 158:b23ee177fd68 1370 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 158:b23ee177fd68 1371
Kojto 158:b23ee177fd68 1372 /**
Kojto 158:b23ee177fd68 1373 * @brief Get DMA underrun interrupt for DAC channel 1
Kojto 158:b23ee177fd68 1374 * @rmtoll CR DMAUDRIE1 LL_DAC_IsEnabledIT_DMAUDR1
Kojto 158:b23ee177fd68 1375 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1376 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1377 */
Kojto 158:b23ee177fd68 1378 __STATIC_INLINE uint32_t LL_DAC_IsEnabledIT_DMAUDR1(DAC_TypeDef *DACx)
Kojto 158:b23ee177fd68 1379 {
Kojto 158:b23ee177fd68 1380 return (READ_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE1) == (LL_DAC_IT_DMAUDRIE1));
Kojto 158:b23ee177fd68 1381 }
Kojto 158:b23ee177fd68 1382
Kojto 158:b23ee177fd68 1383 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 158:b23ee177fd68 1384 /**
Kojto 158:b23ee177fd68 1385 * @brief Get DMA underrun interrupt for DAC channel 2
Kojto 158:b23ee177fd68 1386 * @rmtoll CR DMAUDRIE2 LL_DAC_IsEnabledIT_DMAUDR2
Kojto 158:b23ee177fd68 1387 * @param DACx DAC instance
Kojto 158:b23ee177fd68 1388 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1389 */
Kojto 158:b23ee177fd68 1390 __STATIC_INLINE uint32_t LL_DAC_IsEnabledIT_DMAUDR2(DAC_TypeDef *DACx)
Kojto 158:b23ee177fd68 1391 {
Kojto 158:b23ee177fd68 1392 return (READ_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE2) == (LL_DAC_IT_DMAUDRIE2));
Kojto 158:b23ee177fd68 1393 }
Kojto 158:b23ee177fd68 1394 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 158:b23ee177fd68 1395
Kojto 158:b23ee177fd68 1396 /**
Kojto 158:b23ee177fd68 1397 * @}
Kojto 158:b23ee177fd68 1398 */
Kojto 158:b23ee177fd68 1399
Kojto 158:b23ee177fd68 1400 #if defined(USE_FULL_LL_DRIVER)
Kojto 158:b23ee177fd68 1401 /** @defgroup DAC_LL_EF_Init Initialization and de-initialization functions
Kojto 158:b23ee177fd68 1402 * @{
Kojto 158:b23ee177fd68 1403 */
Kojto 158:b23ee177fd68 1404
Kojto 158:b23ee177fd68 1405 ErrorStatus LL_DAC_DeInit(DAC_TypeDef* DACx);
Kojto 158:b23ee177fd68 1406 ErrorStatus LL_DAC_Init(DAC_TypeDef* DACx, uint32_t DAC_Channel, LL_DAC_InitTypeDef* DAC_InitStruct);
Kojto 158:b23ee177fd68 1407 void LL_DAC_StructInit(LL_DAC_InitTypeDef* DAC_InitStruct);
Kojto 158:b23ee177fd68 1408
Kojto 158:b23ee177fd68 1409 /**
Kojto 158:b23ee177fd68 1410 * @}
Kojto 158:b23ee177fd68 1411 */
Kojto 158:b23ee177fd68 1412 #endif /* USE_FULL_LL_DRIVER */
Kojto 158:b23ee177fd68 1413
Kojto 158:b23ee177fd68 1414 /**
Kojto 158:b23ee177fd68 1415 * @}
Kojto 158:b23ee177fd68 1416 */
Kojto 158:b23ee177fd68 1417
Kojto 158:b23ee177fd68 1418 /**
Kojto 158:b23ee177fd68 1419 * @}
Kojto 158:b23ee177fd68 1420 */
Kojto 158:b23ee177fd68 1421
Kojto 158:b23ee177fd68 1422 #endif /* DAC1 */
Kojto 158:b23ee177fd68 1423
Kojto 158:b23ee177fd68 1424 /**
Kojto 158:b23ee177fd68 1425 * @}
Kojto 158:b23ee177fd68 1426 */
Kojto 158:b23ee177fd68 1427
Kojto 158:b23ee177fd68 1428 #ifdef __cplusplus
Kojto 158:b23ee177fd68 1429 }
Kojto 158:b23ee177fd68 1430 #endif
Kojto 158:b23ee177fd68 1431
Kojto 158:b23ee177fd68 1432 #endif /* __STM32L0xx_LL_DAC_H */
Kojto 158:b23ee177fd68 1433
Kojto 158:b23ee177fd68 1434 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/