Merge pull request #11189 from klutvott123/move-telemetry-displayport-init
[betaflight.git] / lib / main / STM32G4 / Drivers / STM32G4xx_HAL_Driver / Inc / stm32g4xx_ll_opamp.h
blobf36e1c96651798b45014070ca7f06d96428cce2f
1 /**
2 ******************************************************************************
3 * @file stm32g4xx_ll_opamp.h
4 * @author MCD Application Team
5 * @brief Header file of OPAMP LL module.
6 ******************************************************************************
7 * @attention
9 * <h2><center>&copy; Copyright (c) 2018 STMicroelectronics.
10 * All rights reserved.</center></h2>
12 * This software component is licensed by ST under BSD 3-Clause license,
13 * the "License"; You may not use this file except in compliance with the
14 * License. You may obtain a copy of the License at:
15 * opensource.org/licenses/BSD-3-Clause
17 ******************************************************************************
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef STM32G4xx_LL_OPAMP_H
22 #define STM32G4xx_LL_OPAMP_H
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32g4xx.h"
31 /** @addtogroup STM32G4xx_LL_Driver
32 * @{
35 #if defined (OPAMP1) || defined (OPAMP2) || defined (OPAMP3) || defined (OPAMP4) || defined (OPAMP5) || defined (OPAMP6)
37 /** @defgroup OPAMP_LL OPAMP
38 * @{
41 /* Private types -------------------------------------------------------------*/
42 /* Private variables ---------------------------------------------------------*/
44 /* Private constants ---------------------------------------------------------*/
45 /** @defgroup OPAMP_LL_Private_Constants OPAMP Private Constants
46 * @{
49 /* Internal mask for OPAMP trimming of transistors differential pair NMOS */
50 /* or PMOS. */
51 /* To select into literal LL_OPAMP_TRIMMING_x the relevant bits for: */
52 /* - OPAMP trimming selection of transistors differential pair */
53 /* - OPAMP trimming values of transistors differential pair */
54 #define OPAMP_TRIMMING_SELECT_MASK (OPAMP_CSR_CALSEL)
55 #define OPAMP_TRIMMING_VALUE_MASK (OPAMP_CSR_TRIMOFFSETN | OPAMP_CSR_TRIMOFFSETP)
57 /**
58 * @}
62 /* Private macros ------------------------------------------------------------*/
63 /** @defgroup OPAMP_LL_Private_Macros OPAMP Private Macros
64 * @{
67 /**
68 * @brief Driver macro reserved for internal use: set a pointer to
69 * a register from a register basis from which an offset
70 * is applied.
71 * @param __REG__ Register basis from which the offset is applied.
72 * @param __REG_OFFSET__ Offset to be applied (unit: number of registers).
73 * @retval Register address
75 #define __OPAMP_PTR_REG_OFFSET(__REG__, __REG_OFFSET__) \
76 ((uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFSET__) << 2))))
81 /**
82 * @}
86 /* Exported types ------------------------------------------------------------*/
87 #if defined(USE_FULL_LL_DRIVER)
88 /** @defgroup OPAMP_LL_ES_INIT OPAMP Exported Init structure
89 * @{
92 /**
93 * @brief Structure definition of some features of OPAMP instance.
95 typedef struct
97 uint32_t PowerMode; /*!< Set OPAMP power mode.
98 This parameter can be a value of @ref OPAMP_LL_EC_POWERMODE
100 This feature can be modified afterwards using unitary function @ref LL_OPAMP_SetPowerMode(). */
103 uint32_t FunctionalMode; /*!< Set OPAMP functional mode by setting internal connections: OPAMP operation in standalone, follower, ...
104 This parameter can be a value of @ref OPAMP_LL_EC_FUNCTIONAL_MODE
105 @note If OPAMP is configured in mode PGA, the gain can be configured using function @ref LL_OPAMP_SetPGAGain().
107 This feature can be modified afterwards using unitary function @ref LL_OPAMP_SetFunctionalMode(). */
109 uint32_t InputNonInverting; /*!< Set OPAMP input non-inverting connection.
110 This parameter can be a value of @ref OPAMP_LL_EC_INPUT_NONINVERTING
112 This feature can be modified afterwards using unitary function @ref LL_OPAMP_SetInputNonInverting(). */
114 uint32_t InputInverting; /*!< Set OPAMP inverting input connection.
115 This parameter can be a value of @ref OPAMP_LL_EC_INPUT_INVERTING
116 @note OPAMP inverting input is used with OPAMP in mode standalone or PGA with external capacitors for filtering circuit. Otherwise (OPAMP in mode follower), OPAMP inverting input is not used (not connected to GPIO pin), this parameter is discarded.
118 This feature can be modified afterwards using unitary function @ref LL_OPAMP_SetInputInverting(). */
120 } LL_OPAMP_InitTypeDef;
123 * @}
125 #endif /* USE_FULL_LL_DRIVER */
127 /* Exported constants --------------------------------------------------------*/
128 /** @defgroup OPAMP_LL_Exported_Constants OPAMP Exported Constants
129 * @{
132 /** @defgroup OPAMP_LL_EC_MODE OPAMP mode calibration or functional.
133 * @{
135 #define LL_OPAMP_MODE_FUNCTIONAL (0x00000000UL) /*!< OPAMP functional mode */
136 #define LL_OPAMP_MODE_CALIBRATION (OPAMP_CSR_CALON) /*!< OPAMP calibration mode */
138 * @}
141 /** @defgroup OPAMP_LL_EC_FUNCTIONAL_MODE OPAMP functional mode
142 * @{
144 #define LL_OPAMP_MODE_STANDALONE (0x00000000UL) /*!< OPAMP functional mode, OPAMP operation in standalone */
145 #define LL_OPAMP_MODE_FOLLOWER (OPAMP_CSR_VMSEL_1 | OPAMP_CSR_VMSEL_0) /*!< OPAMP functional mode, OPAMP operation in follower */
146 #define LL_OPAMP_MODE_PGA (OPAMP_CSR_VMSEL_1) /*!< OPAMP functional mode, OPAMP operation in PGA */
147 #define LL_OPAMP_MODE_PGA_IO0 (OPAMP_CSR_PGGAIN_4|OPAMP_CSR_VMSEL_1) /*!< In PGA mode, the inverting input is connected to VINM0 for filtering */
148 #define LL_OPAMP_MODE_PGA_IO0_BIAS (OPAMP_CSR_PGGAIN_3|OPAMP_CSR_VMSEL_1) /*!< In PGA mode, the inverting input is connected to VINM0
149 - Input signal on VINM0, bias on VINPx: negative gain
150 - Bias on VINM0, input signal on VINPx: positive gain */
151 #define LL_OPAMP_MODE_PGA_IO0_IO1_BIAS (OPAMP_CSR_PGGAIN_4|OPAMP_CSR_PGGAIN_3|OPAMP_CSR_VMSEL_1) /*!< In PGA mode, the inverting input is connected to VINM0
152 - Input signal on VINM0, bias on VINPx: negative gain
153 - Bias on VINM0, input signal on VINPx: positive gain
154 And VINM1 is connected too for filtering */
157 * @}
160 /** @defgroup OPAMP_LL_EC_MODE_PGA_GAIN OPAMP PGA gain (relevant when OPAMP is in functional mode PGA)
161 * @note Gain sign:
162 * - is positive if the @ref OPAMP_LL_EC_FUNCTIONAL_MODE configuration is
163 * @ref LL_OPAMP_MODE_PGA or LL_OPAMP_MODE_PGA_IO0
164 * - may be positive or negative if the @ref OPAMP_LL_EC_FUNCTIONAL_MODE configuration is
165 * @ref LL_OPAMP_MODE_PGA_IO0_BIAS or LL_OPAMP_MODE_PGA_IO0_IO1_BIAS
166 * see @ref OPAMP_LL_EC_FUNCTIONAL_MODE for more details
167 * @{
169 #define LL_OPAMP_PGA_GAIN_2_OR_MINUS_1 (0x00000000UL) /*!< OPAMP PGA gain 2 or -1 */
170 #define LL_OPAMP_PGA_GAIN_4_OR_MINUS_3 ( OPAMP_CSR_PGGAIN_0) /*!< OPAMP PGA gain 4 or -3 */
171 #define LL_OPAMP_PGA_GAIN_8_OR_MINUS_7 ( OPAMP_CSR_PGGAIN_1 ) /*!< OPAMP PGA gain 8 or -7 */
172 #define LL_OPAMP_PGA_GAIN_16_OR_MINUS_15 ( OPAMP_CSR_PGGAIN_1 | OPAMP_CSR_PGGAIN_0) /*!< OPAMP PGA gain 16 or -15 */
173 #define LL_OPAMP_PGA_GAIN_32_OR_MINUS_31 (OPAMP_CSR_PGGAIN_2 ) /*!< OPAMP PGA gain 32 or -31 */
174 #define LL_OPAMP_PGA_GAIN_64_OR_MINUS_63 (OPAMP_CSR_PGGAIN_2 | OPAMP_CSR_PGGAIN_0) /*!< OPAMP PGA gain 64 or -63 */
176 * @}
179 /** @defgroup OPAMP_LL_EC_INPUT_NONINVERTING OPAMP input non-inverting
180 * @{
182 #define LL_OPAMP_INPUT_NONINVERT_IO0 (0x00000000UL) /*!< OPAMP non inverting input connected to I/O VINP0
183 (PA1 for OPAMP1, PA7 for OPAMP2, PB0 for OPAMP3, PB13 for OPAMP4, PB14 for OPAMP5, PB12 for OPAMP6)
184 Note: On this STM32 serie, all OPAMPx are not available on all devices. Refer to device datasheet for more details */
185 #define LL_OPAMP_INPUT_NONINVERT_IO1 OPAMP_CSR_VPSEL_0 /*!< OPAMP non inverting input connected to I/O VINP1
186 (PA3 for OPAMP1, PB14 for OPAMP2, PB13 for OPAMP3, PD11 for OPAMP4, PD12 for OPAMP5, PD9 for OPAMP6)
187 Note: On this STM32 serie, all OPAMPx are not available on all devices. Refer to device datasheet for more details */
188 #define LL_OPAMP_INPUT_NONINVERT_IO2 OPAMP_CSR_VPSEL_1 /*!< OPAMP non inverting input connected to I/O VINP2
189 (PA7 for OPAMP1, PB0 for OPAMP2, PA1 for OPAMP3, PB11 for OPAMP4, PC3 for OPAMP5, PB13 for OPAMP6)
190 Note: On this STM32 serie, all OPAMPx are not available on all devices. Refer to device datasheet for more details */
191 #define LL_OPAMP_INPUT_NONINVERT_IO3 OPAMP_CSR_VPSEL /*!< OPAMP non inverting input connected to I/O VINP3
192 (PD14 for OPAMP2) */
193 #define LL_OPAMP_INPUT_NONINVERT_DAC OPAMP_CSR_VPSEL /*!< OPAMP non inverting input connected internally to DAC channel
194 (DAC3_CH1 for OPAMP1, DAC3_CH2 for OPAMP3, DAC4_CH1 for OPAMP4, DAC4_CH2 for OPAMP5, DAC3_CH1 for OPAMP6)
195 Note: On this STM32 serie, all OPAMPx are not available on all devices. Refer to device datasheet for more details */
197 * @}
200 /** @defgroup OPAMP_LL_EC_INPUT_INVERTING OPAMP input inverting
201 * @note OPAMP inverting input is used with OPAMP in mode standalone or PGA with negative gain or bias.
202 * Otherwise (OPAMP in mode follower), OPAMP inverting input is not used (not connected to GPIO pin).
203 * @{
205 #define LL_OPAMP_INPUT_INVERT_IO0 (0x00000000UL) /*!< OPAMP inverting input connected to I/O VINM0
206 (PA3 for OPAMP1, PA5 for OPAMP2, PB2 for OPAMP3, PB10 for OPAMP4, PB15 for OPAMP5, PA1 for OPAMP6)
207 Note: On this STM32 serie, all OPAMPx are not available on all devices. Refer to device datasheet for more details */
208 #define LL_OPAMP_INPUT_INVERT_IO1 OPAMP_CSR_VMSEL_0 /*!< OPAMP inverting input connected to I/0 VINM1
209 (PC5 for OPAMP1, PC5 for OPAMP2, PB10 for OPAMP3, PB8 for OPAMP4, PA3 for OPAMP5, PB1 for OPAMP6)
210 Note: On this STM32 serie, all OPAMPx are not available on all devices. Refer to device datasheet for more details */
211 #define LL_OPAMP_INPUT_INVERT_CONNECT_NO OPAMP_CSR_VMSEL_1 /*!< OPAMP inverting input not externally connected (intended for OPAMP in mode follower or PGA with positive gain without bias).
212 Note: On this STM32 serie, this literal include cases of value 0x11 for mode follower and value 0x10 for mode PGA. */
214 * @}
217 /** @defgroup OPAMP_LL_EC_INPUT_NONINVERTING_SECONDARY OPAMP input non-inverting secondary
218 * @{
220 #define LL_OPAMP_INPUT_NONINVERT_IO0_SEC (0x00000000UL) /*!< OPAMP secondary non inverting input connected to I/O VINP0
221 (PA1 for OPAMP1, PA7 for OPAMP2, PB0 for OPAMP3, PB13 for OPAMP4, PB14 for OPAMP5, PB12 for OPAMP6)
222 Note: On this STM32 serie, all OPAMPx are not available on all devices. Refer to device datasheet for more details */
223 #define LL_OPAMP_INPUT_NONINVERT_IO1_SEC OPAMP_TCMR_VPSSEL_0 /*!< OPAMP secondary non inverting input connected to I/O VINP1
224 (PA3 for OPAMP1, PB14 for OPAMP2, PB13 for OPAMP3, PD11 for OPAMP4, PD12 for OPAMP5, PD9 for OPAMP6)
225 Note: On this STM32 serie, all OPAMPx are not available on all devices. Refer to device datasheet for more details */
226 #define LL_OPAMP_INPUT_NONINVERT_IO2_SEC OPAMP_TCMR_VPSSEL_1 /*!< OPAMP secondary non inverting input connected to I/O VINP2
227 (PA7 for OPAMP1, PB0 for OPAMP2, PA1 for OPAMP3, PB11 for OPAMP4, PC3 for OPAMP5, PB13 for OPAMP6)
228 Note: On this STM32 serie, all OPAMPx are not available on all devices. Refer to device datasheet for more details */
229 #define LL_OPAMP_INPUT_NONINVERT_IO3_SEC OPAMP_TCMR_VPSSEL /*!< OPAMP secondary non inverting input connected to I/O VINP3
230 (PD14 for OPAMP2) */
231 #define LL_OPAMP_INPUT_NONINVERT_DAC_SEC OPAMP_TCMR_VPSSEL /*!< OPAMP secondary non inverting input connected internally to DAC channel
232 (DAC3_CH1 for OPAMP1, DAC3_CH2 for OPAMP3, DAC4_CH1 for OPAMP4, DAC4_CH2 for OPAMP5, DAC3_CH1 for OPAMP6)
233 Note: On this STM32 serie, all OPAMPx are not available on all devices. Refer to device datasheet for more details */
235 * @}
238 /** @defgroup OPAMP_LL_EC_INPUT_INVERTING_SECONDARY OPAMP input inverting secondary
239 * @note OPAMP inverting input is used with OPAMP in mode standalone or PGA with negative gain or bias.
240 * Otherwise (OPAMP in mode follower), OPAMP inverting input is not used (not connected to GPIO pin).
241 * @{
243 #define LL_OPAMP_INPUT_INVERT_IO0_SEC (0x00000000UL) /*!< OPAMP secondary mode is standalone mode - Only applicable if @ref LL_OPAMP_MODE_STANDALONE
244 has been configured by call to @ref LL_OPAMP_Init() or @ref LL_OPAMP_SetFunctionalMode().
245 OPAMP secondary inverting input connected to I/O VINM0.
246 (PA3 for OPAMP1, PA5 for OPAMP2, PB2 for OPAMP3, PB10 for OPAMP4, PB15 for OPAMP5, PA1 for OPAMP6)
247 Note: On this STM32 serie, all OPAMPx are not available on all devices. Refer to device datasheet for more details */
248 #define LL_OPAMP_INPUT_INVERT_IO1_SEC OPAMP_TCMR_VMSSEL /*!< OPAMP secondary mode is standalone mode - Only applicable if @ref LL_OPAMP_MODE_STANDALONE
249 has been configured by call to @ref LL_OPAMP_Init() or @ref LL_OPAMP_SetFunctionalMode().
250 OPAMP secondary inverting input connected to I/0 VINM1
251 (PC5 for OPAMP1, PC5 for OPAMP2, PB10 for OPAMP3, PB8 for OPAMP4, PA3 for OPAMP5, PB1 for OPAMP6)
252 Note: On this STM32 serie, all OPAMPx are not available on all devices. Refer to device datasheet for more details */
253 #define LL_OPAMP_INPUT_INVERT_PGA_SEC (0x00000000UL) /*!< OPAMP secondary mode is PGA mode - Only applicable if configured mode through call to @ref LL_OPAMP_Init()
254 or @ref LL_OPAMP_SetFunctionalMode() is NOT @ref LL_OPAMP_MODE_STANDALONE.
255 OPAMP secondary inverting input is:
256 - Not connected if configured mode is @ref LL_OPAMP_MODE_FOLLOWER or @ref LL_OPAMP_MODE_PGA
257 - Connected to VINM0 and possibly VINM1 if any of the other modes as been configured
258 (see @ref OPAMP_LL_EC_FUNCTIONAL_MODE description for more details on PGA connection modes) */
259 #define LL_OPAMP_INPUT_INVERT_FOLLOWER_SEC OPAMP_TCMR_VMSSEL /*!< OPAMP secondary mode is Follower mode - Only applicable if configured mode through call to @ref LL_OPAMP_Init()
260 or @ref LL_OPAMP_SetFunctionalMode() is NOT @ref LL_OPAMP_MODE_STANDALONE.
261 OPAMP secondary inverting input is not connected. */
263 * @}
266 /** @defgroup OPAMP_LL_EC_INTERNAL_OUPUT_MODE OPAMP internal output mode
267 * @{
269 #define LL_OPAMP_INTERNAL_OUPUT_DISABLED (0x00000000UL) /*!< OPAMP internal output to ADC disabled. */
270 #define LL_OPAMP_INTERNAL_OUPUT_ENABLED OPAMP_CSR_OPAMPINTEN /*!< OPAMP internal output to ADC enabled.
271 - OPAMP1 internal output is connected to ADC1/Channel13
272 - OPAMP2 internal output is connected to ADC2/Channel16
273 - OPAMP3 internal output is connected to ADC2/Channel18 & ADC3/Channel13
274 - OPAMP4 internal output is connected to ADC5/Channel5
275 - OPAMP5 internal output is connected to ADC5/Channel3
276 - OPAMP6 internal output is connected to ADC4/Channel17
277 Note: On this STM32 serie, all OPAMPx are not available on all devices. Refer to device datasheet for more details */
279 * @}
282 /** @defgroup OPAMP_LL_EC_INPUT_MUX_MODE OPAMP inputs multiplexer mode
283 * @note The switch can be controlled either by a single timer or a combination of them,
284 * in this case application has to 'ORed' the values below
285 * ex LL_OPAMP_INPUT_MUX_TIM1_CH6 | LL_OPAMP_INPUT_MUX_TIM20_CH6
286 * @{
288 #define LL_OPAMP_INPUT_MUX_DISABLE (0x00000000UL) /*!< OPAMP inputs timer controlled multiplexer mode disabled. */
289 #define LL_OPAMP_INPUT_MUX_TIM1_CH6 OPAMP_TCMR_T1CMEN /*!< OPAMP inputs timer controlled multiplexer mode enabled, controlled by TIM1 OC6. */
290 #define LL_OPAMP_INPUT_MUX_TIM8_CH6 OPAMP_TCMR_T8CMEN /*!< OPAMP inputs timer controlled multiplexer mode enabled, controlled by TIM8 OC6. */
291 #define LL_OPAMP_INPUT_MUX_TIM20_CH6 OPAMP_TCMR_T20CMEN /*!< OPAMP inputs timer controlled multiplexer mode enabled, controlled by TIM20 OC6.
292 Note: On this STM32 serie, TIM20 is not available on all devices. Refer to device datasheet for more details */
294 * @}
297 /** @defgroup OPAMP_LL_EC_POWER_MODE OPAMP PowerMode
298 * @{
300 #define LL_OPAMP_POWERMODE_NORMAL (0x00000000UL) /*!< OPAMP output in normal mode */
301 #define LL_OPAMP_POWERMODE_HIGHSPEED OPAMP_CSR_HIGHSPEEDEN /*!< OPAMP output in highspeed mode */
303 * @}
306 /** @defgroup OPAMP_LL_EC_TRIMMING_MODE OPAMP trimming mode
307 * @{
309 #define LL_OPAMP_TRIMMING_FACTORY (0x00000000UL) /*!< OPAMP trimming factors set to factory values */
310 #define LL_OPAMP_TRIMMING_USER OPAMP_CSR_USERTRIM /*!< OPAMP trimming factors set to user values */
312 * @}
315 /** @defgroup OPAMP_LL_EC_TRIMMING_TRANSISTORS_DIFF_PAIR OPAMP trimming of transistors differential pair NMOS or PMOS
316 * @{
318 #define LL_OPAMP_TRIMMING_NMOS_VREF_90PC_VDDA (OPAMP_CSR_TRIMOFFSETN | OPAMP_CSR_CALSEL_1 | OPAMP_CSR_CALSEL_0) /*!< OPAMP trimming of transistors differential pair NMOS (internal reference voltage set to 0.9*Vdda). Default parameters to be used for calibration using two trimming steps (one with each transistors differential pair NMOS and PMOS). */
319 #define LL_OPAMP_TRIMMING_NMOS_VREF_50PC_VDDA (OPAMP_CSR_TRIMOFFSETN | OPAMP_CSR_CALSEL_1 ) /*!< OPAMP trimming of transistors differential pair NMOS (internal reference voltage set to 0.5*Vdda). */
320 #define LL_OPAMP_TRIMMING_PMOS_VREF_10PC_VDDA (OPAMP_CSR_TRIMOFFSETP | OPAMP_CSR_CALSEL_0) /*!< OPAMP trimming of transistors differential pair PMOS (internal reference voltage set to 0.1*Vdda). Default parameters to be used for calibration using two trimming steps (one with each transistors differential pair NMOS and PMOS). */
321 #define LL_OPAMP_TRIMMING_PMOS_VREF_3_3PC_VDDA (OPAMP_CSR_TRIMOFFSETP ) /*!< OPAMP trimming of transistors differential pair PMOS (internal reference voltage set to 0.33*Vdda). */
322 #define LL_OPAMP_TRIMMING_NMOS (LL_OPAMP_TRIMMING_NMOS_VREF_90PC_VDDA) /*!< OPAMP trimming of transistors differential pair NMOS (internal reference voltage set to 0.9*Vdda). Default parameters to be used for calibration using two trimming steps (one with each transistors differential pair NMOS and PMOS). */
323 #define LL_OPAMP_TRIMMING_PMOS (LL_OPAMP_TRIMMING_PMOS_VREF_10PC_VDDA) /*!< OPAMP trimming of transistors differential pair PMOS (internal reference voltage set to 0.1*Vdda). Default parameters to be used for calibration using two trimming steps (one with each transistors differential pair NMOS and PMOS). */
325 * @}
328 /** @defgroup OPAMP_LL_EC_HW_DELAYS Definitions of OPAMP hardware constraints delays
329 * @note Only OPAMP IP HW delays are defined in OPAMP LL driver driver,
330 * not timeout values.
331 * For details on delays values, refer to descriptions in source code
332 * above each literal definition.
333 * @{
336 /* Delay for OPAMP startup time (transition from state disable to enable). */
337 /* Note: OPAMP startup time depends on board application environment: */
338 /* impedance connected to OPAMP output. */
339 /* The delay below is specified under conditions: */
340 /* - OPAMP in functional mode follower */
341 /* - load impedance of 4kOhm (min), 50pF (max) */
342 /* Literal set to maximum value (refer to device datasheet, */
343 /* parameter "tWAKEUP"). */
344 /* Unit: us */
345 #define LL_OPAMP_DELAY_STARTUP_US (6) /*!< Delay for OPAMP startup time */
347 * @}
351 * @}
354 /* Exported macro ------------------------------------------------------------*/
355 /** @defgroup OPAMP_LL_Exported_Macros OPAMP Exported Macros
356 * @{
358 /** @defgroup OPAMP_LL_EM_WRITE_READ Common write and read registers macro
359 * @{
362 * @brief Write a value in OPAMP register
363 * @param __INSTANCE__ OPAMP Instance
364 * @param __REG__ Register to be written
365 * @param __VALUE__ Value to be written in the register
366 * @retval None
368 #define LL_OPAMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG((__INSTANCE__)->__REG__, (__VALUE__))
371 * @brief Read a value in OPAMP register
372 * @param __INSTANCE__ OPAMP Instance
373 * @param __REG__ Register to be read
374 * @retval Register value
376 #define LL_OPAMP_ReadReg(__INSTANCE__, __REG__) READ_REG((__INSTANCE__)->__REG__)
378 * @}
382 * @}
385 /* Exported functions --------------------------------------------------------*/
386 /** @defgroup OPAMP_LL_Exported_Functions OPAMP Exported Functions
387 * @{
390 /** @defgroup OPAMP_LL_EF_CONFIGURATION_OPAMP_INSTANCE Configuration of OPAMP hierarchical scope: OPAMP instance
391 * @{
395 * @brief Set OPAMP mode calibration or functional.
396 * @note OPAMP mode corresponds to functional or calibration mode:
397 * - functional mode: OPAMP operation in standalone, follower, ...
398 * Set functional mode using function
399 * @ref LL_OPAMP_SetFunctionalMode().
400 * - calibration mode: offset calibration of the selected
401 * transistors differential pair NMOS or PMOS.
402 * @rmtoll CSR CALON LL_OPAMP_SetMode
403 * @param OPAMPx OPAMP instance
404 * @param Mode This parameter can be one of the following values:
405 * @arg @ref LL_OPAMP_MODE_FUNCTIONAL
406 * @arg @ref LL_OPAMP_MODE_CALIBRATION
407 * @retval None
409 __STATIC_INLINE void LL_OPAMP_SetMode(OPAMP_TypeDef *OPAMPx, uint32_t Mode)
411 MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_CALON, Mode);
415 * @brief Get OPAMP mode calibration or functional.
416 * @note OPAMP mode corresponds to functional or calibration mode:
417 * - functional mode: OPAMP operation in standalone, follower, ...
418 * Set functional mode using function
419 * @ref LL_OPAMP_SetFunctionalMode().
420 * - calibration mode: offset calibration of the selected
421 * transistors differential pair NMOS or PMOS.
422 * @rmtoll CSR CALON LL_OPAMP_GetMode
423 * @param OPAMPx OPAMP instance
424 * @retval Returned value can be one of the following values:
425 * @arg @ref LL_OPAMP_MODE_FUNCTIONAL
426 * @arg @ref LL_OPAMP_MODE_CALIBRATION
428 __STATIC_INLINE uint32_t LL_OPAMP_GetMode(OPAMP_TypeDef *OPAMPx)
430 return (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_CALON));
434 * @brief Set OPAMP functional mode by setting internal connections.
435 * OPAMP operation in standalone, follower, ...
436 * @note This function reset bit of calibration mode to ensure
437 * to be in functional mode, in order to have OPAMP parameters
438 * (inputs selection, ...) set with the corresponding OPAMP mode
439 * to be effective.
440 * @rmtoll CSR VMSEL LL_OPAMP_SetFunctionalMode
441 * @param OPAMPx OPAMP instance
442 * @param FunctionalMode This parameter can be one of the following values:
443 * @arg @ref LL_OPAMP_MODE_STANDALONE
444 * @arg @ref LL_OPAMP_MODE_FOLLOWER
445 * @arg @ref LL_OPAMP_MODE_PGA
446 * @arg @ref LL_OPAMP_MODE_PGA_IO0
447 * @arg @ref LL_OPAMP_MODE_PGA_IO0_BIAS
448 * @arg @ref LL_OPAMP_MODE_PGA_IO0_IO1_BIAS
449 * @retval None
451 __STATIC_INLINE void LL_OPAMP_SetFunctionalMode(OPAMP_TypeDef *OPAMPx, uint32_t FunctionalMode)
453 /* Note: Bit OPAMP_CSR_CALON reset to ensure to be in functional mode */
454 MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_PGGAIN_4 | OPAMP_CSR_PGGAIN_3 | OPAMP_CSR_VMSEL | OPAMP_CSR_CALON, FunctionalMode);
458 * @brief Get OPAMP functional mode from setting of internal connections.
459 * OPAMP operation in standalone, follower, ...
460 * @rmtoll CSR VMSEL LL_OPAMP_GetFunctionalMode
461 * @param OPAMPx OPAMP instance
462 * @retval Returned value can be one of the following values:
463 * @arg @ref LL_OPAMP_MODE_STANDALONE
464 * @arg @ref LL_OPAMP_MODE_FOLLOWER
465 * @arg @ref LL_OPAMP_MODE_PGA
466 * @arg @ref LL_OPAMP_MODE_PGA_IO0
467 * @arg @ref LL_OPAMP_MODE_PGA_IO0_BIAS
468 * @arg @ref LL_OPAMP_MODE_PGA_IO0_IO1_BIAS
470 __STATIC_INLINE uint32_t LL_OPAMP_GetFunctionalMode(OPAMP_TypeDef *OPAMPx)
472 return (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_PGGAIN_4 | OPAMP_CSR_PGGAIN_3 | OPAMP_CSR_VMSEL));
476 * @brief Set OPAMP PGA gain.
477 * @note Preliminarily, OPAMP must be set in mode PGA
478 * using function @ref LL_OPAMP_SetFunctionalMode().
479 * @rmtoll CSR PGGAIN LL_OPAMP_SetPGAGain
480 * @param OPAMPx OPAMP instance
481 * @param PGAGain This parameter can be one of the following values:
482 * @arg @ref LL_OPAMP_PGA_GAIN_2_OR_MINUS_1
483 * @arg @ref LL_OPAMP_PGA_GAIN_4_OR_MINUS_3
484 * @arg @ref LL_OPAMP_PGA_GAIN_8_OR_MINUS_7
485 * @arg @ref LL_OPAMP_PGA_GAIN_16_OR_MINUS_15
486 * @arg @ref LL_OPAMP_PGA_GAIN_32_OR_MINUS_31
487 * @arg @ref LL_OPAMP_PGA_GAIN_64_OR_MINUS_63
488 * @retval None
490 __STATIC_INLINE void LL_OPAMP_SetPGAGain(OPAMP_TypeDef *OPAMPx, uint32_t PGAGain)
492 MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_PGGAIN_2 | OPAMP_CSR_PGGAIN_1 | OPAMP_CSR_PGGAIN_0, PGAGain);
496 * @brief Get OPAMP PGA gain.
497 * @note Preliminarily, OPAMP must be set in mode PGA
498 * using function @ref LL_OPAMP_SetFunctionalMode().
499 * @rmtoll CSR PGGAIN LL_OPAMP_GetPGAGain
500 * @param OPAMPx OPAMP instance
501 * @retval Returned value can be one of the following values:
502 * @arg @ref LL_OPAMP_PGA_GAIN_2_OR_MINUS_1
503 * @arg @ref LL_OPAMP_PGA_GAIN_4_OR_MINUS_3
504 * @arg @ref LL_OPAMP_PGA_GAIN_8_OR_MINUS_7
505 * @arg @ref LL_OPAMP_PGA_GAIN_16_OR_MINUS_15
506 * @arg @ref LL_OPAMP_PGA_GAIN_32_OR_MINUS_31
507 * @arg @ref LL_OPAMP_PGA_GAIN_64_OR_MINUS_63
509 __STATIC_INLINE uint32_t LL_OPAMP_GetPGAGain(OPAMP_TypeDef *OPAMPx)
511 return (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_PGGAIN_2 | OPAMP_CSR_PGGAIN_1 | OPAMP_CSR_PGGAIN_0));
515 * @brief Set OPAMP power mode normal or highspeed.
516 * @note OPAMP highspeed mode allows output stage to have a better slew rate.
517 * @rmtoll CSR HIGHSPEEDEN LL_OPAMP_SetPowerMode
518 * @param OPAMPx OPAMP instance
519 * @param PowerMode This parameter can be one of the following values:
520 * @arg @ref LL_OPAMP_POWERMODE_NORMAL
521 * @arg @ref LL_OPAMP_POWERMODE_HIGHSPEED
522 * @retval None
524 __STATIC_INLINE void LL_OPAMP_SetPowerMode(OPAMP_TypeDef *OPAMPx, uint32_t PowerMode)
526 MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_HIGHSPEEDEN, PowerMode);
530 * @brief Get OPAMP power mode normal or highspeed.
531 * @note OPAMP highspeed mode allows output stage to have a better slew rate.
532 * @rmtoll CSR HIGHSPEEDEN LL_OPAMP_GetPowerMode
533 * @param OPAMPx OPAMP instance
534 * @retval Returned value can be one of the following values:
535 * @arg @ref LL_OPAMP_POWERMODE_NORMAL
536 * @arg @ref LL_OPAMP_POWERMODE_HIGHSPEED
538 __STATIC_INLINE uint32_t LL_OPAMP_GetPowerMode(OPAMP_TypeDef *OPAMPx)
540 return (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_HIGHSPEEDEN));
543 * @}
546 /** @defgroup OPAMP_LL_EF_CONFIGURATION_INPUTS Configuration of OPAMP inputs
547 * @{
551 * @brief Set OPAMP non-inverting input connection.
552 * @rmtoll CSR VPSEL LL_OPAMP_SetInputNonInverting
553 * @param OPAMPx OPAMP instance
554 * @param InputNonInverting This parameter can be one of the following values:
555 * @arg @ref LL_OPAMP_INPUT_NONINVERT_IO0
556 * @arg @ref LL_OPAMP_INPUT_NONINVERT_IO1
557 * @arg @ref LL_OPAMP_INPUT_NONINVERT_IO2
558 * @arg @ref LL_OPAMP_INPUT_NONINVERT_IO3
559 * @arg @ref LL_OPAMP_INPUT_NONINVERT_DAC
560 * @retval None
562 __STATIC_INLINE void LL_OPAMP_SetInputNonInverting(OPAMP_TypeDef *OPAMPx, uint32_t InputNonInverting)
564 MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_VPSEL, InputNonInverting);
568 * @brief Get OPAMP non-inverting input connection.
569 * @rmtoll CSR VPSEL LL_OPAMP_GetInputNonInverting
570 * @param OPAMPx OPAMP instance
571 * @retval Returned value can be one of the following values:
572 * @arg @ref LL_OPAMP_INPUT_NONINVERT_IO0
573 * @arg @ref LL_OPAMP_INPUT_NONINVERT_IO1
574 * @arg @ref LL_OPAMP_INPUT_NONINVERT_IO2
575 * @arg @ref LL_OPAMP_INPUT_NONINVERT_IO3
576 * @arg @ref LL_OPAMP_INPUT_NONINVERT_DAC
578 __STATIC_INLINE uint32_t LL_OPAMP_GetInputNonInverting(OPAMP_TypeDef *OPAMPx)
580 return (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_VPSEL));
584 * @brief Set OPAMP inverting input connection.
585 * @note OPAMP inverting input is used with OPAMP in mode standalone
586 * or PGA with external capacitors for filtering circuit.
587 * Otherwise (OPAMP in mode follower), OPAMP inverting input
588 * is not used (not connected to GPIO pin).
589 * @rmtoll CSR VMSEL LL_OPAMP_SetInputInverting
590 * @param OPAMPx OPAMP instance
591 * @param InputInverting This parameter can be one of the following values:
592 * @arg @ref LL_OPAMP_INPUT_INVERT_IO0
593 * @arg @ref LL_OPAMP_INPUT_INVERT_IO1
594 * @arg @ref LL_OPAMP_INPUT_INVERT_CONNECT_NO
595 * @retval None
597 __STATIC_INLINE void LL_OPAMP_SetInputInverting(OPAMP_TypeDef *OPAMPx, uint32_t InputInverting)
599 /* Manage cases of OPAMP inverting input not connected (0x10 and 0x11) */
600 /* to not modify OPAMP mode follower or PGA. */
601 /* Bit OPAMP_CSR_VMSEL_1 is set by OPAMP mode (follower, PGA). */
602 MODIFY_REG(OPAMPx->CSR, (~(InputInverting >> 1)) & OPAMP_CSR_VMSEL_0, InputInverting);
606 * @brief Get OPAMP inverting input connection.
607 * @rmtoll CSR VMSEL LL_OPAMP_GetInputInverting
608 * @param OPAMPx OPAMP instance
609 * @retval Returned value can be one of the following values:
610 * @arg @ref LL_OPAMP_INPUT_INVERT_IO0
611 * @arg @ref LL_OPAMP_INPUT_INVERT_IO1
612 * @arg @ref LL_OPAMP_INPUT_INVERT_CONNECT_NO
614 __STATIC_INLINE uint32_t LL_OPAMP_GetInputInverting(OPAMP_TypeDef *OPAMPx)
616 register uint32_t input_inverting = READ_BIT(OPAMPx->CSR, OPAMP_CSR_VMSEL);
618 /* Manage cases 0x10 and 0x11 to return the same value: OPAMP inverting */
619 /* input not connected. */
620 return (input_inverting & ~((input_inverting >> 1) & OPAMP_CSR_VMSEL_0));
624 * @brief Set OPAMP non-inverting input secondary connection.
625 * @rmtoll TCMR VPSSEL LL_OPAMP_SetInputNonInvertingSecondary
626 * @param OPAMPx OPAMP instance
627 * @param InputNonInverting This parameter can be one of the following values:
628 * @arg @ref LL_OPAMP_INPUT_NONINVERT_IO0_SEC
629 * @arg @ref LL_OPAMP_INPUT_NONINVERT_IO1_SEC
630 * @arg @ref LL_OPAMP_INPUT_NONINVERT_IO2_SEC
631 * @arg @ref LL_OPAMP_INPUT_NONINVERT_IO3_SEC
632 * @arg @ref LL_OPAMP_INPUT_NONINVERT_DAC_SEC
633 * @retval None
635 __STATIC_INLINE void LL_OPAMP_SetInputNonInvertingSecondary(OPAMP_TypeDef *OPAMPx, uint32_t InputNonInverting)
637 MODIFY_REG(OPAMPx->TCMR, OPAMP_TCMR_VPSSEL, InputNonInverting);
641 * @brief Get OPAMP non-inverting input secondary connection.
642 * @rmtoll TCMR VPSSEL LL_OPAMP_GetInputNonInvertingSecondary
643 * @param OPAMPx OPAMP instance
644 * @retval Returned value can be one of the following values:
645 * @arg @ref LL_OPAMP_INPUT_NONINVERT_IO0_SEC
646 * @arg @ref LL_OPAMP_INPUT_NONINVERT_IO1_SEC
647 * @arg @ref LL_OPAMP_INPUT_NONINVERT_IO2_SEC
648 * @arg @ref LL_OPAMP_INPUT_NONINVERT_IO3_SEC
649 * @arg @ref LL_OPAMP_INPUT_NONINVERT_DAC_SEC
651 __STATIC_INLINE uint32_t LL_OPAMP_GetInputNonInvertingSecondary(OPAMP_TypeDef *OPAMPx)
653 return (uint32_t)(READ_BIT(OPAMPx->TCMR, OPAMP_TCMR_VPSSEL));
657 * @brief Set OPAMP inverting input secondary connection.
658 * @note OPAMP inverting input is used with OPAMP in mode standalone
659 * or PGA with external capacitors for filtering circuit.
660 * Otherwise (OPAMP in mode follower), OPAMP inverting input
661 * is not used (not connected to GPIO pin).
662 * @rmtoll TCMR VMSSEL LL_OPAMP_SetInputInvertingSecondary
663 * @param OPAMPx OPAMP instance
664 * @param InputInverting This parameter can be one of the following values:
665 * @arg @ref LL_OPAMP_INPUT_INVERT_IO0_SEC
666 * @arg @ref LL_OPAMP_INPUT_INVERT_IO1_SEC
667 * @arg @ref LL_OPAMP_INPUT_INVERT_PGA_SEC
668 * @arg @ref LL_OPAMP_INPUT_INVERT_FOLLOWER_SEC
669 * @retval None
671 __STATIC_INLINE void LL_OPAMP_SetInputInvertingSecondary(OPAMP_TypeDef *OPAMPx, uint32_t InputInverting)
673 MODIFY_REG(OPAMPx->TCMR, OPAMP_TCMR_VMSSEL, InputInverting);
677 * @brief Get OPAMP inverting input secondary connection.
678 * @rmtoll TCMR VMSSEL LL_OPAMP_GetInputInvertingSecondary
679 * @param OPAMPx OPAMP instance
680 * @retval Returned value can be one of the following values:
681 * @arg @ref LL_OPAMP_INPUT_INVERT_IO0_SEC
682 * @arg @ref LL_OPAMP_INPUT_INVERT_IO1_SEC
683 * @arg @ref LL_OPAMP_INPUT_INVERT_PGA_SEC
684 * @arg @ref LL_OPAMP_INPUT_INVERT_FOLLOWER_SEC
686 __STATIC_INLINE uint32_t LL_OPAMP_GetInputInvertingSecondary(OPAMP_TypeDef *OPAMPx)
688 return (uint32_t)(READ_BIT(OPAMPx->TCMR, OPAMP_TCMR_VMSSEL));
692 * @brief Set OPAMP inputs multiplexer mode.
693 * @rmtoll TCMR TCMEN LL_OPAMP_SetInputsMuxMode
694 * @param OPAMPx OPAMP instance
695 * @param InputsMuxMode This parameter can be one of the following values:
696 * @arg @ref LL_OPAMP_INPUT_MUX_DISABLE
697 * @arg @ref LL_OPAMP_INPUT_MUX_TIM1_CH6
698 * @arg @ref LL_OPAMP_INPUT_MUX_TIM8_CH6
699 * @arg @ref LL_OPAMP_INPUT_MUX_TIM20_CH6 (1)
700 * On this STM32 serie, this value is not available on all devices. Refer to datasheet for details.
701 * @retval None
703 __STATIC_INLINE void LL_OPAMP_SetInputsMuxMode(OPAMP_TypeDef *OPAMPx, uint32_t InputsMuxMode)
705 MODIFY_REG(OPAMPx->TCMR, OPAMP_TCMR_T1CMEN | OPAMP_TCMR_T8CMEN | OPAMP_TCMR_T20CMEN, InputsMuxMode);
709 * @brief Get OPAMP inputs multiplexer mode.
710 * @rmtoll TCMR TCMEN LL_OPAMP_GetInputsMuxMode
711 * @param OPAMPx OPAMP instance
712 * @retval Returned value can be one of the following values:
713 * @arg @ref LL_OPAMP_INPUT_MUX_DISABLE
714 * @arg @ref LL_OPAMP_INPUT_MUX_TIM1_CH6
715 * @arg @ref LL_OPAMP_INPUT_MUX_TIM8_CH6
716 * @arg @ref LL_OPAMP_INPUT_MUX_TIM20_CH6 (1)
717 * On this STM32 serie, this value is not available on all devices. Refer to datasheet for details.
719 __STATIC_INLINE uint32_t LL_OPAMP_GetInputsMuxMode(OPAMP_TypeDef *OPAMPx)
721 return (uint32_t)(READ_BIT(OPAMPx->TCMR, OPAMP_TCMR_T1CMEN | OPAMP_TCMR_T8CMEN | OPAMP_TCMR_T20CMEN));
725 * @brief Set OPAMP internal output.
726 * @note OPAMP internal output is used to link OPAMP output to ADC input internally.
727 * @rmtoll CSR OPAMPINTEN LL_OPAMP_SetInternalOutput
728 * @param OPAMPx OPAMP instance
729 * @param InternalOutput This parameter can be one of the following values:
730 * @arg @ref LL_OPAMP_INTERNAL_OUPUT_DISABLED
731 * @arg @ref LL_OPAMP_INTERNAL_OUPUT_ENABLED
732 * @retval None
734 __STATIC_INLINE void LL_OPAMP_SetInternalOutput(OPAMP_TypeDef *OPAMPx, uint32_t InternalOutput)
736 MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_OPAMPINTEN, InternalOutput);
740 * @brief Get OPAMP internal output state.
741 * @rmtoll CSR OPAMPINTEN LL_OPAMP_GetInternalOutput
742 * @param OPAMPx OPAMP instance
743 * @retval Returned value can be one of the following values:
744 * @arg @ref LL_OPAMP_INTERNAL_OUPUT_DISABLED
745 * @arg @ref LL_OPAMP_INTERNAL_OUPUT_ENABLED
747 __STATIC_INLINE uint32_t LL_OPAMP_GetInternalOutput(OPAMP_TypeDef *OPAMPx)
749 return READ_BIT(OPAMPx->CSR, OPAMP_CSR_OPAMPINTEN);
753 * @}
756 /** @defgroup OPAMP_LL_EF_OPAMP_TRIMMING Configuration and operation of OPAMP trimming
757 * @{
761 * @brief Set OPAMP trimming mode.
762 * @rmtoll CSR USERTRIM LL_OPAMP_SetTrimmingMode
763 * @param OPAMPx OPAMP instance
764 * @param TrimmingMode This parameter can be one of the following values:
765 * @arg @ref LL_OPAMP_TRIMMING_FACTORY
766 * @arg @ref LL_OPAMP_TRIMMING_USER
767 * @retval None
769 __STATIC_INLINE void LL_OPAMP_SetTrimmingMode(OPAMP_TypeDef *OPAMPx, uint32_t TrimmingMode)
771 MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_USERTRIM, TrimmingMode);
775 * @brief Get OPAMP trimming mode.
776 * @rmtoll CSR USERTRIM LL_OPAMP_GetTrimmingMode
777 * @param OPAMPx OPAMP instance
778 * @retval Returned value can be one of the following values:
779 * @arg @ref LL_OPAMP_TRIMMING_FACTORY
780 * @arg @ref LL_OPAMP_TRIMMING_USER
782 __STATIC_INLINE uint32_t LL_OPAMP_GetTrimmingMode(OPAMP_TypeDef *OPAMPx)
784 return (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_USERTRIM));
788 * @brief Set OPAMP offset to calibrate the selected transistors
789 * differential pair NMOS or PMOS.
790 * @note Preliminarily, OPAMP must be set in mode calibration
791 * using function @ref LL_OPAMP_SetMode().
792 * @rmtoll CSR CALSEL LL_OPAMP_SetCalibrationSelection
793 * @param OPAMPx OPAMP instance
794 * @param TransistorsDiffPair This parameter can be one of the following values:
795 * @arg @ref LL_OPAMP_TRIMMING_NMOS (1)
796 * @arg @ref LL_OPAMP_TRIMMING_PMOS (1)
797 * @arg @ref LL_OPAMP_TRIMMING_NMOS_VREF_50PC_VDDA
798 * @arg @ref LL_OPAMP_TRIMMING_PMOS_VREF_3_3PC_VDDA
800 * (1) Default parameters to be used for calibration
801 * using two trimming steps (one with each transistors differential
802 * pair NMOS and PMOS)
803 * @retval None
805 __STATIC_INLINE void LL_OPAMP_SetCalibrationSelection(OPAMP_TypeDef *OPAMPx, uint32_t TransistorsDiffPair)
807 /* Parameter used with mask "OPAMP_TRIMMING_SELECT_MASK" because */
808 /* containing other bits reserved for other purpose. */
809 MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_CALSEL, (TransistorsDiffPair & OPAMP_TRIMMING_SELECT_MASK));
813 * @brief Get OPAMP offset to calibrate the selected transistors
814 * differential pair NMOS or PMOS.
815 * @note Preliminarily, OPAMP must be set in mode calibration
816 * using function @ref LL_OPAMP_SetMode().
817 * @rmtoll CSR CALSEL LL_OPAMP_GetCalibrationSelection
818 * @param OPAMPx OPAMP instance
819 * @retval Returned value can be one of the following values:
820 * @arg @ref LL_OPAMP_TRIMMING_NMOS (1)
821 * @arg @ref LL_OPAMP_TRIMMING_PMOS (1)
822 * @arg @ref LL_OPAMP_TRIMMING_NMOS_VREF_50PC_VDDA
823 * @arg @ref LL_OPAMP_TRIMMING_PMOS_VREF_3_3PC_VDDA
825 * (1) Default parameters to be used for calibration
826 * using two trimming steps (one with each transistors differential
827 * pair NMOS and PMOS)
829 __STATIC_INLINE uint32_t LL_OPAMP_GetCalibrationSelection(OPAMP_TypeDef *OPAMPx)
831 register uint32_t CalibrationSelection = (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_CALSEL));
833 return (CalibrationSelection |
834 (((CalibrationSelection & OPAMP_CSR_CALSEL_1) == 0UL) ? OPAMP_CSR_TRIMOFFSETP : OPAMP_CSR_TRIMOFFSETN));
838 * @brief Get OPAMP calibration result of toggling output.
839 * @note This functions returns:
840 * 0 if OPAMP calibration output is reset
841 * 1 if OPAMP calibration output is set
842 * @rmtoll CSR OUTCAL LL_OPAMP_IsCalibrationOutputSet
843 * @param OPAMPx OPAMP instance
844 * @retval State of bit (1 or 0).
846 __STATIC_INLINE uint32_t LL_OPAMP_IsCalibrationOutputSet(OPAMP_TypeDef *OPAMPx)
848 return ((READ_BIT(OPAMPx->CSR, OPAMP_CSR_OUTCAL) == OPAMP_CSR_OUTCAL) ? 1UL : 0UL);
852 * @brief Set OPAMP trimming factor for the selected transistors
853 * differential pair NMOS or PMOS, corresponding to the selected
854 * power mode.
855 * @rmtoll CSR TRIMOFFSETN LL_OPAMP_SetTrimmingValue\n
856 * CSR TRIMOFFSETP LL_OPAMP_SetTrimmingValue
857 * @param OPAMPx OPAMP instance
858 * @param TransistorsDiffPair This parameter can be one of the following values:
859 * @arg @ref LL_OPAMP_TRIMMING_NMOS
860 * @arg @ref LL_OPAMP_TRIMMING_PMOS
861 * @param TrimmingValue 0x00...0x1F
862 * @retval None
864 __STATIC_INLINE void LL_OPAMP_SetTrimmingValue(OPAMP_TypeDef *OPAMPx, uint32_t TransistorsDiffPair,
865 uint32_t TrimmingValue)
867 MODIFY_REG(OPAMPx->CSR,
868 (TransistorsDiffPair & OPAMP_TRIMMING_VALUE_MASK),
869 TrimmingValue << ((TransistorsDiffPair == LL_OPAMP_TRIMMING_NMOS) ? OPAMP_CSR_TRIMOFFSETN_Pos : OPAMP_CSR_TRIMOFFSETP_Pos));
873 * @brief Get OPAMP trimming factor for the selected transistors
874 * differential pair NMOS or PMOS, corresponding to the selected
875 * power mode.
876 * @rmtoll CSR TRIMOFFSETN LL_OPAMP_GetTrimmingValue\n
877 * CSR TRIMOFFSETP LL_OPAMP_GetTrimmingValue
878 * @param OPAMPx OPAMP instance
879 * @param TransistorsDiffPair This parameter can be one of the following values:
880 * @arg @ref LL_OPAMP_TRIMMING_NMOS
881 * @arg @ref LL_OPAMP_TRIMMING_PMOS
882 * @retval 0x0...0x1F
884 __STATIC_INLINE uint32_t LL_OPAMP_GetTrimmingValue(OPAMP_TypeDef *OPAMPx, uint32_t TransistorsDiffPair)
886 return (uint32_t)(READ_BIT(OPAMPx->CSR, (TransistorsDiffPair & OPAMP_TRIMMING_VALUE_MASK))
887 >> ((TransistorsDiffPair == LL_OPAMP_TRIMMING_NMOS) ? OPAMP_CSR_TRIMOFFSETN_Pos : OPAMP_CSR_TRIMOFFSETP_Pos));
891 * @}
894 /** @defgroup OPAMP_LL_EF_OPERATION Operation on OPAMP instance
895 * @{
898 * @brief Enable OPAMP instance.
899 * @note After enable from off state, OPAMP requires a delay
900 * to fullfill wake up time specification.
901 * Refer to device datasheet, parameter "tWAKEUP".
902 * @rmtoll CSR OPAMPXEN LL_OPAMP_Enable
903 * @param OPAMPx OPAMP instance
904 * @retval None
906 __STATIC_INLINE void LL_OPAMP_Enable(OPAMP_TypeDef *OPAMPx)
908 SET_BIT(OPAMPx->CSR, OPAMP_CSR_OPAMPxEN);
912 * @brief Disable OPAMP instance.
913 * @rmtoll CSR OPAMPXEN LL_OPAMP_Disable
914 * @param OPAMPx OPAMP instance
915 * @retval None
917 __STATIC_INLINE void LL_OPAMP_Disable(OPAMP_TypeDef *OPAMPx)
919 CLEAR_BIT(OPAMPx->CSR, OPAMP_CSR_OPAMPxEN);
923 * @brief Get OPAMP instance enable state
924 * (0: OPAMP is disabled, 1: OPAMP is enabled)
925 * @rmtoll CSR OPAMPXEN LL_OPAMP_IsEnabled
926 * @param OPAMPx OPAMP instance
927 * @retval State of bit (1 or 0).
929 __STATIC_INLINE uint32_t LL_OPAMP_IsEnabled(OPAMP_TypeDef *OPAMPx)
931 return ((READ_BIT(OPAMPx->CSR, OPAMP_CSR_OPAMPxEN) == (OPAMP_CSR_OPAMPxEN)) ? 1UL : 0UL);
935 * @brief Lock OPAMP instance.
936 * @note Once locked, OPAMP configuration can be accessed in read-only.
937 * @note The only way to unlock the OPAMP is a device hardware reset.
938 * @rmtoll CSR LOCK LL_OPAMP_Lock
939 * @param OPAMPx OPAMP instance
940 * @retval None
942 __STATIC_INLINE void LL_OPAMP_Lock(OPAMP_TypeDef *OPAMPx)
944 SET_BIT(OPAMPx->CSR, OPAMP_CSR_LOCK);
948 * @brief Get OPAMP lock state
949 * (0: OPAMP is unlocked, 1: OPAMP is locked).
950 * @note Once locked, OPAMP configuration can be accessed in read-only.
951 * @note The only way to unlock the OPAMP is a device hardware reset.
952 * @rmtoll CSR LOCK LL_OPAMP_IsLocked
953 * @param OPAMPx OPAMP instance
954 * @retval State of bit (1 or 0).
956 __STATIC_INLINE uint32_t LL_OPAMP_IsLocked(OPAMP_TypeDef *OPAMPx)
958 return ((READ_BIT(OPAMPx->CSR, OPAMP_CSR_LOCK) == (OPAMP_CSR_LOCK)) ? 1UL : 0UL);
962 * @brief Lock OPAMP instance timer controlled mux
963 * @note Once locked, OPAMP timer controlled mux configuration can be accessed in read-only.
964 * @note The only way to unlock the OPAMP timer controlled mux is a device hardware reset.
965 * @rmtoll TCMR LOCK LL_OPAMP_LockTimerMux
966 * @param OPAMPx OPAMP instance
967 * @retval None
969 __STATIC_INLINE void LL_OPAMP_LockTimerMux(OPAMP_TypeDef *OPAMPx)
971 SET_BIT(OPAMPx->TCMR, OPAMP_TCMR_LOCK);
975 * @brief Get OPAMP timer controlled mux lock state
976 * (0: OPAMP timer controlled mux is unlocked, 1: OPAMP timer controlled mux is locked).
977 * @note Once locked, OPAMP timer controlled mux configuration can be accessed in read-only.
978 * @note The only way to unlock the OPAMP timer controlled mux is a device hardware reset.
979 * @rmtoll TCMR LOCK LL_OPAMP_IsTimerMuxLocked
980 * @param OPAMPx OPAMP instance
981 * @retval State of bit (1 or 0).
983 __STATIC_INLINE uint32_t LL_OPAMP_IsTimerMuxLocked(OPAMP_TypeDef *OPAMPx)
985 return ((READ_BIT(OPAMPx->TCMR, OPAMP_TCMR_LOCK) == (OPAMP_TCMR_LOCK)) ? 1UL : 0UL);
989 * @}
992 #if defined(USE_FULL_LL_DRIVER)
993 /** @defgroup OPAMP_LL_EF_Init Initialization and de-initialization functions
994 * @{
997 ErrorStatus LL_OPAMP_DeInit(OPAMP_TypeDef *OPAMPx);
998 ErrorStatus LL_OPAMP_Init(OPAMP_TypeDef *OPAMPx, LL_OPAMP_InitTypeDef *OPAMP_InitStruct);
999 void LL_OPAMP_StructInit(LL_OPAMP_InitTypeDef *OPAMP_InitStruct);
1002 * @}
1004 #endif /* USE_FULL_LL_DRIVER */
1007 * @}
1011 * @}
1014 #endif /* OPAMP1 || OPAMP2 || OPAMP3 || OPAMP4 || OPAMP5 || OPAMP6 */
1017 * @}
1020 #ifdef __cplusplus
1022 #endif
1024 #endif /* STM32G4xx_LL_OPAMP_H */
1026 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/