2 ******************************************************************************
\r
3 * @file stm32f0xx_comp.h
\r
4 * @author MCD Application Team
\r
6 * @date 27-January-2012
\r
7 * @brief This file contains all the functions prototypes for the COMP firmware
\r
9 ******************************************************************************
\r
12 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
\r
13 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
\r
14 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
\r
15 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
\r
16 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
\r
17 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
\r
19 * FOR MORE INFORMATION PLEASE READ CAREFULLY THE LICENSE AGREEMENT FILE
\r
20 * LOCATED IN THE ROOT DIRECTORY OF THIS FIRMWARE PACKAGE.
\r
22 * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
\r
23 ******************************************************************************
\r
26 /* Define to prevent recursive inclusion -------------------------------------*/
\r
27 #ifndef __STM32F0XX_COMP_H
\r
28 #define __STM32F0XX_COMP_H
\r
34 /* Includes ------------------------------------------------------------------*/
\r
35 #include "stm32f0xx.h"
\r
37 /** @addtogroup STM32F0xx_StdPeriph_Driver
\r
41 /** @addtogroup COMP
\r
45 /* Exported types ------------------------------------------------------------*/
\r
48 * @brief COMP Init structure definition
\r
54 uint32_t COMP_InvertingInput; /*!< Selects the inverting input of the comparator.
\r
55 This parameter can be a value of @ref COMP_InvertingInput */
\r
57 uint32_t COMP_Output; /*!< Selects the output redirection of the comparator.
\r
58 This parameter can be a value of @ref COMP_Output */
\r
60 uint32_t COMP_OutputPol; /*!< Selects the output polarity of the comparator.
\r
61 This parameter can be a value of @ref COMP_OutputPolarity */
\r
63 uint32_t COMP_Hysteresis; /*!< Selects the hysteresis voltage of the comparator.
\r
64 This parameter can be a value of @ref COMP_Hysteresis */
\r
66 uint32_t COMP_Mode; /*!< Selects the operating mode of the comparator
\r
67 and allows to adjust the speed/consumption.
\r
68 This parameter can be a value of @ref COMP_Mode */
\r
72 /* Exported constants --------------------------------------------------------*/
\r
74 /** @defgroup COMP_Exported_Constants
\r
78 /** @defgroup COMP_Selection
\r
82 #define COMP_Selection_COMP1 ((uint32_t)0x00000000) /*!< COMP1 Selection */
\r
83 #define COMP_Selection_COMP2 ((uint32_t)0x00000010) /*!< COMP2 Selection */
\r
85 #define IS_COMP_ALL_PERIPH(PERIPH) (((PERIPH) == COMP_Selection_COMP1) || \
\r
86 ((PERIPH) == COMP_Selection_COMP2))
\r
92 /** @defgroup COMP_InvertingInput
\r
96 #define COMP_InvertingInput_1_4VREFINT ((uint32_t)0x00000000) /*!< 1/4 VREFINT connected to comparator inverting input */
\r
97 #define COMP_InvertingInput_1_2VREFINT COMP_CSR_COMP1INSEL_0 /*!< 1/2 VREFINT connected to comparator inverting input */
\r
98 #define COMP_InvertingInput_3_4VREFINT COMP_CSR_COMP1INSEL_1 /*!< 3/4 VREFINT connected to comparator inverting input */
\r
99 #define COMP_InvertingInput_VREFINT ((uint32_t)0x00000030) /*!< VREFINT connected to comparator inverting input */
\r
100 #define COMP_InvertingInput_DAC1 COMP_CSR_COMP1INSEL_2 /*!< DAC1_OUT connected to comparator inverting input */
\r
101 #define COMP_InvertingInput_IO ((uint32_t)0x00000060) /*!< I/O (PA0 for COMP1 and PA2 for COMP2) connected to comparator inverting input */
\r
103 #define IS_COMP_INVERTING_INPUT(INPUT) (((INPUT) == COMP_InvertingInput_1_4VREFINT) || \
\r
104 ((INPUT) == COMP_InvertingInput_1_2VREFINT) || \
\r
105 ((INPUT) == COMP_InvertingInput_3_4VREFINT) || \
\r
106 ((INPUT) == COMP_InvertingInput_VREFINT) || \
\r
107 ((INPUT) == COMP_InvertingInput_DAC1) || \
\r
108 ((INPUT) == COMP_InvertingInput_1_4VREFINT) || \
\r
109 ((INPUT) == COMP_InvertingInput_IO))
\r
114 /** @defgroup COMP_Output
\r
118 #define COMP_Output_None ((uint32_t)0x00000000) /*!< COMP output isn't connected to other peripherals */
\r
119 #define COMP_Output_TIM1BKIN COMP_CSR_COMP1OUTSEL_0 /*!< COMP output connected to TIM1 Break Input (BKIN) */
\r
120 #define COMP_Output_TIM1IC1 COMP_CSR_COMP1OUTSEL_1 /*!< COMP output connected to TIM1 Input Capture 1 */
\r
121 #define COMP_Output_TIM1OCREFCLR ((uint32_t)0x00000300) /*!< COMP output connected to TIM1 OCREF Clear */
\r
122 #define COMP_Output_TIM2IC4 COMP_CSR_COMP1OUTSEL_2 /*!< COMP output connected to TIM2 Input Capture 4 */
\r
123 #define COMP_Output_TIM2OCREFCLR ((uint32_t)0x00000500) /*!< COMP output connected to TIM2 OCREF Clear */
\r
124 #define COMP_Output_TIM3IC1 ((uint32_t)0x00000600) /*!< COMP output connected to TIM3 Input Capture 1 */
\r
125 #define COMP_Output_TIM3OCREFCLR COMP_CSR_COMP1OUTSEL /*!< COMP output connected to TIM3 OCREF Clear */
\r
128 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_Output_None) || \
\r
129 ((OUTPUT) == COMP_Output_TIM1BKIN) || \
\r
130 ((OUTPUT) == COMP_Output_TIM1IC1) || \
\r
131 ((OUTPUT) == COMP_Output_TIM1OCREFCLR) || \
\r
132 ((OUTPUT) == COMP_Output_TIM2IC4) || \
\r
133 ((OUTPUT) == COMP_Output_TIM2OCREFCLR) || \
\r
134 ((OUTPUT) == COMP_Output_TIM3IC1) || \
\r
135 ((OUTPUT) == COMP_Output_TIM3OCREFCLR))
\r
140 /** @defgroup COMP_OutputPolarity
\r
143 #define COMP_OutputPol_NonInverted ((uint32_t)0x00000000) /*!< COMP output on GPIO isn't inverted */
\r
144 #define COMP_OutputPol_Inverted COMP_CSR_COMP1POL /*!< COMP output on GPIO is inverted */
\r
146 #define IS_COMP_OUTPUT_POL(POL) (((POL) == COMP_OutputPol_NonInverted) || \
\r
147 ((POL) == COMP_OutputPol_Inverted))
\r
153 /** @defgroup COMP_Hysteresis
\r
156 /* Please refer to the electrical characteristics in the device datasheet for
\r
157 the hysteresis level */
\r
158 #define COMP_Hysteresis_No 0x00000000 /*!< No hysteresis */
\r
159 #define COMP_Hysteresis_Low COMP_CSR_COMP1HYST_0 /*!< Hysteresis level low */
\r
160 #define COMP_Hysteresis_Medium COMP_CSR_COMP1HYST_1 /*!< Hysteresis level medium */
\r
161 #define COMP_Hysteresis_High COMP_CSR_COMP1HYST /*!< Hysteresis level high */
\r
163 #define IS_COMP_HYSTERESIS(HYSTERESIS) (((HYSTERESIS) == COMP_Hysteresis_No) || \
\r
164 ((HYSTERESIS) == COMP_Hysteresis_Low) || \
\r
165 ((HYSTERESIS) == COMP_Hysteresis_Medium) || \
\r
166 ((HYSTERESIS) == COMP_Hysteresis_High))
\r
171 /** @defgroup COMP_Mode
\r
174 /* Please refer to the electrical characteristics in the device datasheet for
\r
175 the power consumption values */
\r
176 #define COMP_Mode_UltraLowPower 0x00000000 /*!< Ultra-low power mode */
\r
177 #define COMP_Mode_LowPower COMP_CSR_COMP1MODE_0 /*!< Low power mode */
\r
178 #define COMP_Mode_MediumSpeed COMP_CSR_COMP1MODE_1 /*!< Medium Speed */
\r
179 #define COMP_Mode_HighSpeed COMP_CSR_COMP1MODE /*!< High Speed */
\r
181 #define IS_COMP_MODE(MODE) (((MODE) == COMP_Mode_UltraLowPower) || \
\r
182 ((MODE) == COMP_Mode_LowPower) || \
\r
183 ((MODE) == COMP_Mode_MediumSpeed) || \
\r
184 ((MODE) == COMP_Mode_HighSpeed))
\r
189 /** @defgroup COMP_OutputLevel
\r
192 /* When output polarity is not inverted, comparator output is high when
\r
193 the non-inverting input is at a higher voltage than the inverting input */
\r
194 #define COMP_OutputLevel_High COMP_CSR_COMP1OUT
\r
195 /* When output polarity is not inverted, comparator output is low when
\r
196 the non-inverting input is at a lower voltage than the inverting input*/
\r
197 #define COMP_OutputLevel_Low ((uint32_t)0x00000000)
\r
207 /* Exported macro ------------------------------------------------------------*/
\r
208 /* Exported functions ------------------------------------------------------- */
\r
210 /* Function used to set the COMP configuration to the default reset state ****/
\r
211 void COMP_DeInit(void);
\r
213 /* Initialization and Configuration functions *********************************/
\r
214 void COMP_Init(uint32_t COMP_Selection, COMP_InitTypeDef* COMP_InitStruct);
\r
215 void COMP_StructInit(COMP_InitTypeDef* COMP_InitStruct);
\r
216 void COMP_Cmd(uint32_t COMP_Selection, FunctionalState NewState);
\r
217 void COMP_SwitchCmd(FunctionalState NewState);
\r
218 uint32_t COMP_GetOutputLevel(uint32_t COMP_Selection);
\r
220 /* Window mode control function ***********************************************/
\r
221 void COMP_WindowCmd(FunctionalState NewState);
\r
223 /* COMP configuration locking function ****************************************/
\r
224 void COMP_LockConfig(uint32_t COMP_Selection);
\r
230 #endif /*__STM32F0XX_COMP_H */
\r
240 /******************* (C) COPYRIGHT 2012 STMicroelectronics *****END OF FILE****/
\r