STM8L15x Standard Peripherals Drivers: COMP

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

COMP driver modules. More...

Modules

 COMP_Exported_Types
 COMP_Private_Functions

Functions

void COMP_ClearFlag (COMP_Selection_TypeDef COMP_Selection)
 Clears the comparator�s pending flag.
void COMP_ClearITPendingBit (COMP_Selection_TypeDef COMP_Selection)
 Clears the interrupt pending bits of the comparator.
void COMP_DeInit (void)
 Deinitializes the COMPx peripheral registers to their default reset values.
void COMP_EdgeConfig (COMP_Selection_TypeDef COMP_Selection, COMP_Edge_TypeDef COMP_Edge)
 Configures the COMP edge detection.
FlagStatus COMP_GetFlagStatus (COMP_Selection_TypeDef COMP_Selection)
 Checks whether the comparator flag is set or not.
ITStatus COMP_GetITStatus (COMP_Selection_TypeDef COMP_Selection)
 Checks whether the comparator interrupt has occurred or not.
COMP_OutputLevel_TypeDef COMP_GetOutputLevel (COMP_Selection_TypeDef COMP_Selection)
 Returns the output level of the comparator.
void COMP_Init (COMP_InvertingInput_Typedef COMP_InvertingInput, COMP_OutputSelect_Typedef COMP_OutputSelect, COMP_Speed_TypeDef COMP_Speed)
 Initializes the comparator inverting input, output and speed.
void COMP_ITConfig (COMP_Selection_TypeDef COMP_Selection, FunctionalState NewState)
 Enables or disables the interrupt generation when an event is detected.
void COMP_SchmittTriggerCmd (FunctionalState NewState)
 Enables or disables the schmitt trigger.
void COMP_TriggerConfig (COMP_TriggerGroup_TypeDef COMP_TriggerGroup, COMP_TriggerPin_TypeDef COMP_TriggerPin, FunctionalState NewState)
 Enables or disables trigger on the specified input/output group.
void COMP_VrefintOutputCmd (FunctionalState NewState)
 Enables or disables the output of the internal reference voltage.
void COMP_VrefintToCOMP1Connect (FunctionalState NewState)
 Enables or disables connection between VREFINT and COMP1 inverting input.
void COMP_WindowCmd (FunctionalState NewState)
 Enables or disables the window mode.

Detailed Description

COMP driver modules.


Function Documentation

void COMP_ClearFlag ( COMP_Selection_TypeDef  COMP_Selection)

Clears the comparator�s pending flag.

Parameters:
COMP_Selection: selects the comparator This parameter can be one of the following values:
  • COMP_Selection_COMP1: Selection of Comparator 1
  • COMP_Selection_COMP2: Selection of Comparator 2
Return values:
None.

Definition at line 605 of file stm8l15x_comp.c.

References COMP, COMP_CSR1_EF1, COMP_CSR2_EF2, COMP_Selection_COMP1, and IS_COMP_ALL_PERIPH.

void COMP_ClearITPendingBit ( COMP_Selection_TypeDef  COMP_Selection)

Clears the interrupt pending bits of the comparator.

Parameters:
COMP_Selection: selects the comparator This parameter can be one of the following values:
  • COMP_Selection_COMP1: Selection of Comparator 1
  • COMP_Selection_COMP2: Selection of Comparator 2
Return values:
None

Definition at line 689 of file stm8l15x_comp.c.

References COMP, COMP_CSR1_EF1, COMP_CSR2_EF2, COMP_Selection_COMP1, and IS_COMP_ALL_PERIPH.

void COMP_DeInit ( void  )

Deinitializes the COMPx peripheral registers to their default reset values.

Parameters:
None.
Return values:
None.

Definition at line 105 of file stm8l15x_comp.c.

References COMP, COMP_CSR1_RESET_VALUE, COMP_CSR2_RESET_VALUE, COMP_CSR3_RESET_VALUE, COMP_CSR4_RESET_VALUE, and COMP_CSR5_RESET_VALUE.

void COMP_EdgeConfig ( COMP_Selection_TypeDef  COMP_Selection,
COMP_Edge_TypeDef  COMP_Edge 
)

Configures the COMP edge detection.

Parameters:
COMP_Selection,:selects the comparator. This parameter can be one of the following values:
  • COMP_Selection_COMP1: Selection of Comparator 1
  • COMP_Selection_COMP2: Selection of Comparator 2
