30 #ifndef __STM32F30x_COMP_H 31 #define __STM32F30x_COMP_H 38 #include "stm32f30x.h" 90 #define COMP_Selection_COMP1 ((uint32_t)0x00000000) 91 #define COMP_Selection_COMP2 ((uint32_t)0x00000004) 92 #define COMP_Selection_COMP3 ((uint32_t)0x00000008) 93 #define COMP_Selection_COMP4 ((uint32_t)0x0000000C) 94 #define COMP_Selection_COMP5 ((uint32_t)0x00000010) 95 #define COMP_Selection_COMP6 ((uint32_t)0x00000014) 96 #define COMP_Selection_COMP7 ((uint32_t)0x00000018) 98 #define IS_COMP_ALL_PERIPH(PERIPH) (((PERIPH) == COMP_Selection_COMP1) || \ 99 ((PERIPH) == COMP_Selection_COMP2) || \ 100 ((PERIPH) == COMP_Selection_COMP3) || \ 101 ((PERIPH) == COMP_Selection_COMP4) || \ 102 ((PERIPH) == COMP_Selection_COMP5) || \ 103 ((PERIPH) == COMP_Selection_COMP6) || \ 104 ((PERIPH) == COMP_Selection_COMP7)) 114 #define COMP_InvertingInput_1_4VREFINT ((uint32_t)0x00000000) 115 #define COMP_InvertingInput_1_2VREFINT COMP_CSR_COMPxINSEL_0 116 #define COMP_InvertingInput_3_4VREFINT COMP_CSR_COMPxINSEL_1 117 #define COMP_InvertingInput_VREFINT ((uint32_t)0x00000030) 118 #define COMP_InvertingInput_DAC1OUT1 COMP_CSR_COMPxINSEL_2 119 #define COMP_InvertingInput_DAC1OUT2 ((uint32_t)0x00000050) 121 #define COMP_InvertingInput_IO1 ((uint32_t)0x00000060) 125 #define COMP_InvertingInput_IO2 COMP_CSR_COMPxINSEL 128 #define COMP_InvertingInput_DAC2OUT1 COMP_CSR_COMPxINSEL_3 130 #define IS_COMP_INVERTING_INPUT(INPUT) (((INPUT) == COMP_InvertingInput_1_4VREFINT) || \ 131 ((INPUT) == COMP_InvertingInput_1_2VREFINT) || \ 132 ((INPUT) == COMP_InvertingInput_3_4VREFINT) || \ 133 ((INPUT) == COMP_InvertingInput_VREFINT) || \ 134 ((INPUT) == COMP_InvertingInput_DAC1OUT1) || \ 135 ((INPUT) == COMP_InvertingInput_DAC1OUT2) || \ 136 ((INPUT) == COMP_InvertingInput_IO1) || \ 137 ((INPUT) == COMP_InvertingInput_IO2) || \ 138 ((INPUT) == COMP_InvertingInput_DAC2OUT1)) 147 #define COMP_NonInvertingInput_IO1 ((uint32_t)0x00000000) 151 #define COMP_NonInvertingInput_IO2 COMP_CSR_COMPxNONINSEL 154 #define IS_COMP_NONINVERTING_INPUT(INPUT) (((INPUT) == COMP_NonInvertingInput_IO1) || \ 155 ((INPUT) == COMP_NonInvertingInput_IO2)) 164 #define COMP_Output_None ((uint32_t)0x00000000) 167 #define COMP_Output_TIM1BKIN COMP_CSR_COMPxOUTSEL_0 168 #define COMP_Output_TIM1BKIN2 ((uint32_t)0x00000800) 169 #define COMP_Output_TIM8BKIN ((uint32_t)0x00000C00) 170 #define COMP_Output_TIM8BKIN2 ((uint32_t)0x00001000) 171 #define COMP_Output_TIM1BKIN2_TIM8BKIN2 ((uint32_t)0x00001400) 174 #define COMP_Output_TIM1OCREFCLR ((uint32_t)0x00001800) 175 #define COMP_Output_TIM1IC1 ((uint32_t)0x00001C00) 176 #define COMP_Output_TIM2IC4 ((uint32_t)0x00002000) 177 #define COMP_Output_TIM2OCREFCLR ((uint32_t)0x00002400) 178 #define COMP_Output_TIM3IC1 ((uint32_t)0x00002800) 179 #define COMP_Output_TIM3OCREFCLR ((uint32_t)0x00002C00) 182 #define COMP_Output_HRTIM1_FLT6 ((uint32_t)0x00003000) 183 #define COMP_Output_HRTIM1_EE1_2 ((uint32_t)0x00003400) 184 #define COMP_Output_HRTIM1_EE6_2 ((uint32_t)0x00003800) 187 #define COMP_Output_TIM4IC1 ((uint32_t)0x00001C00) 188 #define COMP_Output_TIM3IC2 ((uint32_t)0x00002000) 189 #define COMP_Output_TIM15IC1 ((uint32_t)0x00002800) 190 #define COMP_Output_TIM15BKIN ((uint32_t)0x00002C00) 193 #define COMP_Output_TIM3IC3 ((uint32_t)0x00001800) 194 #define COMP_Output_TIM8OCREFCLR ((uint32_t)0x00001C00) 195 #define COMP_Output_TIM15IC2 ((uint32_t)0x00002000) 196 #define COMP_Output_TIM4IC2 ((uint32_t)0x00002400) 197 #define COMP_Output_TIM15OCREFCLR ((uint32_t)0x00002800) 199 #define COMP_Output_HRTIM1_FLT7 ((uint32_t)0x00003000) 200 #define COMP_Output_HRTIM1_EE2_2 ((uint32_t)0x00003400) 201 #define COMP_Output_HRTIM1_EE7_2 ((uint32_t)0x00003800) 204 #define COMP_Output_TIM2IC1 ((uint32_t)0x00001800) 205 #define COMP_Output_TIM17IC1 ((uint32_t)0x00002000) 206 #define COMP_Output_TIM4IC3 ((uint32_t)0x00002400) 207 #define COMP_Output_TIM16BKIN ((uint32_t)0x00002800) 210 #define COMP_Output_TIM2IC2 ((uint32_t)0x00001800) 211 #define COMP_Output_COMP6TIM2OCREFCLR ((uint32_t)0x00002000) 212 #define COMP_Output_TIM16OCREFCLR ((uint32_t)0x00002400) 213 #define COMP_Output_TIM16IC1 ((uint32_t)0x00002800) 214 #define COMP_Output_TIM4IC4 ((uint32_t)0x00002C00) 216 #define COMP_Output_HRTIM1_FLT8 ((uint32_t)0x00003000) 217 #define COMP_Output_HRTIM1_EE3_2 ((uint32_t)0x00003400) 218 #define COMP_Output_HRTIM1_EE8_2 ((uint32_t)0x00003800) 221 #define COMP_Output_TIM2IC3 ((uint32_t)0x00002000) 222 #define COMP_Output_TIM1IC2 ((uint32_t)0x00002400) 223 #define COMP_Output_TIM17OCREFCLR ((uint32_t)0x00002800) 224 #define COMP_Output_TIM17BKIN ((uint32_t)0x00002C00) 226 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_Output_None) || \ 227 ((OUTPUT) == COMP_Output_TIM1BKIN) || \ 228 ((OUTPUT) == COMP_Output_TIM1IC1) || \ 229 ((OUTPUT) == COMP_Output_TIM1OCREFCLR) || \ 230 ((OUTPUT) == COMP_Output_TIM2IC4) || \ 231 ((OUTPUT) == COMP_Output_TIM2OCREFCLR) || \ 232 ((OUTPUT) == COMP_Output_COMP6TIM2OCREFCLR) || \ 233 ((OUTPUT) == COMP_Output_TIM3IC1) || \ 234 ((OUTPUT) == COMP_Output_TIM3OCREFCLR) || \ 235 ((OUTPUT) == COMP_Output_TIM8BKIN) || \ 236 ((OUTPUT) == COMP_Output_TIM1BKIN2) || \ 237 ((OUTPUT) == COMP_Output_TIM8BKIN2) || \ 238 ((OUTPUT) == COMP_Output_TIM2OCREFCLR) || \ 239 ((OUTPUT) == COMP_Output_TIM1BKIN2_TIM8BKIN2) || \ 240 ((OUTPUT) == COMP_Output_TIM3IC2) || \ 241 ((OUTPUT) == COMP_Output_TIM4IC1) || \ 242 ((OUTPUT) == COMP_Output_TIM15IC1) || \ 243 ((OUTPUT) == COMP_Output_TIM15BKIN) || \ 244 ((OUTPUT) == COMP_Output_TIM8OCREFCLR) || \ 245 ((OUTPUT) == COMP_Output_TIM3IC3) || \ 246 ((OUTPUT) == COMP_Output_TIM4IC1) || \ 247 ((OUTPUT) == COMP_Output_TIM15IC1) || \ 248 ((OUTPUT) == COMP_Output_TIM2IC1) || \ 249 ((OUTPUT) == COMP_Output_TIM4IC3) || \ 250 ((OUTPUT) == COMP_Output_TIM16BKIN) || \ 251 ((OUTPUT) == COMP_Output_TIM17IC1) || \ 252 ((OUTPUT) == COMP_Output_TIM2IC2) || \ 253 ((OUTPUT) == COMP_Output_TIM16IC1) || \ 254 ((OUTPUT) == COMP_Output_TIM4IC4) || \ 255 ((OUTPUT) == COMP_Output_TIM16OCREFCLR) || \ 256 ((OUTPUT) == COMP_Output_TIM2IC3) || \ 257 ((OUTPUT) == COMP_Output_TIM1IC2) || \ 258 ((OUTPUT) == COMP_Output_TIM17BKIN) || \ 259 ((OUTPUT) == COMP_Output_TIM17OCREFCLR) || \ 260 ((OUTPUT) == COMP_Output_HRTIM1_FLT6) || \ 261 ((OUTPUT) == COMP_Output_HRTIM1_EE1_2) || \ 262 ((OUTPUT) == COMP_Output_HRTIM1_EE6_2) || \ 263 ((OUTPUT) == COMP_Output_HRTIM1_FLT7) || \ 264 ((OUTPUT) == COMP_Output_HRTIM1_EE2_2) || \ 265 ((OUTPUT) == COMP_Output_HRTIM1_EE7_2) || \ 266 ((OUTPUT) == COMP_Output_HRTIM1_FLT8) || \ 267 ((OUTPUT) == COMP_Output_HRTIM1_EE3_2) || \ 268 ((OUTPUT) == COMP_Output_HRTIM1_EE8_2)) 279 #define COMP_BlankingSrce_None ((uint32_t)0x00000000) 282 #define COMP_BlankingSrce_TIM1OC5 COMP_CSR_COMPxBLANKING_0 285 #define COMP_BlankingSrce_TIM2OC3 COMP_CSR_COMPxBLANKING_1 288 #define COMP_BlankingSrce_TIM3OC3 ((uint32_t)0x000C0000) 291 #define COMP_BlankingSrce_TIM2OC4 ((uint32_t)0x000C0000) 294 #define COMP_BlankingSrce_TIM8OC5 COMP_CSR_COMPxBLANKING_1 297 #define COMP_BlankingSrce_TIM3OC4 COMP_CSR_COMPxBLANKING_0 298 #define COMP_BlankingSrce_TIM15OC1 ((uint32_t)0x000C0000) 301 #define COMP_BlankingSrce_TIM15OC2 COMP_CSR_COMPxBLANKING_2 303 #define IS_COMP_BLANKING_SOURCE(SOURCE) (((SOURCE) == COMP_BlankingSrce_None) || \ 304 ((SOURCE) == COMP_BlankingSrce_TIM1OC5) || \ 305 ((SOURCE) == COMP_BlankingSrce_TIM2OC3) || \ 306 ((SOURCE) == COMP_BlankingSrce_TIM3OC3) || \ 307 ((SOURCE) == COMP_BlankingSrce_TIM2OC4) || \ 308 ((SOURCE) == COMP_BlankingSrce_TIM8OC5) || \ 309 ((SOURCE) == COMP_BlankingSrce_TIM3OC4) || \ 310 ((SOURCE) == COMP_BlankingSrce_TIM15OC1) || \ 311 ((SOURCE) == COMP_BlankingSrce_TIM15OC2)) 319 #define COMP_OutputPol_NonInverted ((uint32_t)0x00000000) 320 #define COMP_OutputPol_Inverted COMP_CSR_COMPxPOL 322 #define IS_COMP_OUTPUT_POL(POL) (((POL) == COMP_OutputPol_NonInverted) || \ 323 ((POL) == COMP_OutputPol_Inverted)) 334 #define COMP_Hysteresis_No 0x00000000 335 #define COMP_Hysteresis_Low COMP_CSR_COMPxHYST_0 336 #define COMP_Hysteresis_Medium COMP_CSR_COMPxHYST_1 337 #define COMP_Hysteresis_High COMP_CSR_COMPxHYST 339 #define IS_COMP_HYSTERESIS(HYSTERESIS) (((HYSTERESIS) == COMP_Hysteresis_No) || \ 340 ((HYSTERESIS) == COMP_Hysteresis_Low) || \ 341 ((HYSTERESIS) == COMP_Hysteresis_Medium) || \ 342 ((HYSTERESIS) == COMP_Hysteresis_High)) 352 #define COMP_Mode_HighSpeed 0x00000000 353 #define COMP_Mode_MediumSpeed COMP_CSR_COMPxMODE_0 354 #define COMP_Mode_LowPower COMP_CSR_COMPxMODE_1 355 #define COMP_Mode_UltraLowPower COMP_CSR_COMPxMODE 357 #define IS_COMP_MODE(MODE) (((MODE) == COMP_Mode_UltraLowPower) || \ 358 ((MODE) == COMP_Mode_LowPower) || \ 359 ((MODE) == COMP_Mode_MediumSpeed) || \ 360 ((MODE) == COMP_Mode_HighSpeed)) 370 #define COMP_OutputLevel_High COMP_CSR_COMPxOUT 373 #define COMP_OutputLevel_Low ((uint32_t)0x00000000) 382 #define IS_COMP_WINDOW(WINDOW) (((WINDOW) == COMP_Selection_COMP2) || \ 383 ((WINDOW) == COMP_Selection_COMP4) || \ 384 ((WINDOW) == COMP_Selection_COMP6)) uint32_t COMP_NonInvertingInput
void COMP_Cmd(uint32_t COMP_Selection, FunctionalState NewState)
Enable or disable the COMP peripheral.
void COMP_SwitchCmd(uint32_t COMP_Selection, FunctionalState NewState)
Close or Open the SW1 switch.
uint32_t COMP_GetOutputLevel(uint32_t COMP_Selection)
Return the output level (high or low) of the selected comparator. The output level depends on the sel...
uint32_t COMP_BlankingSrce
void COMP_StructInit(COMP_InitTypeDef *COMP_InitStruct)
Fills each COMP_InitStruct member with its default value.
COMP Init structure definition.
uint32_t COMP_InvertingInput
void COMP_WindowCmd(uint32_t COMP_Selection, FunctionalState NewState)
Enables or disables the window mode. Window mode for comparators makes use of two comparators: COMP1 ...
void COMP_DeInit(uint32_t COMP_Selection)
Deinitializes COMP peripheral registers to their default reset values.
void COMP_Init(uint32_t COMP_Selection, COMP_InitTypeDef *COMP_InitStruct)
Initializes the COMP peripheral according to the specified parameters in COMP_InitStruct.
void COMP_LockConfig(uint32_t COMP_Selection)
Lock the selected comparator (COMP1/COMP2) configuration.