STM32F37 Standard Peripheral bibliotheek  1.0
ST Microelectronics bibliotheek documentatie voor de STM32F37 Standard Peripheral Library
 All Data Structures Files Functions Variables Enumerations Enumerator Groups
stm32f37x_comp.h
Go to the documentation of this file.
1 
29 /* Define to prevent recursive inclusion -------------------------------------*/
30 #ifndef __STM32F37X_COMP_H
31 #define __STM32F37X_COMP_H
32 
33 #ifdef __cplusplus
34  extern "C" {
35 #endif
36 
37 /* Includes ------------------------------------------------------------------*/
38 #include "stm32f37x.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_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))
116 
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))
148 
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))
160 
168 /* Please refer to the electrical characteristics in the device datasheet for
169  the hysteresis level */
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))
179 
186 /* Please refer to the electrical characteristics in the device datasheet for
187  the power consumption values */
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))
197 
204 /* When output polarity is not inverted, comparator output is high when
205  the non-inverting input is at a higher voltage than the inverting input */
206 #define COMP_OutputLevel_High COMP_CSR_COMP1OUT
207 /* When output polarity is not inverted, comparator output is low when
208  the non-inverting input is at a lower voltage than the inverting input*/
209 #define COMP_OutputLevel_Low ((uint32_t)0x00000000)
210 
219 /* Exported macro ------------------------------------------------------------*/
220 /* Exported functions ------------------------------------------------------- */
221 
222 /* Function used to set the COMP configuration to the default reset state ****/
223 void COMP_DeInit(void);
224 
225 /* Initialization and Configuration functions *********************************/
226 void COMP_Init(uint32_t COMP_Selection, COMP_InitTypeDef* COMP_InitStruct);
227 void COMP_StructInit(COMP_InitTypeDef* COMP_InitStruct);
228 void COMP_Cmd(uint32_t COMP_Selection, FunctionalState NewState);
229 void COMP_SwitchCmd(FunctionalState NewState);
230 uint32_t COMP_GetOutputLevel(uint32_t COMP_Selection);
231 
232 /* Window mode control function ***********************************************/
233 void COMP_WindowCmd(FunctionalState NewState);
234 
235 /* COMP configuration locking function ****************************************/
236 void COMP_LockConfig(uint32_t COMP_Selection);
237 
238 #ifdef __cplusplus
239 }
240 #endif
241 
242 #endif /*__STM32F37X_COMP_H */
243 
252 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/