STM32L4xx_HAL_Driver  1.14.0
Configuration of comparator inputs

Functions

__STATIC_INLINE void LL_COMP_ConfigInputs (COMP_TypeDef *COMPx, uint32_t InputMinus, uint32_t InputPlus)
 Set comparator inputs minus (inverting) and plus (non-inverting). More...
 
__STATIC_INLINE void LL_COMP_SetInputPlus (COMP_TypeDef *COMPx, uint32_t InputPlus)
 Set comparator input plus (non-inverting). More...
 
__STATIC_INLINE uint32_t LL_COMP_GetInputPlus (COMP_TypeDef *COMPx)
 Get comparator input plus (non-inverting). More...
 
__STATIC_INLINE void LL_COMP_SetInputMinus (COMP_TypeDef *COMPx, uint32_t InputMinus)
 Set comparator input minus (inverting). More...
 
__STATIC_INLINE uint32_t LL_COMP_GetInputMinus (COMP_TypeDef *COMPx)
 Get comparator input minus (inverting). More...
 
__STATIC_INLINE void LL_COMP_SetInputHysteresis (COMP_TypeDef *COMPx, uint32_t InputHysteresis)
 Set comparator instance hysteresis mode of the input minus (inverting input). CSR HYST LL_COMP_SetInputHysteresis. More...
 
__STATIC_INLINE uint32_t LL_COMP_GetInputHysteresis (COMP_TypeDef *COMPx)
 Get comparator instance hysteresis mode of the minus (inverting) input. CSR HYST LL_COMP_GetInputHysteresis. More...
 

Detailed Description

Function Documentation

◆ LL_COMP_ConfigInputs()

__STATIC_INLINE void LL_COMP_ConfigInputs ( COMP_TypeDef *  COMPx,
uint32_t  InputMinus,
uint32_t  InputPlus 
)

Set comparator inputs minus (inverting) and plus (non-inverting).

Note
In case of comparator input selected to be connected to IO: GPIO pins are specific to each comparator instance. Refer to description of parameters or to reference manual.
On this STM32 serie, scaler bridge is configurable: to optimize power consumption, this function enables the voltage scaler bridge only when required (when selecting comparator input based on VrefInt: VrefInt or subdivision of VrefInt).
  • For scaler bridge power consumption values, refer to device datasheet, parameter "IDDA(SCALER)".
  • Voltage scaler requires a delay for voltage stabilization. Refer to device datasheet, parameter "tSTART_SCALER".
  • Scaler bridge is common for all comparator instances, therefore if at least one of the comparator instance is requiring the scaler bridge, it remains enabled. CSR INMSEL LL_COMP_ConfigInputs
    CSR INPSEL LL_COMP_ConfigInputs
    CSR BRGEN LL_COMP_ConfigInputs
    CSR SCALEN LL_COMP_ConfigInputs
Parameters
COMPxComparator instance
InputMinusThis parameter can be one of the following values:
  • LL_COMP_INPUT_MINUS_1_4VREFINT
  • LL_COMP_INPUT_MINUS_1_2VREFINT
  • LL_COMP_INPUT_MINUS_3_4VREFINT
  • LL_COMP_INPUT_MINUS_VREFINT
  • LL_COMP_INPUT_MINUS_DAC1_CH1
  • LL_COMP_INPUT_MINUS_DAC1_CH2 (*)
  • LL_COMP_INPUT_MINUS_IO1
  • LL_COMP_INPUT_MINUS_IO2
  • LL_COMP_INPUT_MINUS_IO3 (*)
  • LL_COMP_INPUT_MINUS_IO4 (*)
  • LL_COMP_INPUT_MINUS_IO5 (*)
(*) Parameter not available on all devices.
InputPlusThis parameter can be one of the following values:
  • LL_COMP_INPUT_PLUS_IO1
  • LL_COMP_INPUT_PLUS_IO2
  • LL_COMP_INPUT_PLUS_IO3 (*)
(*) Parameter not available on all devices.
Return values
None

Definition at line 463 of file stm32l4xx_ll_comp.h.

464 {
465 #if defined(COMP_CSR_INMESEL_1)
466  MODIFY_REG(COMPx->CSR,
467  COMP_CSR_INMESEL | COMP_CSR_INMSEL | COMP_CSR_INPSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN,
468  InputMinus | InputPlus);
469 #else
470  MODIFY_REG(COMPx->CSR,
471  COMP_CSR_INMSEL | COMP_CSR_INPSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN,
472  InputMinus | InputPlus);
473 #endif
474 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ LL_COMP_GetInputHysteresis()

__STATIC_INLINE uint32_t LL_COMP_GetInputHysteresis ( COMP_TypeDef *  COMPx)

Get comparator instance hysteresis mode of the minus (inverting) input. CSR HYST LL_COMP_GetInputHysteresis.

Parameters
COMPxComparator instance
Return values
Returnedvalue can be one of the following values:
  • LL_COMP_HYSTERESIS_NONE
  • LL_COMP_HYSTERESIS_LOW
  • LL_COMP_HYSTERESIS_MEDIUM
  • LL_COMP_HYSTERESIS_HIGH

Definition at line 620 of file stm32l4xx_ll_comp.h.

621 {
622  return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_HYST));
623 }

◆ LL_COMP_GetInputMinus()

__STATIC_INLINE uint32_t LL_COMP_GetInputMinus ( COMP_TypeDef *  COMPx)

Get comparator input minus (inverting).

