STM8L15x Standard Peripherals Drivers: stm8l15x_comp.h Source File

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

stm8l15x_comp.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm8l15x_comp.h
00004   * @author  MCD Application Team
00005   * @version V1.5.0
00006   * @date    13-May-2011
00007   * @brief   This file contains all the functions prototypes for the COMP firmware
00008   *          library.
00009   ******************************************************************************
00010   * @attention
00011   *
00012   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00013   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00014   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00015   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00016   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00017   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00018   *
00019   * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
00020   ******************************************************************************  
00021   */
00022 
00023 /* Define to prevent recursive inclusion -------------------------------------*/
00024 #ifndef __STM8L15x_COMP_H
00025 #define __STM8L15x_COMP_H
00026 
00027 
00028 /* Includes ------------------------------------------------------------------*/
00029 #include "stm8l15x.h"
00030 
00031 /** @addtogroup STM8L15x_StdPeriph_Driver
00032   * @{
00033   */
00034 
00035 /** @addtogroup COMP
00036   * @{
00037   */ 
00038   
00039 /* Exported types ------------------------------------------------------------*/
00040 
00041 /** @defgroup COMP_Exported_Types
00042   * @{
00043   */
00044 
00045 /** @defgroup COMP_Selection
00046   * @{
00047   */
00048 typedef enum
00049 {
00050   COMP_Selection_COMP1 = ((uint8_t)0x01), /*!< Selection of Comparator 1. */
00051   COMP_Selection_COMP2 = ((uint8_t)0x02)  /*!< Selection of Comparator 2. */
00052 }COMP_Selection_TypeDef;
00053 
00054 #define IS_COMP_ALL_PERIPH(PERIPH) (((PERIPH) == COMP_Selection_COMP1) || \
00055                                     ((PERIPH) == COMP_Selection_COMP2))
00056 /**
00057   * @}
00058   */
00059   
00060 /** @defgroup COMP_Edge
00061   * @{
00062   */
00063 typedef enum
00064 {
00065   COMP_Edge_Falling         = ((uint8_t)0x01), /*!< Falling edge selection. */
00066   COMP_Edge_Rising          = ((uint8_t)0x02), /*!< Rising edge selection. */
00067   COMP_Edge_Rising_Falling  = ((uint8_t)0x03)  /*!< Rising and Falling edge selection. */
00068 }COMP_Edge_TypeDef;
00069 
00070 #define IS_COMP_EDGE(EDGE) (((EDGE) == COMP_Edge_Falling) || \
00071                             ((EDGE) == COMP_Edge_Rising)  || \
00072                             ((EDGE) == COMP_Edge_Rising_Falling))
00073 /**
00074   * @}
00075   */
00076   
00077 /** @defgroup COMP_Inverting_Input_Selection
00078   * @{
00079   */
00080 typedef enum
00081 {
00082   COMP_InvertingInput_IO         = ((uint8_t)0x08), /*!< Input/Output on comparator inverting input enable.*/
00083   COMP_InvertingInput_VREFINT    = ((uint8_t)0x10), /*!< VREFINT on comparator inverting input enable.     */
00084   COMP_InvertingInput_3_4VREFINT = ((uint8_t)0x18), /*!< 3/4 VREFINT on comparator inverting input enable. */
00085   COMP_InvertingInput_1_2VREFINT = ((uint8_t)0x20), /*!< 1/2 VREFINT on comparator inverting input enable. */
00086   COMP_InvertingInput_1_4VREFINT = ((uint8_t)0x28), /*!< 1/4 VREFINT on comparator inverting input enable. */
00087   COMP_InvertingInput_DAC1       = ((uint8_t)0x30),  /*!< DAC1 output on comparator inverting input enable.  */
00088   COMP_InvertingInput_DAC2       = ((uint8_t)0x38)  /*!< DAC2 output on comparator inverting input enable.  */
00089 }COMP_InvertingInput_Typedef;
00090 
00091 #define IS_COMP_INVERTING_INPUT(INPUT) (((INPUT) == COMP_InvertingInput_IO) || \
00092                                         ((INPUT) == COMP_InvertingInput_VREFINT) || \
00093                                         ((INPUT) == COMP_InvertingInput_3_4VREFINT) || \
00094                                         ((INPUT) == COMP_InvertingInput_1_2VREFINT) || \
00095                                         ((INPUT) == COMP_InvertingInput_1_4VREFINT) || \
00096                                         ((INPUT) == COMP_InvertingInput_DAC1) || \
00097                                         ((INPUT) == COMP_InvertingInput_DAC2))
00098 /**
00099   * @}
00100   */
00101   
00102 /** @defgroup COMP2_Output_Selection
00103   * @{
00104   */
00105 typedef enum
00106 {
00107   COMP_OutputSelect_TIM2IC2       = ((uint8_t)0x00), /*!< COMP2 output connected to TIM2 Input Capture 2 */
00108   COMP_OutputSelect_TIM3IC2       = ((uint8_t)0x40), /*!< COMP2 output connected to TIM3 Input Capture 2 */
00109   COMP_OutputSelect_TIM1BRK       = ((uint8_t)0x80), /*!< COMP2 output connected to TIM1 Break Input     */
00110   COMP_OutputSelect_TIM1OCREFCLR  = ((uint8_t)0xC0)  /*!< COMP2 output connected to TIM1 OCREF Clear     */
00111 }COMP_OutputSelect_Typedef;
00112 
00113 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OutputSelect_TIM2IC2) || \
00114                                 ((OUTPUT) == COMP_OutputSelect_TIM3IC2) || \
00115                                 ((OUTPUT) == COMP_OutputSelect_TIM1BRK) || \
00116                                 ((OUTPUT) == COMP_OutputSelect_TIM1OCREFCLR))
00117 /**
00118   * @}
00119   */
00120   
00121 /** @defgroup COMP_Speed
00122   * @{
00123   */
00124 typedef enum
00125 {
00126   COMP_Speed_Slow  = ((uint8_t)0x00), /*!< Comparator speed: slow */
00127   COMP_Speed_Fast  = ((uint8_t)0x04)  /*!< Comparator speed: fast */
00128 }COMP_Speed_TypeDef;
00129 
00130 #define IS_COMP_SPEED(SPEED) (((SPEED) == COMP_Speed_Slow) || \
00131                               ((SPEED) == COMP_Speed_Fast))
00132 /**
00133   * @}
00134   */
00135   
00136 /** @defgroup COMP_Trigger_Group
00137   * @{
00138   */
00139 typedef enum
00140 {
00141   COMP_TriggerGroup_InvertingInput     = ((uint8_t)0x01), /*!< Trigger on comparator 2 inverting input */
00142   COMP_TriggerGroup_NonInvertingInput  = ((uint8_t)0x02), /*!< Trigger on comparator 2 non inverting input */
00143   COMP_TriggerGroup_VREFINTOutput      = ((uint8_t)0x03), /*!< Trigger on VREFINT output */
00144   COMP_TriggerGroup_DACOutput          = ((uint8_t)0x04)  /*!< Trigger on DAC output */
00145 }COMP_TriggerGroup_TypeDef;
00146 
00147 #define IS_COMP_TRIGGERGROUP(TRIGGERGROUP) (((TRIGGERGROUP) == COMP_TriggerGroup_NonInvertingInput) || \
00148                                             ((TRIGGERGROUP) == COMP_TriggerGroup_InvertingInput) || \
00149                                             ((TRIGGERGROUP) == COMP_TriggerGroup_VREFINTOutput) || \
00150                                             ((TRIGGERGROUP) == COMP_TriggerGroup_DACOutput)
00151 /**
00152   * @}
00153   */
00154   
00155 /** @defgroup COMP_Trigger_Pin
00156   * @{
00157   */
00158 typedef enum
00159 {
00160   COMP_TriggerPin_0 = ((uint8_t)0x01), /*!< PE5 for the non inverting input Trigger Group
00161                                                 PC3 for the inverting input Trigger Group
00162                                                 PB6 for the DAC output Trigger Group
00163                                                 PC2 for the VREFINT output Trigger Group
00164                                               */
00165   COMP_TriggerPin_1 = ((uint8_t)0x02), /*!< PD0 for the non inverting input Trigger Group
00166                                                 PC4 for the inverting input Trigger Group
00167                                                 PB5 for the DAC output Trigger Group
00168                                                 PD7 for the VREFINT output Trigger Group
00169                                               */
00170   COMP_TriggerPin_2 = ((uint8_t)0x04)  /*!< PD1 for the non inverting input Trigger Group
00171                                             PC7 for the inverting input Trigger Group
00172                                             PB4 for the DAC output Trigger Group
00173                                             PD6 for the VREFINT output Trigger Group */
00174 }COMP_TriggerPin_TypeDef;
00175 
00176 #define IS_COMP_TRIGGERPIN(TRIGGERPIN)  ((((uint8_t)(TRIGGERPIN) & (uint8_t)0xF8) == (uint8_t) 0x00) && \
00177                                          ((TRIGGERPIN) != (uint8_t)0x00))
00178 /**
00179   * @}
00180   */
00181   
00182 /** @defgroup COMP_Output_Level
00183   * @{
00184   */
00185 typedef enum
00186 {
00187   COMP_OutputLevel_Low   = ((uint8_t)0x00), /*!< Comparator output level is low */
00188   COMP_OutputLevel_High  = ((uint8_t)0x01)  /*!< Comparator output level is high */
00189 }COMP_OutputLevel_TypeDef;
00190 
00191 /**
00192   * @}
00193   */
00194   
00195 /**
00196   * @}
00197   */
00198 
00199 /* Exported constants --------------------------------------------------------*/
00200 /* Exported macros -----------------------------------------------------------*/
00201 /* Exported functions --------------------------------------------------------*/
00202 /* Function used to set the CLK configuration to the default reset state ******/
00203 void COMP_DeInit(void);
00204 /* Initialization and Configuration functions ****************************/
00205 void COMP_Init(COMP_InvertingInput_Typedef COMP_InvertingInput, COMP_OutputSelect_Typedef COMP_OutputSelect,
00206                COMP_Speed_TypeDef COMP_Speed);
00207 void COMP_VrefintToCOMP1Connect(FunctionalState NewState);
00208 void COMP_EdgeConfig(COMP_Selection_TypeDef COMP_Selection, COMP_Edge_TypeDef COMP_Edge);
00209 COMP_OutputLevel_TypeDef COMP_GetOutputLevel(COMP_Selection_TypeDef COMP_Selection);
00210 /* Window mode control function ***********************************************/
00211 void COMP_WindowCmd(FunctionalState NewState);
00212 /* Internal Reference Voltage (VREFINT) output function ***********************/
00213 void COMP_VrefintOutputCmd(FunctionalState NewState);
00214 /* Comparator channels trigger configuration functions ************************/
00215 void COMP_SchmittTriggerCmd(FunctionalState NewState);
00216 void COMP_TriggerConfig(COMP_TriggerGroup_TypeDef COMP_TriggerGroup,
00217                         COMP_TriggerPin_TypeDef COMP_TriggerPin,
00218                         FunctionalState NewState);
00219 /* Interrupts and flags management functions **********************************/
00220 void COMP_ITConfig(COMP_Selection_TypeDef COMP_Selection, FunctionalState NewState);
00221 FlagStatus COMP_GetFlagStatus(COMP_Selection_TypeDef COMP_Selection);
00222 void COMP_ClearFlag(COMP_Selection_TypeDef COMP_Selection);
00223 ITStatus COMP_GetITStatus(COMP_Selection_TypeDef COMP_Selection);
00224 void COMP_ClearITPendingBit(COMP_Selection_TypeDef COMP_Selection);
00225 
00226 /**
00227   * @}
00228   */
00229 
00230 #endif /* __STM8L15x_COMP_H */
00231 
00232 /**
00233   * @}
00234   */
00235 
00236 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
STM8S Firmware Library: Overview

 

 

 

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