STM32F0 Standard Peripheral bibliotheek  1.0
ST Microelectronics standard peripheral bibliotheek documentatie voor de STM32F0 familie
 All Data Structures Files Functions Variables Enumerations Enumerator Groups
stm32f0xx_comp.h
Go to the documentation of this file.
1 
29 /* Define to prevent recursive inclusion -------------------------------------*/
30 #ifndef __STM32F0XX_COMP_H
31 #define __STM32F0XX_COMP_H
32 
33 #ifdef __cplusplus
34  extern "C" {
35 #endif
36 
37 /* Includes ------------------------------------------------------------------*/
38 #include "stm32f0xx.h"
39 
48 /* Exported types ------------------------------------------------------------*/
49 
54 typedef struct
55 {
56 
57  uint32_t COMP_InvertingInput;
60  uint32_t COMP_Output;
63  uint32_t COMP_OutputPol;
66  uint32_t COMP_Hysteresis;
69  uint32_t COMP_Mode;
74 
75 /* Exported constants --------------------------------------------------------*/
76 
85 #define COMP_Selection_COMP1 ((uint32_t)0x00000000)
86 #define COMP_Selection_COMP2 ((uint32_t)0x00000010)
88 #define IS_COMP_ALL_PERIPH(PERIPH) (((PERIPH) == COMP_Selection_COMP1) || \
89  ((PERIPH) == COMP_Selection_COMP2))
90 
99 #define COMP_InvertingInput_1_4VREFINT ((uint32_t)0x00000000)
100 #define COMP_InvertingInput_1_2VREFINT COMP_CSR_COMP1INSEL_0
101 #define COMP_InvertingInput_3_4VREFINT COMP_CSR_COMP1INSEL_1
102 #define COMP_InvertingInput_VREFINT ((uint32_t)0x00000030)
103 #define COMP_InvertingInput_DAC1 COMP_CSR_COMP1INSEL_2
104 #define COMP_InvertingInput_IO ((uint32_t)0x00000060)
106 #define IS_COMP_INVERTING_INPUT(INPUT) (((INPUT) == COMP_InvertingInput_1_4VREFINT) || \
107  ((INPUT) == COMP_InvertingInput_1_2VREFINT) || \
108  ((INPUT) == COMP_InvertingInput_3_4VREFINT) || \
109  ((INPUT) == COMP_InvertingInput_VREFINT) || \
110  ((INPUT) == COMP_InvertingInput_DAC1) || \
111  ((INPUT) == COMP_InvertingInput_1_4VREFINT) || \
112  ((INPUT) == COMP_InvertingInput_IO))
113 
121 #define COMP_Output_None ((uint32_t)0x00000000)
122 #define COMP_Output_TIM1BKIN COMP_CSR_COMP1OUTSEL_0
123 #define COMP_Output_TIM1IC1 COMP_CSR_COMP1OUTSEL_1
124 #define COMP_Output_TIM1OCREFCLR ((uint32_t)0x00000300)
125 #define COMP_Output_TIM2IC4 COMP_CSR_COMP1OUTSEL_2
126 #define COMP_Output_TIM2OCREFCLR ((uint32_t)0x00000500)
127 #define COMP_Output_TIM3IC1 ((uint32_t)0x00000600)
128 #define COMP_Output_TIM3OCREFCLR COMP_CSR_COMP1OUTSEL
131 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_Output_None) || \
132  ((OUTPUT) == COMP_Output_TIM1BKIN) || \
133  ((OUTPUT) == COMP_Output_TIM1IC1) || \
134  ((OUTPUT) == COMP_Output_TIM1OCREFCLR) || \
135  ((OUTPUT) == COMP_Output_TIM2IC4) || \
136  ((OUTPUT) == COMP_Output_TIM2OCREFCLR) || \
137  ((OUTPUT) == COMP_Output_TIM3IC1) || \
138  ((OUTPUT) == COMP_Output_TIM3OCREFCLR))
139 
146 #define COMP_OutputPol_NonInverted ((uint32_t)0x00000000)
147 #define COMP_OutputPol_Inverted COMP_CSR_COMP1POL
149 #define IS_COMP_OUTPUT_POL(POL) (((POL) == COMP_OutputPol_NonInverted) || \
150  ((POL) == COMP_OutputPol_Inverted))
151 
159 /* Please refer to the electrical characteristics in the device datasheet for
160  the hysteresis level */
161 #define COMP_Hysteresis_No 0x00000000
162 #define COMP_Hysteresis_Low COMP_CSR_COMP1HYST_0
163 #define COMP_Hysteresis_Medium COMP_CSR_COMP1HYST_1
164 #define COMP_Hysteresis_High COMP_CSR_COMP1HYST
166 #define IS_COMP_HYSTERESIS(HYSTERESIS) (((HYSTERESIS) == COMP_Hysteresis_No) || \
167  ((HYSTERESIS) == COMP_Hysteresis_Low) || \
168  ((HYSTERESIS) == COMP_Hysteresis_Medium) || \
169  ((HYSTERESIS) == COMP_Hysteresis_High))
170 
177 /* Please refer to the electrical characteristics in the device datasheet for
178  the power consumption values */
179 #define COMP_Mode_HighSpeed 0x00000000
180 #define COMP_Mode_MediumSpeed COMP_CSR_COMP1MODE_0
181 #define COMP_Mode_LowPower COMP_CSR_COMP1MODE_1
182 #define COMP_Mode_UltraLowPower COMP_CSR_COMP1MODE
184 #define IS_COMP_MODE(MODE) (((MODE) == COMP_Mode_UltraLowPower) || \
185  ((MODE) == COMP_Mode_LowPower) || \
186  ((MODE) == COMP_Mode_MediumSpeed) || \
187  ((MODE) == COMP_Mode_HighSpeed))
188 
195 /* When output polarity is not inverted, comparator output is high when
196  the non-inverting input is at a higher voltage than the inverting input */
197 #define COMP_OutputLevel_High COMP_CSR_COMP1OUT
198 /* When output polarity is not inverted, comparator output is low when
199  the non-inverting input is at a lower voltage than the inverting input*/
200 #define COMP_OutputLevel_Low ((uint32_t)0x00000000)
201 
210 /* Exported macro ------------------------------------------------------------*/
211 /* Exported functions ------------------------------------------------------- */
212 
213 /* Function used to set the COMP configuration to the default reset state ****/
214 void COMP_DeInit(void);
215 
216 /* Initialization and Configuration functions *********************************/
217 void COMP_Init(uint32_t COMP_Selection, COMP_InitTypeDef* COMP_InitStruct);
218 void COMP_StructInit(COMP_InitTypeDef* COMP_InitStruct);
219 void COMP_Cmd(uint32_t COMP_Selection, FunctionalState NewState);
220 void COMP_SwitchCmd(FunctionalState NewState);
221 uint32_t COMP_GetOutputLevel(uint32_t COMP_Selection);
222 
223 /* Window mode control function ***********************************************/
224 void COMP_WindowCmd(FunctionalState NewState);
225 
226 /* COMP configuration locking function ****************************************/
227 void COMP_LockConfig(uint32_t COMP_Selection);
228 
229 #ifdef __cplusplus
230 }
231 #endif
232 
233 #endif /*__STM32F0XX_COMP_H */
234 
243 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/