Amit Gandhi / sensen_copy_2

Fork of mbed-dev by mbed official

Committer:
Kojto
Date:
Tue Feb 14 14:44:10 2017 +0000
Revision:
158:b23ee177fd68
This updates the lib to the mbed lib v136

Who changed what in which revision?

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