30 #ifndef __STM32F0XX_COMP_H
31 #define __STM32F0XX_COMP_H
38 #include "stm32f0xx.h"
57 uint32_t COMP_InvertingInput;
63 uint32_t COMP_OutputPol;
66 uint32_t COMP_Hysteresis;
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))
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))
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))
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))
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))
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))
197 #define COMP_OutputLevel_High COMP_CSR_COMP1OUT
200 #define COMP_OutputLevel_Low ((uint32_t)0x00000000)
219 void COMP_Cmd(uint32_t COMP_Selection, FunctionalState NewState);