30 #ifndef __STM32F37X_COMP_H
31 #define __STM32F37X_COMP_H
38 #include "stm32f37x.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_DAC1OUT1 COMP_CSR_COMP1INSEL_2
104 #define COMP_InvertingInput_DAC1OUT2 ((uint32_t)0x00000050)
105 #define COMP_InvertingInput_DAC2OUT1 ((uint32_t)0x00000070)
106 #define COMP_InvertingInput_IO ((uint32_t)0x00000060)
108 #define IS_COMP_INVERTING_INPUT(INPUT) (((INPUT) == COMP_InvertingInput_1_4VREFINT) || \
109 ((INPUT) == COMP_InvertingInput_1_2VREFINT) || \
110 ((INPUT) == COMP_InvertingInput_3_4VREFINT) || \
111 ((INPUT) == COMP_InvertingInput_VREFINT) || \
112 ((INPUT) == COMP_InvertingInput_DAC1OUT1) || \
113 ((INPUT) == COMP_InvertingInput_DAC1OUT2) || \
114 ((INPUT) == COMP_InvertingInput_DAC2OUT1) || \
115 ((INPUT) == COMP_InvertingInput_IO))
124 #define COMP_Output_None ((uint32_t)0x00000000)
125 #define COMP_Output_TIM5IC4 ((uint32_t)0x00000600)
126 #define COMP_Output_TIM4IC1 ((uint32_t)0x00000200)
127 #define COMP_Output_TIM5OCREFCLR COMP_CSR_COMP1OUTSEL
128 #define COMP_Output_TIM4OCREFCLR ((uint32_t)0x00000300)
129 #define COMP_Output_TIM15BKIN COMP_CSR_COMP1OUTSEL_0
130 #define COMP_Output_TIM16BKIN COMP_CSR_COMP1OUTSEL_0
131 #define COMP_Output_TIM2IC4 COMP_CSR_COMP1OUTSEL_2
132 #define COMP_Output_TIM2OCREFCLR ((uint32_t)0x00000500)
133 #define COMP_Output_TIM3IC1 ((uint32_t)0x00000600)
134 #define COMP_Output_TIM3OCREFCLR COMP_CSR_COMP1OUTSEL
137 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_Output_None) || \
138 ((OUTPUT) == COMP_Output_TIM5IC4) || \
139 ((OUTPUT) == COMP_Output_TIM4IC1) || \
140 ((OUTPUT) == COMP_Output_TIM5OCREFCLR) || \
141 ((OUTPUT) == COMP_Output_TIM4OCREFCLR) || \
142 ((OUTPUT) == COMP_Output_TIM15BKIN) || \
143 ((OUTPUT) == COMP_Output_TIM16BKIN) || \
144 ((OUTPUT) == COMP_Output_TIM2IC4) || \
145 ((OUTPUT) == COMP_Output_TIM2OCREFCLR) || \
146 ((OUTPUT) == COMP_Output_TIM3IC1) || \
147 ((OUTPUT) == COMP_Output_TIM3OCREFCLR))
155 #define COMP_OutputPol_NonInverted ((uint32_t)0x00000000)
156 #define COMP_OutputPol_Inverted COMP_CSR_COMP1POL
158 #define IS_COMP_OUTPUT_POL(POL) (((POL) == COMP_OutputPol_NonInverted) || \
159 ((POL) == COMP_OutputPol_Inverted))
170 #define COMP_Hysteresis_No 0x00000000
171 #define COMP_Hysteresis_Low COMP_CSR_COMP1HYST_0
172 #define COMP_Hysteresis_Medium COMP_CSR_COMP1HYST_1
173 #define COMP_Hysteresis_High COMP_CSR_COMP1HYST
175 #define IS_COMP_HYSTERESIS(HYSTERESIS) (((HYSTERESIS) == COMP_Hysteresis_No) || \
176 ((HYSTERESIS) == COMP_Hysteresis_Low) || \
177 ((HYSTERESIS) == COMP_Hysteresis_Medium) || \
178 ((HYSTERESIS) == COMP_Hysteresis_High))
188 #define COMP_Mode_HighSpeed 0x00000000
189 #define COMP_Mode_MediumSpeed COMP_CSR_COMP1MODE_0
190 #define COMP_Mode_LowPower COMP_CSR_COMP1MODE_1
191 #define COMP_Mode_UltraLowPower COMP_CSR_COMP1MODE
193 #define IS_COMP_MODE(MODE) (((MODE) == COMP_Mode_UltraLowPower) || \
194 ((MODE) == COMP_Mode_LowPower) || \
195 ((MODE) == COMP_Mode_MediumSpeed) || \
196 ((MODE) == COMP_Mode_HighSpeed))
206 #define COMP_OutputLevel_High COMP_CSR_COMP1OUT
209 #define COMP_OutputLevel_Low ((uint32_t)0x00000000)
228 void COMP_Cmd(uint32_t COMP_Selection, FunctionalState NewState);