COMP_Edge,:This parameter can be one of the following values:
  • COMP_Edge_Falling: Falling edge selection
  • COMP_Edge_Rising: Rising edge selection
  • COMP_Edge_Rising_Falling: Rising and Falling edge selection
Return values:
None.

Definition at line 206 of file stm8l15x_comp.c.

References COMP, COMP_CSR1_CMP1, COMP_CSR2_CMP2, COMP_Selection_COMP1, IS_COMP_ALL_PERIPH, and IS_COMP_EDGE.

FlagStatus COMP_GetFlagStatus ( COMP_Selection_TypeDef  COMP_Selection)

Checks whether the comparator flag is set or not.

Parameters:
COMP_Selection: selects the comparator This parameter can be one of the following values:
  • COMP_Selection_COMP1: Selection of Comparator 1
  • COMP_Selection_COMP2: Selection of Comparator 2
Return values:
Thenew state of COMPx event flag (SET or RESET).

Definition at line 558 of file stm8l15x_comp.c.

References COMP, COMP_CSR1_EF1, COMP_CSR2_EF2, COMP_Selection_COMP1, IS_COMP_ALL_PERIPH, RESET, and SET.

ITStatus COMP_GetITStatus ( COMP_Selection_TypeDef  COMP_Selection)

Checks whether the comparator interrupt has occurred or not.

Parameters:
COMP_Selection: selects the comparator This parameter can be one of the following values:
  • COMP_Selection_COMP1: Selection of Comparator 1
  • COMP_Selection_COMP2: Selection of Comparator 2
Return values:
ITStatus: The state of the COMPx event flag (SET or RESET).

Definition at line 630 of file stm8l15x_comp.c.

References COMP, COMP_CSR1_EF1, COMP_CSR1_IE1, COMP_CSR2_EF2, COMP_CSR2_IE2, COMP_Selection_COMP1, IS_COMP_ALL_PERIPH, RESET, and SET.

COMP_OutputLevel_TypeDef COMP_GetOutputLevel ( COMP_Selection_TypeDef  COMP_Selection)

Returns the output level of the comparator.

Note:
Comparators outputs aren't available on GPIO (outputs levels are only internal).
Parameters:
COMP_Selection,:selects the comparator. This parameter can be one of the following values:
  • COMP_Selection_COMP1: Selection of Comparator 1
  • COMP_Selection_COMP2: Selection of Comparator 2
Return values:
Returnsthe comparator output level This value can be one of the following:
  • COMP_OutputLevel_Low: Comparator output level is low
  • COMP_OutputLevel_High: Comparator output level is high

Definition at line 245 of file stm8l15x_comp.c.

References COMP, COMP_CSR1_CMP1OUT, COMP_CSR2_CMP2OUT, COMP_OutputLevel_High, COMP_OutputLevel_Low, COMP_Selection_COMP1, IS_COMP_ALL_PERIPH, and RESET.

void COMP_Init ( COMP_InvertingInput_Typedef  COMP_InvertingInput,
COMP_OutputSelect_Typedef  COMP_OutputSelect,
COMP_Speed_TypeDef  COMP_Speed 
)

Initializes the comparator inverting input, output and speed.

Note:
This function configures only COMP2.
Parameters:
COMP_InvertingInput: selects the comparator inverting input. This parameter can be one of the following values:
  • COMP_InvertingInput_IO: Input/Output on comparator inverting input enable
  • COMP_InvertingInput_VREFINT: VREFINT on comparator inverting input enable
  • COMP_InvertingInput_3_4VREFINT: 3/4 VREFINT on comparator inverting input enable
  • COMP_InvertingInput_1_2VREFINT: 1/2 VREFINT on comparator inverting input enable
  • COMP_InvertingInput_1_4VREFINT: 1/4 VREFINT on comparator inverting input enable
  • COMP_InvertingInput_DAC1: DAC1 output on comparator inverting input enable
  • COMP_InvertingInput_DAC2: DAC2 output on comparator inverting input enable
COMP_OutputSelect: selects the comparator output This parameter can be one of the following values:
  • COMP_OutputSelect_TIM2IC2: COMP2 output connected to TIM2 Input Capture 2
  • COMP_OutputSelect_TIM3IC2: COMP2 output connected to TIM3 Input Capture 2
  • COMP_OutputSelect_TIM1BRK: COMP2 output connected to TIM1 Break Input
  • COMP_OutputSelect_TIM1OCREFCLR: COMP2 output connected to TIM1 OCREF Clear
