21 #ifndef STM32L4xx_LL_COMP_H 22 #define STM32L4xx_LL_COMP_H 29 #include "stm32l4xx.h" 35 #if defined (COMP1) || defined (COMP2) 49 #define LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS (30UL) 57 #if defined(USE_FULL_LL_DRIVER) 113 #define LL_COMP_WINDOWMODE_DISABLE (0x00000000UL) 114 #define LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP_CSR_WINMODE) 123 #define LL_COMP_POWERMODE_HIGHSPEED (0x00000000UL) 124 #define LL_COMP_POWERMODE_MEDIUMSPEED (COMP_CSR_PWRMODE_0) 125 #define LL_COMP_POWERMODE_ULTRALOWPOWER (COMP_CSR_PWRMODE_1 | COMP_CSR_PWRMODE_0) 133 #define LL_COMP_INPUT_PLUS_IO1 (0x00000000UL) 134 #define LL_COMP_INPUT_PLUS_IO2 (COMP_CSR_INPSEL_0) 135 #if defined(COMP_CSR_INPSEL_1) 136 #define LL_COMP_INPUT_PLUS_IO3 (COMP_CSR_INPSEL_1) 145 #define LL_COMP_INPUT_MINUS_1_4VREFINT ( COMP_CSR_SCALEN | COMP_CSR_BRGEN) 146 #define LL_COMP_INPUT_MINUS_1_2VREFINT ( COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) 147 #define LL_COMP_INPUT_MINUS_3_4VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) 148 #define LL_COMP_INPUT_MINUS_VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN ) 149 #define LL_COMP_INPUT_MINUS_DAC1_CH1 (COMP_CSR_INMSEL_2 ) 150 #define LL_COMP_INPUT_MINUS_DAC1_CH2 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_0) 151 #define LL_COMP_INPUT_MINUS_IO1 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 ) 152 #define LL_COMP_INPUT_MINUS_IO2 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) 153 #if defined(COMP_CSR_INMESEL_1) 154 #define LL_COMP_INPUT_MINUS_IO3 ( COMP_CSR_INMESEL_0 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) 155 #define LL_COMP_INPUT_MINUS_IO4 (COMP_CSR_INMESEL_1 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) 156 #define LL_COMP_INPUT_MINUS_IO5 (COMP_CSR_INMESEL_1 | COMP_CSR_INMESEL_0 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) 165 #define LL_COMP_WINDOWMODE_ENABLE LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON 167 #define LL_COMP_INVERTINGINPUT_1_4VREFINT LL_COMP_INPUT_MINUS_1_4VREFINT 168 #define LL_COMP_INVERTINGINPUT_1_2VREFINT LL_COMP_INPUT_MINUS_1_2VREFINT 169 #define LL_COMP_INVERTINGINPUT_3_4VREFINT LL_COMP_INPUT_MINUS_3_4VREFINT 170 #define LL_COMP_INVERTINGINPUT_VREFINT LL_COMP_INPUT_MINUS_VREFINT 171 #define LL_COMP_INVERTINGINPUT_DAC1 LL_COMP_INPUT_MINUS_DAC1_CH1 172 #define LL_COMP_INVERTINGINPUT_DAC2 LL_COMP_INPUT_MINUS_DAC1_CH2 173 #define LL_COMP_INVERTINGINPUT_IO1 LL_COMP_INPUT_MINUS_IO1 174 #define LL_COMP_INVERTINGINPUT_IO2 LL_COMP_INPUT_MINUS_IO2 175 #if defined(COMP_CSR_INMESEL_1) 176 #define LL_COMP_INVERTINGINPUT_IO3 LL_COMP_INPUT_MINUS_IO3 177 #define LL_COMP_INVERTINGINPUT_IO4 LL_COMP_INPUT_MINUS_IO4 178 #define LL_COMP_INVERTINGINPUT_IO5 LL_COMP_INPUT_MINUS_IO5 181 #define LL_COMP_NONINVERTINGINPUT_IO1 LL_COMP_INPUT_PLUS_IO1 182 #define LL_COMP_NONINVERTINGINPUT_IO2 LL_COMP_INPUT_PLUS_IO2 183 #if defined(COMP_CSR_INPSEL_1) 184 #define LL_COMP_NONINVERTINGINPUT_IO3 LL_COMP_INPUT_PLUS_IO3 193 #define LL_COMP_HYSTERESIS_NONE (0x00000000UL) 194 #define LL_COMP_HYSTERESIS_LOW ( COMP_CSR_HYST_0) 195 #define LL_COMP_HYSTERESIS_MEDIUM (COMP_CSR_HYST_1 ) 196 #define LL_COMP_HYSTERESIS_HIGH (COMP_CSR_HYST_1 | COMP_CSR_HYST_0) 204 #define LL_COMP_OUTPUTPOL_NONINVERTED (0x00000000UL) 205 #define LL_COMP_OUTPUTPOL_INVERTED (COMP_CSR_POLARITY) 213 #define LL_COMP_BLANKINGSRC_NONE (0x00000000UL) 214 #define LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1 (COMP_CSR_BLANKING_0) 215 #define LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1 (COMP_CSR_BLANKING_1) 216 #define LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1 (COMP_CSR_BLANKING_2) 217 #define LL_COMP_BLANKINGSRC_TIM3_OC4_COMP2 (COMP_CSR_BLANKING_0) 218 #define LL_COMP_BLANKINGSRC_TIM8_OC5_COMP2 (COMP_CSR_BLANKING_1) 219 #define LL_COMP_BLANKINGSRC_TIM15_OC1_COMP2 (COMP_CSR_BLANKING_2) 227 #define LL_COMP_BLANKINGSRC_TIM1_OC5 (LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1) 228 #define LL_COMP_BLANKINGSRC_TIM2_OC3 (LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1) 229 #define LL_COMP_BLANKINGSRC_TIM3_OC3 (LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1) 231 #define LL_COMP_BLANKINGSRC_TIM3_OC4 (LL_COMP_BLANKINGSRC_TIM3_OC4_COMP2) 232 #define LL_COMP_BLANKINGSRC_TIM8_OC5 (LL_COMP_BLANKINGSRC_TIM8_OC5_COMP2) 233 #define LL_COMP_BLANKINGSRC_TIM15_OC1 (LL_COMP_BLANKINGSRC_TIM15_OC1_COMP2) 241 #define LL_COMP_OUTPUT_LEVEL_LOW (0x00000000UL) 242 #define LL_COMP_OUTPUT_LEVEL_HIGH (0x00000001UL) 260 #define LL_COMP_DELAY_STARTUP_US ( 80UL) 268 #define LL_COMP_DELAY_VOLTAGE_SCALER_STAB_US ( 200UL) 293 #define LL_COMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG((__INSTANCE__)->__REG__, (__VALUE__)) 301 #define LL_COMP_ReadReg(__INSTANCE__, __REG__) READ_REG((__INSTANCE__)->__REG__) 319 #define __LL_COMP_COMMON_INSTANCE(__COMPx__) \ 355 MODIFY_REG(COMPxy_COMMON->CSR, COMP_CSR_WINMODE, WindowMode);
370 return (uint32_t)(READ_BIT(COMPxy_COMMON->CSR, COMP_CSR_WINMODE));
394 MODIFY_REG(COMPx->CSR, COMP_CSR_PWRMODE, PowerMode);
408 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_PWRMODE));
465 #if defined(COMP_CSR_INMESEL_1) 467 COMP_CSR_INMESEL | COMP_CSR_INMSEL | COMP_CSR_INPSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN,
468 InputMinus | InputPlus);
471 COMP_CSR_INMSEL | COMP_CSR_INPSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN,
472 InputMinus | InputPlus);
493 MODIFY_REG(COMPx->CSR, COMP_CSR_INPSEL, InputPlus);
512 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_INPSEL));
554 #if defined(COMP_CSR_INMESEL_1) 555 MODIFY_REG(COMPx->CSR, COMP_CSR_INMESEL | COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN, InputMinus);
557 MODIFY_REG(COMPx->CSR, COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN, InputMinus);
587 #if defined(COMP_CSR_INMESEL_1) 588 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_INMESEL | COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN));
590 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN));
607 MODIFY_REG(COMPx->CSR, COMP_CSR_HYST, InputHysteresis);
622 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_HYST));
644 MODIFY_REG(COMPx->CSR, COMP_CSR_POLARITY, OutputPolarity);
657 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_POLARITY));
685 MODIFY_REG(COMPx->CSR, COMP_CSR_BLANKING, BlankingSource);
712 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_BLANKING));
761 SET_BIT(COMPx->CSR, COMP_CSR_EN);
784 return ((READ_BIT(COMPx->CSR, COMP_CSR_EN) == (COMP_CSR_EN)) ? 1UL : 0UL);
797 SET_BIT(COMPx->CSR, COMP_CSR_LOCK);
811 return ((READ_BIT(COMPx->CSR, COMP_CSR_LOCK) == (COMP_CSR_LOCK)) ? 1UL : 0UL);
836 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_VALUE)
837 >> LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS);
844 #if defined(USE_FULL_LL_DRIVER)
__STATIC_INLINE void LL_COMP_Disable(COMP_TypeDef *COMPx)
Disable comparator instance. CSR EN LL_COMP_Disable.
__STATIC_INLINE void LL_COMP_SetOutputBlankingSource(COMP_TypeDef *COMPx, uint32_t BlankingSource)
Set comparator instance blanking source.
__STATIC_INLINE uint32_t LL_COMP_GetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON)
Get window mode of a pair of comparators instances (2 consecutive COMP instances odd and even COMP<x>...
ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct)
Initialize some features of COMP instance.
__STATIC_INLINE uint32_t LL_COMP_GetOutputPolarity(COMP_TypeDef *COMPx)
Get comparator instance output polarity. CSR POLARITY LL_COMP_GetOutputPolarity. ...
uint32_t OutputBlankingSource
__STATIC_INLINE uint32_t LL_COMP_GetInputNonInverting(COMP_TypeDef *COMPx)
__STATIC_INLINE void LL_COMP_SetOutputPolarity(COMP_TypeDef *COMPx, uint32_t OutputPolarity)
Set comparator instance output polarity. CSR POLARITY LL_COMP_SetOutputPolarity. ...
Structure definition of some features of COMP instance.
__STATIC_INLINE void LL_COMP_Lock(COMP_TypeDef *COMPx)
Lock comparator instance.
__STATIC_INLINE uint32_t LL_COMP_IsLocked(COMP_TypeDef *COMPx)
Get comparator lock state (0: COMP is unlocked, 1: COMP is locked).
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__STATIC_INLINE uint32_t LL_COMP_GetOutputBlankingSource(COMP_TypeDef *COMPx)
Get comparator instance blanking source.
__STATIC_INLINE void LL_COMP_SetInputNonInverting(COMP_TypeDef *COMPx, uint32_t InputNonInverting)
__STATIC_INLINE uint32_t LL_COMP_GetPowerMode(COMP_TypeDef *COMPx)
Get comparator instance operating mode to adjust power and speed. CSR PWRMODE LL_COMP_GetPowerMode.
__STATIC_INLINE void LL_COMP_SetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON, uint32_t WindowMode)
Set window mode of a pair of comparators instances (2 consecutive COMP instances odd and even COMP<x>...
__STATIC_INLINE void LL_COMP_SetPowerMode(COMP_TypeDef *COMPx, uint32_t PowerMode)
Set comparator instance operating mode to adjust power and speed. CSR PWRMODE LL_COMP_SetPowerMode.
__STATIC_INLINE void LL_COMP_Enable(COMP_TypeDef *COMPx)
Enable comparator instance.
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx)
De-initialize registers of the selected COMP instance to their default reset values.
void LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct)
Set each LL_COMP_InitTypeDef field to default value.
__STATIC_INLINE uint32_t LL_COMP_ReadOutputLevel(COMP_TypeDef *COMPx)
Read comparator instance output level.
__STATIC_INLINE uint32_t LL_COMP_GetInputInverting(COMP_TypeDef *COMPx)
__STATIC_INLINE void LL_COMP_SetInputInverting(COMP_TypeDef *COMPx, uint32_t InputInverting)
__STATIC_INLINE uint32_t LL_COMP_IsEnabled(COMP_TypeDef *COMPx)
Get comparator enable state (0: COMP is disabled, 1: COMP is enabled) CSR EN LL_COMP_IsEnabled.