stm32f30x_comp.h
Go to the documentation of this file.
1 
29 /* Define to prevent recursive inclusion -------------------------------------*/
30 #ifndef __STM32F30x_COMP_H
31 #define __STM32F30x_COMP_H
32 
33 #ifdef __cplusplus
34  extern "C" {
35 #endif
36 
37 /* Includes ------------------------------------------------------------------*/
38 #include "stm32f30x.h"
39 
48 /* Exported types ------------------------------------------------------------*/
49 
54 typedef struct
55 {
56 
63  uint32_t COMP_Output;
66  uint32_t COMP_BlankingSrce;
69  uint32_t COMP_OutputPol;
72  uint32_t COMP_Hysteresis;
75  uint32_t COMP_Mode;
79 
80 /* Exported constants --------------------------------------------------------*/
81 
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))
105 
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))
139 
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)
166 /* Output Redirection common for all comparators COMP1...COMP7 */
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)
173 /* Output Redirection common for COMP1 and COMP2 */
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)
181 /* Output Redirection specific to COMP2 */
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)
186 /* Output Redirection specific to COMP3 */
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)
192 /* Output Redirection specific to COMP4 */
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)
203 /* Output Redirection specific to COMP5 */
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)
209 /* Output Redirection specific to COMP6 */
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)
220 /* Output Redirection specific to COMP7 */
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))
269 
278 /* No blanking source can be selected for all comparators */
279 #define COMP_BlankingSrce_None ((uint32_t)0x00000000)
281 /* Blanking source common for COMP1, COMP2, COMP3 and COMP7 */
282 #define COMP_BlankingSrce_TIM1OC5 COMP_CSR_COMPxBLANKING_0
284 /* Blanking source common for COMP1 and COMP2 */
285 #define COMP_BlankingSrce_TIM2OC3 COMP_CSR_COMPxBLANKING_1
287 /* Blanking source common for COMP1, COMP2 and COMP5 */
288 #define COMP_BlankingSrce_TIM3OC3 ((uint32_t)0x000C0000)
290 /* Blanking source common for COMP3 and COMP6 */
291 #define COMP_BlankingSrce_TIM2OC4 ((uint32_t)0x000C0000)
293 /* Blanking source common for COMP4, COMP5, COMP6 and COMP7 */
294 #define COMP_BlankingSrce_TIM8OC5 COMP_CSR_COMPxBLANKING_1
296 /* Blanking source for COMP4 */
297 #define COMP_BlankingSrce_TIM3OC4 COMP_CSR_COMPxBLANKING_0
298 #define COMP_BlankingSrce_TIM15OC1 ((uint32_t)0x000C0000)
300 /* Blanking source common for COMP6 and COMP7 */
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))
312 
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))
324 
332 /* Please refer to the electrical characteristics in the device datasheet for
333  the hysteresis level */
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))
350 /* Please refer to the electrical characteristics in the device datasheet for
351  the power consumption values */
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))
368 /* When output polarity is not inverted, comparator output is high when
369  the non-inverting input is at a higher voltage than the inverting input */
370 #define COMP_OutputLevel_High COMP_CSR_COMPxOUT
371 /* When output polarity is not inverted, comparator output is low when
372  the non-inverting input is at a lower voltage than the inverting input*/
373 #define COMP_OutputLevel_Low ((uint32_t)0x00000000)
374 
382 #define IS_COMP_WINDOW(WINDOW) (((WINDOW) == COMP_Selection_COMP2) || \
383  ((WINDOW) == COMP_Selection_COMP4) || \
384  ((WINDOW) == COMP_Selection_COMP6))
385 
393 /* Exported macro ------------------------------------------------------------*/
394 /* Exported functions ------------------------------------------------------- */
395 
396 /* Function used to set the COMP configuration to the default reset state ****/
397 void COMP_DeInit(uint32_t COMP_Selection);
398 
399 /* Initialization and Configuration functions *********************************/
400 void COMP_Init(uint32_t COMP_Selection, COMP_InitTypeDef* COMP_InitStruct);
401 void COMP_StructInit(COMP_InitTypeDef* COMP_InitStruct);
402 void COMP_Cmd(uint32_t COMP_Selection, FunctionalState NewState);
403 void COMP_SwitchCmd(uint32_t COMP_Selection, FunctionalState NewState);
404 uint32_t COMP_GetOutputLevel(uint32_t COMP_Selection);
405 
406 /* Window mode control function ***********************************************/
407 void COMP_WindowCmd(uint32_t COMP_Selection, FunctionalState NewState);
408 
409 /* COMP configuration locking function ****************************************/
410 void COMP_LockConfig(uint32_t COMP_Selection);
411 
412 #ifdef __cplusplus
413 }
414 #endif
415 
416 #endif /*__STM32F30x_COMP_H */
417 
426 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
uint32_t COMP_NonInvertingInput
void COMP_Cmd(uint32_t COMP_Selection, FunctionalState NewState)
Enable or disable the COMP peripheral.
FunctionalState
Definition: stm32f4xx.h:708
uint32_t COMP_Hysteresis
uint32_t COMP_Output
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.
uint32_t COMP_OutputPol
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.


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Oct 24 2019 03:17:19