123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- #ifndef __STM32F0XX_COMP_H
- #define __STM32F0XX_COMP_H
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include "stm32f0xx.h"
-
- typedef struct
- {
- uint32_t COMP_InvertingInput;
- uint32_t COMP_Output;
- uint32_t COMP_OutputPol;
- uint32_t COMP_Hysteresis;
- uint32_t COMP_Mode;
- }COMP_InitTypeDef;
-
-
- #define COMP_Selection_COMP1 ((uint32_t)0x00000000)
- #define COMP_Selection_COMP2 ((uint32_t)0x00000010)
- #define IS_COMP_ALL_PERIPH(PERIPH) (((PERIPH) == COMP_Selection_COMP1) || \
- ((PERIPH) == COMP_Selection_COMP2))
-
-
- #define COMP_InvertingInput_1_4VREFINT ((uint32_t)0x00000000)
- #define COMP_InvertingInput_1_2VREFINT COMP_CSR_COMP1INSEL_0
- #define COMP_InvertingInput_3_4VREFINT COMP_CSR_COMP1INSEL_1
- #define COMP_InvertingInput_VREFINT ((uint32_t)0x00000030)
- #define COMP_InvertingInput_DAC1 COMP_CSR_COMP1INSEL_2
- #define COMP_InvertingInput_IO ((uint32_t)0x00000060)
- #define IS_COMP_INVERTING_INPUT(INPUT) (((INPUT) == COMP_InvertingInput_1_4VREFINT) || \
- ((INPUT) == COMP_InvertingInput_1_2VREFINT) || \
- ((INPUT) == COMP_InvertingInput_3_4VREFINT) || \
- ((INPUT) == COMP_InvertingInput_VREFINT) || \
- ((INPUT) == COMP_InvertingInput_DAC1) || \
- ((INPUT) == COMP_InvertingInput_1_4VREFINT) || \
- ((INPUT) == COMP_InvertingInput_IO))
-
-
- #define COMP_Output_None ((uint32_t)0x00000000)
- #define COMP_Output_TIM1BKIN COMP_CSR_COMP1OUTSEL_0
- #define COMP_Output_TIM1IC1 COMP_CSR_COMP1OUTSEL_1
- #define COMP_Output_TIM1OCREFCLR ((uint32_t)0x00000300)
- #define COMP_Output_TIM2IC4 COMP_CSR_COMP1OUTSEL_2
- #define COMP_Output_TIM2OCREFCLR ((uint32_t)0x00000500)
- #define COMP_Output_TIM3IC1 ((uint32_t)0x00000600)
- #define COMP_Output_TIM3OCREFCLR COMP_CSR_COMP1OUTSEL
- #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_Output_None) || \
- ((OUTPUT) == COMP_Output_TIM1BKIN) || \
- ((OUTPUT) == COMP_Output_TIM1IC1) || \
- ((OUTPUT) == COMP_Output_TIM1OCREFCLR) || \
- ((OUTPUT) == COMP_Output_TIM2IC4) || \
- ((OUTPUT) == COMP_Output_TIM2OCREFCLR) || \
- ((OUTPUT) == COMP_Output_TIM3IC1) || \
- ((OUTPUT) == COMP_Output_TIM3OCREFCLR))
-
- #define COMP_OutputPol_NonInverted ((uint32_t)0x00000000)
- #define COMP_OutputPol_Inverted COMP_CSR_COMP1POL
- #define IS_COMP_OUTPUT_POL(POL) (((POL) == COMP_OutputPol_NonInverted) || \
- ((POL) == COMP_OutputPol_Inverted))
-
- #define COMP_Hysteresis_No 0x00000000
- #define COMP_Hysteresis_Low COMP_CSR_COMP1HYST_0
- #define COMP_Hysteresis_Medium COMP_CSR_COMP1HYST_1
- #define COMP_Hysteresis_High COMP_CSR_COMP1HYST
- #define IS_COMP_HYSTERESIS(HYSTERESIS) (((HYSTERESIS) == COMP_Hysteresis_No) || \
- ((HYSTERESIS) == COMP_Hysteresis_Low) || \
- ((HYSTERESIS) == COMP_Hysteresis_Medium) || \
- ((HYSTERESIS) == COMP_Hysteresis_High))
- #define COMP_Mode_HighSpeed 0x00000000
- #define COMP_Mode_MediumSpeed COMP_CSR_COMP1MODE_0
- #define COMP_Mode_LowPower COMP_CSR_COMP1MODE_1
- #define COMP_Mode_UltraLowPower COMP_CSR_COMP1MODE
- #define IS_COMP_MODE(MODE) (((MODE) == COMP_Mode_UltraLowPower) || \
- ((MODE) == COMP_Mode_LowPower) || \
- ((MODE) == COMP_Mode_MediumSpeed) || \
- ((MODE) == COMP_Mode_HighSpeed))
-
- #define COMP_OutputLevel_High COMP_CSR_COMP1OUT
- #define COMP_OutputLevel_Low ((uint32_t)0x00000000)
-
-
- void COMP_DeInit(void);
- void COMP_Init(uint32_t COMP_Selection, COMP_InitTypeDef* COMP_InitStruct);
- void COMP_StructInit(COMP_InitTypeDef* COMP_InitStruct);
- void COMP_Cmd(uint32_t COMP_Selection, FunctionalState NewState);
- void COMP_SwitchCmd(FunctionalState NewState);
- uint32_t COMP_GetOutputLevel(uint32_t COMP_Selection);
- void COMP_WindowCmd(FunctionalState NewState);
- void COMP_LockConfig(uint32_t COMP_Selection);
- #ifdef __cplusplus
- }
- #endif
- #endif
-
|