The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Jun 21 17:31:38 2017 +0100
Revision:
145:64910690c574
Parent:
128:9bcdf88f62b0
Release 145 of the mbed library.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 122:f9eeca106725 1 /**
Kojto 122:f9eeca106725 2 ******************************************************************************
Kojto 122:f9eeca106725 3 * @file stm32l4xx_ll_dac.h
Kojto 122:f9eeca106725 4 * @author MCD Application Team
AnnaBridge 145:64910690c574 5 * @version V1.7.1
AnnaBridge 145:64910690c574 6 * @date 21-April-2017
Kojto 122:f9eeca106725 7 * @brief Header file of DAC LL module.
Kojto 122:f9eeca106725 8 ******************************************************************************
Kojto 122:f9eeca106725 9 * @attention
Kojto 122:f9eeca106725 10 *
AnnaBridge 145:64910690c574 11 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
Kojto 122:f9eeca106725 12 *
Kojto 122:f9eeca106725 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 122:f9eeca106725 14 * are permitted provided that the following conditions are met:
Kojto 122:f9eeca106725 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 122:f9eeca106725 16 * this list of conditions and the following disclaimer.
Kojto 122:f9eeca106725 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 122:f9eeca106725 18 * this list of conditions and the following disclaimer in the documentation
Kojto 122:f9eeca106725 19 * and/or other materials provided with the distribution.
Kojto 122:f9eeca106725 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 122:f9eeca106725 21 * may be used to endorse or promote products derived from this software
Kojto 122:f9eeca106725 22 * without specific prior written permission.
Kojto 122:f9eeca106725 23 *
Kojto 122:f9eeca106725 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 122:f9eeca106725 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 122:f9eeca106725 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 122:f9eeca106725 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 122:f9eeca106725 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 122:f9eeca106725 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 122:f9eeca106725 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 122:f9eeca106725 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 122:f9eeca106725 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 122:f9eeca106725 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 122:f9eeca106725 34 *
Kojto 122:f9eeca106725 35 ******************************************************************************
Kojto 122:f9eeca106725 36 */
Kojto 122:f9eeca106725 37
Kojto 122:f9eeca106725 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 122:f9eeca106725 39 #ifndef __STM32L4xx_LL_DAC_H
Kojto 122:f9eeca106725 40 #define __STM32L4xx_LL_DAC_H
Kojto 122:f9eeca106725 41
Kojto 122:f9eeca106725 42 #ifdef __cplusplus
Kojto 122:f9eeca106725 43 extern "C" {
Kojto 122:f9eeca106725 44 #endif
Kojto 122:f9eeca106725 45
Kojto 122:f9eeca106725 46 /* Includes ------------------------------------------------------------------*/
Kojto 122:f9eeca106725 47 #include "stm32l4xx.h"
Kojto 122:f9eeca106725 48
Kojto 122:f9eeca106725 49 /** @addtogroup STM32L4xx_LL_Driver
Kojto 122:f9eeca106725 50 * @{
Kojto 122:f9eeca106725 51 */
Kojto 122:f9eeca106725 52
Kojto 122:f9eeca106725 53 #if defined (DAC1)
Kojto 122:f9eeca106725 54
Kojto 122:f9eeca106725 55 /** @defgroup DAC_LL DAC
Kojto 122:f9eeca106725 56 * @{
Kojto 122:f9eeca106725 57 */
Kojto 122:f9eeca106725 58
Kojto 122:f9eeca106725 59 /* Private types -------------------------------------------------------------*/
Kojto 122:f9eeca106725 60 /* Private variables ---------------------------------------------------------*/
Kojto 122:f9eeca106725 61
Kojto 122:f9eeca106725 62 /* Private constants ---------------------------------------------------------*/
Kojto 122:f9eeca106725 63 /** @defgroup DAC_LL_Private_Constants DAC Private Constants
Kojto 122:f9eeca106725 64 * @{
Kojto 122:f9eeca106725 65 */
Kojto 122:f9eeca106725 66
Kojto 122:f9eeca106725 67 /* Internal masks for DAC channels definition */
Kojto 122:f9eeca106725 68 /* To select into literal LL_DAC_CHANNEL_x the relevant bits for: */
Kojto 122:f9eeca106725 69 /* - channel bits position into registers CR, MCR, CCR, SHHR, SHRR */
Kojto 122:f9eeca106725 70 /* - channel bits position into register SWTRIG */
Kojto 122:f9eeca106725 71 /* - channel register offset of data holding register DHRx */
Kojto 122:f9eeca106725 72 /* - channel register offset of data output register DORx */
Kojto 122:f9eeca106725 73 /* - channel register offset of sample-and-hold sample time register SHSRx */
Kojto 122:f9eeca106725 74
AnnaBridge 145:64910690c574 75 #define DAC_CR_CH1_BITOFFSET 0U /* Position of channel bits into registers CR, MCR, CCR, SHHR, SHRR of channel 1 */
AnnaBridge 145:64910690c574 76 #define DAC_CR_CH2_BITOFFSET 16U /* Position of channel bits into registers CR, MCR, CCR, SHHR, SHRR of channel 2 */
Kojto 122:f9eeca106725 77 #define DAC_CR_CHX_BITOFFSET_MASK (DAC_CR_CH1_BITOFFSET | DAC_CR_CH2_BITOFFSET)
Kojto 122:f9eeca106725 78
Kojto 122:f9eeca106725 79 #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). */
AnnaBridge 145:64910690c574 80 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 122:f9eeca106725 81 #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 122:f9eeca106725 82 #define DAC_SWTR_CHX_MASK (DAC_SWTR_CH1 | DAC_SWTR_CH2)
AnnaBridge 145:64910690c574 83 #else
AnnaBridge 145:64910690c574 84 #define DAC_SWTR_CHX_MASK (DAC_SWTR_CH1)
AnnaBridge 145:64910690c574 85 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 122:f9eeca106725 86
AnnaBridge 145:64910690c574 87 #define DAC_REG_DHR12R1_REGOFFSET 0x00000000U /* Register DHR12Rx channel 1 taken as reference */
AnnaBridge 145:64910690c574 88 #define DAC_REG_DHR12L1_REGOFFSET 0x00100000U /* Register offset of DHR12Lx channel 1 versus DHR12Rx channel 1 (shifted left of 20 bits) */
AnnaBridge 145:64910690c574 89 #define DAC_REG_DHR8R1_REGOFFSET 0x02000000U /* Register offset of DHR8Rx channel 1 versus DHR12Rx channel 1 (shifted left of 24 bits) */
AnnaBridge 145:64910690c574 90 #if defined(DAC_CHANNEL2_SUPPORT)
AnnaBridge 145:64910690c574 91 #define DAC_REG_DHR12R2_REGOFFSET 0x00030000U /* Register offset of DHR12Rx channel 2 versus DHR12Rx channel 1 (shifted left of 16 bits) */
AnnaBridge 145:64910690c574 92 #define DAC_REG_DHR12L2_REGOFFSET 0x00400000U /* Register offset of DHR12Lx channel 2 versus DHR12Rx channel 1 (shifted left of 20 bits) */
AnnaBridge 145:64910690c574 93 #define DAC_REG_DHR8R2_REGOFFSET 0x05000000U /* Register offset of DHR8Rx channel 2 versus DHR12Rx channel 1 (shifted left of 24 bits) */
AnnaBridge 145:64910690c574 94 #endif /* DAC_CHANNEL2_SUPPORT */
AnnaBridge 145:64910690c574 95 #define DAC_REG_DHR12RX_REGOFFSET_MASK 0x000F0000U
AnnaBridge 145:64910690c574 96 #define DAC_REG_DHR12LX_REGOFFSET_MASK 0x00F00000U
AnnaBridge 145:64910690c574 97 #define DAC_REG_DHR8RX_REGOFFSET_MASK 0x0F000000U
Kojto 122:f9eeca106725 98 #define DAC_REG_DHRX_REGOFFSET_MASK (DAC_REG_DHR12RX_REGOFFSET_MASK | DAC_REG_DHR12LX_REGOFFSET_MASK | DAC_REG_DHR8RX_REGOFFSET_MASK)
Kojto 122:f9eeca106725 99
AnnaBridge 145:64910690c574 100 #define DAC_REG_DOR1_REGOFFSET 0x00000000U /* Register DORx channel 1 taken as reference */
AnnaBridge 145:64910690c574 101 #if defined(DAC_CHANNEL2_SUPPORT)
AnnaBridge 145:64910690c574 102 #define DAC_REG_DOR2_REGOFFSET 0x10000000U /* Register offset of DORx channel 1 versus DORx channel 2 (shifted left of 28 bits) */
Kojto 122:f9eeca106725 103 #define DAC_REG_DORX_REGOFFSET_MASK (DAC_REG_DOR1_REGOFFSET | DAC_REG_DOR2_REGOFFSET)
AnnaBridge 145:64910690c574 104 #else
AnnaBridge 145:64910690c574 105 #define DAC_REG_DORX_REGOFFSET_MASK (DAC_REG_DOR1_REGOFFSET)
AnnaBridge 145:64910690c574 106 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 122:f9eeca106725 107
AnnaBridge 145:64910690c574 108 #define DAC_REG_SHSR1_REGOFFSET 0x00000000U /* Register SHSRx channel 1 taken as reference */
AnnaBridge 145:64910690c574 109 #if defined(DAC_CHANNEL2_SUPPORT)
AnnaBridge 145:64910690c574 110 #define DAC_REG_SHSR2_REGOFFSET 0x00001000U /* Register offset of SHSRx channel 1 versus SHSRx channel 2 (shifted left of 12 bits) */
Kojto 122:f9eeca106725 111 #define DAC_REG_SHSRX_REGOFFSET_MASK (DAC_REG_SHSR1_REGOFFSET | DAC_REG_SHSR2_REGOFFSET)
AnnaBridge 145:64910690c574 112 #else
AnnaBridge 145:64910690c574 113 #define DAC_REG_SHSRX_REGOFFSET_MASK (DAC_REG_SHSR1_REGOFFSET)
AnnaBridge 145:64910690c574 114 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 122:f9eeca106725 115
Kojto 122:f9eeca106725 116 /* DAC registers bits positions */
AnnaBridge 145:64910690c574 117 #if defined(DAC_CHANNEL2_SUPPORT)
AnnaBridge 145:64910690c574 118 #define DAC_DHR12RD_DACC2DHR_BITOFFSET_POS 16U /* Value equivalent to POSITION_VAL(DAC_DHR12RD_DACC2DHR) */
AnnaBridge 145:64910690c574 119 #define DAC_DHR12LD_DACC2DHR_BITOFFSET_POS 20U /* Value equivalent to POSITION_VAL(DAC_DHR12LD_DACC2DHR) */
AnnaBridge 145:64910690c574 120 #define DAC_DHR8RD_DACC2DHR_BITOFFSET_POS 8U /* Value equivalent to POSITION_VAL(DAC_DHR8RD_DACC2DHR) */
AnnaBridge 145:64910690c574 121 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 122:f9eeca106725 122
Kojto 122:f9eeca106725 123 /* Miscellaneous data */
AnnaBridge 145:64910690c574 124 #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 122:f9eeca106725 125
Kojto 122:f9eeca106725 126 /**
Kojto 122:f9eeca106725 127 * @}
Kojto 122:f9eeca106725 128 */
Kojto 122:f9eeca106725 129
Kojto 122:f9eeca106725 130
Kojto 122:f9eeca106725 131 /* Private macros ------------------------------------------------------------*/
Kojto 122:f9eeca106725 132 /** @defgroup DAC_LL_Private_Macros DAC Private Macros
Kojto 122:f9eeca106725 133 * @{
Kojto 122:f9eeca106725 134 */
Kojto 122:f9eeca106725 135
Kojto 122:f9eeca106725 136 /**
Kojto 122:f9eeca106725 137 * @brief Driver macro reserved for internal use: isolate bits with the
Kojto 122:f9eeca106725 138 * selected mask and shift them to the register LSB
Kojto 122:f9eeca106725 139 * (shift mask on register position bit 0).
Kojto 122:f9eeca106725 140 * @param __BITS__ Bits in register 32 bits
Kojto 122:f9eeca106725 141 * @param __MASK__ Mask in register 32 bits
Kojto 122:f9eeca106725 142 * @retval Bits in register 32 bits
Kojto 122:f9eeca106725 143 */
Kojto 122:f9eeca106725 144 #define __DAC_MASK_SHIFT(__BITS__, __MASK__) \
Kojto 122:f9eeca106725 145 (((__BITS__) & (__MASK__)) >> POSITION_VAL((__MASK__)))
Kojto 122:f9eeca106725 146
Kojto 122:f9eeca106725 147 /**
Kojto 122:f9eeca106725 148 * @brief Driver macro reserved for internal use: set a pointer to
Kojto 122:f9eeca106725 149 * a register from a register basis from which an offset
Kojto 122:f9eeca106725 150 * is applied.
Kojto 122:f9eeca106725 151 * @param __REG__ Register basis from which the offset is applied.
Kojto 122:f9eeca106725 152 * @param __REG_OFFFSET__ Offset to be applied (unit: number of registers).
Kojto 122:f9eeca106725 153 * @retval Pointer to register address
Kojto 122:f9eeca106725 154 */
Kojto 122:f9eeca106725 155 #define __DAC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__) \
Kojto 122:f9eeca106725 156 ((uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2U))))
Kojto 122:f9eeca106725 157
Kojto 122:f9eeca106725 158 /**
Kojto 122:f9eeca106725 159 * @}
Kojto 122:f9eeca106725 160 */
Kojto 122:f9eeca106725 161
Kojto 122:f9eeca106725 162
Kojto 122:f9eeca106725 163 /* Exported types ------------------------------------------------------------*/
Kojto 122:f9eeca106725 164 #if defined(USE_FULL_LL_DRIVER)
Kojto 122:f9eeca106725 165 /** @defgroup DAC_LL_ES_INIT DAC Exported Init structure
Kojto 122:f9eeca106725 166 * @{
Kojto 122:f9eeca106725 167 */
Kojto 122:f9eeca106725 168
Kojto 122:f9eeca106725 169 /**
Kojto 122:f9eeca106725 170 * @brief Structure definition of some features of DAC instance.
Kojto 122:f9eeca106725 171 */
Kojto 122:f9eeca106725 172 typedef struct
Kojto 122:f9eeca106725 173 {
Kojto 122:f9eeca106725 174 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 122:f9eeca106725 175 This parameter can be a value of @ref DAC_LL_EC_TRIGGER_SOURCE
Kojto 122:f9eeca106725 176
Kojto 122:f9eeca106725 177 This feature can be modified afterwards using unitary function @ref LL_DAC_SetTriggerSource(). */
Kojto 122:f9eeca106725 178
Kojto 122:f9eeca106725 179 uint32_t WaveAutoGeneration; /*!< Set the waveform automatic generation mode for the selected DAC channel.
Kojto 122:f9eeca106725 180 This parameter can be a value of @ref DAC_LL_EC_WAVE_AUTO_GENERATION_MODE
Kojto 122:f9eeca106725 181
Kojto 122:f9eeca106725 182 This feature can be modified afterwards using unitary function @ref LL_DAC_SetWaveAutoGeneration(). */
Kojto 122:f9eeca106725 183
Kojto 122:f9eeca106725 184 uint32_t WaveAutoGenerationConfig; /*!< Set the waveform automatic generation mode for the selected DAC channel.
Kojto 122:f9eeca106725 185 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 122:f9eeca106725 186 If waveform automatic generation mode is set to triangle, this parameter can be a value of @ref DAC_LL_EC_WAVE_TRIANGLE_AMPLITUDE
Kojto 122:f9eeca106725 187 @note If waveform automatic generation mode is disabled, this parameter is discarded.
Kojto 122:f9eeca106725 188
Kojto 122:f9eeca106725 189 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 122:f9eeca106725 190
Kojto 122:f9eeca106725 191 uint32_t OutputBuffer; /*!< Set the output buffer for the selected DAC channel.
Kojto 122:f9eeca106725 192 This parameter can be a value of @ref DAC_LL_EC_OUTPUT_BUFFER
Kojto 122:f9eeca106725 193
Kojto 122:f9eeca106725 194 This feature can be modified afterwards using unitary function @ref LL_DAC_SetOutputBuffer(). */
Kojto 122:f9eeca106725 195
Kojto 122:f9eeca106725 196 uint32_t OutputConnection; /*!< Set the output connection for the selected DAC channel.
Kojto 122:f9eeca106725 197 This parameter can be a value of @ref DAC_LL_EC_OUTPUT_CONNECTION
Kojto 122:f9eeca106725 198
Kojto 122:f9eeca106725 199 This feature can be modified afterwards using unitary function @ref LL_DAC_SetOutputConnection(). */
Kojto 122:f9eeca106725 200
Kojto 122:f9eeca106725 201 uint32_t OutputMode; /*!< Set the output mode normal or sample-and-hold for the selected DAC channel.
Kojto 122:f9eeca106725 202 This parameter can be a value of @ref DAC_LL_EC_OUTPUT_MODE
Kojto 122:f9eeca106725 203
Kojto 122:f9eeca106725 204 This feature can be modified afterwards using unitary function @ref LL_DAC_SetOutputMode(). */
Kojto 122:f9eeca106725 205
Kojto 122:f9eeca106725 206 } LL_DAC_InitTypeDef;
Kojto 122:f9eeca106725 207
Kojto 122:f9eeca106725 208 /**
Kojto 122:f9eeca106725 209 * @}
Kojto 122:f9eeca106725 210 */
Kojto 122:f9eeca106725 211 #endif /* USE_FULL_LL_DRIVER */
Kojto 122:f9eeca106725 212
Kojto 122:f9eeca106725 213 /* Exported constants --------------------------------------------------------*/
Kojto 122:f9eeca106725 214 /** @defgroup DAC_LL_Exported_Constants DAC Exported Constants
Kojto 122:f9eeca106725 215 * @{
Kojto 122:f9eeca106725 216 */
Kojto 122:f9eeca106725 217
Kojto 122:f9eeca106725 218 /** @defgroup DAC_LL_EC_GET_FLAG DAC flags
Kojto 122:f9eeca106725 219 * @brief Flags defines which can be used with LL_DAC_ReadReg function
Kojto 122:f9eeca106725 220 * @{
Kojto 122:f9eeca106725 221 */
Kojto 122:f9eeca106725 222 /* DAC channel 1 flags */
Kojto 122:f9eeca106725 223 #define LL_DAC_FLAG_DMAUDR1 (DAC_SR_DMAUDR1) /*!< DAC channel 1 flag DMA underrun */
Kojto 122:f9eeca106725 224 #define LL_DAC_FLAG_CAL1 (DAC_SR_CAL_FLAG1) /*!< DAC channel 1 flag offset calibration status */
Kojto 122:f9eeca106725 225 #define LL_DAC_FLAG_BWST1 (DAC_SR_BWST1) /*!< DAC channel 1 flag busy writing sample time */
Kojto 122:f9eeca106725 226
AnnaBridge 145:64910690c574 227 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 122:f9eeca106725 228 /* DAC channel 2 flags */
Kojto 122:f9eeca106725 229 #define LL_DAC_FLAG_DMAUDR2 (DAC_SR_DMAUDR2) /*!< DAC channel 2 flag DMA underrun */
Kojto 122:f9eeca106725 230 #define LL_DAC_FLAG_CAL2 (DAC_SR_CAL_FLAG2) /*!< DAC channel 2 flag offset calibration status */
Kojto 122:f9eeca106725 231 #define LL_DAC_FLAG_BWST2 (DAC_SR_BWST2) /*!< DAC channel 2 flag busy writing sample time */
AnnaBridge 145:64910690c574 232 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 122:f9eeca106725 233 /**
Kojto 122:f9eeca106725 234 * @}
Kojto 122:f9eeca106725 235 */
Kojto 122:f9eeca106725 236
Kojto 122:f9eeca106725 237 /** @defgroup DAC_LL_EC_IT DAC interruptions
Kojto 122:f9eeca106725 238 * @brief IT defines which can be used with LL_DAC_ReadReg and LL_DAC_WriteReg functions
Kojto 122:f9eeca106725 239 * @{
Kojto 122:f9eeca106725 240 */
Kojto 122:f9eeca106725 241 #define LL_DAC_IT_DMAUDRIE1 (DAC_CR_DMAUDRIE1) /*!< DAC channel 1 interruption DMA underrun */
AnnaBridge 145:64910690c574 242 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 122:f9eeca106725 243 #define LL_DAC_IT_DMAUDRIE2 (DAC_CR_DMAUDRIE2) /*!< DAC channel 2 interruption DMA underrun */
AnnaBridge 145:64910690c574 244 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 122:f9eeca106725 245 /**
Kojto 122:f9eeca106725 246 * @}
Kojto 122:f9eeca106725 247 */
Kojto 122:f9eeca106725 248
Kojto 122:f9eeca106725 249 /** @defgroup DAC_LL_EC_CHANNEL DAC channels
Kojto 122:f9eeca106725 250 * @{
Kojto 122:f9eeca106725 251 */
Kojto 122:f9eeca106725 252 #define LL_DAC_CHANNEL_1 (DAC_REG_SHSR1_REGOFFSET | 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 */
AnnaBridge 145:64910690c574 253 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 122:f9eeca106725 254 #define LL_DAC_CHANNEL_2 (DAC_REG_SHSR2_REGOFFSET | 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 */
AnnaBridge 145:64910690c574 255 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 122:f9eeca106725 256 /**
Kojto 122:f9eeca106725 257 * @}
Kojto 122:f9eeca106725 258 */
Kojto 122:f9eeca106725 259
Kojto 122:f9eeca106725 260 /** @defgroup DAC_LL_EC_OPERATING_MODE DAC operating mode
Kojto 122:f9eeca106725 261 * @{
Kojto 122:f9eeca106725 262 */
AnnaBridge 145:64910690c574 263 #define LL_DAC_MODE_NORMAL_OPERATION 0x00000000U /*!< DAC channel in mode normal operation */
Kojto 122:f9eeca106725 264 #define LL_DAC_MODE_CALIBRATION (DAC_CR_CEN1) /*!< DAC channel in mode calibration */
Kojto 122:f9eeca106725 265 /**
Kojto 122:f9eeca106725 266 * @}
Kojto 122:f9eeca106725 267 */
Kojto 122:f9eeca106725 268
Kojto 122:f9eeca106725 269 /** @defgroup DAC_LL_EC_TRIGGER_SOURCE DAC trigger source
Kojto 122:f9eeca106725 270 * @{
Kojto 122:f9eeca106725 271 */
Kojto 122:f9eeca106725 272 #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 122:f9eeca106725 273 #define LL_DAC_TRIG_EXT_TIM2_TRGO (DAC_CR_TSEL1_2 ) /*!< DAC channel conversion trigger from external IP: TIM2 TRGO. */
Kojto 122:f9eeca106725 274 #define LL_DAC_TRIG_EXT_TIM4_TRGO (DAC_CR_TSEL1_2 | DAC_CR_TSEL1_0) /*!< DAC channel conversion trigger from external IP: TIM4 TRGO. */
Kojto 122:f9eeca106725 275 #define LL_DAC_TRIG_EXT_TIM5_TRGO ( DAC_CR_TSEL1_1 | DAC_CR_TSEL1_0) /*!< DAC channel conversion trigger from external IP: TIM5 TRGO. */
AnnaBridge 145:64910690c574 276 #define LL_DAC_TRIG_EXT_TIM6_TRGO 0x00000000U /*!< DAC channel conversion trigger from external IP: TIM6 TRGO. */
Kojto 122:f9eeca106725 277 #define LL_DAC_TRIG_EXT_TIM7_TRGO ( DAC_CR_TSEL1_1 ) /*!< DAC channel conversion trigger from external IP: TIM7 TRGO. */
Kojto 122:f9eeca106725 278 #define LL_DAC_TRIG_EXT_TIM8_TRGO ( DAC_CR_TSEL1_0) /*!< DAC channel conversion trigger from external IP: TIM8 TRGO. */
Kojto 122:f9eeca106725 279 #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. */
AnnaBridge 145:64910690c574 280
Kojto 122:f9eeca106725 281 /**
Kojto 122:f9eeca106725 282 * @}
Kojto 122:f9eeca106725 283 */
Kojto 122:f9eeca106725 284
Kojto 122:f9eeca106725 285 /** @defgroup DAC_LL_EC_WAVE_AUTO_GENERATION_MODE DAC waveform automatic generation mode
Kojto 122:f9eeca106725 286 * @{
Kojto 122:f9eeca106725 287 */
AnnaBridge 145:64910690c574 288 #define LL_DAC_WAVE_AUTO_GENERATION_NONE 0x00000000U /*!< DAC channel wave auto generation mode disabled. */
Kojto 122:f9eeca106725 289 #define LL_DAC_WAVE_AUTO_GENERATION_NOISE (DAC_CR_WAVE1_0) /*!< DAC channel wave auto generation mode enabled, set generated noise waveform. */
Kojto 122:f9eeca106725 290 #define LL_DAC_WAVE_AUTO_GENERATION_TRIANGLE (DAC_CR_WAVE1_1) /*!< DAC channel wave auto generation mode enabled, set generated triangle waveform. */
Kojto 122:f9eeca106725 291 /**
Kojto 122:f9eeca106725 292 * @}
Kojto 122:f9eeca106725 293 */
Kojto 122:f9eeca106725 294
Kojto 122:f9eeca106725 295 /** @defgroup DAC_LL_EC_WAVE_NOISE_LFSR_UNMASK_BITS DAC wave generation - Noise LFSR unmask bits
Kojto 122:f9eeca106725 296 * @{
Kojto 122:f9eeca106725 297 */
AnnaBridge 145:64910690c574 298 #define LL_DAC_NOISE_LFSR_UNMASK_BIT0 0x00000000U /*!< Noise wave generation, unmask LFSR bit0, for the selected DAC channel */
Kojto 122:f9eeca106725 299 #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 122:f9eeca106725 300 #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 122:f9eeca106725 301 #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 122:f9eeca106725 302 #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 122:f9eeca106725 303 #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 122:f9eeca106725 304 #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 122:f9eeca106725 305 #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 122:f9eeca106725 306 #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 122:f9eeca106725 307 #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 122:f9eeca106725 308 #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 122:f9eeca106725 309 #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 122:f9eeca106725 310 /**
Kojto 122:f9eeca106725 311 * @}
Kojto 122:f9eeca106725 312 */
Kojto 122:f9eeca106725 313
Kojto 122:f9eeca106725 314 /** @defgroup DAC_LL_EC_WAVE_TRIANGLE_AMPLITUDE DAC wave generation - Triangle amplitude
Kojto 122:f9eeca106725 315 * @{
Kojto 122:f9eeca106725 316 */
AnnaBridge 145:64910690c574 317 #define LL_DAC_TRIANGLE_AMPLITUDE_1 0x00000000U /*!< Triangle wave generation, amplitude of 1 LSB of DAC output range, for the selected DAC channel */
Kojto 122:f9eeca106725 318 #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 122:f9eeca106725 319 #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 122:f9eeca106725 320 #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 122:f9eeca106725 321 #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 122:f9eeca106725 322 #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 122:f9eeca106725 323 #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 122:f9eeca106725 324 #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 122:f9eeca106725 325 #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 122:f9eeca106725 326 #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 122:f9eeca106725 327 #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 122:f9eeca106725 328 #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 122:f9eeca106725 329 /**
Kojto 122:f9eeca106725 330 * @}
Kojto 122:f9eeca106725 331 */
Kojto 122:f9eeca106725 332
Kojto 122:f9eeca106725 333 /** @defgroup DAC_LL_EC_OUTPUT_MODE DAC channel output mode
Kojto 122:f9eeca106725 334 * @{
Kojto 122:f9eeca106725 335 */
AnnaBridge 145:64910690c574 336 #define LL_DAC_OUTPUT_MODE_NORMAL 0x00000000U /*!< The selected DAC channel output is on mode normal. */
Kojto 122:f9eeca106725 337 #define LL_DAC_OUTPUT_MODE_SAMPLE_AND_HOLD (DAC_MCR_MODE1_2) /*!< The selected DAC channel output is on mode sample-and-hold. Mode sample-and-hold requires an external capacitor, refer to description of function @ref LL_DAC_ConfigOutput() or @ref LL_DAC_SetOutputMode(). */
Kojto 122:f9eeca106725 338 /**
Kojto 122:f9eeca106725 339 * @}
Kojto 122:f9eeca106725 340 */
Kojto 122:f9eeca106725 341
Kojto 122:f9eeca106725 342 /** @defgroup DAC_LL_EC_OUTPUT_BUFFER DAC channel output buffer
Kojto 122:f9eeca106725 343 * @{
Kojto 122:f9eeca106725 344 */
AnnaBridge 145:64910690c574 345 #define LL_DAC_OUTPUT_BUFFER_ENABLE 0x00000000U /*!< The selected DAC channel output is buffered: higher drive current capability, but also higher current consumption */
Kojto 122:f9eeca106725 346 #define LL_DAC_OUTPUT_BUFFER_DISABLE (DAC_MCR_MODE1_1) /*!< The selected DAC channel output is not buffered: lower drive current capability, but also lower current consumption */
Kojto 122:f9eeca106725 347 /**
Kojto 122:f9eeca106725 348 * @}
Kojto 122:f9eeca106725 349 */
Kojto 122:f9eeca106725 350
Kojto 122:f9eeca106725 351 /** @defgroup DAC_LL_EC_OUTPUT_CONNECTION DAC channel output connection
Kojto 122:f9eeca106725 352 * @{
Kojto 122:f9eeca106725 353 */
AnnaBridge 145:64910690c574 354 #define LL_DAC_OUTPUT_CONNECT_GPIO 0x00000000U /*!< The selected DAC channel output is connected to external pin */
Kojto 122:f9eeca106725 355 #define LL_DAC_OUTPUT_CONNECT_INTERNAL (DAC_MCR_MODE1_0) /*!< The selected DAC channel output is connected to on-chip peripherals via internal paths. On this STM32 serie, output connection depends on output mode (normal or sample and hold) and output buffer state. Refer to comments of function @ref LL_DAC_SetOutputConnection(). */
Kojto 122:f9eeca106725 356 /**
Kojto 122:f9eeca106725 357 * @}
Kojto 122:f9eeca106725 358 */
Kojto 122:f9eeca106725 359
Kojto 122:f9eeca106725 360 /** @defgroup DAC_LL_EC_LEGACY DAC literals legacy naming
Kojto 122:f9eeca106725 361 * @{
Kojto 122:f9eeca106725 362 */
Kojto 122:f9eeca106725 363 #define LL_DAC_TRIGGER_SOFTWARE (LL_DAC_TRIG_SOFTWARE)
Kojto 122:f9eeca106725 364 #define LL_DAC_TRIGGER_TIM2_TRGO (LL_DAC_TRIG_EXT_TIM2_TRGO)
Kojto 122:f9eeca106725 365 #define LL_DAC_TRIGGER_TIM4_TRGO (LL_DAC_TRIG_EXT_TIM4_TRGO)
Kojto 122:f9eeca106725 366 #define LL_DAC_TRIGGER_TIM5_TRGO (LL_DAC_TRIG_EXT_TIM5_TRGO)
Kojto 122:f9eeca106725 367 #define LL_DAC_TRIGGER_TIM6_TRGO (LL_DAC_TRIG_EXT_TIM6_TRGO)
Kojto 122:f9eeca106725 368 #define LL_DAC_TRIGGER_TIM7_TRGO (LL_DAC_TRIG_EXT_TIM7_TRGO)
Kojto 122:f9eeca106725 369 #define LL_DAC_TRIGGER_TIM8_TRGO (LL_DAC_TRIG_EXT_TIM8_TRGO)
Kojto 122:f9eeca106725 370 #define LL_DAC_TRIGGER_EXT_IT9 (LL_DAC_TRIG_EXT_EXTI_LINE9)
Kojto 122:f9eeca106725 371
Kojto 122:f9eeca106725 372 #define LL_DAC_WAVEGENERATION_NONE (LL_DAC_WAVE_AUTO_GENERATION_NONE)
Kojto 122:f9eeca106725 373 #define LL_DAC_WAVEGENERATION_NOISE (LL_DAC_WAVE_AUTO_GENERATION_NOISE)
Kojto 122:f9eeca106725 374 #define LL_DAC_WAVEGENERATION_TRIANGLE (LL_DAC_WAVE_AUTO_GENERATION_TRIANGLE)
Kojto 122:f9eeca106725 375
Kojto 122:f9eeca106725 376 #define LL_DAC_CONNECT_GPIO (LL_DAC_OUTPUT_CONNECT_GPIO)
Kojto 122:f9eeca106725 377 #define LL_DAC_CONNECT_INTERNAL (LL_DAC_OUTPUT_CONNECT_INTERNAL)
Kojto 122:f9eeca106725 378 /**
Kojto 122:f9eeca106725 379 * @}
Kojto 122:f9eeca106725 380 */
Kojto 122:f9eeca106725 381
Kojto 122:f9eeca106725 382 /** @defgroup DAC_LL_EC_RESOLUTION DAC channel output resolution
Kojto 122:f9eeca106725 383 * @{
Kojto 122:f9eeca106725 384 */
AnnaBridge 145:64910690c574 385 #define LL_DAC_RESOLUTION_12B 0x00000000U /*!< DAC channel resolution 12 bits */
AnnaBridge 145:64910690c574 386 #define LL_DAC_RESOLUTION_8B 0x00000002U /*!< DAC channel resolution 8 bits */
Kojto 122:f9eeca106725 387 /**
Kojto 122:f9eeca106725 388 * @}
Kojto 122:f9eeca106725 389 */
Kojto 122:f9eeca106725 390
Kojto 122:f9eeca106725 391 /** @defgroup DAC_LL_EC_REGISTERS DAC registers compliant with specific purpose
Kojto 122:f9eeca106725 392 * @{
Kojto 122:f9eeca106725 393 */
Kojto 122:f9eeca106725 394 /* List of DAC registers intended to be used (most commonly) with */
Kojto 122:f9eeca106725 395 /* DMA transfer. */
Kojto 122:f9eeca106725 396 /* Refer to function @ref LL_DAC_DMA_GetRegAddr(). */
Kojto 122:f9eeca106725 397 #define LL_DAC_DMA_REG_DATA_12BITS_RIGHT_ALIGNED DAC_REG_DHR12RX_REGOFFSET_MASK /*!< DAC channel data holding register 12 bits right aligned */
Kojto 122:f9eeca106725 398 #define LL_DAC_DMA_REG_DATA_12BITS_LEFT_ALIGNED DAC_REG_DHR12LX_REGOFFSET_MASK /*!< DAC channel data holding register 12 bits left aligned */
Kojto 122:f9eeca106725 399 #define LL_DAC_DMA_REG_DATA_8BITS_RIGHT_ALIGNED DAC_REG_DHR8RX_REGOFFSET_MASK /*!< DAC channel data holding register 8 bits right aligned */
Kojto 122:f9eeca106725 400 /**
Kojto 122:f9eeca106725 401 * @}
Kojto 122:f9eeca106725 402 */
Kojto 122:f9eeca106725 403
Kojto 122:f9eeca106725 404 /** @defgroup DAC_LL_EC_HW_DELAYS Definitions of DAC hardware constraints delays
Kojto 122:f9eeca106725 405 * @note Only DAC IP HW delays are defined in DAC LL driver driver,
Kojto 122:f9eeca106725 406 * not timeout values.
Kojto 122:f9eeca106725 407 * For details on delays values, refer to descriptions in source code
Kojto 122:f9eeca106725 408 * above each literal definition.
Kojto 122:f9eeca106725 409 * @{
Kojto 122:f9eeca106725 410 */
Kojto 122:f9eeca106725 411
Kojto 122:f9eeca106725 412 /* Delay for DAC channel voltage settling time from DAC channel startup */
Kojto 122:f9eeca106725 413 /* (transition from disable to enable). */
Kojto 122:f9eeca106725 414 /* Note: DAC channel startup time depends on board application environment: */
Kojto 122:f9eeca106725 415 /* impedance connected to DAC channel output. */
Kojto 122:f9eeca106725 416 /* The delay below is specified under conditions: */
Kojto 122:f9eeca106725 417 /* - voltage maximum transition (lowest to highest value) */
Kojto 122:f9eeca106725 418 /* - until voltage reaches final value +-1LSB */
Kojto 122:f9eeca106725 419 /* - DAC channel output buffer enabled */
Kojto 122:f9eeca106725 420 /* - load impedance of 5kOhm (min), 50pF (max) */
Kojto 122:f9eeca106725 421 /* Literal set to maximum value (refer to device datasheet, */
Kojto 122:f9eeca106725 422 /* parameter "tWAKEUP"). */
Kojto 122:f9eeca106725 423 /* Unit: us */
AnnaBridge 145:64910690c574 424 #define LL_DAC_DELAY_STARTUP_VOLTAGE_SETTLING_US 8U /*!< Delay for DAC channel voltage settling time from DAC channel startup (transition from disable to enable) */
Kojto 122:f9eeca106725 425
Kojto 122:f9eeca106725 426
Kojto 122:f9eeca106725 427 /* Delay for DAC channel voltage settling time. */
Kojto 122:f9eeca106725 428 /* Note: DAC channel startup time depends on board application environment: */
Kojto 122:f9eeca106725 429 /* impedance connected to DAC channel output. */
Kojto 122:f9eeca106725 430 /* The delay below is specified under conditions: */
Kojto 122:f9eeca106725 431 /* - voltage maximum transition (lowest to highest value) */
Kojto 122:f9eeca106725 432 /* - until voltage reaches final value +-1LSB */
Kojto 122:f9eeca106725 433 /* - DAC channel output buffer enabled */
Kojto 122:f9eeca106725 434 /* - load impedance of 5kOhm min, 50pF max */
Kojto 122:f9eeca106725 435 /* Literal set to maximum value (refer to device datasheet, */
Kojto 122:f9eeca106725 436 /* parameter "tSETTLING"). */
Kojto 122:f9eeca106725 437 /* Unit: us */
AnnaBridge 145:64910690c574 438 #define LL_DAC_DELAY_VOLTAGE_SETTLING_US 2U /*!< Delay for DAC channel voltage settling time */
Kojto 122:f9eeca106725 439
Kojto 122:f9eeca106725 440 /**
Kojto 122:f9eeca106725 441 * @}
Kojto 122:f9eeca106725 442 */
Kojto 122:f9eeca106725 443
Kojto 122:f9eeca106725 444 /**
Kojto 122:f9eeca106725 445 * @}
Kojto 122:f9eeca106725 446 */
Kojto 122:f9eeca106725 447
Kojto 122:f9eeca106725 448 /* Exported macro ------------------------------------------------------------*/
Kojto 122:f9eeca106725 449 /** @defgroup DAC_LL_Exported_Macros DAC Exported Macros
Kojto 122:f9eeca106725 450 * @{
Kojto 122:f9eeca106725 451 */
Kojto 122:f9eeca106725 452
Kojto 122:f9eeca106725 453 /** @defgroup DAC_LL_EM_WRITE_READ Common write and read registers macros
Kojto 122:f9eeca106725 454 * @{
Kojto 122:f9eeca106725 455 */
Kojto 122:f9eeca106725 456
Kojto 122:f9eeca106725 457 /**
Kojto 122:f9eeca106725 458 * @brief Write a value in DAC register
Kojto 122:f9eeca106725 459 * @param __INSTANCE__ DAC Instance
Kojto 122:f9eeca106725 460 * @param __REG__ Register to be written
Kojto 122:f9eeca106725 461 * @param __VALUE__ Value to be written in the register
Kojto 122:f9eeca106725 462 * @retval None
Kojto 122:f9eeca106725 463 */
Kojto 122:f9eeca106725 464 #define LL_DAC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
Kojto 122:f9eeca106725 465
Kojto 122:f9eeca106725 466 /**
Kojto 122:f9eeca106725 467 * @brief Read a value in DAC register
Kojto 122:f9eeca106725 468 * @param __INSTANCE__ DAC Instance
Kojto 122:f9eeca106725 469 * @param __REG__ Register to be read
Kojto 122:f9eeca106725 470 * @retval Register value
Kojto 122:f9eeca106725 471 */
Kojto 122:f9eeca106725 472 #define LL_DAC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
Kojto 122:f9eeca106725 473
Kojto 122:f9eeca106725 474 /**
Kojto 122:f9eeca106725 475 * @}
Kojto 122:f9eeca106725 476 */
Kojto 122:f9eeca106725 477
Kojto 122:f9eeca106725 478 /** @defgroup DAC_LL_EM_HELPER_MACRO DAC helper macro
Kojto 122:f9eeca106725 479 * @{
Kojto 122:f9eeca106725 480 */
Kojto 122:f9eeca106725 481
Kojto 122:f9eeca106725 482 /**
Kojto 122:f9eeca106725 483 * @brief Helper macro to get DAC channel number in decimal format
Kojto 122:f9eeca106725 484 * from literals LL_DAC_CHANNEL_x.
Kojto 122:f9eeca106725 485 * Example:
Kojto 122:f9eeca106725 486 * __LL_DAC_CHANNEL_TO_DECIMAL_NB(LL_DAC_CHANNEL_1)
Kojto 122:f9eeca106725 487 * will return decimal number "1".
Kojto 122:f9eeca106725 488 * @note The input can be a value from functions where a channel
Kojto 122:f9eeca106725 489 * number is returned.
Kojto 122:f9eeca106725 490 * @param __CHANNEL__ This parameter can be one of the following values:
Kojto 122:f9eeca106725 491 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 492 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 493 *
AnnaBridge 145:64910690c574 494 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 495 * Refer to device datasheet for channels availability.
AnnaBridge 145:64910690c574 496 * @retval 1...2 (value "2" depending on DAC channel 2 availability)
Kojto 122:f9eeca106725 497 */
Kojto 122:f9eeca106725 498 #define __LL_DAC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
Kojto 122:f9eeca106725 499 ((__CHANNEL__) & DAC_SWTR_CHX_MASK)
Kojto 122:f9eeca106725 500
Kojto 122:f9eeca106725 501 /**
Kojto 122:f9eeca106725 502 * @brief Helper macro to get DAC channel in literal format LL_DAC_CHANNEL_x
Kojto 122:f9eeca106725 503 * from number in decimal format.
Kojto 122:f9eeca106725 504 * Example:
Kojto 122:f9eeca106725 505 * __LL_DAC_DECIMAL_NB_TO_CHANNEL(1)
Kojto 122:f9eeca106725 506 * will return a data equivalent to "LL_DAC_CHANNEL_1".
Kojto 122:f9eeca106725 507 * @note If the input parameter does not correspond to a DAC channel,
Kojto 122:f9eeca106725 508 * this macro returns value '0'.
AnnaBridge 145:64910690c574 509 * @param __DECIMAL_NB__ 1...2 (value "2" depending on DAC channel 2 availability)
Kojto 122:f9eeca106725 510 * @retval Returned value can be one of the following values:
Kojto 122:f9eeca106725 511 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 512 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 513 *
AnnaBridge 145:64910690c574 514 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 515 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 516 */
AnnaBridge 145:64910690c574 517 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 122:f9eeca106725 518 #define __LL_DAC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
Kojto 122:f9eeca106725 519 (((__DECIMAL_NB__) == 1U) \
Kojto 122:f9eeca106725 520 ? ( \
Kojto 122:f9eeca106725 521 LL_DAC_CHANNEL_1 \
Kojto 122:f9eeca106725 522 ) \
Kojto 122:f9eeca106725 523 : \
Kojto 122:f9eeca106725 524 (((__DECIMAL_NB__) == 2U) \
Kojto 122:f9eeca106725 525 ? ( \
Kojto 122:f9eeca106725 526 LL_DAC_CHANNEL_2 \
Kojto 122:f9eeca106725 527 ) \
Kojto 122:f9eeca106725 528 : \
Kojto 122:f9eeca106725 529 ( \
Kojto 122:f9eeca106725 530 0 \
Kojto 122:f9eeca106725 531 ) \
Kojto 122:f9eeca106725 532 ) \
Kojto 122:f9eeca106725 533 )
AnnaBridge 145:64910690c574 534 #else
AnnaBridge 145:64910690c574 535 #define __LL_DAC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
AnnaBridge 145:64910690c574 536 (((__DECIMAL_NB__) == 1U) \
AnnaBridge 145:64910690c574 537 ? ( \
AnnaBridge 145:64910690c574 538 LL_DAC_CHANNEL_1 \
AnnaBridge 145:64910690c574 539 ) \
AnnaBridge 145:64910690c574 540 : \
AnnaBridge 145:64910690c574 541 ( \
AnnaBridge 145:64910690c574 542 0 \
AnnaBridge 145:64910690c574 543 ) \
AnnaBridge 145:64910690c574 544 )
AnnaBridge 145:64910690c574 545 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 122:f9eeca106725 546
Kojto 122:f9eeca106725 547 /**
Kojto 122:f9eeca106725 548 * @brief Helper macro to define the DAC conversion data full-scale digital
Kojto 122:f9eeca106725 549 * value corresponding to the selected DAC resolution.
Kojto 122:f9eeca106725 550 * @note DAC conversion data full-scale corresponds to voltage range
Kojto 122:f9eeca106725 551 * determined by analog voltage references Vref+ and Vref-
Kojto 122:f9eeca106725 552 * (refer to reference manual).
Kojto 122:f9eeca106725 553 * @param __DAC_RESOLUTION__ This parameter can be one of the following values:
Kojto 122:f9eeca106725 554 * @arg @ref LL_DAC_RESOLUTION_12B
Kojto 122:f9eeca106725 555 * @arg @ref LL_DAC_RESOLUTION_8B
Kojto 122:f9eeca106725 556 * @retval ADC conversion data equivalent voltage value (unit: mVolt)
Kojto 122:f9eeca106725 557 */
Kojto 122:f9eeca106725 558 #define __LL_DAC_DIGITAL_SCALE(__DAC_RESOLUTION__) \
AnnaBridge 145:64910690c574 559 ((0x00000FFFU) >> ((__DAC_RESOLUTION__) << 1U))
Kojto 122:f9eeca106725 560
Kojto 122:f9eeca106725 561 /**
Kojto 122:f9eeca106725 562 * @brief Helper macro to calculate the DAC conversion data (unit: digital
Kojto 122:f9eeca106725 563 * value) corresponding to a voltage (unit: mVolt).
Kojto 122:f9eeca106725 564 * @note This helper macro is intended to provide input data in voltage
Kojto 122:f9eeca106725 565 * rather than digital value,
Kojto 122:f9eeca106725 566 * to be used with LL DAC functions such as
Kojto 122:f9eeca106725 567 * @ref LL_DAC_ConvertData12RightAligned().
Kojto 122:f9eeca106725 568 * @note Analog reference voltage (Vref+) must be either known from
Kojto 122:f9eeca106725 569 * user board environment or can be calculated using ADC measurement
Kojto 122:f9eeca106725 570 * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
Kojto 122:f9eeca106725 571 * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
Kojto 122:f9eeca106725 572 * @param __DAC_VOLTAGE__ Voltage to be generated by DAC channel
Kojto 122:f9eeca106725 573 * (unit: mVolt).
Kojto 122:f9eeca106725 574 * @param __DAC_RESOLUTION__ This parameter can be one of the following values:
Kojto 122:f9eeca106725 575 * @arg @ref LL_DAC_RESOLUTION_12B
Kojto 122:f9eeca106725 576 * @arg @ref LL_DAC_RESOLUTION_8B
Kojto 122:f9eeca106725 577 * @retval DAC conversion data (unit: digital value)
Kojto 122:f9eeca106725 578 */
Kojto 122:f9eeca106725 579 #define __LL_DAC_CALC_VOLTAGE_TO_DATA(__VREFANALOG_VOLTAGE__,\
Kojto 122:f9eeca106725 580 __DAC_VOLTAGE__,\
Kojto 122:f9eeca106725 581 __DAC_RESOLUTION__) \
Kojto 122:f9eeca106725 582 ((__DAC_VOLTAGE__) * __LL_DAC_DIGITAL_SCALE(__DAC_RESOLUTION__) \
Kojto 122:f9eeca106725 583 / (__VREFANALOG_VOLTAGE__) \
Kojto 122:f9eeca106725 584 )
Kojto 122:f9eeca106725 585
Kojto 122:f9eeca106725 586 /**
Kojto 122:f9eeca106725 587 * @}
Kojto 122:f9eeca106725 588 */
Kojto 122:f9eeca106725 589
Kojto 122:f9eeca106725 590 /**
Kojto 122:f9eeca106725 591 * @}
Kojto 122:f9eeca106725 592 */
Kojto 122:f9eeca106725 593
Kojto 122:f9eeca106725 594
Kojto 122:f9eeca106725 595 /* Exported functions --------------------------------------------------------*/
Kojto 122:f9eeca106725 596 /** @defgroup DAC_LL_Exported_Functions DAC Exported Functions
Kojto 122:f9eeca106725 597 * @{
Kojto 122:f9eeca106725 598 */
Kojto 122:f9eeca106725 599 /** @defgroup DAC_LL_EF_Configuration Configuration of DAC channels
Kojto 122:f9eeca106725 600 * @{
Kojto 122:f9eeca106725 601 */
Kojto 122:f9eeca106725 602
Kojto 122:f9eeca106725 603 /**
Kojto 122:f9eeca106725 604 * @brief Set the operating mode for the selected DAC channel:
Kojto 122:f9eeca106725 605 * calibration or normal operating mode.
Kojto 122:f9eeca106725 606 * @rmtoll CR CEN1 LL_DAC_SetMode\n
Kojto 122:f9eeca106725 607 * CR CEN2 LL_DAC_SetMode
Kojto 122:f9eeca106725 608 * @param DACx DAC instance
Kojto 122:f9eeca106725 609 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 610 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 611 *
AnnaBridge 145:64910690c574 612 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 613 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 614 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 615 * @param ChannelMode This parameter can be one of the following values:
Kojto 122:f9eeca106725 616 * @arg @ref LL_DAC_MODE_NORMAL_OPERATION
Kojto 122:f9eeca106725 617 * @arg @ref LL_DAC_MODE_CALIBRATION
Kojto 122:f9eeca106725 618 * @retval None
Kojto 122:f9eeca106725 619 */
Kojto 122:f9eeca106725 620 __STATIC_INLINE void LL_DAC_SetMode(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t ChannelMode)
Kojto 122:f9eeca106725 621 {
Kojto 122:f9eeca106725 622 MODIFY_REG(DACx->CR,
Kojto 122:f9eeca106725 623 DAC_CR_CEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
Kojto 122:f9eeca106725 624 ChannelMode << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 625 }
Kojto 122:f9eeca106725 626
Kojto 122:f9eeca106725 627 /**
Kojto 122:f9eeca106725 628 * @brief Get the operating mode for the selected DAC channel:
Kojto 122:f9eeca106725 629 * calibration or normal operating mode.
Kojto 122:f9eeca106725 630 * @rmtoll CR CEN1 LL_DAC_GetMode\n
Kojto 122:f9eeca106725 631 * CR CEN2 LL_DAC_GetMode
Kojto 122:f9eeca106725 632 * @param DACx DAC instance
Kojto 122:f9eeca106725 633 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 634 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 635 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 636 *
AnnaBridge 145:64910690c574 637 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 638 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 639 * @retval Returned value can be one of the following values:
Kojto 122:f9eeca106725 640 * @arg @ref LL_DAC_MODE_NORMAL_OPERATION
Kojto 122:f9eeca106725 641 * @arg @ref LL_DAC_MODE_CALIBRATION
Kojto 122:f9eeca106725 642 */
Kojto 122:f9eeca106725 643 __STATIC_INLINE uint32_t LL_DAC_GetMode(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 644 {
Kojto 122:f9eeca106725 645 return (uint32_t)(READ_BIT(DACx->CR, DAC_CR_CEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 122:f9eeca106725 646 >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
Kojto 122:f9eeca106725 647 );
Kojto 122:f9eeca106725 648 }
Kojto 122:f9eeca106725 649
Kojto 122:f9eeca106725 650 /**
Kojto 122:f9eeca106725 651 * @brief Set the offset trimming value for the selected DAC channel.
Kojto 122:f9eeca106725 652 * Trimming has an impact when output buffer is enabled
Kojto 122:f9eeca106725 653 * and is intended to replace factory calibration default values.
Kojto 122:f9eeca106725 654 * @rmtoll CCR OTRIM1 LL_DAC_SetTrimmingValue\n
Kojto 122:f9eeca106725 655 * CCR OTRIM2 LL_DAC_SetTrimmingValue
Kojto 122:f9eeca106725 656 * @param DACx DAC instance
Kojto 122:f9eeca106725 657 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 658 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 659 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 660 *
AnnaBridge 145:64910690c574 661 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 662 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 663 * @param TrimmingValue Value between Min_Data=0x00 and Max_Data=0x1F
Kojto 122:f9eeca106725 664 * @retval None
Kojto 122:f9eeca106725 665 */
Kojto 122:f9eeca106725 666 __STATIC_INLINE void LL_DAC_SetTrimmingValue(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t TrimmingValue)
Kojto 122:f9eeca106725 667 {
Kojto 122:f9eeca106725 668 MODIFY_REG(DACx->CCR,
Kojto 122:f9eeca106725 669 DAC_CCR_OTRIM1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
Kojto 122:f9eeca106725 670 TrimmingValue << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 671 }
Kojto 122:f9eeca106725 672
Kojto 122:f9eeca106725 673 /**
Kojto 122:f9eeca106725 674 * @brief Get the offset trimming value for the selected DAC channel.
Kojto 122:f9eeca106725 675 * Trimming has an impact when output buffer is enabled
Kojto 122:f9eeca106725 676 * and is intended to replace factory calibration default values.
Kojto 122:f9eeca106725 677 * @rmtoll CCR OTRIM1 LL_DAC_GetTrimmingValue\n
Kojto 122:f9eeca106725 678 * CCR OTRIM2 LL_DAC_GetTrimmingValue
Kojto 122:f9eeca106725 679 * @param DACx DAC instance
Kojto 122:f9eeca106725 680 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 681 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 682 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 683 *
AnnaBridge 145:64910690c574 684 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 685 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 686 * @retval TrimmingValue Value between Min_Data=0x00 and Max_Data=0x1F
Kojto 122:f9eeca106725 687 */
Kojto 122:f9eeca106725 688 __STATIC_INLINE uint32_t LL_DAC_GetTrimmingValue(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 689 {
Kojto 122:f9eeca106725 690 return (uint32_t)(READ_BIT(DACx->CCR, DAC_CCR_OTRIM1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 122:f9eeca106725 691 >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
Kojto 122:f9eeca106725 692 );
Kojto 122:f9eeca106725 693 }
Kojto 122:f9eeca106725 694
Kojto 122:f9eeca106725 695 /**
Kojto 122:f9eeca106725 696 * @brief Set the conversion trigger source for the selected DAC channel.
Kojto 122:f9eeca106725 697 * @note For conversion trigger source to be effective, DAC trigger
Kojto 122:f9eeca106725 698 * must be enabled using function @ref LL_DAC_EnableTrigger().
Kojto 122:f9eeca106725 699 * @note To set conversion trigger source, DAC channel must be disabled.
Kojto 122:f9eeca106725 700 * Otherwise, the setting is discarded.
Kojto 122:f9eeca106725 701 * @note Availability of parameters of trigger sources from timer
Kojto 122:f9eeca106725 702 * depends on timers availability on the selected device.
Kojto 122:f9eeca106725 703 * @rmtoll CR TSEL1 LL_DAC_SetTriggerSource\n
Kojto 122:f9eeca106725 704 * CR TSEL2 LL_DAC_SetTriggerSource
Kojto 122:f9eeca106725 705 * @param DACx DAC instance
Kojto 122:f9eeca106725 706 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 707 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 708 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 709 *
AnnaBridge 145:64910690c574 710 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 711 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 712 * @param TriggerSource This parameter can be one of the following values:
Kojto 122:f9eeca106725 713 * @arg @ref LL_DAC_TRIG_SOFTWARE
Kojto 122:f9eeca106725 714 * @arg @ref LL_DAC_TRIG_EXT_TIM2_TRGO
Kojto 122:f9eeca106725 715 * @arg @ref LL_DAC_TRIG_EXT_TIM4_TRGO
Kojto 122:f9eeca106725 716 * @arg @ref LL_DAC_TRIG_EXT_TIM5_TRGO
Kojto 122:f9eeca106725 717 * @arg @ref LL_DAC_TRIG_EXT_TIM6_TRGO
Kojto 122:f9eeca106725 718 * @arg @ref LL_DAC_TRIG_EXT_TIM7_TRGO
Kojto 122:f9eeca106725 719 * @arg @ref LL_DAC_TRIG_EXT_TIM8_TRGO
Kojto 122:f9eeca106725 720 * @arg @ref LL_DAC_TRIG_EXT_EXTI_LINE9
Kojto 122:f9eeca106725 721 * @retval None
Kojto 122:f9eeca106725 722 */
Kojto 122:f9eeca106725 723 __STATIC_INLINE void LL_DAC_SetTriggerSource(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t TriggerSource)
Kojto 122:f9eeca106725 724 {
Kojto 122:f9eeca106725 725 MODIFY_REG(DACx->CR,
Kojto 122:f9eeca106725 726 DAC_CR_TSEL1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
Kojto 122:f9eeca106725 727 TriggerSource << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 728 }
Kojto 122:f9eeca106725 729
Kojto 122:f9eeca106725 730 /**
Kojto 122:f9eeca106725 731 * @brief Get the conversion trigger source for the selected DAC channel.
Kojto 122:f9eeca106725 732 * @note For conversion trigger source to be effective, DAC trigger
Kojto 122:f9eeca106725 733 * must be enabled using function @ref LL_DAC_EnableTrigger().
Kojto 122:f9eeca106725 734 * @note Availability of parameters of trigger sources from timer
Kojto 122:f9eeca106725 735 * depends on timers availability on the selected device.
Kojto 122:f9eeca106725 736 * @rmtoll CR TSEL1 LL_DAC_GetTriggerSource\n
Kojto 122:f9eeca106725 737 * CR TSEL2 LL_DAC_GetTriggerSource
Kojto 122:f9eeca106725 738 * @param DACx DAC instance
Kojto 122:f9eeca106725 739 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 740 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 741 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 742 *
AnnaBridge 145:64910690c574 743 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 744 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 745 * @retval Returned value can be one of the following values:
Kojto 122:f9eeca106725 746 * @arg @ref LL_DAC_TRIG_SOFTWARE
Kojto 122:f9eeca106725 747 * @arg @ref LL_DAC_TRIG_EXT_TIM2_TRGO
Kojto 122:f9eeca106725 748 * @arg @ref LL_DAC_TRIG_EXT_TIM4_TRGO
Kojto 122:f9eeca106725 749 * @arg @ref LL_DAC_TRIG_EXT_TIM5_TRGO
Kojto 122:f9eeca106725 750 * @arg @ref LL_DAC_TRIG_EXT_TIM6_TRGO
Kojto 122:f9eeca106725 751 * @arg @ref LL_DAC_TRIG_EXT_TIM7_TRGO
Kojto 122:f9eeca106725 752 * @arg @ref LL_DAC_TRIG_EXT_TIM8_TRGO
Kojto 122:f9eeca106725 753 * @arg @ref LL_DAC_TRIGGER_EXT_IT9
Kojto 122:f9eeca106725 754 */
Kojto 122:f9eeca106725 755 __STATIC_INLINE uint32_t LL_DAC_GetTriggerSource(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 756 {
Kojto 122:f9eeca106725 757 return (uint32_t)(READ_BIT(DACx->CR, DAC_CR_TSEL1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 122:f9eeca106725 758 >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
Kojto 122:f9eeca106725 759 );
Kojto 122:f9eeca106725 760 }
Kojto 122:f9eeca106725 761
Kojto 122:f9eeca106725 762 /**
Kojto 122:f9eeca106725 763 * @brief Set the waveform automatic generation mode
Kojto 122:f9eeca106725 764 * for the selected DAC channel.
Kojto 122:f9eeca106725 765 * @rmtoll CR WAVE1 LL_DAC_SetWaveAutoGeneration\n
Kojto 122:f9eeca106725 766 * CR WAVE2 LL_DAC_SetWaveAutoGeneration
Kojto 122:f9eeca106725 767 * @param DACx DAC instance
Kojto 122:f9eeca106725 768 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 769 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 770 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 771 *
AnnaBridge 145:64910690c574 772 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 773 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 774 * @param WaveAutoGeneration This parameter can be one of the following values:
Kojto 122:f9eeca106725 775 * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_NONE
Kojto 122:f9eeca106725 776 * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_NOISE
Kojto 122:f9eeca106725 777 * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_TRIANGLE
Kojto 122:f9eeca106725 778 * @retval None
Kojto 122:f9eeca106725 779 */
Kojto 122:f9eeca106725 780 __STATIC_INLINE void LL_DAC_SetWaveAutoGeneration(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t WaveAutoGeneration)
Kojto 122:f9eeca106725 781 {
Kojto 122:f9eeca106725 782 MODIFY_REG(DACx->CR,
Kojto 122:f9eeca106725 783 DAC_CR_WAVE1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
Kojto 122:f9eeca106725 784 WaveAutoGeneration << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 785 }
Kojto 122:f9eeca106725 786
Kojto 122:f9eeca106725 787 /**
Kojto 122:f9eeca106725 788 * @brief Get the waveform automatic generation mode
Kojto 122:f9eeca106725 789 * for the selected DAC channel.
Kojto 122:f9eeca106725 790 * @rmtoll CR WAVE1 LL_DAC_GetWaveAutoGeneration\n
Kojto 122:f9eeca106725 791 * CR WAVE2 LL_DAC_GetWaveAutoGeneration
Kojto 122:f9eeca106725 792 * @param DACx DAC instance
Kojto 122:f9eeca106725 793 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 794 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 795 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 796 *
AnnaBridge 145:64910690c574 797 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 798 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 799 * @retval Returned value can be one of the following values:
Kojto 122:f9eeca106725 800 * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_NONE
Kojto 122:f9eeca106725 801 * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_NOISE
Kojto 122:f9eeca106725 802 * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_TRIANGLE
Kojto 122:f9eeca106725 803 */
Kojto 122:f9eeca106725 804 __STATIC_INLINE uint32_t LL_DAC_GetWaveAutoGeneration(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 805 {
Kojto 122:f9eeca106725 806 return (uint32_t)(READ_BIT(DACx->CR, DAC_CR_WAVE1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 122:f9eeca106725 807 >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
Kojto 122:f9eeca106725 808 );
Kojto 122:f9eeca106725 809 }
Kojto 122:f9eeca106725 810
Kojto 122:f9eeca106725 811 /**
Kojto 122:f9eeca106725 812 * @brief Set the noise waveform generation for the selected DAC channel:
Kojto 122:f9eeca106725 813 * Noise mode and parameters LFSR (linear feedback shift register).
Kojto 122:f9eeca106725 814 * @note For wave generation to be effective, DAC channel
Kojto 122:f9eeca106725 815 * wave generation mode must be enabled using
Kojto 122:f9eeca106725 816 * function @ref LL_DAC_SetWaveAutoGeneration().
Kojto 122:f9eeca106725 817 * @note This setting can be set when the selected DAC channel is disabled
Kojto 122:f9eeca106725 818 * (otherwise, the setting operation is ignored).
Kojto 122:f9eeca106725 819 * @rmtoll CR MAMP1 LL_DAC_SetWaveNoiseLFSR\n
Kojto 122:f9eeca106725 820 * CR MAMP2 LL_DAC_SetWaveNoiseLFSR
Kojto 122:f9eeca106725 821 * @param DACx DAC instance
Kojto 122:f9eeca106725 822 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 823 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 824 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 825 *
AnnaBridge 145:64910690c574 826 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 827 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 828 * @param NoiseLFSRMask This parameter can be one of the following values:
Kojto 122:f9eeca106725 829 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BIT0
Kojto 122:f9eeca106725 830 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS1_0
Kojto 122:f9eeca106725 831 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS2_0
Kojto 122:f9eeca106725 832 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS3_0
Kojto 122:f9eeca106725 833 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS4_0
Kojto 122:f9eeca106725 834 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS5_0
Kojto 122:f9eeca106725 835 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS6_0
Kojto 122:f9eeca106725 836 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS7_0
Kojto 122:f9eeca106725 837 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS8_0
Kojto 122:f9eeca106725 838 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS9_0
Kojto 122:f9eeca106725 839 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS10_0
Kojto 122:f9eeca106725 840 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS11_0
Kojto 122:f9eeca106725 841 * @retval None
Kojto 122:f9eeca106725 842 */
Kojto 122:f9eeca106725 843 __STATIC_INLINE void LL_DAC_SetWaveNoiseLFSR(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t NoiseLFSRMask)
Kojto 122:f9eeca106725 844 {
Kojto 122:f9eeca106725 845 MODIFY_REG(DACx->CR,
Kojto 122:f9eeca106725 846 DAC_CR_MAMP1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
Kojto 122:f9eeca106725 847 NoiseLFSRMask << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 848 }
Kojto 122:f9eeca106725 849
Kojto 122:f9eeca106725 850 /**
Kojto 122:f9eeca106725 851 * @brief Set the noise waveform generation for the selected DAC channel:
Kojto 122:f9eeca106725 852 * Noise mode and parameters LFSR (linear feedback shift register).
Kojto 122:f9eeca106725 853 * @rmtoll CR MAMP1 LL_DAC_GetWaveNoiseLFSR\n
Kojto 122:f9eeca106725 854 * CR MAMP2 LL_DAC_GetWaveNoiseLFSR
Kojto 122:f9eeca106725 855 * @param DACx DAC instance
Kojto 122:f9eeca106725 856 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 857 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 858 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 859 *
AnnaBridge 145:64910690c574 860 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 861 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 862 * @retval Returned value can be one of the following values:
Kojto 122:f9eeca106725 863 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BIT0
Kojto 122:f9eeca106725 864 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS1_0
Kojto 122:f9eeca106725 865 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS2_0
Kojto 122:f9eeca106725 866 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS3_0
Kojto 122:f9eeca106725 867 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS4_0
Kojto 122:f9eeca106725 868 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS5_0
Kojto 122:f9eeca106725 869 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS6_0
Kojto 122:f9eeca106725 870 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS7_0
Kojto 122:f9eeca106725 871 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS8_0
Kojto 122:f9eeca106725 872 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS9_0
Kojto 122:f9eeca106725 873 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS10_0
Kojto 122:f9eeca106725 874 * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS11_0
Kojto 122:f9eeca106725 875 */
Kojto 122:f9eeca106725 876 __STATIC_INLINE uint32_t LL_DAC_GetWaveNoiseLFSR(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 877 {
Kojto 122:f9eeca106725 878 return (uint32_t)(READ_BIT(DACx->CR, DAC_CR_MAMP1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 122:f9eeca106725 879 >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
Kojto 122:f9eeca106725 880 );
Kojto 122:f9eeca106725 881 }
Kojto 122:f9eeca106725 882
Kojto 122:f9eeca106725 883 /**
Kojto 122:f9eeca106725 884 * @brief Set the triangle waveform generation for the selected DAC channel:
Kojto 122:f9eeca106725 885 * triangle mode and amplitude.
Kojto 122:f9eeca106725 886 * @note For wave generation to be effective, DAC channel
Kojto 122:f9eeca106725 887 * wave generation mode must be enabled using
Kojto 122:f9eeca106725 888 * function @ref LL_DAC_SetWaveAutoGeneration().
Kojto 122:f9eeca106725 889 * @note This setting can be set when the selected DAC channel is disabled
Kojto 122:f9eeca106725 890 * (otherwise, the setting operation is ignored).
Kojto 122:f9eeca106725 891 * @rmtoll CR MAMP1 LL_DAC_SetWaveTriangleAmplitude\n
Kojto 122:f9eeca106725 892 * CR MAMP2 LL_DAC_SetWaveTriangleAmplitude
Kojto 122:f9eeca106725 893 * @param DACx DAC instance
Kojto 122:f9eeca106725 894 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 895 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 896 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 897 *
AnnaBridge 145:64910690c574 898 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 899 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 900 * @param TriangleAmplitude This parameter can be one of the following values:
Kojto 122:f9eeca106725 901 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_1
Kojto 122:f9eeca106725 902 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_3
Kojto 122:f9eeca106725 903 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_7
Kojto 122:f9eeca106725 904 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_15
Kojto 122:f9eeca106725 905 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_31
Kojto 122:f9eeca106725 906 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_63
Kojto 122:f9eeca106725 907 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_127
Kojto 122:f9eeca106725 908 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_255
Kojto 122:f9eeca106725 909 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_511
Kojto 122:f9eeca106725 910 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_1023
Kojto 122:f9eeca106725 911 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_2047
Kojto 122:f9eeca106725 912 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_4095
Kojto 122:f9eeca106725 913 * @retval None
Kojto 122:f9eeca106725 914 */
Kojto 122:f9eeca106725 915 __STATIC_INLINE void LL_DAC_SetWaveTriangleAmplitude(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t TriangleAmplitude)
Kojto 122:f9eeca106725 916 {
Kojto 122:f9eeca106725 917 MODIFY_REG(DACx->CR,
Kojto 122:f9eeca106725 918 DAC_CR_MAMP1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
Kojto 122:f9eeca106725 919 TriangleAmplitude << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 920 }
Kojto 122:f9eeca106725 921
Kojto 122:f9eeca106725 922 /**
Kojto 122:f9eeca106725 923 * @brief Set the triangle waveform generation for the selected DAC channel:
Kojto 122:f9eeca106725 924 * triangle mode and amplitude.
Kojto 122:f9eeca106725 925 * @rmtoll CR MAMP1 LL_DAC_GetWaveTriangleAmplitude\n
Kojto 122:f9eeca106725 926 * CR MAMP2 LL_DAC_GetWaveTriangleAmplitude
Kojto 122:f9eeca106725 927 * @param DACx DAC instance
Kojto 122:f9eeca106725 928 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 929 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 930 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 931 *
AnnaBridge 145:64910690c574 932 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 933 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 934 * @retval Returned value can be one of the following values:
Kojto 122:f9eeca106725 935 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_1
Kojto 122:f9eeca106725 936 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_3
Kojto 122:f9eeca106725 937 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_7
Kojto 122:f9eeca106725 938 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_15
Kojto 122:f9eeca106725 939 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_31
Kojto 122:f9eeca106725 940 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_63
Kojto 122:f9eeca106725 941 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_127
Kojto 122:f9eeca106725 942 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_255
Kojto 122:f9eeca106725 943 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_511
Kojto 122:f9eeca106725 944 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_1023
Kojto 122:f9eeca106725 945 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_2047
Kojto 122:f9eeca106725 946 * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_4095
Kojto 122:f9eeca106725 947 */
Kojto 122:f9eeca106725 948 __STATIC_INLINE uint32_t LL_DAC_GetWaveTriangleAmplitude(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 949 {
Kojto 122:f9eeca106725 950 return (uint32_t)(READ_BIT(DACx->CR, DAC_CR_MAMP1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 122:f9eeca106725 951 >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
Kojto 122:f9eeca106725 952 );
Kojto 122:f9eeca106725 953 }
Kojto 122:f9eeca106725 954
Kojto 122:f9eeca106725 955 /**
Kojto 122:f9eeca106725 956 * @brief Set the output for the selected DAC channel.
Kojto 122:f9eeca106725 957 * @note This function set several features:
Kojto 122:f9eeca106725 958 * - mode normal or sample-and-hold
Kojto 122:f9eeca106725 959 * - buffer
Kojto 122:f9eeca106725 960 * - connection to GPIO or internal path.
Kojto 122:f9eeca106725 961 * These features can also be set individually using
Kojto 122:f9eeca106725 962 * dedicated functions:
Kojto 122:f9eeca106725 963 * - @ref LL_DAC_SetOutputBuffer()
Kojto 122:f9eeca106725 964 * - @ref LL_DAC_SetOutputMode()
Kojto 122:f9eeca106725 965 * - @ref LL_DAC_SetOutputConnection()
Kojto 122:f9eeca106725 966 * @note On this STM32 serie, output connection depends on output mode
Kojto 122:f9eeca106725 967 * (normal or sample and hold) and output buffer state.
Kojto 122:f9eeca106725 968 * - if output connection is set to internal path and output buffer
Kojto 122:f9eeca106725 969 * is enabled (whatever output mode):
Kojto 122:f9eeca106725 970 * output connection is also connected to GPIO pin
Kojto 122:f9eeca106725 971 * (both connections to GPIO pin and internal path).
Kojto 122:f9eeca106725 972 * - if output connection is set to GPIO pin, output buffer
Kojto 122:f9eeca106725 973 * is disabled, output mode set to sample and hold:
Kojto 122:f9eeca106725 974 * output connection is also connected to internal path
Kojto 122:f9eeca106725 975 * (both connections to GPIO pin and internal path).
Kojto 122:f9eeca106725 976 * @note Mode sample-and-hold requires an external capacitor
Kojto 122:f9eeca106725 977 * to be connected between DAC channel output and ground.
Kojto 122:f9eeca106725 978 * Capacitor value depends on load on DAC channel output and
Kojto 122:f9eeca106725 979 * sample-and-hold timings configured.
Kojto 122:f9eeca106725 980 * As indication, capacitor typical value is 100nF
Kojto 122:f9eeca106725 981 * (refer to device datasheet, parameter "CSH").
Kojto 122:f9eeca106725 982 * @rmtoll CR MODE1 LL_DAC_ConfigOutput\n
Kojto 122:f9eeca106725 983 * CR MODE2 LL_DAC_ConfigOutput
Kojto 122:f9eeca106725 984 * @param DACx DAC instance
Kojto 122:f9eeca106725 985 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 986 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 987 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 988 *
AnnaBridge 145:64910690c574 989 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 990 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 991 * @param OutputMode This parameter can be one of the following values:
Kojto 122:f9eeca106725 992 * @arg @ref LL_DAC_OUTPUT_MODE_NORMAL
Kojto 122:f9eeca106725 993 * @arg @ref LL_DAC_OUTPUT_MODE_SAMPLE_AND_HOLD
Kojto 122:f9eeca106725 994 * @param OutputBuffer This parameter can be one of the following values:
Kojto 122:f9eeca106725 995 * @arg @ref LL_DAC_OUTPUT_BUFFER_ENABLE
Kojto 122:f9eeca106725 996 * @arg @ref LL_DAC_OUTPUT_BUFFER_DISABLE
Kojto 122:f9eeca106725 997 * @param OutputConnection This parameter can be one of the following values:
Kojto 122:f9eeca106725 998 * @arg @ref LL_DAC_OUTPUT_CONNECT_GPIO
Kojto 122:f9eeca106725 999 * @arg @ref LL_DAC_OUTPUT_CONNECT_INTERNAL
Kojto 122:f9eeca106725 1000 * @retval None
Kojto 122:f9eeca106725 1001 */
Kojto 122:f9eeca106725 1002 __STATIC_INLINE void LL_DAC_ConfigOutput(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t OutputMode, uint32_t OutputBuffer, uint32_t OutputConnection)
Kojto 122:f9eeca106725 1003 {
Kojto 122:f9eeca106725 1004 MODIFY_REG(DACx->MCR,
Kojto 122:f9eeca106725 1005 (DAC_MCR_MODE1_2 | DAC_MCR_MODE1_1 | DAC_MCR_MODE1_0) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
Kojto 122:f9eeca106725 1006 (OutputMode | OutputBuffer | OutputConnection) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 1007 }
Kojto 122:f9eeca106725 1008
Kojto 122:f9eeca106725 1009 /**
Kojto 122:f9eeca106725 1010 * @brief Set the output mode normal or sample-and-hold
Kojto 122:f9eeca106725 1011 * for the selected DAC channel.
Kojto 122:f9eeca106725 1012 * @note Mode sample-and-hold requires an external capacitor
Kojto 122:f9eeca106725 1013 * to be connected between DAC channel output and ground.
Kojto 122:f9eeca106725 1014 * Capacitor value depends on load on DAC channel output and
Kojto 122:f9eeca106725 1015 * sample-and-hold timings configured.
Kojto 122:f9eeca106725 1016 * As indication, capacitor typical value is 100nF
Kojto 122:f9eeca106725 1017 * (refer to device datasheet, parameter "CSH").
Kojto 122:f9eeca106725 1018 * @rmtoll CR MODE1 LL_DAC_SetOutputMode\n
Kojto 122:f9eeca106725 1019 * CR MODE2 LL_DAC_SetOutputMode
Kojto 122:f9eeca106725 1020 * @param DACx DAC instance
Kojto 122:f9eeca106725 1021 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1022 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1023 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1024 *
AnnaBridge 145:64910690c574 1025 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1026 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1027 * @param OutputMode This parameter can be one of the following values:
Kojto 122:f9eeca106725 1028 * @arg @ref LL_DAC_OUTPUT_MODE_NORMAL
Kojto 122:f9eeca106725 1029 * @arg @ref LL_DAC_OUTPUT_MODE_SAMPLE_AND_HOLD
Kojto 122:f9eeca106725 1030 * @retval None
Kojto 122:f9eeca106725 1031 */
Kojto 122:f9eeca106725 1032 __STATIC_INLINE void LL_DAC_SetOutputMode(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t OutputMode)
Kojto 122:f9eeca106725 1033 {
Kojto 122:f9eeca106725 1034 MODIFY_REG(DACx->MCR,
Kojto 122:f9eeca106725 1035 DAC_MCR_MODE1_2 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
Kojto 122:f9eeca106725 1036 OutputMode << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 1037 }
Kojto 122:f9eeca106725 1038
Kojto 122:f9eeca106725 1039 /**
Kojto 122:f9eeca106725 1040 * @brief Get the output mode normal or sample-and-hold for the selected DAC channel.
Kojto 122:f9eeca106725 1041 * @rmtoll CR MODE1 LL_DAC_GetOutputMode\n
Kojto 122:f9eeca106725 1042 * CR MODE2 LL_DAC_GetOutputMode
Kojto 122:f9eeca106725 1043 * @param DACx DAC instance
Kojto 122:f9eeca106725 1044 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1045 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1046 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1047 *
AnnaBridge 145:64910690c574 1048 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1049 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1050 * @retval Returned value can be one of the following values:
Kojto 122:f9eeca106725 1051 * @arg @ref LL_DAC_OUTPUT_MODE_NORMAL
Kojto 122:f9eeca106725 1052 * @arg @ref LL_DAC_OUTPUT_MODE_SAMPLE_AND_HOLD
Kojto 122:f9eeca106725 1053 */
Kojto 122:f9eeca106725 1054 __STATIC_INLINE uint32_t LL_DAC_GetOutputMode(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1055 {
Kojto 122:f9eeca106725 1056 return (uint32_t)(READ_BIT(DACx->MCR, DAC_MCR_MODE1_2 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 122:f9eeca106725 1057 >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
Kojto 122:f9eeca106725 1058 );
Kojto 122:f9eeca106725 1059 }
Kojto 122:f9eeca106725 1060
Kojto 122:f9eeca106725 1061 /**
Kojto 122:f9eeca106725 1062 * @brief Set the output buffer for the selected DAC channel.
Kojto 122:f9eeca106725 1063 * @note On this STM32 serie, when buffer is enabled, its offset can be
Kojto 122:f9eeca106725 1064 * trimmed: factory calibration default values can be
Kojto 122:f9eeca106725 1065 * replaced by user trimming values, using function
Kojto 122:f9eeca106725 1066 * @ref LL_DAC_SetTrimmingValue().
Kojto 122:f9eeca106725 1067 * @rmtoll CR MODE1 LL_DAC_SetOutputBuffer\n
Kojto 122:f9eeca106725 1068 * CR MODE2 LL_DAC_SetOutputBuffer
Kojto 122:f9eeca106725 1069 * @param DACx DAC instance
Kojto 122:f9eeca106725 1070 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1071 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1072 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1073 *
AnnaBridge 145:64910690c574 1074 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1075 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1076 * @param OutputBuffer This parameter can be one of the following values:
Kojto 122:f9eeca106725 1077 * @arg @ref LL_DAC_OUTPUT_BUFFER_ENABLE
Kojto 122:f9eeca106725 1078 * @arg @ref LL_DAC_OUTPUT_BUFFER_DISABLE
Kojto 122:f9eeca106725 1079 * @retval None
Kojto 122:f9eeca106725 1080 */
Kojto 122:f9eeca106725 1081 __STATIC_INLINE void LL_DAC_SetOutputBuffer(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t OutputBuffer)
Kojto 122:f9eeca106725 1082 {
Kojto 122:f9eeca106725 1083 MODIFY_REG(DACx->MCR,
Kojto 122:f9eeca106725 1084 DAC_MCR_MODE1_1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
Kojto 122:f9eeca106725 1085 OutputBuffer << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 1086 }
Kojto 122:f9eeca106725 1087
Kojto 122:f9eeca106725 1088 /**
Kojto 122:f9eeca106725 1089 * @brief Get the output buffer state for the selected DAC channel.
Kojto 122:f9eeca106725 1090 * @rmtoll CR MODE1 LL_DAC_GetOutputBuffer\n
Kojto 122:f9eeca106725 1091 * CR MODE2 LL_DAC_GetOutputBuffer
Kojto 122:f9eeca106725 1092 * @param DACx DAC instance
Kojto 122:f9eeca106725 1093 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1094 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1095 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1096 *
AnnaBridge 145:64910690c574 1097 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1098 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1099 * @retval Returned value can be one of the following values:
Kojto 122:f9eeca106725 1100 * @arg @ref LL_DAC_OUTPUT_BUFFER_ENABLE
Kojto 122:f9eeca106725 1101 * @arg @ref LL_DAC_OUTPUT_BUFFER_DISABLE
Kojto 122:f9eeca106725 1102 */
Kojto 122:f9eeca106725 1103 __STATIC_INLINE uint32_t LL_DAC_GetOutputBuffer(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1104 {
Kojto 122:f9eeca106725 1105 return (uint32_t)(READ_BIT(DACx->MCR, DAC_MCR_MODE1_1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 122:f9eeca106725 1106 >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
Kojto 122:f9eeca106725 1107 );
Kojto 122:f9eeca106725 1108 }
Kojto 122:f9eeca106725 1109
Kojto 122:f9eeca106725 1110 /**
Kojto 122:f9eeca106725 1111 * @brief Set the output connection for the selected DAC channel.
Kojto 122:f9eeca106725 1112 * @note On this STM32 serie, output connection depends on output mode (normal or
Kojto 122:f9eeca106725 1113 * sample and hold) and output buffer state.
Kojto 122:f9eeca106725 1114 * - if output connection is set to internal path and output buffer
Kojto 122:f9eeca106725 1115 * is enabled (whatever output mode):
Kojto 122:f9eeca106725 1116 * output connection is also connected to GPIO pin
Kojto 122:f9eeca106725 1117 * (both connections to GPIO pin and internal path).
Kojto 122:f9eeca106725 1118 * - if output connection is set to GPIO pin, output buffer
Kojto 122:f9eeca106725 1119 * is disabled, output mode set to sample and hold:
Kojto 122:f9eeca106725 1120 * output connection is also connected to internal path
Kojto 122:f9eeca106725 1121 * (both connections to GPIO pin and internal path).
Kojto 122:f9eeca106725 1122 * @rmtoll CR MODE1 LL_DAC_SetOutputConnection\n
Kojto 122:f9eeca106725 1123 * CR MODE2 LL_DAC_SetOutputConnection
Kojto 122:f9eeca106725 1124 * @param DACx DAC instance
Kojto 122:f9eeca106725 1125 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1126 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1127 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1128 *
AnnaBridge 145:64910690c574 1129 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1130 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1131 * @param OutputConnection This parameter can be one of the following values:
Kojto 122:f9eeca106725 1132 * @arg @ref LL_DAC_OUTPUT_CONNECT_GPIO
Kojto 122:f9eeca106725 1133 * @arg @ref LL_DAC_OUTPUT_CONNECT_INTERNAL
Kojto 122:f9eeca106725 1134 * @retval None
Kojto 122:f9eeca106725 1135 */
Kojto 122:f9eeca106725 1136 __STATIC_INLINE void LL_DAC_SetOutputConnection(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t OutputConnection)
Kojto 122:f9eeca106725 1137 {
Kojto 122:f9eeca106725 1138 MODIFY_REG(DACx->MCR,
Kojto 122:f9eeca106725 1139 DAC_MCR_MODE1_0 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
Kojto 122:f9eeca106725 1140 OutputConnection << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 1141 }
Kojto 122:f9eeca106725 1142
Kojto 122:f9eeca106725 1143 /**
Kojto 122:f9eeca106725 1144 * @brief Get the output connection for the selected DAC channel.
Kojto 122:f9eeca106725 1145 * @note On this STM32 serie, output connection depends on output mode (normal or
Kojto 122:f9eeca106725 1146 * sample and hold) and output buffer state.
Kojto 122:f9eeca106725 1147 * - if output connection is set to internal path and output buffer
Kojto 122:f9eeca106725 1148 * is enabled (whatever output mode):
Kojto 122:f9eeca106725 1149 * output connection is also connected to GPIO pin
Kojto 122:f9eeca106725 1150 * (both connections to GPIO pin and internal path).
Kojto 122:f9eeca106725 1151 * - if output connection is set to GPIO pin, output buffer
Kojto 122:f9eeca106725 1152 * is disabled, output mode set to sample and hold:
Kojto 122:f9eeca106725 1153 * output connection is also connected to internal path
Kojto 122:f9eeca106725 1154 * (both connections to GPIO pin and internal path).
Kojto 122:f9eeca106725 1155 * @rmtoll CR MODE1 LL_DAC_GetOutputConnection\n
Kojto 122:f9eeca106725 1156 * CR MODE2 LL_DAC_GetOutputConnection
Kojto 122:f9eeca106725 1157 * @param DACx DAC instance
Kojto 122:f9eeca106725 1158 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1159 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1160 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1161 *
AnnaBridge 145:64910690c574 1162 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1163 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1164 * @retval Returned value can be one of the following values:
Kojto 122:f9eeca106725 1165 * @arg @ref LL_DAC_OUTPUT_CONNECT_GPIO
Kojto 122:f9eeca106725 1166 * @arg @ref LL_DAC_OUTPUT_CONNECT_INTERNAL
Kojto 122:f9eeca106725 1167 */
Kojto 122:f9eeca106725 1168 __STATIC_INLINE uint32_t LL_DAC_GetOutputConnection(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1169 {
Kojto 122:f9eeca106725 1170 return (uint32_t)(READ_BIT(DACx->MCR, DAC_MCR_MODE1_0 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 122:f9eeca106725 1171 >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
Kojto 122:f9eeca106725 1172 );
Kojto 122:f9eeca106725 1173 }
Kojto 122:f9eeca106725 1174
Kojto 122:f9eeca106725 1175 /**
Kojto 122:f9eeca106725 1176 * @brief Set the sample-and-hold timing for the selected DAC channel:
Kojto 122:f9eeca106725 1177 * sample time
Kojto 122:f9eeca106725 1178 * @note Sample time must be set when DAC channel is disabled
Kojto 122:f9eeca106725 1179 * or during DAC operation when DAC channel flag BWSTx is reset,
Kojto 122:f9eeca106725 1180 * otherwise the setting is ignored.
Kojto 122:f9eeca106725 1181 * Check BWSTx flag state using function "LL_DAC_IsActiveFlag_BWSTx()".
Kojto 122:f9eeca106725 1182 * @rmtoll SHSR1 TSAMPLE1 LL_DAC_SetSampleAndHoldSampleTime\n
Kojto 122:f9eeca106725 1183 * SHSR2 TSAMPLE2 LL_DAC_SetSampleAndHoldSampleTime
Kojto 122:f9eeca106725 1184 * @param DACx DAC instance
Kojto 122:f9eeca106725 1185 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1186 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1187 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1188 *
AnnaBridge 145:64910690c574 1189 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1190 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1191 * @param SampleTime Value between Min_Data=0x000 and Max_Data=0x3FF
Kojto 122:f9eeca106725 1192 * @retval None
Kojto 122:f9eeca106725 1193 */
Kojto 122:f9eeca106725 1194 __STATIC_INLINE void LL_DAC_SetSampleAndHoldSampleTime(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t SampleTime)
Kojto 122:f9eeca106725 1195 {
Kojto 122:f9eeca106725 1196 register uint32_t *preg = __DAC_PTR_REG_OFFSET(DACx->SHSR1, __DAC_MASK_SHIFT(DAC_Channel, DAC_REG_SHSRX_REGOFFSET_MASK));
Kojto 122:f9eeca106725 1197
Kojto 122:f9eeca106725 1198 MODIFY_REG(*preg,
Kojto 122:f9eeca106725 1199 DAC_SHSR1_TSAMPLE1,
Kojto 122:f9eeca106725 1200 SampleTime);
Kojto 122:f9eeca106725 1201 }
Kojto 122:f9eeca106725 1202
Kojto 122:f9eeca106725 1203 /**
Kojto 122:f9eeca106725 1204 * @brief Get the sample-and-hold timing for the selected DAC channel:
Kojto 122:f9eeca106725 1205 * sample time
Kojto 122:f9eeca106725 1206 * @rmtoll SHSR1 TSAMPLE1 LL_DAC_GetSampleAndHoldSampleTime\n
Kojto 122:f9eeca106725 1207 * SHSR2 TSAMPLE2 LL_DAC_GetSampleAndHoldSampleTime
Kojto 122:f9eeca106725 1208 * @param DACx DAC instance
Kojto 122:f9eeca106725 1209 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1210 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1211 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1212 *
AnnaBridge 145:64910690c574 1213 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1214 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1215 * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
Kojto 122:f9eeca106725 1216 */
Kojto 122:f9eeca106725 1217 __STATIC_INLINE uint32_t LL_DAC_GetSampleAndHoldSampleTime(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1218 {
Kojto 122:f9eeca106725 1219 register uint32_t *preg = __DAC_PTR_REG_OFFSET(DACx->SHSR1, __DAC_MASK_SHIFT(DAC_Channel, DAC_REG_SHSRX_REGOFFSET_MASK));
Kojto 122:f9eeca106725 1220
Kojto 122:f9eeca106725 1221 return (uint32_t) READ_BIT(*preg, DAC_SHSR1_TSAMPLE1);
Kojto 122:f9eeca106725 1222 }
Kojto 122:f9eeca106725 1223
Kojto 122:f9eeca106725 1224 /**
Kojto 122:f9eeca106725 1225 * @brief Set the sample-and-hold timing for the selected DAC channel:
Kojto 122:f9eeca106725 1226 * hold time
Kojto 122:f9eeca106725 1227 * @rmtoll SHHR THOLD1 LL_DAC_SetSampleAndHoldHoldTime\n
Kojto 122:f9eeca106725 1228 * SHHR THOLD2 LL_DAC_SetSampleAndHoldHoldTime
Kojto 122:f9eeca106725 1229 * @param DACx DAC instance
Kojto 122:f9eeca106725 1230 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1231 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1232 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1233 *
AnnaBridge 145:64910690c574 1234 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1235 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1236 * @param HoldTime Value between Min_Data=0x000 and Max_Data=0x3FF
Kojto 122:f9eeca106725 1237 * @retval None
Kojto 122:f9eeca106725 1238 */
Kojto 122:f9eeca106725 1239 __STATIC_INLINE void LL_DAC_SetSampleAndHoldHoldTime(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t HoldTime)
Kojto 122:f9eeca106725 1240 {
Kojto 122:f9eeca106725 1241 MODIFY_REG(DACx->SHHR,
Kojto 122:f9eeca106725 1242 DAC_SHHR_THOLD1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
Kojto 122:f9eeca106725 1243 HoldTime << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 1244 }
Kojto 122:f9eeca106725 1245
Kojto 122:f9eeca106725 1246 /**
Kojto 122:f9eeca106725 1247 * @brief Get the sample-and-hold timing for the selected DAC channel:
Kojto 122:f9eeca106725 1248 * hold time
Kojto 122:f9eeca106725 1249 * @rmtoll SHHR THOLD1 LL_DAC_GetSampleAndHoldHoldTime\n
Kojto 122:f9eeca106725 1250 * SHHR THOLD2 LL_DAC_GetSampleAndHoldHoldTime
Kojto 122:f9eeca106725 1251 * @param DACx DAC instance
Kojto 122:f9eeca106725 1252 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1253 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1254 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1255 *
AnnaBridge 145:64910690c574 1256 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1257 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1258 * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
Kojto 122:f9eeca106725 1259 */
Kojto 122:f9eeca106725 1260 __STATIC_INLINE uint32_t LL_DAC_GetSampleAndHoldHoldTime(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1261 {
Kojto 122:f9eeca106725 1262 return (uint32_t)(READ_BIT(DACx->SHHR, DAC_SHHR_THOLD1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 122:f9eeca106725 1263 >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
Kojto 122:f9eeca106725 1264 );
Kojto 122:f9eeca106725 1265 }
Kojto 122:f9eeca106725 1266
Kojto 122:f9eeca106725 1267 /**
Kojto 122:f9eeca106725 1268 * @brief Set the sample-and-hold timing for the selected DAC channel:
Kojto 122:f9eeca106725 1269 * refresh time
Kojto 122:f9eeca106725 1270 * @rmtoll SHRR TREFRESH1 LL_DAC_SetSampleAndHoldRefreshTime\n
Kojto 122:f9eeca106725 1271 * SHRR TREFRESH2 LL_DAC_SetSampleAndHoldRefreshTime
Kojto 122:f9eeca106725 1272 * @param DACx DAC instance
Kojto 122:f9eeca106725 1273 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1274 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1275 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1276 *
AnnaBridge 145:64910690c574 1277 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1278 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1279 * @param RefreshTime Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 122:f9eeca106725 1280 * @retval None
Kojto 122:f9eeca106725 1281 */
Kojto 122:f9eeca106725 1282 __STATIC_INLINE void LL_DAC_SetSampleAndHoldRefreshTime(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t RefreshTime)
Kojto 122:f9eeca106725 1283 {
Kojto 122:f9eeca106725 1284 MODIFY_REG(DACx->SHRR,
Kojto 122:f9eeca106725 1285 DAC_SHRR_TREFRESH1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
Kojto 122:f9eeca106725 1286 RefreshTime << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 1287 }
Kojto 122:f9eeca106725 1288
Kojto 122:f9eeca106725 1289 /**
Kojto 122:f9eeca106725 1290 * @brief Get the sample-and-hold timing for the selected DAC channel:
Kojto 122:f9eeca106725 1291 * refresh time
Kojto 122:f9eeca106725 1292 * @rmtoll SHRR TREFRESH1 LL_DAC_GetSampleAndHoldRefreshTime\n
Kojto 122:f9eeca106725 1293 * SHRR TREFRESH2 LL_DAC_GetSampleAndHoldRefreshTime
Kojto 122:f9eeca106725 1294 * @param DACx DAC instance
Kojto 122:f9eeca106725 1295 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1296 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1297 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1298 *
AnnaBridge 145:64910690c574 1299 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1300 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1301 * @retval Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 122:f9eeca106725 1302 */
Kojto 122:f9eeca106725 1303 __STATIC_INLINE uint32_t LL_DAC_GetSampleAndHoldRefreshTime(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1304 {
Kojto 122:f9eeca106725 1305 return (uint32_t)(READ_BIT(DACx->SHRR, DAC_SHRR_TREFRESH1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 122:f9eeca106725 1306 >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
Kojto 122:f9eeca106725 1307 );
Kojto 122:f9eeca106725 1308 }
Kojto 122:f9eeca106725 1309
Kojto 122:f9eeca106725 1310 /**
Kojto 122:f9eeca106725 1311 * @}
Kojto 122:f9eeca106725 1312 */
Kojto 122:f9eeca106725 1313
Kojto 122:f9eeca106725 1314 /** @defgroup DAC_LL_EF_Configuration_Legacy_Functions DAC configuration, legacy functions name
Kojto 122:f9eeca106725 1315 * @{
Kojto 122:f9eeca106725 1316 */
Kojto 122:f9eeca106725 1317 /* Old functions name kept for legacy purpose, to be replaced by the */
Kojto 122:f9eeca106725 1318 /* current functions name. */
Kojto 122:f9eeca106725 1319 __STATIC_INLINE void LL_DAC_SetWaveMode(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t WaveMode)
Kojto 122:f9eeca106725 1320 {
Kojto 122:f9eeca106725 1321 LL_DAC_SetWaveAutoGeneration(DACx, DAC_Channel, WaveMode);
Kojto 122:f9eeca106725 1322 }
Kojto 122:f9eeca106725 1323 __STATIC_INLINE uint32_t LL_DAC_GetWaveMode(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1324 {
Kojto 122:f9eeca106725 1325 return LL_DAC_GetWaveAutoGeneration(DACx, DAC_Channel);
Kojto 122:f9eeca106725 1326 }
Kojto 122:f9eeca106725 1327
Kojto 122:f9eeca106725 1328 /**
Kojto 122:f9eeca106725 1329 * @}
Kojto 122:f9eeca106725 1330 */
Kojto 122:f9eeca106725 1331
Kojto 122:f9eeca106725 1332 /** @defgroup DAC_LL_EF_DMA_Management DMA Management
Kojto 122:f9eeca106725 1333 * @{
Kojto 122:f9eeca106725 1334 */
Kojto 122:f9eeca106725 1335
Kojto 122:f9eeca106725 1336 /**
Kojto 122:f9eeca106725 1337 * @brief Enable DAC DMA transfer request of the selected channel.
Kojto 122:f9eeca106725 1338 * @note To configure DMA source address (peripheral address),
Kojto 122:f9eeca106725 1339 * use function @ref LL_DAC_DMA_GetRegAddr().
Kojto 122:f9eeca106725 1340 * @rmtoll CR DMAEN1 LL_DAC_EnableDMAReq\n
Kojto 122:f9eeca106725 1341 * CR DMAEN2 LL_DAC_EnableDMAReq
Kojto 122:f9eeca106725 1342 * @param DACx DAC instance
Kojto 122:f9eeca106725 1343 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1344 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1345 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1346 *
AnnaBridge 145:64910690c574 1347 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1348 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1349 * @retval None
Kojto 122:f9eeca106725 1350 */
Kojto 122:f9eeca106725 1351 __STATIC_INLINE void LL_DAC_EnableDMAReq(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1352 {
Kojto 122:f9eeca106725 1353 SET_BIT(DACx->CR,
Kojto 122:f9eeca106725 1354 DAC_CR_DMAEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 1355 }
Kojto 122:f9eeca106725 1356
Kojto 122:f9eeca106725 1357 /**
Kojto 122:f9eeca106725 1358 * @brief Disable DAC DMA transfer request of the selected channel.
Kojto 122:f9eeca106725 1359 * @note To configure DMA source address (peripheral address),
Kojto 122:f9eeca106725 1360 * use function @ref LL_DAC_DMA_GetRegAddr().
Kojto 122:f9eeca106725 1361 * @rmtoll CR DMAEN1 LL_DAC_DisableDMAReq\n
Kojto 122:f9eeca106725 1362 * CR DMAEN2 LL_DAC_DisableDMAReq
Kojto 122:f9eeca106725 1363 * @param DACx DAC instance
Kojto 122:f9eeca106725 1364 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1365 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1366 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1367 *
AnnaBridge 145:64910690c574 1368 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1369 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1370 * @retval None
Kojto 122:f9eeca106725 1371 */
Kojto 122:f9eeca106725 1372 __STATIC_INLINE void LL_DAC_DisableDMAReq(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1373 {
Kojto 122:f9eeca106725 1374 CLEAR_BIT(DACx->CR,
Kojto 122:f9eeca106725 1375 DAC_CR_DMAEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 1376 }
Kojto 122:f9eeca106725 1377
Kojto 122:f9eeca106725 1378 /**
Kojto 122:f9eeca106725 1379 * @brief Get DAC DMA transfer request state of the selected channel.
Kojto 122:f9eeca106725 1380 * (0: DAC DMA transfer request is disabled, 1: DAC DMA transfer request is enabled)
Kojto 122:f9eeca106725 1381 * @rmtoll CR DMAEN1 LL_DAC_IsDMAReqEnabled\n
Kojto 122:f9eeca106725 1382 * CR DMAEN2 LL_DAC_IsDMAReqEnabled
Kojto 122:f9eeca106725 1383 * @param DACx DAC instance
Kojto 122:f9eeca106725 1384 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1385 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1386 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1387 *
AnnaBridge 145:64910690c574 1388 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1389 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1390 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 1391 */
Kojto 122:f9eeca106725 1392 __STATIC_INLINE uint32_t LL_DAC_IsDMAReqEnabled(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1393 {
Kojto 122:f9eeca106725 1394 return (READ_BIT(DACx->CR,
Kojto 122:f9eeca106725 1395 DAC_CR_DMAEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 122:f9eeca106725 1396 == (DAC_CR_DMAEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)));
Kojto 122:f9eeca106725 1397 }
Kojto 122:f9eeca106725 1398
Kojto 122:f9eeca106725 1399 /**
Kojto 122:f9eeca106725 1400 * @brief Function to help to configure DMA transfer to DAC: retrieve the
Kojto 122:f9eeca106725 1401 * DAC register address from DAC instance and a list of DAC registers
Kojto 122:f9eeca106725 1402 * intended to be used (most commonly) with DMA transfer.
Kojto 122:f9eeca106725 1403 * @note These DAC registers are data holding registers:
Kojto 122:f9eeca106725 1404 * when DAC conversion is requested, DAC generates a DMA transfer
Kojto 122:f9eeca106725 1405 * request to have data available in DAC data holding registers.
Kojto 122:f9eeca106725 1406 * @note This macro is intended to be used with LL DMA driver, refer to
Kojto 122:f9eeca106725 1407 * function "LL_DMA_ConfigAddresses()".
Kojto 122:f9eeca106725 1408 * Example:
Kojto 122:f9eeca106725 1409 * LL_DMA_ConfigAddresses(DMA1,
Kojto 122:f9eeca106725 1410 * LL_DMA_CHANNEL_1,
Kojto 122:f9eeca106725 1411 * (uint32_t)&< array or variable >,
Kojto 122:f9eeca106725 1412 * LL_DAC_DMA_GetRegAddr(DAC1, LL_DAC_CHANNEL_1, LL_DAC_DMA_REG_DATA_12BITS_RIGHT_ALIGNED),
Kojto 122:f9eeca106725 1413 * LL_DMA_DIRECTION_MEMORY_TO_PERIPH);
Kojto 122:f9eeca106725 1414 * @rmtoll DHR12R1 DACC1DHR LL_DAC_DMA_GetRegAddr\n
Kojto 122:f9eeca106725 1415 * DHR12L1 DACC1DHR LL_DAC_DMA_GetRegAddr\n
Kojto 122:f9eeca106725 1416 * DHR8R1 DACC1DHR LL_DAC_DMA_GetRegAddr\n
Kojto 122:f9eeca106725 1417 * DHR12R2 DACC2DHR LL_DAC_DMA_GetRegAddr\n
Kojto 122:f9eeca106725 1418 * DHR12L2 DACC2DHR LL_DAC_DMA_GetRegAddr\n
Kojto 122:f9eeca106725 1419 * DHR8R2 DACC2DHR LL_DAC_DMA_GetRegAddr
Kojto 122:f9eeca106725 1420 * @param DACx DAC instance
Kojto 122:f9eeca106725 1421 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1422 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1423 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1424 *
AnnaBridge 145:64910690c574 1425 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1426 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1427 * @param Register This parameter can be one of the following values:
Kojto 122:f9eeca106725 1428 * @arg @ref LL_DAC_DMA_REG_DATA_12BITS_RIGHT_ALIGNED
Kojto 122:f9eeca106725 1429 * @arg @ref LL_DAC_DMA_REG_DATA_12BITS_LEFT_ALIGNED
Kojto 122:f9eeca106725 1430 * @arg @ref LL_DAC_DMA_REG_DATA_8BITS_RIGHT_ALIGNED
Kojto 122:f9eeca106725 1431 * @retval DAC register address
Kojto 122:f9eeca106725 1432 */
Kojto 122:f9eeca106725 1433 __STATIC_INLINE uint32_t LL_DAC_DMA_GetRegAddr(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t Register)
Kojto 122:f9eeca106725 1434 {
Kojto 122:f9eeca106725 1435 /* Retrieve address of register DHR12Rx, DHR12Lx or DHR8Rx depending on */
Kojto 122:f9eeca106725 1436 /* DAC channel selected. */
Kojto 122:f9eeca106725 1437 return ((uint32_t)(__DAC_PTR_REG_OFFSET((DACx)->DHR12R1, __DAC_MASK_SHIFT(DAC_Channel, Register))));
Kojto 122:f9eeca106725 1438 }
Kojto 122:f9eeca106725 1439 /**
Kojto 122:f9eeca106725 1440 * @}
Kojto 122:f9eeca106725 1441 */
Kojto 122:f9eeca106725 1442
Kojto 122:f9eeca106725 1443 /** @defgroup DAC_LL_EF_Operation Operation on DAC channels
Kojto 122:f9eeca106725 1444 * @{
Kojto 122:f9eeca106725 1445 */
Kojto 122:f9eeca106725 1446
Kojto 122:f9eeca106725 1447 /**
Kojto 122:f9eeca106725 1448 * @brief Enable DAC selected channel.
Kojto 122:f9eeca106725 1449 * @rmtoll CR EN1 LL_DAC_Enable\n
Kojto 122:f9eeca106725 1450 * CR EN2 LL_DAC_Enable
Kojto 122:f9eeca106725 1451 * @note After enable from off state, DAC channel requires a delay
Kojto 122:f9eeca106725 1452 * for output voltage to reach accuracy +/- 1 LSB.
Kojto 122:f9eeca106725 1453 * Refer to device datasheet, parameter "tWAKEUP".
Kojto 122:f9eeca106725 1454 * @param DACx DAC instance
Kojto 122:f9eeca106725 1455 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1456 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1457 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1458 *
AnnaBridge 145:64910690c574 1459 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1460 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1461 * @retval None
Kojto 122:f9eeca106725 1462 */
Kojto 122:f9eeca106725 1463 __STATIC_INLINE void LL_DAC_Enable(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1464 {
Kojto 122:f9eeca106725 1465 SET_BIT(DACx->CR,
Kojto 122:f9eeca106725 1466 DAC_CR_EN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 1467 }
Kojto 122:f9eeca106725 1468
Kojto 122:f9eeca106725 1469 /**
Kojto 122:f9eeca106725 1470 * @brief Disable DAC selected channel.
Kojto 122:f9eeca106725 1471 * @rmtoll CR EN1 LL_DAC_Disable\n
Kojto 122:f9eeca106725 1472 * CR EN2 LL_DAC_Disable
Kojto 122:f9eeca106725 1473 * @param DACx DAC instance
Kojto 122:f9eeca106725 1474 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1475 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1476 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1477 *
AnnaBridge 145:64910690c574 1478 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1479 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1480 * @retval None
Kojto 122:f9eeca106725 1481 */
Kojto 122:f9eeca106725 1482 __STATIC_INLINE void LL_DAC_Disable(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1483 {
Kojto 122:f9eeca106725 1484 CLEAR_BIT(DACx->CR,
Kojto 122:f9eeca106725 1485 DAC_CR_EN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 1486 }
Kojto 122:f9eeca106725 1487
Kojto 122:f9eeca106725 1488 /**
Kojto 122:f9eeca106725 1489 * @brief Get DAC enable state of the selected channel.
Kojto 122:f9eeca106725 1490 * (0: DAC channel is disabled, 1: DAC channel is enabled)
Kojto 122:f9eeca106725 1491 * @rmtoll CR EN1 LL_DAC_IsEnabled\n
Kojto 122:f9eeca106725 1492 * CR EN2 LL_DAC_IsEnabled
Kojto 122:f9eeca106725 1493 * @param DACx DAC instance
Kojto 122:f9eeca106725 1494 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1495 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1496 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1497 *
AnnaBridge 145:64910690c574 1498 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1499 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1500 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 1501 */
Kojto 122:f9eeca106725 1502 __STATIC_INLINE uint32_t LL_DAC_IsEnabled(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1503 {
Kojto 122:f9eeca106725 1504 return (READ_BIT(DACx->CR,
Kojto 122:f9eeca106725 1505 DAC_CR_EN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 122:f9eeca106725 1506 == (DAC_CR_EN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)));
Kojto 122:f9eeca106725 1507 }
Kojto 122:f9eeca106725 1508
Kojto 122:f9eeca106725 1509 /**
Kojto 122:f9eeca106725 1510 * @brief Enable DAC trigger of the selected channel.
Kojto 122:f9eeca106725 1511 * @note - If DAC trigger is disabled, DAC conversion is performed
Kojto 122:f9eeca106725 1512 * automatically once the data holding register is updated,
Kojto 122:f9eeca106725 1513 * using functions "LL_DAC_ConvertData{8; 12}{Right; Left} Aligned()":
Kojto 122:f9eeca106725 1514 * @ref LL_DAC_ConvertData12RightAligned(), ...
Kojto 122:f9eeca106725 1515 * - If DAC trigger is enabled, DAC conversion is performed
Kojto 122:f9eeca106725 1516 * only when a hardware of software trigger event is occurring.
Kojto 122:f9eeca106725 1517 * Select trigger source using
Kojto 122:f9eeca106725 1518 * function @ref LL_DAC_SetTriggerSource().
Kojto 122:f9eeca106725 1519 * @rmtoll CR TEN1 LL_DAC_EnableTrigger\n
Kojto 122:f9eeca106725 1520 * CR TEN2 LL_DAC_EnableTrigger
Kojto 122:f9eeca106725 1521 * @param DACx DAC instance
Kojto 122:f9eeca106725 1522 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1523 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1524 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1525 *
AnnaBridge 145:64910690c574 1526 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1527 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1528 * @retval None
Kojto 122:f9eeca106725 1529 */
Kojto 122:f9eeca106725 1530 __STATIC_INLINE void LL_DAC_EnableTrigger(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1531 {
Kojto 122:f9eeca106725 1532 SET_BIT(DACx->CR,
Kojto 122:f9eeca106725 1533 DAC_CR_TEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 1534 }
Kojto 122:f9eeca106725 1535
Kojto 122:f9eeca106725 1536 /**
Kojto 122:f9eeca106725 1537 * @brief Disable DAC trigger of the selected channel.
Kojto 122:f9eeca106725 1538 * @rmtoll CR TEN1 LL_DAC_DisableTrigger\n
Kojto 122:f9eeca106725 1539 * CR TEN2 LL_DAC_DisableTrigger
Kojto 122:f9eeca106725 1540 * @param DACx DAC instance
Kojto 122:f9eeca106725 1541 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1542 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1543 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1544 *
AnnaBridge 145:64910690c574 1545 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1546 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1547 * @retval None
Kojto 122:f9eeca106725 1548 */
Kojto 122:f9eeca106725 1549 __STATIC_INLINE void LL_DAC_DisableTrigger(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1550 {
Kojto 122:f9eeca106725 1551 CLEAR_BIT(DACx->CR,
Kojto 122:f9eeca106725 1552 DAC_CR_TEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
Kojto 122:f9eeca106725 1553 }
Kojto 122:f9eeca106725 1554
Kojto 122:f9eeca106725 1555 /**
Kojto 122:f9eeca106725 1556 * @brief Get DAC trigger state of the selected channel.
Kojto 122:f9eeca106725 1557 * (0: DAC trigger is disabled, 1: DAC trigger is enabled)
Kojto 122:f9eeca106725 1558 * @rmtoll CR TEN1 LL_DAC_IsTriggerEnabled\n
Kojto 122:f9eeca106725 1559 * CR TEN2 LL_DAC_IsTriggerEnabled
Kojto 122:f9eeca106725 1560 * @param DACx DAC instance
Kojto 122:f9eeca106725 1561 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1562 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1563 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1564 *
AnnaBridge 145:64910690c574 1565 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1566 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1567 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 1568 */
Kojto 122:f9eeca106725 1569 __STATIC_INLINE uint32_t LL_DAC_IsTriggerEnabled(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1570 {
Kojto 122:f9eeca106725 1571 return (READ_BIT(DACx->CR,
Kojto 122:f9eeca106725 1572 DAC_CR_TEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
Kojto 122:f9eeca106725 1573 == (DAC_CR_TEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)));
Kojto 122:f9eeca106725 1574 }
Kojto 122:f9eeca106725 1575
Kojto 122:f9eeca106725 1576 /**
Kojto 122:f9eeca106725 1577 * @brief Trig DAC conversion by software for the selected DAC channel.
Kojto 122:f9eeca106725 1578 * @note Preliminarily, DAC trigger must be set to software trigger
Kojto 122:f9eeca106725 1579 * using function @ref LL_DAC_SetTriggerSource()
Kojto 122:f9eeca106725 1580 * with parameter "LL_DAC_TRIGGER_SOFTWARE".
Kojto 122:f9eeca106725 1581 * and DAC trigger must be enabled using
Kojto 122:f9eeca106725 1582 * function @ref LL_DAC_EnableTrigger().
Kojto 122:f9eeca106725 1583 * @note For devices featuring DAC with 2 channels: this function
Kojto 122:f9eeca106725 1584 * can perform a SW start of both DAC channels simultaneously.
Kojto 122:f9eeca106725 1585 * Two channels can be selected as parameter.
Kojto 122:f9eeca106725 1586 * Example: (LL_DAC_CHANNEL_1 | LL_DAC_CHANNEL_2)
Kojto 122:f9eeca106725 1587 * @rmtoll SWTRIGR SWTRIG1 LL_DAC_TrigSWConversion\n
Kojto 122:f9eeca106725 1588 * SWTRIGR SWTRIG2 LL_DAC_TrigSWConversion
Kojto 122:f9eeca106725 1589 * @param DACx DAC instance
Kojto 122:f9eeca106725 1590 * @param DAC_Channel This parameter can a combination of the following values:
Kojto 122:f9eeca106725 1591 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1592 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1593 *
AnnaBridge 145:64910690c574 1594 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1595 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1596 * @retval None
Kojto 122:f9eeca106725 1597 */
Kojto 122:f9eeca106725 1598 __STATIC_INLINE void LL_DAC_TrigSWConversion(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1599 {
Kojto 122:f9eeca106725 1600 SET_BIT(DACx->SWTRIGR,
Kojto 122:f9eeca106725 1601 (DAC_Channel & DAC_SWTR_CHX_MASK));
Kojto 122:f9eeca106725 1602 }
Kojto 122:f9eeca106725 1603
Kojto 122:f9eeca106725 1604 /**
Kojto 122:f9eeca106725 1605 * @brief Set the data to be loaded in the data holding register
Kojto 122:f9eeca106725 1606 * in format 12 bits left alignment (LSB aligned on bit 0),
Kojto 122:f9eeca106725 1607 * for the selected DAC channel.
Kojto 122:f9eeca106725 1608 * @rmtoll DHR12R1 DACC1DHR LL_DAC_ConvertData12RightAligned\n
Kojto 122:f9eeca106725 1609 * DHR12R2 DACC2DHR LL_DAC_ConvertData12RightAligned
Kojto 122:f9eeca106725 1610 * @param DACx DAC instance
Kojto 122:f9eeca106725 1611 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1612 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1613 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1614 *
AnnaBridge 145:64910690c574 1615 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1616 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1617 * @param Data Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 122:f9eeca106725 1618 * @retval None
Kojto 122:f9eeca106725 1619 */
Kojto 122:f9eeca106725 1620 __STATIC_INLINE void LL_DAC_ConvertData12RightAligned(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t Data)
Kojto 122:f9eeca106725 1621 {
Kojto 122:f9eeca106725 1622 register uint32_t *preg = __DAC_PTR_REG_OFFSET(DACx->DHR12R1, __DAC_MASK_SHIFT(DAC_Channel, DAC_REG_DHR12RX_REGOFFSET_MASK));
Kojto 122:f9eeca106725 1623
Kojto 122:f9eeca106725 1624 MODIFY_REG(*preg,
Kojto 122:f9eeca106725 1625 DAC_DHR12R1_DACC1DHR,
Kojto 122:f9eeca106725 1626 Data);
Kojto 122:f9eeca106725 1627 }
Kojto 122:f9eeca106725 1628
Kojto 122:f9eeca106725 1629 /**
Kojto 122:f9eeca106725 1630 * @brief Set the data to be loaded in the data holding register
Kojto 122:f9eeca106725 1631 * in format 12 bits left alignment (MSB aligned on bit 15),
Kojto 122:f9eeca106725 1632 * for the selected DAC channel.
Kojto 122:f9eeca106725 1633 * @rmtoll DHR12L1 DACC1DHR LL_DAC_ConvertData12LeftAligned\n
Kojto 122:f9eeca106725 1634 * DHR12L2 DACC2DHR LL_DAC_ConvertData12LeftAligned
Kojto 122:f9eeca106725 1635 * @param DACx DAC instance
Kojto 122:f9eeca106725 1636 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1637 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1638 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1639 *
AnnaBridge 145:64910690c574 1640 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1641 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1642 * @param Data Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 122:f9eeca106725 1643 * @retval None
Kojto 122:f9eeca106725 1644 */
Kojto 122:f9eeca106725 1645 __STATIC_INLINE void LL_DAC_ConvertData12LeftAligned(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t Data)
Kojto 122:f9eeca106725 1646 {
Kojto 122:f9eeca106725 1647 register uint32_t *preg = __DAC_PTR_REG_OFFSET(DACx->DHR12R1, __DAC_MASK_SHIFT(DAC_Channel, DAC_REG_DHR12LX_REGOFFSET_MASK));
Kojto 122:f9eeca106725 1648
Kojto 122:f9eeca106725 1649 MODIFY_REG(*preg,
Kojto 122:f9eeca106725 1650 DAC_DHR12L1_DACC1DHR,
Kojto 122:f9eeca106725 1651 Data);
Kojto 122:f9eeca106725 1652 }
Kojto 122:f9eeca106725 1653
Kojto 122:f9eeca106725 1654 /**
Kojto 122:f9eeca106725 1655 * @brief Set the data to be loaded in the data holding register
Kojto 122:f9eeca106725 1656 * in format 8 bits left alignment (LSB aligned on bit 0),
Kojto 122:f9eeca106725 1657 * for the selected DAC channel.
Kojto 122:f9eeca106725 1658 * @rmtoll DHR8R1 DACC1DHR LL_DAC_ConvertData8RightAligned\n
Kojto 122:f9eeca106725 1659 * DHR8R2 DACC2DHR LL_DAC_ConvertData8RightAligned
Kojto 122:f9eeca106725 1660 * @param DACx DAC instance
Kojto 122:f9eeca106725 1661 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1662 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1663 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1664 *
AnnaBridge 145:64910690c574 1665 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1666 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1667 * @param Data Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 122:f9eeca106725 1668 * @retval None
Kojto 122:f9eeca106725 1669 */
Kojto 122:f9eeca106725 1670 __STATIC_INLINE void LL_DAC_ConvertData8RightAligned(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t Data)
Kojto 122:f9eeca106725 1671 {
Kojto 122:f9eeca106725 1672 register uint32_t *preg = __DAC_PTR_REG_OFFSET(DACx->DHR12R1, __DAC_MASK_SHIFT(DAC_Channel, DAC_REG_DHR8RX_REGOFFSET_MASK));
Kojto 122:f9eeca106725 1673
Kojto 122:f9eeca106725 1674 MODIFY_REG(*preg,
Kojto 122:f9eeca106725 1675 DAC_DHR8R1_DACC1DHR,
Kojto 122:f9eeca106725 1676 Data);
Kojto 122:f9eeca106725 1677 }
Kojto 122:f9eeca106725 1678
AnnaBridge 145:64910690c574 1679 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 122:f9eeca106725 1680 /**
Kojto 122:f9eeca106725 1681 * @brief Set the data to be loaded in the data holding register
Kojto 122:f9eeca106725 1682 * in format 12 bits left alignment (LSB aligned on bit 0),
Kojto 122:f9eeca106725 1683 * for both DAC channels.
Kojto 122:f9eeca106725 1684 * @rmtoll DHR12RD DACC1DHR LL_DAC_ConvertDualData12RightAligned\n
Kojto 122:f9eeca106725 1685 * DHR12RD DACC2DHR LL_DAC_ConvertDualData12RightAligned
Kojto 122:f9eeca106725 1686 * @param DACx DAC instance
Kojto 122:f9eeca106725 1687 * @param DataChannel1 Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 122:f9eeca106725 1688 * @param DataChannel2 Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 122:f9eeca106725 1689 * @retval None
Kojto 122:f9eeca106725 1690 */
Kojto 122:f9eeca106725 1691 __STATIC_INLINE void LL_DAC_ConvertDualData12RightAligned(DAC_TypeDef *DACx, uint32_t DataChannel1, uint32_t DataChannel2)
Kojto 122:f9eeca106725 1692 {
Kojto 122:f9eeca106725 1693 MODIFY_REG(DACx->DHR12RD,
Kojto 122:f9eeca106725 1694 (DAC_DHR12RD_DACC2DHR | DAC_DHR12RD_DACC1DHR),
Kojto 122:f9eeca106725 1695 ((DataChannel2 << DAC_DHR12RD_DACC2DHR_BITOFFSET_POS) | DataChannel1));
Kojto 122:f9eeca106725 1696 }
Kojto 122:f9eeca106725 1697
Kojto 122:f9eeca106725 1698 /**
Kojto 122:f9eeca106725 1699 * @brief Set the data to be loaded in the data holding register
Kojto 122:f9eeca106725 1700 * in format 12 bits left alignment (MSB aligned on bit 15),
Kojto 122:f9eeca106725 1701 * for both DAC channels.
Kojto 122:f9eeca106725 1702 * @rmtoll DHR12LD DACC1DHR LL_DAC_ConvertDualData12LeftAligned\n
Kojto 122:f9eeca106725 1703 * DHR12LD DACC2DHR LL_DAC_ConvertDualData12LeftAligned
Kojto 122:f9eeca106725 1704 * @param DACx DAC instance
Kojto 122:f9eeca106725 1705 * @param DataChannel1 Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 122:f9eeca106725 1706 * @param DataChannel2 Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 122:f9eeca106725 1707 * @retval None
Kojto 122:f9eeca106725 1708 */
Kojto 122:f9eeca106725 1709 __STATIC_INLINE void LL_DAC_ConvertDualData12LeftAligned(DAC_TypeDef *DACx, uint32_t DataChannel1, uint32_t DataChannel2)
Kojto 122:f9eeca106725 1710 {
Kojto 122:f9eeca106725 1711 /* Note: Data of DAC channel 2 shift value subtracted of 4 because */
Kojto 122:f9eeca106725 1712 /* data on 16 bits and DAC channel 2 bits field is on the 12 MSB, */
Kojto 122:f9eeca106725 1713 /* the 4 LSB must be taken into account for the shift value. */
Kojto 122:f9eeca106725 1714 MODIFY_REG(DACx->DHR12LD,
Kojto 122:f9eeca106725 1715 (DAC_DHR12LD_DACC2DHR | DAC_DHR12LD_DACC1DHR),
Kojto 122:f9eeca106725 1716 ((DataChannel2 << (DAC_DHR12LD_DACC2DHR_BITOFFSET_POS - 4U)) | DataChannel1));
Kojto 122:f9eeca106725 1717 }
Kojto 122:f9eeca106725 1718
Kojto 122:f9eeca106725 1719 /**
Kojto 122:f9eeca106725 1720 * @brief Set the data to be loaded in the data holding register
Kojto 122:f9eeca106725 1721 * in format 8 bits left alignment (LSB aligned on bit 0),
Kojto 122:f9eeca106725 1722 * for both DAC channels.
Kojto 122:f9eeca106725 1723 * @rmtoll DHR8RD DACC1DHR LL_DAC_ConvertDualData8RightAligned\n
Kojto 122:f9eeca106725 1724 * DHR8RD DACC2DHR LL_DAC_ConvertDualData8RightAligned
Kojto 122:f9eeca106725 1725 * @param DACx DAC instance
Kojto 122:f9eeca106725 1726 * @param DataChannel1 Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 122:f9eeca106725 1727 * @param DataChannel2 Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 122:f9eeca106725 1728 * @retval None
Kojto 122:f9eeca106725 1729 */
Kojto 122:f9eeca106725 1730 __STATIC_INLINE void LL_DAC_ConvertDualData8RightAligned(DAC_TypeDef *DACx, uint32_t DataChannel1, uint32_t DataChannel2)
Kojto 122:f9eeca106725 1731 {
Kojto 122:f9eeca106725 1732 MODIFY_REG(DACx->DHR8RD,
Kojto 122:f9eeca106725 1733 (DAC_DHR8RD_DACC2DHR | DAC_DHR8RD_DACC1DHR),
Kojto 122:f9eeca106725 1734 ((DataChannel2 << DAC_DHR8RD_DACC2DHR_BITOFFSET_POS) | DataChannel1));
Kojto 122:f9eeca106725 1735 }
Kojto 122:f9eeca106725 1736
AnnaBridge 145:64910690c574 1737 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 122:f9eeca106725 1738 /**
Kojto 122:f9eeca106725 1739 * @brief Retrieve output data currently generated for the selected DAC channel.
Kojto 122:f9eeca106725 1740 * @note Whatever alignment and resolution settings
Kojto 122:f9eeca106725 1741 * (using functions "LL_DAC_ConvertData{8; 12}{Right; Left} Aligned()":
Kojto 122:f9eeca106725 1742 * @ref LL_DAC_ConvertData12RightAligned(), ...),
Kojto 122:f9eeca106725 1743 * output data format is 12 bits right aligned (LSB aligned on bit 0).
Kojto 122:f9eeca106725 1744 * @rmtoll DOR1 DACC1DOR LL_DAC_RetrieveOutputData\n
Kojto 122:f9eeca106725 1745 * DOR2 DACC2DOR LL_DAC_RetrieveOutputData
Kojto 122:f9eeca106725 1746 * @param DACx DAC instance
Kojto 122:f9eeca106725 1747 * @param DAC_Channel This parameter can be one of the following values:
Kojto 122:f9eeca106725 1748 * @arg @ref LL_DAC_CHANNEL_1
AnnaBridge 145:64910690c574 1749 * @arg @ref LL_DAC_CHANNEL_2 (1)
AnnaBridge 145:64910690c574 1750 *
AnnaBridge 145:64910690c574 1751 * (1) On this STM32 serie, parameter not available on all devices.
AnnaBridge 145:64910690c574 1752 * Refer to device datasheet for channels availability.
Kojto 122:f9eeca106725 1753 * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 122:f9eeca106725 1754 */
Kojto 122:f9eeca106725 1755 __STATIC_INLINE uint32_t LL_DAC_RetrieveOutputData(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Kojto 122:f9eeca106725 1756 {
Kojto 122:f9eeca106725 1757 register uint32_t *preg = __DAC_PTR_REG_OFFSET(DACx->DOR1, __DAC_MASK_SHIFT(DAC_Channel, DAC_REG_DORX_REGOFFSET_MASK));
Kojto 122:f9eeca106725 1758
Kojto 122:f9eeca106725 1759 return (uint16_t) READ_BIT(*preg, DAC_DOR1_DACC1DOR);
Kojto 122:f9eeca106725 1760 }
Kojto 122:f9eeca106725 1761
Kojto 122:f9eeca106725 1762 /**
Kojto 122:f9eeca106725 1763 * @}
Kojto 122:f9eeca106725 1764 */
Kojto 122:f9eeca106725 1765
Kojto 122:f9eeca106725 1766 /** @defgroup DAC_LL_EF_FLAG_Management FLAG Management
Kojto 122:f9eeca106725 1767 * @{
Kojto 122:f9eeca106725 1768 */
Kojto 122:f9eeca106725 1769 /**
Kojto 122:f9eeca106725 1770 * @brief Get DAC calibration offset flag for DAC channel 1
Kojto 122:f9eeca106725 1771 * @rmtoll SR CAL_FLAG1 LL_DAC_IsActiveFlag_CAL1
Kojto 122:f9eeca106725 1772 * @param DACx DAC instance
Kojto 122:f9eeca106725 1773 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 1774 */
Kojto 122:f9eeca106725 1775 __STATIC_INLINE uint32_t LL_DAC_IsActiveFlag_CAL1(DAC_TypeDef *DACx)
Kojto 122:f9eeca106725 1776 {
Kojto 122:f9eeca106725 1777 return (READ_BIT(DACx->SR, LL_DAC_FLAG_CAL1) == (LL_DAC_FLAG_CAL1));
Kojto 122:f9eeca106725 1778 }
Kojto 122:f9eeca106725 1779
AnnaBridge 145:64910690c574 1780 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 122:f9eeca106725 1781 /**
Kojto 122:f9eeca106725 1782 * @brief Get DAC calibration offset flag for DAC channel 2
Kojto 122:f9eeca106725 1783 * @rmtoll SR CAL_FLAG2 LL_DAC_IsActiveFlag_CAL2
Kojto 122:f9eeca106725 1784 * @param DACx DAC instance
Kojto 122:f9eeca106725 1785 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 1786 */
Kojto 122:f9eeca106725 1787 __STATIC_INLINE uint32_t LL_DAC_IsActiveFlag_CAL2(DAC_TypeDef *DACx)
Kojto 122:f9eeca106725 1788 {
Kojto 122:f9eeca106725 1789 return (READ_BIT(DACx->SR, LL_DAC_FLAG_CAL2) == (LL_DAC_FLAG_CAL2));
Kojto 122:f9eeca106725 1790 }
Kojto 122:f9eeca106725 1791
AnnaBridge 145:64910690c574 1792 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 122:f9eeca106725 1793 /**
Kojto 122:f9eeca106725 1794 * @brief Get DAC busy writing sample time flag for DAC channel 1
Kojto 122:f9eeca106725 1795 * @rmtoll SR BWST1 LL_DAC_IsActiveFlag_BWST1
Kojto 122:f9eeca106725 1796 * @param DACx DAC instance
Kojto 122:f9eeca106725 1797 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 1798 */
Kojto 122:f9eeca106725 1799 __STATIC_INLINE uint32_t LL_DAC_IsActiveFlag_BWST1(DAC_TypeDef *DACx)
Kojto 122:f9eeca106725 1800 {
Kojto 122:f9eeca106725 1801 return (READ_BIT(DACx->SR, LL_DAC_FLAG_BWST1) == (LL_DAC_FLAG_BWST1));
Kojto 122:f9eeca106725 1802 }
Kojto 122:f9eeca106725 1803
AnnaBridge 145:64910690c574 1804 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 122:f9eeca106725 1805 /**
Kojto 122:f9eeca106725 1806 * @brief Get DAC busy writing sample time flag for DAC channel 2
Kojto 122:f9eeca106725 1807 * @rmtoll SR BWST2 LL_DAC_IsActiveFlag_BWST2
Kojto 122:f9eeca106725 1808 * @param DACx DAC instance
Kojto 122:f9eeca106725 1809 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 1810 */
Kojto 122:f9eeca106725 1811 __STATIC_INLINE uint32_t LL_DAC_IsActiveFlag_BWST2(DAC_TypeDef *DACx)
Kojto 122:f9eeca106725 1812 {
Kojto 122:f9eeca106725 1813 return (READ_BIT(DACx->SR, LL_DAC_FLAG_BWST2) == (LL_DAC_FLAG_BWST2));
Kojto 122:f9eeca106725 1814 }
Kojto 122:f9eeca106725 1815
AnnaBridge 145:64910690c574 1816 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 122:f9eeca106725 1817 /**
Kojto 122:f9eeca106725 1818 * @brief Get DAC underrun flag for DAC channel 1
Kojto 122:f9eeca106725 1819 * @rmtoll SR DMAUDR1 LL_DAC_IsActiveFlag_DMAUDR1
Kojto 122:f9eeca106725 1820 * @param DACx DAC instance
Kojto 122:f9eeca106725 1821 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 1822 */
Kojto 122:f9eeca106725 1823 __STATIC_INLINE uint32_t LL_DAC_IsActiveFlag_DMAUDR1(DAC_TypeDef *DACx)
Kojto 122:f9eeca106725 1824 {
Kojto 122:f9eeca106725 1825 return (READ_BIT(DACx->SR, LL_DAC_FLAG_DMAUDR1) == (LL_DAC_FLAG_DMAUDR1));
Kojto 122:f9eeca106725 1826 }
Kojto 122:f9eeca106725 1827
AnnaBridge 145:64910690c574 1828 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 122:f9eeca106725 1829 /**
Kojto 122:f9eeca106725 1830 * @brief Get DAC underrun flag for DAC channel 2
Kojto 122:f9eeca106725 1831 * @rmtoll SR DMAUDR2 LL_DAC_IsActiveFlag_DMAUDR2
Kojto 122:f9eeca106725 1832 * @param DACx DAC instance
Kojto 122:f9eeca106725 1833 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 1834 */
Kojto 122:f9eeca106725 1835 __STATIC_INLINE uint32_t LL_DAC_IsActiveFlag_DMAUDR2(DAC_TypeDef *DACx)
Kojto 122:f9eeca106725 1836 {
Kojto 122:f9eeca106725 1837 return (READ_BIT(DACx->SR, LL_DAC_FLAG_DMAUDR2) == (LL_DAC_FLAG_DMAUDR2));
Kojto 122:f9eeca106725 1838 }
AnnaBridge 145:64910690c574 1839 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 122:f9eeca106725 1840
Kojto 122:f9eeca106725 1841 /**
Kojto 122:f9eeca106725 1842 * @brief Clear DAC underrun flag for DAC channel 1
Kojto 122:f9eeca106725 1843 * @rmtoll SR DMAUDR1 LL_DAC_ClearFlag_DMAUDR1
Kojto 122:f9eeca106725 1844 * @param DACx DAC instance
Kojto 122:f9eeca106725 1845 * @retval None
Kojto 122:f9eeca106725 1846 */
Kojto 122:f9eeca106725 1847 __STATIC_INLINE void LL_DAC_ClearFlag_DMAUDR1(DAC_TypeDef *DACx)
Kojto 122:f9eeca106725 1848 {
Kojto 122:f9eeca106725 1849 WRITE_REG(DACx->SR, LL_DAC_FLAG_DMAUDR1);
Kojto 122:f9eeca106725 1850 }
Kojto 122:f9eeca106725 1851
AnnaBridge 145:64910690c574 1852 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 122:f9eeca106725 1853 /**
Kojto 122:f9eeca106725 1854 * @brief Clear DAC underrun flag for DAC channel 2
Kojto 122:f9eeca106725 1855 * @rmtoll SR DMAUDR2 LL_DAC_ClearFlag_DMAUDR2
Kojto 122:f9eeca106725 1856 * @param DACx DAC instance
Kojto 122:f9eeca106725 1857 * @retval None
Kojto 122:f9eeca106725 1858 */
Kojto 122:f9eeca106725 1859 __STATIC_INLINE void LL_DAC_ClearFlag_DMAUDR2(DAC_TypeDef *DACx)
Kojto 122:f9eeca106725 1860 {
Kojto 122:f9eeca106725 1861 WRITE_REG(DACx->SR, LL_DAC_FLAG_DMAUDR2);
Kojto 122:f9eeca106725 1862 }
AnnaBridge 145:64910690c574 1863 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 122:f9eeca106725 1864
Kojto 122:f9eeca106725 1865 /**
Kojto 122:f9eeca106725 1866 * @}
Kojto 122:f9eeca106725 1867 */
Kojto 122:f9eeca106725 1868
Kojto 122:f9eeca106725 1869 /** @defgroup DAC_LL_EF_IT_Management IT management
Kojto 122:f9eeca106725 1870 * @{
Kojto 122:f9eeca106725 1871 */
Kojto 122:f9eeca106725 1872
Kojto 122:f9eeca106725 1873 /**
Kojto 122:f9eeca106725 1874 * @brief Enable DMA underrun interrupt for DAC channel 1
Kojto 122:f9eeca106725 1875 * @rmtoll CR DMAUDRIE1 LL_DAC_EnableIT_DMAUDR1
Kojto 122:f9eeca106725 1876 * @param DACx DAC instance
Kojto 122:f9eeca106725 1877 * @retval None
Kojto 122:f9eeca106725 1878 */
Kojto 122:f9eeca106725 1879 __STATIC_INLINE void LL_DAC_EnableIT_DMAUDR1(DAC_TypeDef *DACx)
Kojto 122:f9eeca106725 1880 {
Kojto 122:f9eeca106725 1881 SET_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE1);
Kojto 122:f9eeca106725 1882 }
Kojto 122:f9eeca106725 1883
AnnaBridge 145:64910690c574 1884 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 122:f9eeca106725 1885 /**
Kojto 122:f9eeca106725 1886 * @brief Enable DMA underrun interrupt for DAC channel 2
Kojto 122:f9eeca106725 1887 * @rmtoll CR DMAUDRIE2 LL_DAC_EnableIT_DMAUDR2
Kojto 122:f9eeca106725 1888 * @param DACx DAC instance
Kojto 122:f9eeca106725 1889 * @retval None
Kojto 122:f9eeca106725 1890 */
Kojto 122:f9eeca106725 1891 __STATIC_INLINE void LL_DAC_EnableIT_DMAUDR2(DAC_TypeDef *DACx)
Kojto 122:f9eeca106725 1892 {
Kojto 122:f9eeca106725 1893 SET_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE2);
Kojto 122:f9eeca106725 1894 }
AnnaBridge 145:64910690c574 1895 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 122:f9eeca106725 1896
Kojto 122:f9eeca106725 1897 /**
Kojto 122:f9eeca106725 1898 * @brief Disable DMA underrun interrupt for DAC channel 1
Kojto 122:f9eeca106725 1899 * @rmtoll CR DMAUDRIE1 LL_DAC_DisableIT_DMAUDR1
Kojto 122:f9eeca106725 1900 * @param DACx DAC instance
Kojto 122:f9eeca106725 1901 * @retval None
Kojto 122:f9eeca106725 1902 */
Kojto 122:f9eeca106725 1903 __STATIC_INLINE void LL_DAC_DisableIT_DMAUDR1(DAC_TypeDef *DACx)
Kojto 122:f9eeca106725 1904 {
Kojto 122:f9eeca106725 1905 CLEAR_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE1);
Kojto 122:f9eeca106725 1906 }
Kojto 122:f9eeca106725 1907
AnnaBridge 145:64910690c574 1908 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 122:f9eeca106725 1909 /**
Kojto 122:f9eeca106725 1910 * @brief Disable DMA underrun interrupt for DAC channel 2
Kojto 122:f9eeca106725 1911 * @rmtoll CR DMAUDRIE2 LL_DAC_DisableIT_DMAUDR2
Kojto 122:f9eeca106725 1912 * @param DACx DAC instance
Kojto 122:f9eeca106725 1913 * @retval None
Kojto 122:f9eeca106725 1914 */
Kojto 122:f9eeca106725 1915 __STATIC_INLINE void LL_DAC_DisableIT_DMAUDR2(DAC_TypeDef *DACx)
Kojto 122:f9eeca106725 1916 {
Kojto 122:f9eeca106725 1917 CLEAR_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE2);
Kojto 122:f9eeca106725 1918 }
AnnaBridge 145:64910690c574 1919 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 122:f9eeca106725 1920
Kojto 122:f9eeca106725 1921 /**
Kojto 122:f9eeca106725 1922 * @brief Get DMA underrun interrupt for DAC channel 1
Kojto 122:f9eeca106725 1923 * @rmtoll CR DMAUDRIE1 LL_DAC_IsEnabledIT_DMAUDR1
Kojto 122:f9eeca106725 1924 * @param DACx DAC instance
Kojto 122:f9eeca106725 1925 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 1926 */
Kojto 122:f9eeca106725 1927 __STATIC_INLINE uint32_t LL_DAC_IsEnabledIT_DMAUDR1(DAC_TypeDef *DACx)
Kojto 122:f9eeca106725 1928 {
Kojto 122:f9eeca106725 1929 return (READ_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE1) == (LL_DAC_IT_DMAUDRIE1));
Kojto 122:f9eeca106725 1930 }
Kojto 122:f9eeca106725 1931
AnnaBridge 145:64910690c574 1932 #if defined(DAC_CHANNEL2_SUPPORT)
Kojto 122:f9eeca106725 1933 /**
Kojto 122:f9eeca106725 1934 * @brief Get DMA underrun interrupt for DAC channel 2
Kojto 122:f9eeca106725 1935 * @rmtoll CR DMAUDRIE2 LL_DAC_IsEnabledIT_DMAUDR2
Kojto 122:f9eeca106725 1936 * @param DACx DAC instance
Kojto 122:f9eeca106725 1937 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 1938 */
Kojto 122:f9eeca106725 1939 __STATIC_INLINE uint32_t LL_DAC_IsEnabledIT_DMAUDR2(DAC_TypeDef *DACx)
Kojto 122:f9eeca106725 1940 {
Kojto 122:f9eeca106725 1941 return (READ_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE2) == (LL_DAC_IT_DMAUDRIE2));
Kojto 122:f9eeca106725 1942 }
AnnaBridge 145:64910690c574 1943 #endif /* DAC_CHANNEL2_SUPPORT */
Kojto 122:f9eeca106725 1944
Kojto 122:f9eeca106725 1945 /**
Kojto 122:f9eeca106725 1946 * @}
Kojto 122:f9eeca106725 1947 */
Kojto 122:f9eeca106725 1948
Kojto 122:f9eeca106725 1949 #if defined(USE_FULL_LL_DRIVER)
Kojto 122:f9eeca106725 1950 /** @defgroup DAC_LL_EF_Init Initialization and de-initialization functions
Kojto 122:f9eeca106725 1951 * @{
Kojto 122:f9eeca106725 1952 */
Kojto 122:f9eeca106725 1953
Kojto 122:f9eeca106725 1954 ErrorStatus LL_DAC_DeInit(DAC_TypeDef* DACx);
Kojto 122:f9eeca106725 1955 ErrorStatus LL_DAC_Init(DAC_TypeDef* DACx, uint32_t DAC_Channel, LL_DAC_InitTypeDef* DAC_InitStruct);
Kojto 122:f9eeca106725 1956 void LL_DAC_StructInit(LL_DAC_InitTypeDef* DAC_InitStruct);
Kojto 122:f9eeca106725 1957
Kojto 122:f9eeca106725 1958 /**
Kojto 122:f9eeca106725 1959 * @}
Kojto 122:f9eeca106725 1960 */
Kojto 122:f9eeca106725 1961 #endif /* USE_FULL_LL_DRIVER */
Kojto 122:f9eeca106725 1962
Kojto 122:f9eeca106725 1963 /**
Kojto 122:f9eeca106725 1964 * @}
Kojto 122:f9eeca106725 1965 */
Kojto 122:f9eeca106725 1966
Kojto 122:f9eeca106725 1967 /**
Kojto 122:f9eeca106725 1968 * @}
Kojto 122:f9eeca106725 1969 */
Kojto 122:f9eeca106725 1970
Kojto 122:f9eeca106725 1971 #endif /* DAC1 */
Kojto 122:f9eeca106725 1972
Kojto 122:f9eeca106725 1973 /**
Kojto 122:f9eeca106725 1974 * @}
Kojto 122:f9eeca106725 1975 */
Kojto 122:f9eeca106725 1976
Kojto 122:f9eeca106725 1977 #ifdef __cplusplus
Kojto 122:f9eeca106725 1978 }
Kojto 122:f9eeca106725 1979 #endif
Kojto 122:f9eeca106725 1980
Kojto 122:f9eeca106725 1981 #endif /* __STM32L4xx_LL_DAC_H */
Kojto 122:f9eeca106725 1982
Kojto 122:f9eeca106725 1983 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/