1 /**
2   ******************************************************************************
3   * @file    stm32h7xx_hal_comp.h
4   * @author  MCD Application Team
5   * @brief   Header file of COMP HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2017 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32H7xx_HAL_COMP_H
21 #define STM32H7xx_HAL_COMP_H
22 
23 #ifdef __cplusplus
24  extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32h7xx_hal_def.h"
29 
30 /** @addtogroup STM32H7xx_HAL_Driver
31   * @{
32   */
33 
34 /** @addtogroup COMP
35   * @{
36   */
37 
38 /* Exported types ------------------------------------------------------------*/
39 /** @defgroup COMP_Exported_Types COMP Exported Types
40   * @{
41   */
42 
43 /**
44   * @brief  COMP Init structure definition
45   */
46 typedef struct
47 {
48 
49   uint32_t WindowMode;         /*!< Set window mode of a pair of comparators instances
50                                     (2 consecutive instances odd and even COMP<x> and COMP<x+1>).
51                                     Note: HAL COMP driver allows to set window mode from any COMP instance of the pair of COMP instances composing window mode.
52                                     This parameter can be a value of @ref COMP_WindowMode */
53 
54   uint32_t Mode;               /*!< Set comparator operating mode to adjust power and speed.
55                                     Note: For the characteritics of comparator power modes
56                                           (propagation delay and power consumption), refer to device datasheet.
57                                     This parameter can be a value of @ref COMP_PowerMode */
58 
59   uint32_t NonInvertingInput;  /*!< Set comparator input plus (non-inverting input).
60                                     This parameter can be a value of @ref COMP_InputPlus */
61 
62   uint32_t InvertingInput;     /*!< Set comparator input minus (inverting input).
63                                     This parameter can be a value of @ref COMP_InputMinus */
64 
65   uint32_t Hysteresis;         /*!< Set comparator hysteresis mode of the input minus.
66                                     This parameter can be a value of @ref COMP_Hysteresis */
67 
68   uint32_t OutputPol;          /*!< Set comparator output polarity.
69                                     This parameter can be a value of @ref COMP_OutputPolarity */
70 
71   uint32_t BlankingSrce;       /*!< Set comparator blanking source.
72                                     This parameter can be a value of @ref COMP_BlankingSrce */
73 
74   uint32_t TriggerMode;        /*!< Set the comparator output triggering External Interrupt Line (EXTI).
75                                     This parameter can be a value of @ref COMP_EXTI_TriggerMode */
76 
77 }COMP_InitTypeDef;
78 
79 /**
80   * @brief  HAL COMP state machine: HAL COMP states definition
81   */
82 #define COMP_STATE_BITFIELD_LOCK  ((uint32_t)0x10)
83 typedef enum
84 {
85   HAL_COMP_STATE_RESET             = 0x00,                                              /*!< COMP not yet initialized                             */
86   HAL_COMP_STATE_RESET_LOCKED      = (HAL_COMP_STATE_RESET | COMP_STATE_BITFIELD_LOCK), /*!< COMP not yet initialized and configuration is locked */
87   HAL_COMP_STATE_READY             = 0x01,                                              /*!< COMP initialized and ready for use                   */
88   HAL_COMP_STATE_READY_LOCKED      = (HAL_COMP_STATE_READY | COMP_STATE_BITFIELD_LOCK), /*!< COMP initialized but configuration is locked         */
89   HAL_COMP_STATE_BUSY              = 0x02,                                              /*!< COMP is running                                      */
90   HAL_COMP_STATE_BUSY_LOCKED       = (HAL_COMP_STATE_BUSY | COMP_STATE_BITFIELD_LOCK)   /*!< COMP is running and configuration is locked          */
91 }HAL_COMP_StateTypeDef;
92 
93 /**
94   * @brief  COMP Handle Structure definition
95   */
96 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
97 typedef struct __COMP_HandleTypeDef
98 #else
99 typedef struct
100 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
101 {
102   COMP_TypeDef       *Instance;       /*!< Register base address    */
103   COMP_InitTypeDef   Init;            /*!< COMP required parameters */
104   HAL_LockTypeDef    Lock;            /*!< Locking object           */
105   __IO HAL_COMP_StateTypeDef  State;  /*!< COMP communication state */
106   __IO uint32_t      ErrorCode;       /*!< COMP error code */
107 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
108   void (* TriggerCallback)(struct __COMP_HandleTypeDef *hcomp);   /*!< COMP trigger callback */
109   void (* MspInitCallback)(struct __COMP_HandleTypeDef *hcomp);   /*!< COMP Msp Init callback */
110   void (* MspDeInitCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP Msp DeInit callback */
111 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
112 
113 } COMP_HandleTypeDef;
114 
115 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
116 /**
117   * @brief  HAL COMP Callback ID enumeration definition
118   */
119 typedef enum
120 {
121   HAL_COMP_TRIGGER_CB_ID                = 0x00U,  /*!< COMP trigger callback ID */
122   HAL_COMP_MSPINIT_CB_ID                = 0x01U,  /*!< COMP Msp Init callback ID */
123   HAL_COMP_MSPDEINIT_CB_ID              = 0x02U   /*!< COMP Msp DeInit callback ID */
124 } HAL_COMP_CallbackIDTypeDef;
125 
126 /**
127   * @brief  HAL COMP Callback pointer definition
128   */
129 typedef  void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer to a COMP callback function */
130 
131 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
132 /**
133   * @}
134   */
135 
136 /* Exported constants --------------------------------------------------------*/
137 /** @defgroup COMP_Exported_Constants COMP Exported Constants
138   * @{
139   */
140 
141 /** @defgroup COMP_Error_Code COMP Error Code
142   * @{
143   */
144 #define HAL_COMP_ERROR_NONE             (0x00U)   /*!< No error */
145 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
146 #define HAL_COMP_ERROR_INVALID_CALLBACK (0x01U)   /*!< Invalid Callback error */
147 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
148 /**
149   * @}
150   */
151 
152 /** @defgroup COMP_WindowMode COMP Window Mode
153   * @{
154   */
155 #define COMP_WINDOWMODE_DISABLE                 ((uint32_t)0x00000000)   /*!< Window mode disable: Comparators instances pair COMP1 and COMP2 are independent */
156 #define COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP_CFGRx_WINMODE)     /*!< Window mode enable: Comparators instances pair COMP1 and COMP2 have their input plus connected together. The common input is COMP1 input plus (COMP2 input plus is no more accessible). */
157 
158 /**
159   * @}
160   */
161 
162 /** @defgroup COMP_PowerMode COMP power mode
163   * @{
164   */
165 /* Note: For the characteritics of comparator power modes                     */
166 /*       (propagation delay and power consumption),                           */
167 /*       refer to device datasheet.                                           */
168 #define COMP_POWERMODE_HIGHSPEED       ((uint32_t)0x00000000)   /*!< High Speed */
169 #define COMP_POWERMODE_MEDIUMSPEED     (COMP_CFGRx_PWRMODE_0)   /*!< Medium Speed */
170 #define COMP_POWERMODE_ULTRALOWPOWER   (COMP_CFGRx_PWRMODE)     /*!< Ultra-low power mode */
171 /**
172   * @}
173   */
174 
175 /** @defgroup COMP_InputPlus COMP input plus (non-inverting input)
176   * @{
177   */
178 #define COMP_INPUT_PLUS_IO1            ((uint32_t)0x00000000) /*!< Comparator input plus connected to IO1 (pin PB0 for COMP1, pin PE9 for COMP2) */
179 #define COMP_INPUT_PLUS_IO2            (COMP_CFGRx_INPSEL)    /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PE11 for COMP2) */
180 #if defined (COMP_CFGRx_INP2SEL)
181 #define COMP_INPUT_PLUS_DAC2_CH1       (COMP_CFGRx_INP2SEL)   /*!< Comparator input plus 2 connected to (DAC2_CH1 for COMP1) */
182 #endif
183 /**
184   * @}
185   */
186 
187 /** @defgroup COMP_InputMinus COMP input minus (inverting input)
188   * @{
189   */
190 #define COMP_INPUT_MINUS_1_4VREFINT     (                                                                                        COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN)    /*!< Comparator input minus connected to 1/4 VrefInt */
191 #define COMP_INPUT_MINUS_1_2VREFINT     (                                                                  COMP_CFGRx_INMSEL_0 | COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN)    /*!< Comparator input minus connected to 1/2 VrefInt */
192 #define COMP_INPUT_MINUS_3_4VREFINT     (                                            COMP_CFGRx_INMSEL_1                       | COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN)    /*!< Comparator input minus connected to 3/4 VrefInt */
193 #define COMP_INPUT_MINUS_VREFINT        (                                            COMP_CFGRx_INMSEL_1 | COMP_CFGRx_INMSEL_0 | COMP_CFGRx_SCALEN                   )    /*!< Comparator input minus connected to VrefInt */
194 #define COMP_INPUT_MINUS_DAC1_CH1       (                      COMP_CFGRx_INMSEL_2                                                                                   )    /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1) */
195 #define COMP_INPUT_MINUS_DAC1_CH2       (                      COMP_CFGRx_INMSEL_2                       | COMP_CFGRx_INMSEL_0                                       )    /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2) */
196 #define COMP_INPUT_MINUS_IO1            (                      COMP_CFGRx_INMSEL_2 | COMP_CFGRx_INMSEL_1                                                             )    /*!< Comparator input minus connected to IO1 (pin PB1 for COMP1, pin PE10 for COMP2) */
197 #define COMP_INPUT_MINUS_IO2            (                      COMP_CFGRx_INMSEL_2 | COMP_CFGRx_INMSEL_1 | COMP_CFGRx_INMSEL_0                                       )    /*!< Comparator input minus connected to IO2 (pin PC4 for COMP1, pin PE7 for COMP2) */
198 #if defined (COMP_CFGRx_INMSEL_3)
199 #define COMP_INPUT_MINUS_TPSENS_DAC2CH1 (COMP_CFGRx_INMSEL_3                                                                                                         )    /*!< Comparator input minus connected to (temp sensor which is exist in ADC for COMP1, DAC2_CH1 for COMP2) */
200 #define COMP_INPUT_MINUS_VBAT_VDDAP     (COMP_CFGRx_INMSEL_3                                             | COMP_CFGRx_INMSEL_0                                       )    /*!< Comparator input minus connected to (VBAT/4 for COMP1, VDDAP for COMP2) */
201 #endif
202 /**
203   * @}
204   */
205 
206 /** @defgroup COMP_Hysteresis COMP hysteresis
207   * @{
208   */
209 #define COMP_HYSTERESIS_NONE           ((uint32_t)0x00000000)   /*!< No hysteresis */
210 #define COMP_HYSTERESIS_LOW            (COMP_CFGRx_HYST_0)      /*!< Hysteresis level low */
211 #define COMP_HYSTERESIS_MEDIUM         (COMP_CFGRx_HYST_1)      /*!< Hysteresis level medium */
212 #define COMP_HYSTERESIS_HIGH           (COMP_CFGRx_HYST)        /*!< Hysteresis level high */
213 /**
214   * @}
215   */
216 
217 /** @defgroup COMP_OutputPolarity COMP Output Polarity
218   * @{
219   */
220 #define COMP_OUTPUTPOL_NONINVERTED     ((uint32_t)0x00000000)  /*!< COMP output level is not inverted (comparator output is high when the input plus is at a higher voltage than the input minus) */
221 #define COMP_OUTPUTPOL_INVERTED        (COMP_CFGRx_POLARITY)   /*!< COMP output level is inverted     (comparator output is low  when the input plus is at a higher voltage than the input minus) */
222 /**
223   * @}
224   */
225 
226 
227 /** @defgroup COMP_BlankingSrce  COMP Blanking Source
228   * @{
229   */
230 /* Any blanking source can be selected for all comparators */
231 #define COMP_BLANKINGSRC_NONE             ((uint32_t)0x00000000)                           /*!< No blanking source */
232 #define COMP_BLANKINGSRC_TIM1_OC5         (COMP_CFGRx_BLANKING_0)                          /*!< TIM1 OC5 selected as blanking source for comparator */
233 #define COMP_BLANKINGSRC_TIM2_OC3         (COMP_CFGRx_BLANKING_1)                          /*!< TIM2 OC3 selected as blanking source for comparator */
234 #define COMP_BLANKINGSRC_TIM3_OC3         (COMP_CFGRx_BLANKING_0 |COMP_CFGRx_BLANKING_1)   /*!< TIM3 OC3 selected as blanking source for compartor */
235 #define COMP_BLANKINGSRC_TIM3_OC4         (COMP_CFGRx_BLANKING_2)                          /*!< TIM3 OC4 selected as blanking source for comparator */
236 #define COMP_BLANKINGSRC_TIM8_OC5         (COMP_CFGRx_BLANKING_2|COMP_CFGRx_BLANKING_0)    /*!< TIM8 OC5 selected as blanking source for comparator */
237 #define COMP_BLANKINGSRC_TIM15_OC1        (COMP_CFGRx_BLANKING_2|COMP_CFGRx_BLANKING_1)    /*!< TIM15 OC1 selected as blanking source for comparator */
238 /**
239   * @}
240   */
241 
242 
243 
244 
245 /** @defgroup COMP_OutputLevel COMP Output Level
246   * @{
247   */
248 
249 /* Note: Comparator output level values are fixed to "0" and "1",             */
250 /* corresponding COMP register bit is managed by HAL function to match        */
251 /* with these values (independently of bit position in register).             */
252 
253 /* When output polarity is not inverted, comparator output is low when
254    the input plus is at a lower voltage than the input minus */
255 #define COMP_OUTPUT_LEVEL_LOW              ((uint32_t)0x00000000)
256 /* When output polarity is not inverted, comparator output is high when
257    the input plus is at a higher voltage than the input minus */
258 #define COMP_OUTPUT_LEVEL_HIGH             ((uint32_t)0x00000001)
259 
260 /**
261   * @}
262   */
263 
264 /** @defgroup COMP_EXTI_TriggerMode COMP output to EXTI
265   * @{
266   */
267 #define COMP_TRIGGERMODE_NONE                 ((uint32_t)0x00000000)                                    /*!< Comparator output triggering no External Interrupt Line */
268 #define COMP_TRIGGERMODE_IT_RISING            (COMP_EXTI_IT | COMP_EXTI_RISING)                         /*!< Comparator output triggering External Interrupt Line event with interruption, on rising edge */
269 #define COMP_TRIGGERMODE_IT_FALLING           (COMP_EXTI_IT | COMP_EXTI_FALLING)                        /*!< Comparator output triggering External Interrupt Line event with interruption, on falling edge */
270 #define COMP_TRIGGERMODE_IT_RISING_FALLING    (COMP_EXTI_IT | COMP_EXTI_RISING | COMP_EXTI_FALLING)     /*!< Comparator output triggering External Interrupt Line event with interruption, on both rising and falling edges */
271 #define COMP_TRIGGERMODE_EVENT_RISING         (COMP_EXTI_EVENT | COMP_EXTI_RISING)                      /*!< Comparator output triggering External Interrupt Line event only (without interruption), on rising edge */
272 #define COMP_TRIGGERMODE_EVENT_FALLING        (COMP_EXTI_EVENT | COMP_EXTI_FALLING)                     /*!< Comparator output triggering External Interrupt Line event only (without interruption), on falling edge */
273 #define COMP_TRIGGERMODE_EVENT_RISING_FALLING (COMP_EXTI_EVENT | COMP_EXTI_RISING | COMP_EXTI_FALLING)  /*!< Comparator output triggering External Interrupt Line event only (without interruption), on both rising and falling edges */
274 
275 /**
276   * @}
277   */
278 
279 /** @defgroup COMP_Flag COMP Flag
280   * @{
281   */
282 #define COMP_FLAG_C1I           COMP_SR_C1IF           /*!< Comparator 1 Interrupt Flag */
283 #define COMP_FLAG_C2I           COMP_SR_C2IF           /*!< Comparator 2 Interrupt Flag */
284 #define COMP_FLAG_LOCK          COMP_CFGRx_LOCK        /*!< Lock flag */
285 /**
286   * @}
287   */
288 /** @defgroup COMP_IT_CLEAR_Flags  COMP Interruption Clear Flags
289   * @{
290   */
291 #define COMP_CLEAR_C1IF          COMP_ICFR_C1IF     /*!< Clear Comparator 1 Interrupt Flag */
292 #define COMP_CLEAR_C2IF          COMP_ICFR_C2IF     /*!< Clear Comparator 2 Interrupt Flag */
293 /**
294   * @}
295   */
296 /** @defgroup COMP_Interrupts_Definitions COMP Interrupts Definitions
297   * @{
298   */
299 #define COMP_IT_EN               COMP_CFGRx_ITEN
300 
301 /**
302   * @}
303   */
304 
305 
306 /**
307   * @}
308   */
309 
310 /* Exported macros -----------------------------------------------------------*/
311 /** @defgroup COMP_Exported_Macros COMP Exported Macros
312   * @{
313   */
314 /** @defgroup COMP_Handle_Management  COMP Handle Management
315  * @{
316   */
317 
318 /** @brief  Reset COMP handle state.
319   * @param  __HANDLE__  COMP handle
320   * @retval None
321   */
322 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
323 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) do{                                                 \
324                                                      (__HANDLE__)->State = HAL_COMP_STATE_RESET;      \
325                                                      (__HANDLE__)->MspInitCallback = NULL;            \
326                                                      (__HANDLE__)->MspDeInitCallback = NULL;          \
327                                                     } while(0)
328 #else
329 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
330 #endif
331 
332 /**
333   * @brief Clear COMP error code (set it to no error code "HAL_COMP_ERROR_NONE").
334   * @param __HANDLE__ COMP handle
335   * @retval None
336   */
337 #define COMP_CLEAR_ERRORCODE(__HANDLE__) ((__HANDLE__)->ErrorCode = HAL_COMP_ERROR_NONE)
338 
339 /**
340   * @brief  Enable the specified comparator.
341   * @param  __HANDLE__ COMP handle
342   * @retval None
343   */
344 #define __HAL_COMP_ENABLE(__HANDLE__)                 SET_BIT((__HANDLE__)->Instance->CFGR, COMP_CFGRx_EN)
345 
346 /**
347   * @brief  Disable the specified comparator.
348   * @param  __HANDLE__ COMP handle
349   * @retval None
350   */
351 #define __HAL_COMP_DISABLE(__HANDLE__)                CLEAR_BIT((__HANDLE__)->Instance->CFGR, COMP_CFGRx_EN)
352 
353 /**
354   * @brief  Lock the specified comparator configuration.
355   * @note   Using this macro induce HAL COMP handle state machine being no
356   *         more in line with COMP instance state.
357   *         To keep HAL COMP handle state machine updated, it is recommended
358   *         to use function "HAL_COMP_Lock')".
359   * @param  __HANDLE__ COMP handle
360   * @retval None
361   */
362 #define __HAL_COMP_LOCK(__HANDLE__)                   SET_BIT((__HANDLE__)->Instance->CFGR, COMP_CFGRx_LOCK)
363 
364 /**
365   * @brief  Check whether the specified comparator is locked.
366   * @param  __HANDLE__  COMP handle
367   * @retval Value 0 if COMP instance is not locked, value 1 if COMP instance is locked
368   */
369 #define __HAL_COMP_IS_LOCKED(__HANDLE__)           (READ_BIT((__HANDLE__)->Instance->CFGR, COMP_CFGRx_LOCK) == COMP_CFGRx_LOCK)
370 
371 /**
372   * @}
373   */
374 
375 /** @defgroup COMP_Exti_Management  COMP external interrupt line management
376   * @{
377   */
378 
379 /**
380   * @brief  Enable the COMP1 EXTI line rising edge trigger.
381   * @retval None
382   */
383 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE()    SET_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP1)
384 
385 
386 /**
387   * @brief  Disable the COMP1 EXTI line rising edge trigger.
388   * @retval None
389   */
390 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE()    CLEAR_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP1)
391 
392 /**
393   * @brief  Enable the COMP1 EXTI line falling edge trigger.
394   * @retval None
395   */
396 #define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE()    SET_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP1)
397 
398 /**
399   * @brief  Disable the COMP1 EXTI line falling edge trigger.
400   * @retval None
401   */
402 #define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE()    CLEAR_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP1)
403 
404 
405 /**
406   * @brief  Enable the COMP1 EXTI line rising & falling edge trigger.
407   * @retval None
408   */
409 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE()   do {                                           \
410                                                                __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE();  \
411                                                                __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE(); \
412                                                              } while(0)
413 
414 
415 /**
416   * @brief  Disable the COMP1 EXTI line rising & falling edge trigger.
417   * @retval None
418   */
419 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE()  do {                                            \
420                                                                __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE();  \
421                                                                __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE(); \
422                                                              } while(0)
423 
424 
425 /**
426   * @brief  Enable the COMP1 EXTI line in interrupt mode.
427   * @retval None
428   */
429 #define __HAL_COMP_COMP1_EXTI_ENABLE_IT()             SET_BIT(EXTI_D1->IMR1, COMP_EXTI_LINE_COMP1)
430 
431 /**
432   * @brief  Disable the COMP1 EXTI line in interrupt mode.
433   * @retval None
434   */
435 #define __HAL_COMP_COMP1_EXTI_DISABLE_IT()            CLEAR_BIT(EXTI_D1->IMR1, COMP_EXTI_LINE_COMP1)
436 
437 /**
438   * @brief  Enable the COMP1 EXTI Line in event mode.
439   * @retval None
440   */
441 #define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT()           SET_BIT(EXTI_D1->EMR1, COMP_EXTI_LINE_COMP1)
442 
443 /**
444   * @brief  Disable the COMP1 EXTI Line in event mode.
445   * @retval None
446   */
447 #define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT()          CLEAR_BIT(EXTI_D1->EMR1, COMP_EXTI_LINE_COMP1)
448 
449 /**
450   * @brief  Check whether the COMP1 EXTI line flag is set or not.
451   * @retval RESET or SET
452   */
453 #define __HAL_COMP_COMP1_EXTI_GET_FLAG()              READ_BIT(EXTI_D1->PR1, COMP_EXTI_LINE_COMP1)
454 /**
455   * @brief  Clear the COMP1 EXTI flag.
456   * @retval None
457   */
458 #define __HAL_COMP_COMP1_EXTI_CLEAR_FLAG()            WRITE_REG(EXTI_D1->PR1, COMP_EXTI_LINE_COMP1)
459 
460 /**
461   * @brief  Generate a software interrupt on the COMP1 EXTI line.
462   * @retval None
463   */
464 #define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT()         SET_BIT(EXTI->SWIER1, COMP_EXTI_LINE_COMP1)
465 
466 /**
467   * @brief  Enable the COMP1 D3 EXTI Line in event mode.
468   * @retval None
469   */
470 #define __HAL_COMP_COMP1_EXTID3_ENABLE_EVENT()        SET_BIT(EXTI->D3PMR1, COMP_EXTI_LINE_COMP1)
471 
472 /**
473   * @brief  Disable the COMP1 D3 EXTI Line in event mode.
474   * @retval None
475   */
476 #define __HAL_COMP_COMP1_EXTID3_DISABLE_EVENT()        CLEAR_BIT(EXTI->D3PMR1, COMP_EXTI_LINE_COMP1)
477 
478 #if defined(DUAL_CORE)
479 /**
480   * @brief  Enable the COMP1 D2 EXTI line in interrupt mode.
481   * @retval None
482   */
483 #define __HAL_COMP_COMP1_EXTID2_ENABLE_IT()           SET_BIT(EXTI_D2->IMR1, COMP_EXTI_LINE_COMP1)
484 
485 /**
486   * @brief  Disable the COMP1 D2 EXTI line in interrupt mode.
487   * @retval None
488   */
489 #define __HAL_COMP_COMP1_EXTID2_DISABLE_IT()          CLEAR_BIT(EXTI_D2->IMR1, COMP_EXTI_LINE_COMP1)
490 
491 /**
492   * @brief  Enable the COMP1 D2 EXTI Line in event mode.
493   * @retval None
494   */
495 #define __HAL_COMP_COMP1_EXTID2_ENABLE_EVENT()         SET_BIT(EXTI_D2->EMR1, COMP_EXTI_LINE_COMP1)
496 
497 /**
498   * @brief  Disable the COMP1 D2 EXTI Line in event mode.
499   * @retval None
500   */
501 #define __HAL_COMP_COMP1_EXTID2_DISABLE_EVENT()        CLEAR_BIT(EXTI_D2->EMR1, COMP_EXTI_LINE_COMP1)
502 
503 /**
504   * @brief  Check whether the COMP1 D2 EXTI line flag is set or not.
505   * @retval RESET or SET
506   */
507 #define __HAL_COMP_COMP1_EXTID2_GET_FLAG()              READ_BIT(EXTI_D2->PR1, COMP_EXTI_LINE_COMP1)
508 
509 /**
510   * @brief  Clear the COMP1 D2 EXTI flag.
511   * @retval None
512   */
513 #define __HAL_COMP_COMP1_EXTID2_CLEAR_FLAG()            WRITE_REG(EXTI_D2->PR1, COMP_EXTI_LINE_COMP1)
514 
515 #endif
516 
517 /**
518   * @brief  Enable the COMP2 EXTI line rising edge trigger.
519   * @retval None
520   */
521 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE()    SET_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP2)
522 
523 /**
524   * @brief  Disable the COMP2 EXTI line rising edge trigger.
525   * @retval None
526   */
527 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE()   CLEAR_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP2)
528 
529 /**
530   * @brief  Enable the COMP2 EXTI line falling edge trigger.
531   * @retval None
532   */
533 #define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE()   SET_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP2)
534 
535 /**
536   * @brief  Disable the COMP2 EXTI line falling edge trigger.
537   * @retval None
538   */
539 #define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE()  CLEAR_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP2)
540 
541 /**
542   * @brief  Enable the COMP2 EXTI line rising & falling edge trigger.
543   * @retval None
544   */
545 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE()   do {                                           \
546                                                                __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE();  \
547                                                                __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE(); \
548                                                              } while(0)
549 
550 /**
551   * @brief  Disable the COMP2 EXTI line rising & falling edge trigger.
552   * @retval None
553   */
554 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE()   do {                                           \
555                                                                __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE();  \
556                                                                __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE(); \
557                                                              } while(0)
558 /**
559   * @brief  Enable the COMP2 EXTI line.
560   * @retval None
561   */
562 #define __HAL_COMP_COMP2_EXTI_ENABLE_IT()             SET_BIT(EXTI_D1->IMR1, COMP_EXTI_LINE_COMP2)
563 
564 /**
565   * @brief  Disable the COMP2 EXTI line.
566   * @retval None
567   */
568 #define __HAL_COMP_COMP2_EXTI_DISABLE_IT()            CLEAR_BIT(EXTI_D1->IMR1, COMP_EXTI_LINE_COMP2)
569 
570 /**
571   * @brief  Enable the COMP2 EXTI Line in event mode.
572   * @retval None
573   */
574 #define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT()          SET_BIT(EXTI_D1->EMR1, COMP_EXTI_LINE_COMP2)
575 
576 /**
577   * @brief  Disable the COMP2 EXTI Line in event mode.
578   * @retval None
579   */
580 #define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT()          CLEAR_BIT(EXTI_D1->EMR1, COMP_EXTI_LINE_COMP2)
581 
582 /**
583   * @brief  Check whether the COMP2 EXTI line flag is set or not.
584   * @retval RESET or SET
585   */
586 #define __HAL_COMP_COMP2_EXTI_GET_FLAG()              READ_BIT(EXTI_D1->PR1, COMP_EXTI_LINE_COMP2)
587 
588 /**
589   * @brief  Clear the the COMP2 EXTI flag.
590   * @retval None
591   */
592 #define __HAL_COMP_COMP2_EXTI_CLEAR_FLAG()            WRITE_REG(EXTI_D1->PR1, COMP_EXTI_LINE_COMP2)
593 
594 /**
595   * @brief  Enable the COMP2 D3 EXTI Line in event mode.
596   * @retval None
597   */
598 #define __HAL_COMP_COMP2_EXTID3_ENABLE_EVENT()        SET_BIT(EXTI->D3PMR1, COMP_EXTI_LINE_COMP2)
599 
600 /**
601   * @brief  Disable the COMP2 D3 EXTI Line in event mode.
602   * @retval None
603   */
604 #define __HAL_COMP_COMP2_EXTID3_DISABLE_EVENT()       CLEAR_BIT(EXTI->D3PMR1, COMP_EXTI_LINE_COMP2)
605 
606 /**
607   * @brief  Generate a software interrupt on the COMP2 EXTI line.
608   * @retval None
609   */
610 #define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT()         SET_BIT(EXTI->SWIER1, COMP_EXTI_LINE_COMP2)
611 
612 #if defined(DUAL_CORE)
613 /**
614   * @brief  Enable the COMP2 D2 EXTI line
615   * @retval None
616   */
617 #define __HAL_COMP_COMP2_EXTID2_ENABLE_IT()           SET_BIT(EXTI_D2->IMR1, COMP_EXTI_LINE_COMP2)
618 
619 
620 /**
621   * @brief  Disable the COMP2 D2 EXTI line.
622   * @retval None
623   */
624 #define __HAL_COMP_COMP2_EXTID2_DISABLE_IT()          CLEAR_BIT(EXTI_D2->IMR1, COMP_EXTI_LINE_COMP2)
625 
626 
627 
628 /**
629   * @brief  Enable the COMP2 D2 EXTI Line in event mode.
630   * @retval None
631   */
632 #define __HAL_COMP_COMP2_EXTID2_ENABLE_EVENT()         SET_BIT(EXTI_D2->EMR1, COMP_EXTI_LINE_COMP2)
633 
634 
635 
636 /**
637   * @brief  Disable the COMP2 D2 EXTI Line in event mode.
638   * @retval None
639   */
640 #define __HAL_COMP_COMP2_EXTID2_DISABLE_EVENT()        CLEAR_BIT(EXTI_D2->EMR1, COMP_EXTI_LINE_COMP2)
641 
642 
643 /**
644   * @brief  Check whether the COMP2 D2 EXTI line flag is set or not.
645   * @retval RESET or SET
646   */
647 #define __HAL_COMP_COMP2_EXTID2_GET_FLAG()            READ_BIT(EXTI_D2->PR1, COMP_EXTI_LINE_COMP2)
648 
649 /**
650   * @brief  Clear the the COMP2 D2 EXTI flag.
651   * @retval None
652   */
653 #define __HAL_COMP_COMP2_EXTID2_CLEAR_FLAG()          WRITE_REG(EXTI_D2->PR1, COMP_EXTI_LINE_COMP2)
654 
655 #endif
656 /** @brief  Checks if the specified COMP interrupt source is enabled or disabled.
657   * @param  __HANDLE__: specifies the COMP Handle.
658   *         This parameter can be COMP1 where x: 1 or 2 to select the COMP peripheral.
659   * @param  __INTERRUPT__: specifies the COMP interrupt source to check.
660   *          This parameter can be one of the following values:
661   *            @arg COMP_IT_EN: Comparator interrupt enable
662   *
663   * @retval The new state of __IT__ (TRUE or FALSE)
664   */
665 #define __HAL_COMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CFGR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
666 
667 /** @brief  Checks whether the specified COMP flag is set or not.
668   * @param  __FLAG__: specifies the flag to check.
669   *        This parameter can be one of the following values:
670   *            @arg COMP_FLAG_C1I:  Comparator 1 Interrupt Flag
671   *            @arg COMP_FLAG_C2I:  Comparator 2 Interrupt Flag
672   *            @retval The new state of __FLAG__ (TRUE or FALSE)
673   */
674 #define __HAL_COMP_GET_FLAG(__FLAG__)     ((COMP12->SR & (__FLAG__)) == (__FLAG__))
675 
676 /** @brief  Clears the specified COMP pending flag.
677   * @param  __FLAG__: specifies the flag to check.
678   *          This parameter can be any combination of the following values:
679   *            @arg COMP_CLEAR_C1IF  : Clear Comparator 1 Interrupt Flag
680   *            @arg COMP_CLEAR_C2IF  : Clear Comparator 2 Interrupt Flag
681   * @retval None
682   */
683 #define __HAL_COMP_CLEAR_FLAG(__FLAG__)   (COMP12->ICFR = (__FLAG__))
684 
685 /** @brief  Clear the COMP C1I  flag.
686   * @retval None
687   */
688 #define __HAL_COMP_CLEAR_C1IFLAG()   __HAL_COMP_CLEAR_FLAG( COMP_CLEAR_C1IF)
689 
690 /** @brief  Clear the COMP C2I  flag.
691   * @retval None
692   */
693 #define __HAL_COMP_CLEAR_C2IFLAG()   __HAL_COMP_CLEAR_FLAG( COMP_CLEAR_C2IF)
694 
695 /** @brief  Enable the specified COMP interrupt.
696   * @param  __HANDLE__: specifies the COMP Handle.
697   * @param  __INTERRUPT__: specifies the COMP interrupt source to enable.
698   *          This parameter can be one of the following values:
699   *            @arg COMP_CFGRx_ITEN :  Comparator  interrupt
700   * @retval None
701   */
702 #define __HAL_COMP_ENABLE_IT(__HANDLE__, __INTERRUPT__)   ( ((__HANDLE__)->Instance->CFGR) |= (__INTERRUPT__) )
703 
704 /** @brief  Disable the specified COMP interrupt.
705   * @param  __HANDLE__: specifies the COMP Handle.
706   * @param  __INTERRUPT__: specifies the COMP interrupt source to enable.
707   *          This parameter can be one of the following values:
708   *            @arg COMP_CFGRx_ITEN :  Comparator  interrupt
709   * @retval None
710   */
711 #define __HAL_COMP_DISABLE_IT(__HANDLE__,__INTERRUPT__) (((__HANDLE__)->Instance->CFGR) &= ~(__INTERRUPT__))
712 
713 /**
714   * @}
715   */
716 /** @brief  Enable the specified bit in the Option register.
717   * @param  __AF__: specifies the Alternate Function source selection .
718   *          This parameter can be one of the following values:
719   *            @arg COMP_OR_AFOPA6  :  Alternate Function PA6 source selection
720   *            @arg COMP_OR_AFOPA8  :  Alternate Function PA8 source selection
721   *            @arg COMP_OR_AFOPB12 :  Alternate Function PB12 source selection
722   *            @arg COMP_OR_AFOPE6  :  Alternate Function PE6 source selection
723   *            @arg COMP_OR_AFOPE15 :  Alternate Function PE15 source selection
724   *            @arg COMP_OR_AFOPG2  :  Alternate Function PG2 source selection
725   *            @arg COMP_OR_AFOPG3  :  Alternate Function PG3 source selection
726   *            @arg COMP_OR_AFOPG4  :  Alternate Function PG4 source selection
727   *            @arg COMP_OR_AFOPI1  :  Alternate Function PI1 source selection
728   *            @arg COMP_OR_AFOPI4  :  Alternate Function PI4 source selection
729   *            @arg COMP_OR_AFOPK2  :  Alternate Function PK2 source selection
730   * @retval None
731   */
732 #define __HAL_COMP_ENABLE_OR(__AF__) SET_BIT(COMP12->OR, (__AF__))
733 
734 /** @brief  Disable the specified bit in the Option register.
735   * @param  __AF__: specifies the Alternate Function source selection .
736   *          This parameter can be one of the following values:
737   *            @arg COMP_OR_AFOPA6  :  Alternate Function PA6 source selection
738   *            @arg COMP_OR_AFOPA8  :  Alternate Function PA8 source selection
739   *            @arg COMP_OR_AFOPB12 :  Alternate Function PB12 source selection
740   *            @arg COMP_OR_AFOPE6  :  Alternate Function PE6 source selection
741   *            @arg COMP_OR_AFOPE15 :  Alternate Function PE15 source selection
742   *            @arg COMP_OR_AFOPG2  :  Alternate Function PG2 source selection
743   *            @arg COMP_OR_AFOPG3  :  Alternate Function PG3 source selection
744   *            @arg COMP_OR_AFOPG4  :  Alternate Function PG4 source selection
745   *            @arg COMP_OR_AFOPI1  :  Alternate Function PI1 source selection
746   *            @arg COMP_OR_AFOPI4  :  Alternate Function PI4 source selection
747   *            @arg COMP_OR_AFOPK2  :  Alternate Function PK2 source selection
748   * @retval None
749   */
750 #define __HAL_COMP_DISABLE_OR(__AF__) CLEAR_BIT(COMP12->OR, (__AF__))
751 /**
752   * @}
753   */
754 
755 /* Private types -------------------------------------------------------------*/
756 /* Private constants ---------------------------------------------------------*/
757 /** @defgroup COMP_Private_Constants COMP Private Constants
758   * @{
759   */
760 /** @defgroup COMP_ExtiLine COMP EXTI Lines
761   * @{
762   */
763 #define COMP_EXTI_LINE_COMP1           (EXTI_IMR1_IM20)  /*!< EXTI line 20 connected to COMP1 output */
764 #define COMP_EXTI_LINE_COMP2           (EXTI_IMR1_IM21)  /*!< EXTI line 21 connected to COMP2 output */
765 /**
766   * @}
767   */
768 /** @defgroup COMP_ExtiLine COMP EXTI Lines
769   * @{
770   */
771 #define COMP_EXTI_IT                        ((uint32_t) 0x01)  /*!< EXTI line event with interruption */
772 #define COMP_EXTI_EVENT                     ((uint32_t) 0x02)  /*!< EXTI line event only (without interruption) */
773 #define COMP_EXTI_RISING                    ((uint32_t) 0x10)  /*!< EXTI line event on rising edge */
774 #define COMP_EXTI_FALLING                   ((uint32_t) 0x20)  /*!< EXTI line event on falling edge */
775 /**
776   * @}
777   */
778 /**
779   * @}
780   */
781 
782 /* Private macros ------------------------------------------------------------*/
783 /** @defgroup COMP_Private_Macros COMP Private Macros
784   * @{
785   */
786 /** @defgroup COMP_GET_EXTI_LINE COMP Private macros to get EXTI line associated with Comparators
787   * @{
788   */
789 /**
790   * @brief  Get the specified EXTI line for a comparator instance.
791   * @param  __INSTANCE__: specifies the COMP instance.
792   * @retval value of @ref COMP_ExtiLine
793   */
794 #define COMP_GET_EXTI_LINE(__INSTANCE__)             (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 : \
795                                                       COMP_EXTI_LINE_COMP2)
796 /**
797   * @}
798   */
799 /** @defgroup COMP_IS_COMP_Definitions COMP private macros to check input parameters
800   * @{
801   */
802 #define IS_COMP_WINDOWMODE(__WINDOWMODE__)  (((__WINDOWMODE__) == COMP_WINDOWMODE_DISABLE)                || \
803                                              ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON)  )
804 
805 #define IS_COMP_POWERMODE(__POWERMODE__)    (((__POWERMODE__) == COMP_POWERMODE_HIGHSPEED)    || \
806                                              ((__POWERMODE__) == COMP_POWERMODE_MEDIUMSPEED)  || \
807                                              ((__POWERMODE__) == COMP_POWERMODE_ULTRALOWPOWER)  )
808 
809 #if defined (COMP_CFGRx_INP2SEL)
810 #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
811                                                                ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2) || \
812                                                                ((__INPUT_PLUS__) == COMP_INPUT_PLUS_DAC2_CH1))
813 #else
814 #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
815                                                                ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2))
816 #endif
817 
818 
819 #if defined (COMP_CFGRx_INMSEL_3)
820 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT)     || \
821                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT)     || \
822                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT)     || \
823                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT)        || \
824                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1)       || \
825                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2)       || \
826                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1)            || \
827                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2)            || \
828                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_TPSENS_DAC2CH1) || \
829                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VBAT_VDDAP))
830 #else
831 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT)  || \
832                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT)  || \
833                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT)  || \
834                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT)     || \
835                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1)    || \
836                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2)    || \
837                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1)         || \
838                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2))
839 #endif
840 
841 #define IS_COMP_HYSTERESIS(__HYSTERESIS__)  (((__HYSTERESIS__) == COMP_HYSTERESIS_NONE)   || \
842                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_LOW)    || \
843                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_MEDIUM) || \
844                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_HIGH))
845 
846 #define IS_COMP_OUTPUTPOL(__POL__)          (((__POL__) == COMP_OUTPUTPOL_NONINVERTED) || \
847                                              ((__POL__) == COMP_OUTPUTPOL_INVERTED))
848 
849 #define IS_COMP_BLANKINGSRCE(__SOURCE__)    (((__SOURCE__) == COMP_BLANKINGSRC_NONE)      || \
850                                              ((__SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5)  || \
851                                              ((__SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3)  || \
852                                              ((__SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3)  || \
853                                              ((__SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4)  || \
854                                              ((__SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5)  || \
855                                              ((__SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1))
856 
857 
858 #define IS_COMP_TRIGGERMODE(__MODE__)       (((__MODE__) == COMP_TRIGGERMODE_NONE)                 || \
859                                              ((__MODE__) == COMP_TRIGGERMODE_IT_RISING)            || \
860                                              ((__MODE__) == COMP_TRIGGERMODE_IT_FALLING)           || \
861                                              ((__MODE__) == COMP_TRIGGERMODE_IT_RISING_FALLING)    || \
862                                              ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING)         || \
863                                              ((__MODE__) == COMP_TRIGGERMODE_EVENT_FALLING)        || \
864                                              ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING_FALLING))
865 
866 #define IS_COMP_OUTPUT_LEVEL(__OUTPUT_LEVEL__) (((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_LOW)     || \
867                                                 ((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_HIGH))
868 
869 /**
870   * @}
871   */
872 
873 /**
874   * @}
875   */
876 
877 /* Exported functions --------------------------------------------------------*/
878 /** @addtogroup COMP_Exported_Functions
879   * @{
880   */
881 
882 /** @addtogroup COMP_Exported_Functions_Group1
883   * @{
884   */
885 /* Initialization and de-initialization functions  **********************************/
886 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
887 HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp);
888 void              HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
889 void              HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
890 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
891 /* Callbacks Register/UnRegister functions  ***********************************/
892 HAL_StatusTypeDef HAL_COMP_RegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID, pCOMP_CallbackTypeDef pCallback);
893 HAL_StatusTypeDef HAL_COMP_UnRegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID);
894 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
895 /**
896   * @}
897   */
898 
899 /* IO operation functions  *****************************************************/
900 /** @addtogroup COMP_Exported_Functions_Group2
901   * @{
902   */
903 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
904 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
905 HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp);
906 HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp);
907 void              HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
908 
909 /**
910   * @}
911   */
912 
913 /* Peripheral Control functions  ************************************************/
914 /** @addtogroup COMP_Exported_Functions_Group3
915   * @{
916   */
917 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
918 uint32_t          HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
919 /* Callback in Interrupt mode */
920 void              HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
921 /**
922   * @}
923   */
924 
925 /* Peripheral State functions  **************************************************/
926 /** @addtogroup COMP_Exported_Functions_Group4
927   * @{
928   */
929 HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
930 uint32_t              HAL_COMP_GetError(COMP_HandleTypeDef *hcomp);
931 /**
932   * @}
933   */
934 
935 /**
936   * @}
937   */
938 
939 
940 /**
941   * @}
942   */
943 
944 /**
945   * @}
946   */
947 #ifdef __cplusplus
948 }
949 #endif
950 
951 #endif /* STM32H7xx_HAL_COMP_H */
952 
953