COMP_Speedselects the comparator speed This parameter can be one of the following values:
  • COMP_Speed_Slow: Comparator speed: slow
  • COMP_Speed_Fast: Comparator speed: fast
Return values:
None.

Definition at line 147 of file stm8l15x_comp.c.

References COMP, COMP_CSR2_SPEED, COMP_CSR3_INSEL, COMP_CSR3_OUTSEL, IS_COMP_INVERTING_INPUT, IS_COMP_OUTPUT, and IS_COMP_SPEED.

void COMP_ITConfig ( COMP_Selection_TypeDef  COMP_Selection,
FunctionalState  NewState 
)

Enables or disables the interrupt generation when an event is detected.

Parameters:
COMP_Selection: selects the comparator This parameter can be one of the following values:
  • COMP_Selection_COMP1: Selection of Comparator 1
  • COMP_Selection_COMP2: Selection of Comparator 2
NewState: new state of the COMPx interrupt. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 515 of file stm8l15x_comp.c.

References COMP, COMP_CSR1_IE1, COMP_CSR2_IE2, COMP_Selection_COMP1, DISABLE, IS_COMP_ALL_PERIPH, and IS_FUNCTIONAL_STATE.

void COMP_SchmittTriggerCmd ( FunctionalState  NewState)

Enables or disables the schmitt trigger.

Parameters:
NewState: new state of the schmitt trigger. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 395 of file stm8l15x_comp.c.

References COMP, COMP_CSR1_STE, DISABLE, and IS_FUNCTIONAL_STATE.

void COMP_TriggerConfig ( COMP_TriggerGroup_TypeDef  COMP_TriggerGroup,
COMP_TriggerPin_TypeDef  COMP_TriggerPin,
FunctionalState  NewState 
)

Enables or disables trigger on the specified input/output group.

Parameters:
COMP_TriggerGroup: specifies the input/output group This parameter can be one of the following values:
  • COMP_TriggerGroup_InvertingInput: Trigger on comparator 2 inverting input
  • COMP_TriggerGroup_NonInvertingInput: Trigger on comparator 2 non inverting input
  • COMP_TriggerGroup_VREFINTOutput: Trigger on VREFINT output
  • COMP_TriggerGroup_DACOutput: Trigger on DAC output
COMP_TriggerPin: specifies the pin(s) within the input/output group This parameter can be one of the following values:
  • COMP_TriggerPin_0: Trigger Pin 0
  • COMP_TriggerPin_0: Trigger Pin 1
  • COMP_TriggerPin_0: Trigger Pin 2
NewState: enable or disable the trigger on the selected pin(s) This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 429 of file stm8l15x_comp.c.

References COMP, COMP_TriggerGroup_DACOutput, COMP_TriggerGroup_InvertingInput, COMP_TriggerGroup_NonInvertingInput, COMP_TriggerGroup_VREFINTOutput, DISABLE, IS_COMP_TRIGGERGROUP, and IS_COMP_TRIGGERPIN.

void COMP_VrefintOutputCmd ( FunctionalState  NewState)

Enables or disables the output of the internal reference voltage.

Parameters:
NewState: new state of the Vrefint output. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 356 of file stm8l15x_comp.c.

References COMP, COMP_CSR3_VREFOUTEN, DISABLE, and IS_FUNCTIONAL_STATE.

void COMP_VrefintToCOMP1Connect ( FunctionalState  NewState)

Enables or disables connection between VREFINT and COMP1 inverting input.

Parameters:
NewStatenew state of the VREFINT connection to COMP1 inverting input. This parameter can be ENABLE or DISABLE.
Return values:
None

Definition at line 177 of file stm8l15x_comp.c.

References COMP, COMP_CSR3_VREFEN, DISABLE, and IS_FUNCTIONAL_STATE.

void COMP_WindowCmd ( FunctionalState  NewState)

Enables or disables the window mode.

Parameters:
NewStatenew state of the window mode. This parameter can be ENABLE or DISABLE.
Return values:
None

Definition at line 318 of file stm8l15x_comp.c.

References COMP, COMP_CSR3_WNDWE, DISABLE, and IS_FUNCTIONAL_STATE.

STM8S Firmware Library: Overview

 

 

 

For complete documentation on STM8L15x 8-bit microcontrollers platform visit www.st.com