Note
In case of comparator input selected to be connected to IO: GPIO pins are specific to each comparator instance. Refer to description of parameters or to reference manual. CSR INMSEL LL_COMP_GetInputMinus
CSR BRGEN LL_COMP_GetInputMinus
CSR SCALEN LL_COMP_GetInputMinus
Parameters
COMPxComparator instance
Return values
Returnedvalue can be one of the following values:
  • LL_COMP_INPUT_MINUS_1_4VREFINT
  • LL_COMP_INPUT_MINUS_1_2VREFINT
  • LL_COMP_INPUT_MINUS_3_4VREFINT
  • LL_COMP_INPUT_MINUS_VREFINT
  • LL_COMP_INPUT_MINUS_DAC1_CH1
  • LL_COMP_INPUT_MINUS_DAC1_CH2 (*)
  • LL_COMP_INPUT_MINUS_IO1
  • LL_COMP_INPUT_MINUS_IO2
  • LL_COMP_INPUT_MINUS_IO3 (*)
  • LL_COMP_INPUT_MINUS_IO4 (*)
  • LL_COMP_INPUT_MINUS_IO5 (*)
(*) Parameter not available on all devices.

Definition at line 585 of file stm32l4xx_ll_comp.h.

586 {
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));
589 #else
590  return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN));
591 #endif
592 }

◆ LL_COMP_GetInputPlus()

__STATIC_INLINE uint32_t LL_COMP_GetInputPlus ( COMP_TypeDef *  COMPx)

Get comparator input plus (non-inverting).

Note
In case of comparator input selected to be connected to IO: GPIO pins are specific to each comparator instance. Refer to description of parameters or to reference manual. CSR INPSEL LL_COMP_GetInputPlus
Parameters
COMPxComparator instance
Return values
Returnedvalue can be one of the following values:
  • LL_COMP_INPUT_PLUS_IO1
  • LL_COMP_INPUT_PLUS_IO2
  • LL_COMP_INPUT_PLUS_IO3 (*)
(*) Parameter not available on all devices.

Definition at line 510 of file stm32l4xx_ll_comp.h.

511 {
512  return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_INPSEL));
513 }

◆ LL_COMP_SetInputHysteresis()

__STATIC_INLINE void LL_COMP_SetInputHysteresis ( COMP_TypeDef *  COMPx,
uint32_t  InputHysteresis 
)

Set comparator instance hysteresis mode of the input minus (inverting input). CSR HYST LL_COMP_SetInputHysteresis.

Parameters
COMPxComparator instance
InputHysteresisThis parameter can be one of the following values:
  • LL_COMP_HYSTERESIS_NONE
  • LL_COMP_HYSTERESIS_LOW
  • LL_COMP_HYSTERESIS_MEDIUM
  • LL_COMP_HYSTERESIS_HIGH
Return values
None

Definition at line 605 of file stm32l4xx_ll_comp.h.

606 {
607  MODIFY_REG(COMPx->CSR, COMP_CSR_HYST, InputHysteresis);
608 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ LL_COMP_SetInputMinus()

__STATIC_INLINE void LL_COMP_SetInputMinus ( COMP_TypeDef *  COMPx,
uint32_t  InputMinus 
)

Set comparator input minus (inverting).

Note
In case of comparator input selected to be connected to IO: GPIO pins are specific to each comparator instance. Refer to description of parameters or to reference manual.
On this STM32 serie, scaler bridge is configurable: to optimize power consumption, this function enables the voltage scaler bridge only when required (when selecting comparator input based on VrefInt: VrefInt or subdivision of VrefInt).
  • For scaler bridge power consumption values, refer to device datasheet, parameter "IDDA(SCALER)".
  • Voltage scaler requires a delay for voltage stabilization. Refer to device datasheet, parameter "tSTART_SCALER".
  • Scaler bridge is common for all comparator instances, therefore if at least one of the comparator instance is requiring the scaler bridge, it remains enabled. CSR INMSEL LL_COMP_SetInputMinus
    CSR BRGEN LL_COMP_SetInputMinus
    CSR SCALEN LL_COMP_SetInputMinus
Parameters
COMPxComparator instance
InputMinusThis parameter can be one of the following values:
  • LL_COMP_INPUT_MINUS_1_4VREFINT
  • LL_COMP_INPUT_MINUS_1_2VREFINT
  • LL_COMP_INPUT_MINUS_3_4VREFINT
  • LL_COMP_INPUT_MINUS_VREFINT
  • LL_COMP_INPUT_MINUS_DAC1_CH1
  • LL_COMP_INPUT_MINUS_DAC1_CH2 (*)
  • LL_COMP_INPUT_MINUS_IO1
  • LL_COMP_INPUT_MINUS_IO2
  • LL_COMP_INPUT_MINUS_IO3 (*)
  • LL_COMP_INPUT_MINUS_IO4 (*)
  • LL_COMP_INPUT_MINUS_IO5 (*)
(*) Parameter not available on all devices.
Return values
None

Definition at line 552 of file stm32l4xx_ll_comp.h.

553 {
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);
556 #else
557  MODIFY_REG(COMPx->CSR, COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN, InputMinus);
558 #endif
559 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ LL_COMP_SetInputPlus()

__STATIC_INLINE void LL_COMP_SetInputPlus ( COMP_TypeDef *  COMPx,
uint32_t  InputPlus 
)

Set comparator input plus (non-inverting).

Note
In case of comparator input selected to be connected to IO: GPIO pins are specific to each comparator instance. Refer to description of parameters or to reference manual. CSR INPSEL LL_COMP_SetInputPlus
Parameters
COMPxComparator instance
InputPlusThis parameter can be one of the following values:
  • LL_COMP_INPUT_PLUS_IO1
  • LL_COMP_INPUT_PLUS_IO2
  • LL_COMP_INPUT_PLUS_IO3 (*)
(*) Parameter not available on all devices.
Return values
None

Definition at line 491 of file stm32l4xx_ll_comp.h.

492 {
493  MODIFY_REG(COMPx->CSR, COMP_CSR_INPSEL, InputPlus);
494 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)