1 /**
2   ******************************************************************************
3   * @file    stm32g0xx_hal_comp.h
4   * @author  MCD Application Team
5   * @brief   Header file of COMP HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2018 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 STM32G0xx_HAL_COMP_H
21 #define STM32G0xx_HAL_COMP_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32g0xx_hal_def.h"
29 #include "stm32g0xx_ll_exti.h"
30 
31 /** @addtogroup STM32G0xx_HAL_Driver
32   * @{
33   */
34 #if defined (COMP1) || defined (COMP2)
35 
36 /** @addtogroup COMP
37   * @{
38   */
39 
40 /* Exported types ------------------------------------------------------------*/
41 /** @defgroup COMP_Exported_Types COMP Exported Types
42   * @{
43   */
44 
45 /**
46   * @brief  COMP Init structure definition
47   */
48 typedef struct
49 {
50 
51   uint32_t WindowMode;         /*!< Set window mode of a pair of comparators instances
52                                     (2 consecutive instances odd and even COMP<x> and COMP<x+1>).
53                                     Note: HAL COMP driver allows to set window mode from any COMP instance of the pair of COMP instances composing window mode, except for window mode with COMP2 and COMP3 (for devices featuring COMP3): it must be set from COMP3 instance.
54                                     This parameter can be a value of @ref COMP_WindowMode */
55 
56   uint32_t WindowOutput;       /*!< Set window mode output.
57                                     This parameter can be a value of @ref COMP_WindowOutput */
58 
59   uint32_t Mode;               /*!< Set comparator operating mode to adjust power and speed.
60                                     Note: For the characteristics of comparator power modes
61                                           (propagation delay and power consumption), refer to device datasheet.
62                                     This parameter can be a value of @ref COMP_PowerMode */
63 
64   uint32_t InputPlus;          /*!< Set comparator input plus (non-inverting input).
65                                     This parameter can be a value of @ref COMP_InputPlus */
66 
67   uint32_t InputMinus;         /*!< Set comparator input minus (inverting input).
68                                     This parameter can be a value of @ref COMP_InputMinus */
69 
70   uint32_t Hysteresis;         /*!< Set comparator hysteresis mode of the input minus.
71                                     This parameter can be a value of @ref COMP_Hysteresis */
72 
73   uint32_t OutputPol;          /*!< Set comparator output polarity.
74                                     This parameter can be a value of @ref COMP_OutputPolarity */
75 
76   uint32_t BlankingSrce;       /*!< Set comparator blanking source.
77                                     This parameter can be a value of @ref COMP_BlankingSrce */
78 
79   uint32_t TriggerMode;        /*!< Set the comparator output triggering External Interrupt Line (EXTI).
80                                     This parameter can be a value of @ref COMP_EXTI_TriggerMode */
81 
82 } COMP_InitTypeDef;
83 
84 /**
85   * @brief  HAL COMP state machine: HAL COMP states definition
86   */
87 #define COMP_STATE_BITFIELD_LOCK  (0x10U)
88 typedef enum
89 {
90   HAL_COMP_STATE_RESET             = 0x00U,                                             /*!< COMP not yet initialized                             */
91   HAL_COMP_STATE_RESET_LOCKED      = (HAL_COMP_STATE_RESET | COMP_STATE_BITFIELD_LOCK), /*!< COMP not yet initialized and configuration is locked */
92   HAL_COMP_STATE_READY             = 0x01U,                                             /*!< COMP initialized and ready for use                   */
93   HAL_COMP_STATE_READY_LOCKED      = (HAL_COMP_STATE_READY | COMP_STATE_BITFIELD_LOCK), /*!< COMP initialized but configuration is locked         */
94   HAL_COMP_STATE_BUSY              = 0x02U,                                             /*!< COMP is running                                      */
95   HAL_COMP_STATE_BUSY_LOCKED       = (HAL_COMP_STATE_BUSY | COMP_STATE_BITFIELD_LOCK)   /*!< COMP is running and configuration is locked          */
96 } HAL_COMP_StateTypeDef;
97 
98 /**
99   * @brief  COMP Handle Structure definition
100   */
101 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
102 typedef struct __COMP_HandleTypeDef
103 #else
104 typedef struct
105 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
106 {
107   COMP_TypeDef       *Instance;       /*!< Register base address    */
108   COMP_InitTypeDef   Init;            /*!< COMP required parameters */
109   HAL_LockTypeDef    Lock;            /*!< Locking object           */
110   __IO HAL_COMP_StateTypeDef  State;  /*!< COMP communication state */
111   __IO uint32_t      ErrorCode;       /*!< COMP error code */
112 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
113   void (* TriggerCallback)(struct __COMP_HandleTypeDef *hcomp);   /*!< COMP trigger callback */
114   void (* MspInitCallback)(struct __COMP_HandleTypeDef *hcomp);   /*!< COMP Msp Init callback */
115   void (* MspDeInitCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP Msp DeInit callback */
116 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
117 } COMP_HandleTypeDef;
118 
119 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
120 /**
121   * @brief  HAL COMP Callback ID enumeration definition
122   */
123 typedef enum
124 {
125   HAL_COMP_TRIGGER_CB_ID                = 0x00U,  /*!< COMP trigger callback ID */
126   HAL_COMP_MSPINIT_CB_ID                = 0x01U,  /*!< COMP Msp Init callback ID */
127   HAL_COMP_MSPDEINIT_CB_ID              = 0x02U   /*!< COMP Msp DeInit callback ID */
128 } HAL_COMP_CallbackIDTypeDef;
129 
130 /**
131   * @brief  HAL COMP Callback pointer definition
132   */
133 typedef  void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer to a COMP callback function */
134 
135 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
136 
137 /**
138   * @}
139   */
140 
141 /* Exported constants --------------------------------------------------------*/
142 /** @defgroup COMP_Exported_Constants COMP Exported Constants
143   * @{
144   */
145 
146 /** @defgroup COMP_Error_Code COMP Error Code
147   * @{
148   */
149 #define HAL_COMP_ERROR_NONE             (0x00UL)  /*!< No error */
150 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
151 #define HAL_COMP_ERROR_INVALID_CALLBACK (0x01UL)  /*!< Invalid Callback error */
152 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
153 /**
154   * @}
155   */
156 
157 /** @defgroup COMP_WindowMode COMP Window Mode
158   * @{
159   */
160 #define COMP_WINDOWMODE_DISABLE                 (0x00000000UL)         /*!< Window mode disable: Comparators instances pair COMP1 and COMP2 are independent */
161 #define COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP_CSR_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). */
162 #define COMP_WINDOWMODE_COMP2_INPUT_PLUS_COMMON (COMP_CSR_WINMODE | COMP_WINDOWMODE_COMP2) /*!< Window mode enable: if used from COMP1 or COMP2 instance, comparators instances pair COMP1 and COMP2 have their input plus connected together, the common input is COMP2 input plus (COMP1 input plus is no more accessible). If used from COMP3 instance (when available), comparators instances pair COMP2 and COMP3 have their input plus connected together, the common input is COMP2 input plus (COMP3 input plus is no more accessible). */
163 /**
164   * @}
165   */
166 
167 /** @defgroup COMP_WindowOutput COMP Window output
168   * @{
169   */
170 #define COMP_WINDOWOUTPUT_EACH_COMP             (0x00000000UL)                            /*!< Window output default mode: Comparators output are indicating each their own state. To know window mode state: each comparator output must be read, if "((COMPx exclusive or COMPy) == 1)" then monitored signal is within comparators window.  */
171 #define COMP_WINDOWOUTPUT_COMP1                 (COMP_CSR_WINOUT)                         /*!< Window output synthetized on COMP1 output: COMP1 output is no more indicating its own state, but global window mode state (logical high means monitored signal is within comparators window).
172                                                                                                Note: impacts only comparator output signal level (COMPx_OUT propagated to GPIO, EXTI lines, timers, ...), does not impact output digital state of comparator (COMPx_VALUE) always reflecting each comparator output state.*/
173 #define COMP_WINDOWOUTPUT_COMP2                 (COMP_CSR_WINOUT | COMP_WINDOWMODE_COMP2) /*!< Window output synthetized on COMP2 output: COMP2 output is no more indicating its own state, but global window mode state (logical high means monitored signal is within comparators window).
174                                                                                                Note: impacts only comparator output signal level (COMPx_OUT propagated to GPIO, EXTI lines, timers, ...), does not impact output digital state of comparator (COMPx_VALUE) always reflecting each comparator output state.*/
175 #if defined(COMP3)
176 #define COMP_WINDOWOUTPUT_COMP3                 (COMP_CSR_WINOUT)                         /*!< Window output synthetized on COMP3 output: COMP3 output is no more indicating its own state, but global window mode state (logical high means monitored signal is within comparators window). */
177 #endif /* COMP3 */
178 #define COMP_WINDOWOUTPUT_BOTH                  (0x00000001UL)                            /*!< Window output synthetized on both comparators output of pair of comparator selected (COMP1 and COMP2, or COMP2 and COMP3 for devices featuring COMP3 instance): both comparators outputs are no more indicating their own state, but global window mode state (logical high means monitored signal is within comparators window). This is a specific configuration (technically possible but not relevant from application point of view: 2 comparators output used for the same signal level), standard configuration for window mode is one of the settings above. */
179 /**
180   * @}
181   */
182 
183 /** @defgroup COMP_PowerMode COMP power mode
184   * @{
185   */
186 /* Note: For the characteristics of comparator power modes                    */
187 /*       (propagation delay and power consumption),                           */
188 /*       refer to device datasheet.                                           */
189 #define COMP_POWERMODE_HIGHSPEED       (0x00000000UL)         /*!< High Speed */
190 #define COMP_POWERMODE_MEDIUMSPEED     (COMP_CSR_PWRMODE_0)   /*!< Medium Speed */
191 /**
192   * @}
193   */
194 
195 /** @defgroup COMP_InputPlus COMP input plus (non-inverting input)
196   * @{
197   */
198 #define COMP_INPUT_PLUS_IO1            (0x00000000UL)         /*!< Comparator input plus connected to IO1 (pin PC5 for COMP1, pin PB4 for COMP2, pin PB0 for COMP3 (for devices featuring COMP3 instance)) */
199 #define COMP_INPUT_PLUS_IO2            (COMP_CSR_INPSEL_0)    /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PB6 for COMP2, pin PC1 for COMP3 (for devices featuring COMP3 instance)) */
200 #define COMP_INPUT_PLUS_IO3            (COMP_CSR_INPSEL_1)    /*!< Comparator input plus connected to IO3 (pin PA1 for COMP1, pin PA3 for COMP2, pin PE7 for COMP3 (for devices featuring COMP3 instance)) */
201 /**
202   * @}
203   */
204 
205 /** @defgroup COMP_InputMinus COMP input minus (inverting input)
206   * @{
207   */
208 #define COMP_INPUT_MINUS_1_4VREFINT    (0x00000000UL)                                                                  /*!< Comparator input minus connected to 1/4 VrefInt  */
209 #define COMP_INPUT_MINUS_1_2VREFINT    (                                                            COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to 1/2 VrefInt  */
210 #define COMP_INPUT_MINUS_3_4VREFINT    (                                        COMP_CSR_INMSEL_1                    ) /*!< Comparator input minus connected to 3/4 VrefInt  */
211 #define COMP_INPUT_MINUS_VREFINT       (                                        COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to VrefInt */
212 #define COMP_INPUT_MINUS_DAC1_CH1      (                    COMP_CSR_INMSEL_2                                        ) /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1)  */
213 #define COMP_INPUT_MINUS_DAC1_CH2      (                    COMP_CSR_INMSEL_2                     | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2)  */
214 #define COMP_INPUT_MINUS_IO1           (                    COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1                    ) /*!< Comparator input minus connected to IO1 (pin PB1 for COMP1, pin PB3 for COMP2, pin PB2 for COMP3 (for devices featuring COMP3 instance)) */
215 #define COMP_INPUT_MINUS_IO2           (                    COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO2 (pin PC4 for COMP1, pin PB7 for COMP2, pin PC0 for COMP3 (for devices featuring COMP3 instance)) */
216 #define COMP_INPUT_MINUS_IO3           (COMP_CSR_INMSEL_3                                                            ) /*!< Comparator input minus connected to IO3 (pin PA0 for COMP1, pin PA2 for COMP2, pin PE8 for COMP3 (for devices featuring COMP3 instance)) */
217 /**
218   * @}
219   */
220 
221 /** @defgroup COMP_Hysteresis COMP hysteresis
222   * @{
223   */
224 #define COMP_HYSTERESIS_NONE           (0x00000000UL)                       /*!< No hysteresis */
225 #define COMP_HYSTERESIS_LOW            (                  COMP_CSR_HYST_0)  /*!< Hysteresis level low */
226 #define COMP_HYSTERESIS_MEDIUM         (COMP_CSR_HYST_1                  )  /*!< Hysteresis level medium */
227 #define COMP_HYSTERESIS_HIGH           (COMP_CSR_HYST_1 | COMP_CSR_HYST_0)  /*!< Hysteresis level high */
228 /**
229   * @}
230   */
231 
232 /** @defgroup COMP_OutputPolarity COMP output Polarity
233   * @{
234   */
235 #define COMP_OUTPUTPOL_NONINVERTED     (0x00000000UL)         /*!< COMP output level is not inverted (comparator output is high when the input plus is at a higher voltage than the input minus) */
236 #define COMP_OUTPUTPOL_INVERTED        (COMP_CSR_POLARITY)    /*!< COMP output level is inverted     (comparator output is low  when the input plus is at a higher voltage than the input minus) */
237 /**
238   * @}
239   */
240 
241 /** @defgroup COMP_BlankingSrce  COMP blanking source
242   * @{
243   */
244 #define COMP_BLANKINGSRC_NONE            (0x00000000UL)          /*!<Comparator output without blanking */
245 /* Note: Output blanking source common to all COMP instances */
246 #define COMP_BLANKINGSRC_TIM1_OC4        (COMP_CSR_BLANKING_0)   /*!< Comparator output blanking source TIM1 OC4 (common to all COMP instances: COMP1, COMP2, COMP3 (when available)) */
247 #define COMP_BLANKINGSRC_TIM1_OC5        (COMP_CSR_BLANKING_1)   /*!< Comparator output blanking source TIM1 OC5 (common to all COMP instances: COMP1, COMP2, COMP3 (when available)) */
248 #define COMP_BLANKINGSRC_TIM2_OC3        (COMP_CSR_BLANKING_2)   /*!< Comparator output blanking source TIM2 OC3 (common to all COMP instances: COMP1, COMP2, COMP3 (when available)) */
249 #define COMP_BLANKINGSRC_TIM3_OC3        (COMP_CSR_BLANKING_3)   /*!< Comparator output blanking source TIM3 OC3 (common to all COMP instances: COMP1, COMP2, COMP3 (when available)) */
250 #define COMP_BLANKINGSRC_TIM15_OC2       (COMP_CSR_BLANKING_4)   /*!< Comparator output blanking source TIM15 OC2 (common to all COMP instances: COMP1, COMP2, COMP3 (when available)) */
251 /**
252   * @}
253   */
254 
255 /** @defgroup COMP_OutputLevel COMP Output Level
256   * @{
257   */
258 /* Note: Comparator output level values are fixed to "0" and "1",             */
259 /* corresponding COMP register bit is managed by HAL function to match        */
260 /* with these values (independently of bit position in register).             */
261 
262 /* When output polarity is not inverted, comparator output is low when
263    the input plus is at a lower voltage than the input minus */
264 #define COMP_OUTPUT_LEVEL_LOW              (0x00000000UL)
265 /* When output polarity is not inverted, comparator output is high when
266    the input plus is at a higher voltage than the input minus */
267 #define COMP_OUTPUT_LEVEL_HIGH             (0x00000001UL)
268 /**
269   * @}
270   */
271 
272 /** @defgroup COMP_EXTI_TriggerMode COMP output to EXTI
273   * @{
274   */
275 #define COMP_TRIGGERMODE_NONE                 (0x00000000UL)                                            /*!< Comparator output triggering no External Interrupt Line */
276 #define COMP_TRIGGERMODE_IT_RISING            (COMP_EXTI_IT | COMP_EXTI_RISING)                         /*!< Comparator output triggering External Interrupt Line event with interruption, on rising edge */
277 #define COMP_TRIGGERMODE_IT_FALLING           (COMP_EXTI_IT | COMP_EXTI_FALLING)                        /*!< Comparator output triggering External Interrupt Line event with interruption, on falling edge */
278 #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 */
279 #define COMP_TRIGGERMODE_EVENT_RISING         (COMP_EXTI_EVENT | COMP_EXTI_RISING)                      /*!< Comparator output triggering External Interrupt Line event only (without interruption), on rising edge */
280 #define COMP_TRIGGERMODE_EVENT_FALLING        (COMP_EXTI_EVENT | COMP_EXTI_FALLING)                     /*!< Comparator output triggering External Interrupt Line event only (without interruption), on falling edge */
281 #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 */
282 /**
283   * @}
284   */
285 
286 /**
287   * @}
288   */
289 
290 /* Exported macro ------------------------------------------------------------*/
291 /** @defgroup COMP_Exported_Macros COMP Exported Macros
292   * @{
293   */
294 
295 /** @defgroup COMP_Handle_Management  COMP Handle Management
296   * @{
297   */
298 
299 /** @brief  Reset COMP handle state.
300   * @param  __HANDLE__  COMP handle
301   * @retval None
302   */
303 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
304 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) do{                                                  \
305                                                       (__HANDLE__)->State = HAL_COMP_STATE_RESET;      \
306                                                       (__HANDLE__)->MspInitCallback = NULL;            \
307                                                       (__HANDLE__)->MspDeInitCallback = NULL;          \
308                                                     } while(0)
309 #else
310 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
311 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
312 
313 /**
314   * @brief Clear COMP error code (set it to no error code "HAL_COMP_ERROR_NONE").
315   * @param __HANDLE__ COMP handle
316   * @retval None
317   */
318 #define COMP_CLEAR_ERRORCODE(__HANDLE__) ((__HANDLE__)->ErrorCode = HAL_COMP_ERROR_NONE)
319 
320 /**
321   * @brief  Enable the specified comparator.
322   * @param  __HANDLE__  COMP handle
323   * @retval None
324   */
325 #define __HAL_COMP_ENABLE(__HANDLE__)              SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN)
326 
327 /**
328   * @brief  Disable the specified comparator.
329   * @param  __HANDLE__  COMP handle
330   * @retval None
331   */
332 #define __HAL_COMP_DISABLE(__HANDLE__)             CLEAR_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN)
333 
334 /**
335   * @brief  Lock the specified comparator configuration.
336   * @note   Using this macro induce HAL COMP handle state machine being no
337   *         more in line with COMP instance state.
338   *         To keep HAL COMP handle state machine updated, it is recommended
339   *         to use function "HAL_COMP_Lock')".
340   * @param  __HANDLE__  COMP handle
341   * @retval None
342   */
343 #define __HAL_COMP_LOCK(__HANDLE__)                SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK)
344 
345 /**
346   * @brief  Check whether the specified comparator is locked.
347   * @param  __HANDLE__  COMP handle
348   * @retval Value 0 if COMP instance is not locked, value 1 if COMP instance is locked
349   */
350 #define __HAL_COMP_IS_LOCKED(__HANDLE__)           (READ_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK) == COMP_CSR_LOCK)
351 
352 /**
353   * @}
354   */
355 
356 /** @defgroup COMP_Exti_Management  COMP external interrupt line management
357   * @{
358   */
359 
360 /**
361   * @brief  Enable the COMP1 EXTI line rising edge trigger.
362   * @retval None
363   */
364 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE()    LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP1)
365 
366 /**
367   * @brief  Disable the COMP1 EXTI line rising edge trigger.
368   * @retval None
369   */
370 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE()   LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP1)
371 
372 /**
373   * @brief  Enable the COMP1 EXTI line falling edge trigger.
374   * @retval None
375   */
376 #define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE()   LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP1)
377 
378 /**
379   * @brief  Disable the COMP1 EXTI line falling edge trigger.
380   * @retval None
381   */
382 #define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE()  LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP1)
383 
384 /**
385   * @brief  Enable the COMP1 EXTI line rising & falling edge trigger.
386   * @retval None
387   */
388 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE()   do { \
389                                                                LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP1); \
390                                                                LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP1); \
391                                                              } while(0)
392 
393 /**
394   * @brief  Disable the COMP1 EXTI line rising & falling edge trigger.
395   * @retval None
396   */
397 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE()  do { \
398                                                                LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP1); \
399                                                                LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP1); \
400                                                              } while(0)
401 
402 /**
403   * @brief  Enable the COMP1 EXTI line in interrupt mode.
404   * @retval None
405   */
406 #define __HAL_COMP_COMP1_EXTI_ENABLE_IT()             LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP1)
407 
408 /**
409   * @brief  Disable the COMP1 EXTI line in interrupt mode.
410   * @retval None
411   */
412 #define __HAL_COMP_COMP1_EXTI_DISABLE_IT()            LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP1)
413 
414 /**
415   * @brief  Generate a software interrupt on the COMP1 EXTI line.
416   * @retval None
417   */
418 #define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT()         LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP1)
419 
420 /**
421   * @brief  Enable the COMP1 EXTI line in event mode.
422   * @retval None
423   */
424 #define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT()          LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP1)
425 
426 /**
427   * @brief  Disable the COMP1 EXTI line in event mode.
428   * @retval None
429   */
430 #define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT()         LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP1)
431 
432 /**
433   * @brief  Check whether the COMP1 EXTI line rising flag is set.
434   * @retval RESET or SET
435   */
436 #define __HAL_COMP_COMP1_EXTI_GET_RISING_FLAG()       LL_EXTI_IsActiveRisingFlag_0_31(COMP_EXTI_LINE_COMP1)
437 
438 /**
439   * @brief  Clear the COMP1 EXTI rising flag.
440   * @retval None
441   */
442 #define __HAL_COMP_COMP1_EXTI_CLEAR_RISING_FLAG()     LL_EXTI_ClearRisingFlag_0_31(COMP_EXTI_LINE_COMP1)
443 
444 /**
445   * @brief  Check whether the COMP1 EXTI line falling flag is set.
446   * @retval RESET or SET
447   */
448 #define __HAL_COMP_COMP1_EXTI_GET_FALLING_FLAG()      LL_EXTI_IsActiveFallingFlag_0_31(COMP_EXTI_LINE_COMP1)
449 
450 /**
451   * @brief  Clear the COMP1 EXTI falling flag.
452   * @retval None
453   */
454 #define __HAL_COMP_COMP1_EXTI_CLEAR_FALLING_FLAG()    LL_EXTI_ClearFallingFlag_0_31(COMP_EXTI_LINE_COMP1)
455 
456 /**
457   * @brief  Enable the COMP2 EXTI line rising edge trigger.
458   * @retval None
459   */
460 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE()    LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP2)
461 
462 /**
463   * @brief  Disable the COMP2 EXTI line rising edge trigger.
464   * @retval None
465   */
466 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE()   LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP2)
467 
468 /**
469   * @brief  Enable the COMP2 EXTI line falling edge trigger.
470   * @retval None
471   */
472 #define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE()   LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP2)
473 
474 /**
475   * @brief  Disable the COMP2 EXTI line falling edge trigger.
476   * @retval None
477   */
478 #define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE()  LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP2)
479 
480 /**
481   * @brief  Enable the COMP2 EXTI line rising & falling edge trigger.
482   * @retval None
483   */
484 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE()   do { \
485                                                                LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP2); \
486                                                                LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP2); \
487                                                              } while(0)
488 
489 /**
490   * @brief  Disable the COMP2 EXTI line rising & falling edge trigger.
491   * @retval None
492   */
493 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE()  do { \
494                                                                LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP2); \
495                                                                LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP2); \
496                                                              } while(0)
497 
498 /**
499   * @brief  Enable the COMP2 EXTI line in interrupt mode.
500   * @retval None
501   */
502 #define __HAL_COMP_COMP2_EXTI_ENABLE_IT()             LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP2)
503 
504 /**
505   * @brief  Disable the COMP2 EXTI line in interrupt mode.
506   * @retval None
507   */
508 #define __HAL_COMP_COMP2_EXTI_DISABLE_IT()            LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP2)
509 
510 /**
511   * @brief  Generate a software interrupt on the COMP2 EXTI line.
512   * @retval None
513   */
514 #define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT()         LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP2)
515 
516 /**
517   * @brief  Enable the COMP2 EXTI line in event mode.
518   * @retval None
519   */
520 #define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT()          LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP2)
521 
522 /**
523   * @brief  Disable the COMP2 EXTI line in event mode.
524   * @retval None
525   */
526 #define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT()         LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP2)
527 
528 /**
529   * @brief  Check whether the COMP2 EXTI line rising flag is set.
530   * @retval RESET or SET
531   */
532 #define __HAL_COMP_COMP2_EXTI_GET_RISING_FLAG()       LL_EXTI_IsActiveRisingFlag_0_31(COMP_EXTI_LINE_COMP2)
533 
534 /**
535   * @brief  Clear the COMP2 EXTI rising flag.
536   * @retval None
537   */
538 #define __HAL_COMP_COMP2_EXTI_CLEAR_RISING_FLAG()     LL_EXTI_ClearRisingFlag_0_31(COMP_EXTI_LINE_COMP2)
539 
540 /**
541   * @brief  Check whether the COMP2 EXTI line falling flag is set.
542   * @retval RESET or SET
543   */
544 #define __HAL_COMP_COMP2_EXTI_GET_FALLING_FLAG()      LL_EXTI_IsActiveFallingFlag_0_31(COMP_EXTI_LINE_COMP2)
545 
546 /**
547   * @brief  Clear the COMP2 EXTI falling flag.
548   * @retval None
549   */
550 #define __HAL_COMP_COMP2_EXTI_CLEAR_FALLING_FLAG()    LL_EXTI_ClearFallingFlag_0_31(COMP_EXTI_LINE_COMP2)
551 
552 /**
553   * @brief  Enable the COMP3 EXTI line rising edge trigger.
554   * @retval None
555   */
556 #define __HAL_COMP_COMP3_EXTI_ENABLE_RISING_EDGE()    LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP3)
557 
558 /**
559   * @brief  Disable the COMP3 EXTI line rising edge trigger.
560   * @retval None
561   */
562 #define __HAL_COMP_COMP3_EXTI_DISABLE_RISING_EDGE()   LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP3)
563 
564 /**
565   * @brief  Enable the COMP3 EXTI line falling edge trigger.
566   * @retval None
567   */
568 #define __HAL_COMP_COMP3_EXTI_ENABLE_FALLING_EDGE()   LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP3)
569 
570 /**
571   * @brief  Disable the COMP3 EXTI line falling edge trigger.
572   * @retval None
573   */
574 #define __HAL_COMP_COMP3_EXTI_DISABLE_FALLING_EDGE()  LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP3)
575 
576 /**
577   * @brief  Enable the COMP3 EXTI line rising & falling edge trigger.
578   * @retval None
579   */
580 #define __HAL_COMP_COMP3_EXTI_ENABLE_RISING_FALLING_EDGE()   do { \
581                                                                LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP3); \
582                                                                LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP3); \
583                                                              } while(0)
584 
585 /**
586   * @brief  Disable the COMP3 EXTI line rising & falling edge trigger.
587   * @retval None
588   */
589 #define __HAL_COMP_COMP3_EXTI_DISABLE_RISING_FALLING_EDGE()  do { \
590                                                                LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP3); \
591                                                                LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP3); \
592                                                              } while(0)
593 
594 /**
595   * @brief  Enable the COMP3 EXTI line in interrupt mode.
596   * @retval None
597   */
598 #define __HAL_COMP_COMP3_EXTI_ENABLE_IT()             LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP3)
599 
600 /**
601   * @brief  Disable the COMP3 EXTI line in interrupt mode.
602   * @retval None
603   */
604 #define __HAL_COMP_COMP3_EXTI_DISABLE_IT()            LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP3)
605 
606 /**
607   * @brief  Generate a software interrupt on the COMP3 EXTI line.
608   * @retval None
609   */
610 #define __HAL_COMP_COMP3_EXTI_GENERATE_SWIT()         LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP3)
611 
612 /**
613   * @brief  Enable the COMP3 EXTI line in event mode.
614   * @retval None
615   */
616 #define __HAL_COMP_COMP3_EXTI_ENABLE_EVENT()          LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP3)
617 
618 /**
619   * @brief  Disable the COMP3 EXTI line in event mode.
620   * @retval None
621   */
622 #define __HAL_COMP_COMP3_EXTI_DISABLE_EVENT()         LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP3)
623 
624 /**
625   * @brief  Check whether the COMP3 EXTI line rising flag is set.
626   * @retval RESET or SET
627   */
628 #define __HAL_COMP_COMP3_EXTI_GET_RISING_FLAG()       LL_EXTI_IsActiveRisingFlag_0_31(COMP_EXTI_LINE_COMP3)
629 
630 /**
631   * @brief  Clear the COMP3 EXTI rising flag.
632   * @retval None
633   */
634 #define __HAL_COMP_COMP3_EXTI_CLEAR_RISING_FLAG()     LL_EXTI_ClearRisingFlag_0_31(COMP_EXTI_LINE_COMP3)
635 
636 /**
637   * @brief  Check whether the COMP3 EXTI line falling flag is set.
638   * @retval RESET or SET
639   */
640 #define __HAL_COMP_COMP3_EXTI_GET_FALLING_FLAG()      LL_EXTI_IsActiveFallingFlag_0_31(COMP_EXTI_LINE_COMP3)
641 
642 /**
643   * @brief  Clear the COMP3 EXTI falling flag.
644   * @retval None
645   */
646 #define __HAL_COMP_COMP3_EXTI_CLEAR_FALLING_FLAG()    LL_EXTI_ClearFallingFlag_0_31(COMP_EXTI_LINE_COMP3)
647 
648 /**
649   * @}
650   */
651 
652 /**
653   * @}
654   */
655 
656 
657 /* Private types -------------------------------------------------------------*/
658 /* Private constants ---------------------------------------------------------*/
659 /** @defgroup COMP_Private_Constants COMP Private Constants
660   * @{
661   */
662 
663 /** @defgroup COMP_WindowMode_Instance_Differentiator COMP window mode instance differentiator
664   * @{
665   */
666 #define COMP_WINDOWMODE_COMP2          0x00001000U       /*!< COMP window mode using common input of COMP instance: COMP2 */
667 /**
668   * @}
669   */
670 
671 /** @defgroup COMP_ExtiLine COMP EXTI Lines
672   * @{
673   */
674 #define COMP_EXTI_LINE_COMP1           (EXTI_IMR1_IM17)  /*!< EXTI line 17 connected to COMP1 output */
675 #define COMP_EXTI_LINE_COMP2           (EXTI_IMR1_IM18)  /*!< EXTI line 18 connected to COMP2 output */
676 #if defined(COMP3)
677 #define COMP_EXTI_LINE_COMP3           (EXTI_IMR1_IM20)  /*!< EXTI line 20 connected to COMP3 output */
678 #endif /* COMP3 */
679 /**
680   * @}
681   */
682 
683 /** @defgroup COMP_ExtiLine COMP EXTI Lines
684   * @{
685   */
686 #define COMP_EXTI_IT                        (0x00000001UL)  /*!< EXTI line event with interruption */
687 #define COMP_EXTI_EVENT                     (0x00000002UL)  /*!< EXTI line event only (without interruption) */
688 #define COMP_EXTI_RISING                    (0x00000010UL)  /*!< EXTI line event on rising edge */
689 #define COMP_EXTI_FALLING                   (0x00000020UL)  /*!< EXTI line event on falling edge */
690 /**
691   * @}
692   */
693 
694 /**
695   * @}
696   */
697 
698 /* Private macros ------------------------------------------------------------*/
699 /** @defgroup COMP_Private_Macros COMP Private Macros
700   * @{
701   */
702 
703 /** @defgroup COMP_GET_EXTI_LINE COMP private macros to get EXTI line associated with comparators
704   * @{
705   */
706 /**
707   * @brief  Get the specified EXTI line for a comparator instance.
708   * @param  __INSTANCE__  specifies the COMP instance.
709   * @retval value of @ref COMP_ExtiLine
710   */
711 #if defined(COMP3)
712 #define COMP_GET_EXTI_LINE(__INSTANCE__)    (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1  \
713                                              :((__INSTANCE__) == COMP2) ? COMP_EXTI_LINE_COMP2 \
714                                              : COMP_EXTI_LINE_COMP3)
715 #else
716 #define COMP_GET_EXTI_LINE(__INSTANCE__)    (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1  \
717                                              : COMP_EXTI_LINE_COMP2)
718 #endif /* COMP3 */
719 /**
720   * @}
721   */
722 
723 /** @defgroup COMP_IS_COMP_Private_Definitions COMP private macros to check input parameters
724   * @{
725   */
726 #if defined(COMP3)
727 #define IS_COMP_WINDOWMODE(__INSTANCE__, __WINDOWMODE__) \
728 (((__INSTANCE__) == COMP3) \
729   ? \
730   (((__WINDOWMODE__) == COMP_WINDOWMODE_DISABLE)                ||  \
731    ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP2_INPUT_PLUS_COMMON)  ) \
732   :\
733   (((__WINDOWMODE__) == COMP_WINDOWMODE_DISABLE)                ||  \
734    ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON)||  \
735    ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP2_INPUT_PLUS_COMMON)  ) \
736 )
737 #else
738 #define IS_COMP_WINDOWMODE(__INSTANCE__, __WINDOWMODE__) \
739 (((__WINDOWMODE__) == COMP_WINDOWMODE_DISABLE)                || \
740  ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON)|| \
741  ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP2_INPUT_PLUS_COMMON)  )
742 #endif /* COMP3 */
743 
744 #define IS_COMP_WINDOWOUTPUT(__WINDOWOUTPUT__) (((__WINDOWOUTPUT__) == COMP_WINDOWOUTPUT_EACH_COMP) || \
745                                                 ((__WINDOWOUTPUT__) == COMP_WINDOWOUTPUT_COMP1)     || \
746                                                 ((__WINDOWOUTPUT__) == COMP_WINDOWOUTPUT_COMP2)     || \
747                                                 ((__WINDOWOUTPUT__) == COMP_WINDOWOUTPUT_BOTH)        )
748 
749 #define IS_COMP_POWERMODE(__POWERMODE__)    (((__POWERMODE__) == COMP_POWERMODE_HIGHSPEED)    || \
750                                              ((__POWERMODE__) == COMP_POWERMODE_MEDIUMSPEED)    )
751 
752 #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
753                                                                ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2) || \
754                                                                ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO3))
755 
756 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT)  || \
757                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT)  || \
758                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT)  || \
759                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT)     || \
760                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1)    || \
761                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2)    || \
762                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1)         || \
763                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2)         || \
764                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO3))
765 
766 #define IS_COMP_HYSTERESIS(__HYSTERESIS__)  (((__HYSTERESIS__) == COMP_HYSTERESIS_NONE)   || \
767                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_LOW)    || \
768                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_MEDIUM) || \
769                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_HIGH))
770 
771 #define IS_COMP_OUTPUTPOL(__POL__)          (((__POL__) == COMP_OUTPUTPOL_NONINVERTED) || \
772                                              ((__POL__) == COMP_OUTPUTPOL_INVERTED))
773 
774 #define IS_COMP_BLANKINGSRCE(__OUTPUT_BLANKING_SOURCE__)                    \
775   (   ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)               \
776    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC4)           \
777    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5)           \
778    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3)           \
779    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3)           \
780    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC2)          \
781   )
782 
783 /* Note: Output blanking source common to all COMP instances */
784 /*       Macro kept for compatibility with other STM32 series */
785 #define IS_COMP_BLANKINGSRC_INSTANCE(__INSTANCE__, __OUTPUT_BLANKING_SOURCE__)  \
786    (IS_COMP_BLANKINGSRCE(__OUTPUT_BLANKING_SOURCE__))
787 
788 
789 #define IS_COMP_TRIGGERMODE(__MODE__)       (((__MODE__) == COMP_TRIGGERMODE_NONE)                 || \
790                                              ((__MODE__) == COMP_TRIGGERMODE_IT_RISING)            || \
791                                              ((__MODE__) == COMP_TRIGGERMODE_IT_FALLING)           || \
792                                              ((__MODE__) == COMP_TRIGGERMODE_IT_RISING_FALLING)    || \
793                                              ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING)         || \
794                                              ((__MODE__) == COMP_TRIGGERMODE_EVENT_FALLING)        || \
795                                              ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING_FALLING))
796 
797 #define IS_COMP_OUTPUT_LEVEL(__OUTPUT_LEVEL__) (((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_LOW)     || \
798                                                 ((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_HIGH))
799 
800 /**
801   * @}
802   */
803 
804 /**
805   * @}
806   */
807 
808 
809 /* Exported functions --------------------------------------------------------*/
810 /** @addtogroup COMP_Exported_Functions
811   * @{
812   */
813 
814 /** @addtogroup COMP_Exported_Functions_Group1
815   * @{
816   */
817 
818 /* Initialization and de-initialization functions  **********************************/
819 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
820 HAL_StatusTypeDef HAL_COMP_DeInit(COMP_HandleTypeDef *hcomp);
821 void              HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
822 void              HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
823 
824 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
825 /* Callbacks Register/UnRegister functions  ***********************************/
826 HAL_StatusTypeDef HAL_COMP_RegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID,
827                                             pCOMP_CallbackTypeDef pCallback);
828 HAL_StatusTypeDef HAL_COMP_UnRegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID);
829 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
830 /**
831   * @}
832   */
833 
834 /* IO operation functions  *****************************************************/
835 /** @addtogroup COMP_Exported_Functions_Group2
836   * @{
837   */
838 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
839 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
840 void              HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
841 /**
842   * @}
843   */
844 
845 /* Peripheral Control functions  ************************************************/
846 /** @addtogroup COMP_Exported_Functions_Group3
847   * @{
848   */
849 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
850 uint32_t          HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
851 /* Callback in interrupt mode */
852 void              HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
853 /**
854   * @}
855   */
856 
857 /* Peripheral State functions  **************************************************/
858 /** @addtogroup COMP_Exported_Functions_Group4
859   * @{
860   */
861 HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
862 uint32_t              HAL_COMP_GetError(COMP_HandleTypeDef *hcomp);
863 /**
864   * @}
865   */
866 
867 /**
868   * @}
869   */
870 
871 /**
872   * @}
873   */
874 #endif /* COMP1 || COMP2 */
875 /**
876   * @}
877   */
878 
879 #ifdef __cplusplus
880 }
881 #endif
882 
883 #endif /* STM32G0xx_HAL_COMP_H */
884