STM8L15x Standard Peripherals Drivers: stm8l15x_comp.c File Reference

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

stm8l15x_comp.c File Reference

This file provides firmware functions to manage the following functionalities of the comparators (COMP1 and COMP2) peripheral:

  • Comparators configuration
  • Window mode control
  • Internal Reference Voltage (VREFINT) output
  • Comparator channels trigger configuration
  • Interrupts and flags management.
More...
#include "stm8l15x_comp.h"

Go to the source code of this file.

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

This file provides firmware functions to manage the following functionalities of the comparators (COMP1 and COMP2) peripheral:

  • Comparators configuration
  • Window mode control
  • Internal Reference Voltage (VREFINT) output
  • Comparator channels trigger configuration
  • Interrupts and flags management.
Author:
MCD Application Team
Version:
V1.5.0
Date:
13-May-2011
  *
  *          ===================================================================
  *                                 How to use this driver
  *          ===================================================================
  *          1- Enable comparators clock using CLK_PeripheralClockConfig(CLK_Peripheral_COMP, ENABLE);
  *            
  *          When using COMP1:
  *          2- Connect internal reference voltage to COMP1 inverting input
  *             using COMP_VrefintToCOMP1Connect()
  *          3- Close the analog switch number 14 using SYSCFG_RIAnalogSwitchConfig()
  *          4- Close the analog switch that corresponds to the pin to be used as 
  *             non inverting input using SYSCFG_RIAnalogSwitchConfig()
  *          5- Close the I/O switch of the pin to be used as non inverting input
  *             using SYSCFG_RIIOSwitchConfig()
  *          6- Configure the event detection using COMP_EdgeConfig()    
  *
  *          When using COMP2:
  *          2- Select the COMP2 inverting input, configure the speed and COMP2
  *             output redirection using COMP_Init()
  *             If the inverting input is an external pin, close the I/O channel
  *             switch using SYSCFG_RIIOSwitchConfig()
  *          3- Close I/O Switch that corresponds to the selected pin as
  *             comparator 2 non inverting input using SYSCFG_RIIOSwitchConfig()    
  *          4- Configure the event detection using COMP_EdgeConfig()   
  *
  * @note
  *          1- COMP1 comparator and ADC can't be used at the same time since
  *             they share the same ADC switch matrix (analog switches).
  *
  *          2- When an I/O is used as comparator input, the corresponding GPIO 
  *             registers should be configured in input floating.
  *
  *          3- Comparators outputs (CMP1OUT and CMP2OUT) are not mapped on
  *             GPIO pin. They are only internal.
  *             To get the comparator output level, use COMP_GetOutputLevel() function    
  *  
Attention:

THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.

© COPYRIGHT 2011 STMicroelectronics

Definition in file stm8l15x_comp.c.

STM8S Firmware Library: Overview

 

 

 

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