RTEMS 6.1-rc5
Loading...
Searching...
No Matches
stm32h7xx_ll_opamp.h
Go to the documentation of this file.
1
19/* Define to prevent recursive inclusion -------------------------------------*/
20#ifndef __STM32H7xx_LL_OPAMP_H
21#define __STM32H7xx_LL_OPAMP_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/* Includes ------------------------------------------------------------------*/
28#include "stm32h7xx.h"
29
34#if defined (OPAMP1) || defined (OPAMP2)
35
41/* Private types -------------------------------------------------------------*/
42/* Private variables ---------------------------------------------------------*/
43
44/* Private constants ---------------------------------------------------------*/
50/* Internal mask for OPAMP power mode: */
51/* To select into literal LL_OPAMP_POWERMODE_x the relevant bits for: */
52/* - OPAMP power mode into control register */
53/* - OPAMP trimming register offset */
54
55/* Internal register offset for OPAMP trimming configuration */
56#define OPAMP_POWERMODE_OTR_REGOFFSET 0x00000000U
57#define OPAMP_POWERMODE_HSOTR_REGOFFSET 0x00000001U
58#define OPAMP_POWERMODE_OTR_REGOFFSET_MASK (OPAMP_POWERMODE_OTR_REGOFFSET | OPAMP_POWERMODE_HSOTR_REGOFFSET)
59
60/* Mask for OPAMP power mode into control register */
61#define OPAMP_POWERMODE_CSR_BIT_MASK (OPAMP_CSR_OPAHSM)
62
63/* Internal mask for OPAMP trimming of transistors differential pair NMOS */
64/* or PMOS. */
65/* To select into literal LL_OPAMP_TRIMMING_x the relevant bits for: */
66/* - OPAMP trimming selection of transistors differential pair */
67/* - OPAMP trimming values of transistors differential pair */
68#define OPAMP_TRIMMING_SELECT_MASK 0x00030000U
69#define OPAMP_TRIMMING_VALUE_MASK (OPAMP_OTR_TRIMOFFSETP | OPAMP_OTR_TRIMOFFSETN)
70
76/* Private macros ------------------------------------------------------------*/
90#define __OPAMP_PTR_REG_OFFSET(__REG__, __REG_OFFSET__) \
91 ((__IO uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFSET__) << 2U))))
92
93
94
100/* Exported types ------------------------------------------------------------*/
101#if defined(USE_FULL_LL_DRIVER) || defined(__rtems__)
110typedef struct
111{
112 uint32_t PowerMode;
118 uint32_t FunctionalMode;
124 uint32_t InputNonInverting;
129 uint32_t InputInverting;
135} LL_OPAMP_InitTypeDef;
136
140#endif /* USE_FULL_LL_DRIVER */
141
142/* Exported constants --------------------------------------------------------*/
152#define LL_OPAMP_MODE_FUNCTIONAL 0x00000000U
153#define LL_OPAMP_MODE_CALIBRATION (OPAMP_CSR_CALON)
162#define LL_OPAMP_MODE_STANDALONE 0x00000000U
163#define LL_OPAMP_MODE_FOLLOWER (OPAMP_CSR_VMSEL_1 | OPAMP_CSR_VMSEL_0)
164#define LL_OPAMP_MODE_PGA (OPAMP_CSR_VMSEL_1)
165#define LL_OPAMP_MODE_PGA_IO0 (OPAMP_CSR_PGGAIN_2|OPAMP_CSR_VMSEL_1)
166#define LL_OPAMP_MODE_PGA_IO0_BIAS (OPAMP_CSR_PGGAIN_3|OPAMP_CSR_VMSEL_1)
169#define LL_OPAMP_MODE_PGA_IO0_IO1_BIAS (OPAMP_CSR_PGGAIN_3|OPAMP_CSR_PGGAIN_2|OPAMP_CSR_VMSEL_1)
188#define LL_OPAMP_PGA_GAIN_2_OR_MINUS_1 0x00000000U
189#define LL_OPAMP_PGA_GAIN_4_OR_MINUS_3 ( OPAMP_CSR_PGGAIN_0)
190#define LL_OPAMP_PGA_GAIN_8_OR_MINUS_7 ( OPAMP_CSR_PGGAIN_1 )
191#define LL_OPAMP_PGA_GAIN_16_OR_MINUS_15 ( OPAMP_CSR_PGGAIN_1 | OPAMP_CSR_PGGAIN_0)
200#define LL_OPAMP_INPUT_NONINVERT_IO0 0x00000000U
203#define LL_OPAMP_INPUT_NONINVERT_DAC OPAMP_CSR_VPSEL_0
206#if defined(DAC2)
207#define LL_OPAMP_INPUT_NONINVERT_DAC2 OPAMP_CSR_VPSEL_1
209#endif /* DAC2 */
210
221#define LL_OPAMP_INPUT_INVERT_IO0 0x00000000U
224#define LL_OPAMP_INPUT_INVERT_IO1 OPAMP_CSR_VMSEL_0
227#define LL_OPAMP_INPUT_INVERT_CONNECT_NO OPAMP_CSR_VMSEL_1
239#define LL_OPAMP_POWERMODE_NORMAL (OPAMP_POWERMODE_OTR_REGOFFSET)
240#define LL_OPAMP_POWERMODE_HIGHSPEED (OPAMP_POWERMODE_HSOTR_REGOFFSET | OPAMP_CSR_OPAHSM)
249#define LL_OPAMP_TRIMMING_FACTORY 0x00000000U
250#define LL_OPAMP_TRIMMING_USER OPAMP_CSR_USERTRIM
259#define LL_OPAMP_TRIMMING_NMOS_VREF_90PC_VDDA (OPAMP_OTR_TRIMOFFSETN | ((OPAMP_CSR_CALSEL_1 | OPAMP_CSR_CALSEL_0) << 4))
260#define LL_OPAMP_TRIMMING_NMOS_VREF_50PC_VDDA (OPAMP_OTR_TRIMOFFSETN | (OPAMP_CSR_CALSEL_1 << 4))
261#define LL_OPAMP_TRIMMING_PMOS_VREF_10PC_VDDA (OPAMP_OTR_TRIMOFFSETP | (OPAMP_CSR_CALSEL_0 << 4))
262#define LL_OPAMP_TRIMMING_PMOS_VREF_3_3PC_VDDA (OPAMP_OTR_TRIMOFFSETP )
263#define LL_OPAMP_TRIMMING_NMOS (LL_OPAMP_TRIMMING_NMOS_VREF_90PC_VDDA)
264#define LL_OPAMP_TRIMMING_PMOS (LL_OPAMP_TRIMMING_PMOS_VREF_10PC_VDDA)
278/* Delay for OPAMP startup time (transition from state disable to enable). */
279/* Note: OPAMP startup time depends on board application environment: */
280/* impedance connected to OPAMP output. */
281/* The delay below is specified under conditions: */
282/* - OPAMP in functional mode follower */
283/* - load impedance of 4kOhm (min), 50pF (max) */
284/* Literal set to maximum value (refer to device datasheet, */
285/* parameter "tWAKEUP"). */
286/* Unit: us */
287#define LL_OPAMP_DELAY_STARTUP_US (3U)
296/* Exported macro ------------------------------------------------------------*/
312#define LL_OPAMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG((__INSTANCE__)->__REG__, (__VALUE__))
313
320#define LL_OPAMP_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
338#if defined(OPAMP1) && defined(OPAMP2)
339#define __LL_OPAMP_COMMON_INSTANCE(__OPAMPx__) \
340 (OPAMP12_COMMON)
341#endif
342
355#if defined(OPAMP1) && defined(OPAMP2)
356#define __LL_OPAMP_IS_ENABLED_ALL_COMMON_INSTANCE() \
357 (LL_OPAMP_IsEnabled(OPAMP1) | \
358 LL_OPAMP_IsEnabled(OPAMP2) )
359#endif
360
369/* Exported functions --------------------------------------------------------*/
395__STATIC_INLINE void LL_OPAMP_SetMode(OPAMP_TypeDef *OPAMPx, uint32_t Mode)
396{
397 MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_CALON, Mode);
398}
399
414__STATIC_INLINE uint32_t LL_OPAMP_GetMode(OPAMP_TypeDef *OPAMPx)
415{
416 return (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_CALON));
417}
418
437__STATIC_INLINE void LL_OPAMP_SetFunctionalMode(OPAMP_TypeDef *OPAMPx, uint32_t FunctionalMode)
438{
439 /* Note: Bit OPAMP_CSR_CALON reset to ensure to be in functional mode */
440 MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_PGGAIN_3 | OPAMP_CSR_PGGAIN_2 | OPAMP_CSR_VMSEL | OPAMP_CSR_CALON, FunctionalMode);
441}
442
456__STATIC_INLINE uint32_t LL_OPAMP_GetFunctionalMode(OPAMP_TypeDef *OPAMPx)
457{
458 return (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_PGGAIN_3 | OPAMP_CSR_PGGAIN_2 | OPAMP_CSR_VMSEL));
459}
460
474__STATIC_INLINE void LL_OPAMP_SetPGAGain(OPAMP_TypeDef *OPAMPx, uint32_t PGAGain)
475{
476 MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_PGGAIN_1 | OPAMP_CSR_PGGAIN_0, PGAGain);
477}
478
491__STATIC_INLINE uint32_t LL_OPAMP_GetPGAGain(OPAMP_TypeDef *OPAMPx)
492{
493 return (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_PGGAIN_1 | OPAMP_CSR_PGGAIN_0));
494}
495
506__STATIC_INLINE void LL_OPAMP_SetPowerMode(OPAMP_TypeDef *OPAMPx, uint32_t PowerMode)
507{
508 MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_OPAHSM, (PowerMode & OPAMP_POWERMODE_CSR_BIT_MASK));
509}
510
520__STATIC_INLINE uint32_t LL_OPAMP_GetPowerMode(OPAMP_TypeDef *OPAMPx)
521{
522 uint32_t power_mode = (READ_BIT(OPAMPx->CSR, OPAMP_CSR_OPAHSM));
523
524 return (uint32_t)(power_mode | (power_mode >> (OPAMP_CSR_OPAHSM_Pos)));
525}
545__STATIC_INLINE void LL_OPAMP_SetInputNonInverting(OPAMP_TypeDef *OPAMPx, uint32_t InputNonInverting)
546{
547 MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_VPSEL, InputNonInverting);
548}
549
559__STATIC_INLINE uint32_t LL_OPAMP_GetInputNonInverting(OPAMP_TypeDef *OPAMPx)
560{
561 return (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_VPSEL));
562}
563
578__STATIC_INLINE void LL_OPAMP_SetInputInverting(OPAMP_TypeDef *OPAMPx, uint32_t InputInverting)
579{
580 /* Manage cases of OPAMP inverting input not connected (0x10 and 0x11) */
581 /* to not modify OPAMP mode follower or PGA. */
582 /* Bit OPAMP_CSR_VMSEL_1 is set by OPAMP mode (follower, PGA). */
583 MODIFY_REG(OPAMPx->CSR, (~(InputInverting >> 1)) & OPAMP_CSR_VMSEL_0, InputInverting);
584}
585
595__STATIC_INLINE uint32_t LL_OPAMP_GetInputInverting(OPAMP_TypeDef *OPAMPx)
596{
597 uint32_t input_inverting = READ_BIT(OPAMPx->CSR, OPAMP_CSR_VMSEL);
598
599 /* Manage cases 0x10 and 0x11 to return the same value: OPAMP inverting */
600 /* input not connected. */
601 return (input_inverting & ~((input_inverting >> 1) & OPAMP_CSR_VMSEL_0));
602}
603
622__STATIC_INLINE void LL_OPAMP_SetTrimmingMode(OPAMP_TypeDef *OPAMPx, uint32_t TrimmingMode)
623{
624 MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_USERTRIM, TrimmingMode);
625}
626
635__STATIC_INLINE uint32_t LL_OPAMP_GetTrimmingMode(OPAMP_TypeDef *OPAMPx)
636{
637 return (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_USERTRIM));
638}
639
658__STATIC_INLINE void LL_OPAMP_SetCalibrationSelection(OPAMP_TypeDef *OPAMPx, uint32_t TransistorsDiffPair)
659{
660 /* Parameter used with mask "OPAMP_TRIMMING_SELECT_MASK" because */
661 /* containing other bits reserved for other purpose. */
662 MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_CALSEL, ((TransistorsDiffPair & OPAMP_TRIMMING_SELECT_MASK) >> 4));
663}
664
682__STATIC_INLINE uint32_t LL_OPAMP_GetCalibrationSelection(OPAMP_TypeDef *OPAMPx)
683{
684 uint32_t CalibrationSelection = (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_CALSEL));
685
686 return (uint32_t)((CalibrationSelection << 4)|
687 (((CalibrationSelection & OPAMP_CSR_CALSEL_1) == 0UL) ? OPAMP_OTR_TRIMOFFSETN : OPAMP_OTR_TRIMOFFSETP));
688}
689
699__STATIC_INLINE uint32_t LL_OPAMP_IsCalibrationOutputSet(OPAMP_TypeDef *OPAMPx)
700{
701 return ((READ_BIT(OPAMPx->CSR, OPAMP_CSR_CALOUT) == OPAMP_CSR_CALOUT)?1UL:0UL);
702}
703
722__STATIC_INLINE void LL_OPAMP_SetTrimmingValue(OPAMP_TypeDef* OPAMPx, uint32_t PowerMode, uint32_t TransistorsDiffPair, uint32_t TrimmingValue)
723{
724 __IO uint32_t *preg = __OPAMP_PTR_REG_OFFSET(OPAMPx->OTR, (PowerMode & OPAMP_POWERMODE_OTR_REGOFFSET_MASK));
725
726 /* Set bits with position in register depending on parameter */
727 /* "TransistorsDiffPair". */
728 /* Parameter used with mask "OPAMP_TRIMMING_VALUE_MASK" because */
729 /* containing other bits reserved for other purpose. */
730 MODIFY_REG(*preg,
731 (TransistorsDiffPair & OPAMP_TRIMMING_VALUE_MASK) << 1U,
732 TrimmingValue << ((TransistorsDiffPair == LL_OPAMP_TRIMMING_NMOS) ? OPAMP_OTR_TRIMOFFSETN_Pos : OPAMP_OTR_TRIMOFFSETP_Pos));
733}
734
752__STATIC_INLINE uint32_t LL_OPAMP_GetTrimmingValue(OPAMP_TypeDef* OPAMPx, uint32_t PowerMode, uint32_t TransistorsDiffPair)
753{
754 const __IO uint32_t *preg = __OPAMP_PTR_REG_OFFSET(OPAMPx->OTR, (PowerMode & OPAMP_POWERMODE_OTR_REGOFFSET_MASK));
755
756 /* Retrieve bits with position in register depending on parameter */
757 /* "TransistorsDiffPair". */
758 /* Parameter used with mask "OPAMP_TRIMMING_VALUE_MASK" because */
759 /* containing other bits reserved for other purpose. */
760 return (uint32_t)(READ_BIT(*preg, (TransistorsDiffPair & OPAMP_TRIMMING_VALUE_MASK))
761 >> ((TransistorsDiffPair == LL_OPAMP_TRIMMING_NMOS) ? OPAMP_OTR_TRIMOFFSETN_Pos : OPAMP_OTR_TRIMOFFSETP_Pos));
762}
763
781__STATIC_INLINE void LL_OPAMP_Enable(OPAMP_TypeDef *OPAMPx)
782{
783 SET_BIT(OPAMPx->CSR, OPAMP_CSR_OPAMPxEN);
784}
785
792__STATIC_INLINE void LL_OPAMP_Disable(OPAMP_TypeDef *OPAMPx)
793{
794 CLEAR_BIT(OPAMPx->CSR, OPAMP_CSR_OPAMPxEN);
795}
796
804__STATIC_INLINE uint32_t LL_OPAMP_IsEnabled(OPAMP_TypeDef *OPAMPx)
805{
806 return ((READ_BIT(OPAMPx->CSR, OPAMP_CSR_OPAMPxEN) == (OPAMP_CSR_OPAMPxEN))?1UL:0UL);
807}
812#if defined(USE_FULL_LL_DRIVER) || defined(__rtems__)
818ErrorStatus LL_OPAMP_DeInit(OPAMP_TypeDef *OPAMPx);
819ErrorStatus LL_OPAMP_Init(OPAMP_TypeDef *OPAMPx, LL_OPAMP_InitTypeDef *OPAMP_InitStruct);
820void LL_OPAMP_StructInit(LL_OPAMP_InitTypeDef *OPAMP_InitStruct);
821
825#endif /* USE_FULL_LL_DRIVER */
826
835#endif /* OPAMP1 || OPAMP2 */
836
841#ifdef __cplusplus
842}
843#endif
844
845#endif /* __STM32H7xx_LL_OPAMP_H */
846
847
#define __IO
Definition: core_cm4.h:239
#define OPAMP_CSR_OPAHSM
Definition: stm32h723xx.h:13846
#define OPAMP_CSR_CALSEL_1
Definition: stm32h723xx.h:13855
#define OPAMP_CSR_VPSEL
Definition: stm32h723xx.h:13834
#define OPAMP_CSR_VMSEL_0
Definition: stm32h723xx.h:13841
#define OPAMP_CSR_USERTRIM
Definition: stm32h723xx.h:13867
#define OPAMP_CSR_OPAMPxEN
Definition: stm32h723xx.h:13827
#define OPAMP_OTR_TRIMOFFSETP
Definition: stm32h723xx.h:13983
#define OPAMP_OTR_TRIMOFFSETN
Definition: stm32h723xx.h:13980
#define OPAMP_CSR_PGGAIN_1
Definition: stm32h723xx.h:13861
#define OPAMP_CSR_CALOUT
Definition: stm32h723xx.h:13873
#define OPAMP_CSR_PGGAIN_3
Definition: stm32h723xx.h:13863
#define OPAMP_CSR_PGGAIN_2
Definition: stm32h723xx.h:13862
#define OPAMP_CSR_CALSEL
Definition: stm32h723xx.h:13853
#define OPAMP_CSR_CALON
Definition: stm32h723xx.h:13849
#define OPAMP_CSR_VMSEL
Definition: stm32h723xx.h:13840
#define OPAMP_CSR_PGGAIN_0
Definition: stm32h723xx.h:13860
CMSIS STM32H7xx Device Peripheral Access Layer Header File.
Operational Amplifier (OPAMP)
Definition: stm32h723xx.h:1083
__IO uint32_t OTR
Definition: stm32h723xx.h:1085
__IO uint32_t CSR
Definition: stm32h723xx.h:1084