1 /**
2   ******************************************************************************
3   * @file    stm32g4xx_hal_comp.h
4   * @author  MCD Application Team
5   * @brief   Header file of COMP HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2019 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 STM32G4xx_HAL_COMP_H
21 #define STM32G4xx_HAL_COMP_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32g4xx_hal_def.h"
29 #include "stm32g4xx_ll_exti.h"
30 
31 /** @addtogroup STM32G4xx_HAL_Driver
32   * @{
33   */
34 
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 InputPlus;          /*!< Set comparator input plus (non-inverting input).
52                                     This parameter can be a value of @ref COMP_InputPlus */
53 
54   uint32_t InputMinus;         /*!< Set comparator input minus (inverting input).
55                                     This parameter can be a value of @ref COMP_InputMinus */
56 
57   uint32_t Hysteresis;         /*!< Set comparator hysteresis mode of the input minus.
58                                     This parameter can be a value of @ref COMP_Hysteresis */
59 
60   uint32_t OutputPol;          /*!< Set comparator output polarity.
61                                     This parameter can be a value of @ref COMP_OutputPolarity */
62 
63   uint32_t BlankingSrce;       /*!< Set comparator blanking source.
64                                     This parameter can be a value of @ref COMP_BlankingSrce */
65 
66   uint32_t TriggerMode;        /*!< Set the comparator output triggering External Interrupt Line (EXTI).
67                                     This parameter can be a value of @ref COMP_EXTI_TriggerMode */
68 
69 } COMP_InitTypeDef;
70 
71 /**
72   * @brief  HAL COMP state machine: HAL COMP states definition
73   */
74 #define COMP_STATE_BITFIELD_LOCK  (0x10U)
75 typedef enum
76 {
77   HAL_COMP_STATE_RESET             = 0x00U,                                             /*!< COMP not yet initialized                             */
78   HAL_COMP_STATE_RESET_LOCKED      = (HAL_COMP_STATE_RESET | COMP_STATE_BITFIELD_LOCK), /*!< COMP not yet initialized and configuration is locked */
79   HAL_COMP_STATE_READY             = 0x01U,                                             /*!< COMP initialized and ready for use                   */
80   HAL_COMP_STATE_READY_LOCKED      = (HAL_COMP_STATE_READY | COMP_STATE_BITFIELD_LOCK), /*!< COMP initialized but configuration is locked         */
81   HAL_COMP_STATE_BUSY              = 0x02U,                                             /*!< COMP is running                                      */
82   HAL_COMP_STATE_BUSY_LOCKED       = (HAL_COMP_STATE_BUSY | COMP_STATE_BITFIELD_LOCK)   /*!< COMP is running and configuration is locked          */
83 } HAL_COMP_StateTypeDef;
84 
85 /**
86   * @brief  COMP Handle Structure definition
87   */
88 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
89 typedef struct __COMP_HandleTypeDef
90 #else
91 typedef struct
92 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
93 {
94   COMP_TypeDef       *Instance;       /*!< Register base address    */
95   COMP_InitTypeDef   Init;            /*!< COMP required parameters */
96   HAL_LockTypeDef    Lock;            /*!< Locking object           */
97   __IO HAL_COMP_StateTypeDef  State;  /*!< COMP communication state */
98   __IO uint32_t      ErrorCode;       /*!< COMP error code */
99 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
100   void (* TriggerCallback)(struct __COMP_HandleTypeDef *hcomp);   /*!< COMP trigger callback */
101   void (* MspInitCallback)(struct __COMP_HandleTypeDef *hcomp);   /*!< COMP Msp Init callback */
102   void (* MspDeInitCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP Msp DeInit callback */
103 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
104 } COMP_HandleTypeDef;
105 
106 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
107 /**
108   * @brief  HAL COMP Callback ID enumeration definition
109   */
110 typedef enum
111 {
112   HAL_COMP_TRIGGER_CB_ID                = 0x00U,  /*!< COMP trigger callback ID */
113   HAL_COMP_MSPINIT_CB_ID                = 0x01U,  /*!< COMP Msp Init callback ID */
114   HAL_COMP_MSPDEINIT_CB_ID              = 0x02U   /*!< COMP Msp DeInit callback ID */
115 } HAL_COMP_CallbackIDTypeDef;
116 
117 /**
118   * @brief  HAL COMP Callback pointer definition
119   */
120 typedef  void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer to a COMP callback function */
121 
122 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
123 
124 /**
125   * @}
126   */
127 
128 /* Exported constants --------------------------------------------------------*/
129 /** @defgroup COMP_Exported_Constants COMP Exported Constants
130   * @{
131   */
132 
133 /** @defgroup COMP_Error_Code COMP Error Code
134   * @{
135   */
136 #define HAL_COMP_ERROR_NONE             (0x00UL)  /*!< No error */
137 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
138 #define HAL_COMP_ERROR_INVALID_CALLBACK (0x01UL)  /*!< Invalid Callback error */
139 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
140 /**
141   * @}
142   */
143 
144 /** @defgroup COMP_InputPlus COMP input plus (non-inverting input)
145   * @{
146   */
147 #define COMP_INPUT_PLUS_IO1            (0x00000000UL)         /*!< Comparator input plus connected to IO1 (pin PA1 for COMP1, pin PA7 for COMP2, pin PA0 for COMP3, pin PB0 for COMP4, pin PB13 for COMP5, pin PB11 for COMP6, pin PB14 for COMP7). Note: For COMPx instance availability, please refer to datasheet */
148 #define COMP_INPUT_PLUS_IO2            (COMP_CSR_INPSEL)      /*!< Comparator input plus connected to IO2 (pin PB1 for COMP1, pin PA3 for COMP2, pin PC1 for COMP3, pin PE7 for COMP4, pin PD12 for COMP5, pin PD11 for COMP6, pin PD14 for COMP7). Note: For COMPx instance availability, please refer to datasheet */
149 /**
150   * @}
151   */
152 
153 /** @defgroup COMP_InputMinus COMP input minus (inverting input)
154   * @{
155   */
156 #define COMP_INPUT_MINUS_1_4VREFINT    (                                                            COMP_CSR_SCALEN | COMP_CSR_BRGEN)        /*!< Comparator input minus connected to 1/4 VrefInt */
157 #define COMP_INPUT_MINUS_1_2VREFINT    (                                        COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN | COMP_CSR_BRGEN)        /*!< Comparator input minus connected to 1/2 VrefInt */
158 #define COMP_INPUT_MINUS_3_4VREFINT    (                    COMP_CSR_INMSEL_1                     | COMP_CSR_SCALEN | COMP_CSR_BRGEN)        /*!< Comparator input minus connected to 3/4 VrefInt */
159 #define COMP_INPUT_MINUS_VREFINT       (                    COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN                 )        /*!< Comparator input minus connected to VrefInt */
160 #define COMP_INPUT_MINUS_DAC1_CH1      (COMP_CSR_INMSEL_2                     | COMP_CSR_INMSEL_0)                                           /*!< Comparator input minus connected to DAC1 Channel 1 for COMP1/3/4. Note: For COMPx & DACx instances availability, please refer to datasheet */
161 #define COMP_INPUT_MINUS_DAC1_CH2      (COMP_CSR_INMSEL_2                     | COMP_CSR_INMSEL_0)                                           /*!< Comparator input minus connected to DAC1 Channel 2 for COMP2/5. Note: For COMPx & DACx instances availability, please refer to datasheet */
162 #define COMP_INPUT_MINUS_DAC2_CH1      (COMP_CSR_INMSEL_2                     | COMP_CSR_INMSEL_0)                                           /*!< Comparator input minus connected to DAC2 Channel 1 for COMP6/7. Note: For COMPx & DACx instances availability, please refer to datasheet */
163 #define COMP_INPUT_MINUS_DAC3_CH1      (COMP_CSR_INMSEL_2                                        )                                           /*!< Comparator input minus connected to DAC3 Channel 1 for COMP1/3. Note: For COMPx & DACx instances availability, please refer to datasheet */
164 #define COMP_INPUT_MINUS_DAC3_CH2      (COMP_CSR_INMSEL_2                                        )                                           /*!< Comparator input minus connected to DAC3 Channel 2 for COMP2/4. Note: For COMPx & DACx instances availability, please refer to datasheet */
165 #define COMP_INPUT_MINUS_DAC4_CH1      (COMP_CSR_INMSEL_2                                        )                                           /*!< Comparator input minus connected to DAC4 Channel 1 for COMP5/7. Note: For COMPx & DACx instances availability, please refer to datasheet */
166 #define COMP_INPUT_MINUS_DAC4_CH2      (COMP_CSR_INMSEL_2                                        )                                           /*!< Comparator input minus connected to DAC4 Channel 2 for COMP6. Note: For COMPx & DACx instances availability, please refer to datasheet */
167 #define COMP_INPUT_MINUS_IO1           (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1                    )                                           /*!< Comparator input minus connected to IO1 (pin PA4 for COMP1, pin PA5 for COMP2, pin PF1 for COMP3, pin PE8 for COMP4, pin PB10 for COMP5, pin PD10 for COMP6, pin PD15 for COMP7). Note: For COMPx instance availability, please refer to datasheet */
168 #define COMP_INPUT_MINUS_IO2           (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0)                                           /*!< Comparator input minus connected to IO2 (pin PA0 for COMP1, pin PA2 for COMP2, pin PC0 for COMP3, pin PB2 for COMP4, pin PD13 for COMP5, pin PB15 for COMP6, pin PB12 for COMP7). Note: For COMPx instance availability, please refer to datasheet */
169 /**
170   * @}
171   */
172 
173 /** @defgroup COMP_Hysteresis COMP hysteresis
174   * @{
175   */
176 #define COMP_HYSTERESIS_NONE           (0x00000000UL)                                        /*!< No hysteresis */
177 #define COMP_HYSTERESIS_10MV           (                                    COMP_CSR_HYST_0) /*!< Hysteresis level 10mV */
178 #define COMP_HYSTERESIS_20MV           (                  COMP_CSR_HYST_1                  ) /*!< Hysteresis level 20mV */
179 #define COMP_HYSTERESIS_30MV           (                  COMP_CSR_HYST_1 | COMP_CSR_HYST_0) /*!< Hysteresis level 30mV */
180 #define COMP_HYSTERESIS_40MV           (COMP_CSR_HYST_2                                    ) /*!< Hysteresis level 40mV */
181 #define COMP_HYSTERESIS_50MV           (COMP_CSR_HYST_2                   | COMP_CSR_HYST_0) /*!< Hysteresis level 50mV */
182 #define COMP_HYSTERESIS_60MV           (COMP_CSR_HYST_2 | COMP_CSR_HYST_1                  ) /*!< Hysteresis level 60mV */
183 #define COMP_HYSTERESIS_70MV           (COMP_CSR_HYST_2 | COMP_CSR_HYST_1 | COMP_CSR_HYST_0) /*!< Hysteresis level 70mV */
184 #define COMP_HYSTERESIS_LOW            COMP_HYSTERESIS_10MV  /*!< Hysteresis level low */
185 #define COMP_HYSTERESIS_MEDIUM         COMP_HYSTERESIS_40MV  /*!< Hysteresis level medium */
186 #define COMP_HYSTERESIS_HIGH           COMP_HYSTERESIS_70MV  /*!< Hysteresis level high */
187 /**
188   * @}
189   */
190 
191 /** @defgroup COMP_OutputPolarity COMP output Polarity
192   * @{
193   */
194 #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) */
195 #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) */
196 /**
197   * @}
198   */
199 
200 /** @defgroup COMP_BlankingSrce  COMP blanking source
201   * @{
202   */
203 #define COMP_BLANKINGSRC_NONE            (0x00000000UL)          /*!<Comparator output without blanking */
204 #define COMP_BLANKINGSRC_TIM1_OC5_COMP1  (                                            COMP_CSR_BLANKING_0)   /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP1). Note: For COMPx & TIMx instances availability, please refer to datasheet */
205 #define COMP_BLANKINGSRC_TIM1_OC5_COMP2  (                                            COMP_CSR_BLANKING_0)   /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP2). Note: For COMPx & TIMx instances availability, please refer to datasheet */
206 #define COMP_BLANKINGSRC_TIM1_OC5_COMP3  (                                            COMP_CSR_BLANKING_0)   /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP3). Note: For COMPx & TIMx instances availability, please refer to datasheet */
207 #define COMP_BLANKINGSRC_TIM1_OC5_COMP4  (COMP_CSR_BLANKING_2                                            )   /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP4). Note: For COMPx & TIMx instances availability, please refer to datasheet */
208 #define COMP_BLANKINGSRC_TIM1_OC5_COMP5  (COMP_CSR_BLANKING_2                                            )   /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP5). Note: For COMPx & TIMx instances availability, please refer to datasheet */
209 #define COMP_BLANKINGSRC_TIM1_OC5_COMP6  (COMP_CSR_BLANKING_2                                            )   /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP6). Note: For COMPx & TIMx instances availability, please refer to datasheet */
210 #define COMP_BLANKINGSRC_TIM1_OC5_COMP7  (                                            COMP_CSR_BLANKING_0)   /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP7). Note: For COMPx & TIMx instances availability, please refer to datasheet */
211 #define COMP_BLANKINGSRC_TIM2_OC3_COMP1  (                      COMP_CSR_BLANKING_1                      )   /*!< Comparator output blanking source TIM2 OC3 (specific to COMP instance: COMP1). Note: For COMPx & TIMx instances availability, please refer to datasheet */
212 #define COMP_BLANKINGSRC_TIM2_OC3_COMP2  (                      COMP_CSR_BLANKING_1                      )   /*!< Comparator output blanking source TIM2 OC3 (specific to COMP instance: COMP2). Note: For COMPx & TIMx instances availability, please refer to datasheet */
213 #define COMP_BLANKINGSRC_TIM2_OC3_COMP5  (                                            COMP_CSR_BLANKING_0)   /*!< Comparator output blanking source TIM2 OC3 (specific to COMP instance: COMP5). Note: For COMPx & TIMx instances availability, please refer to datasheet */
214 #define COMP_BLANKINGSRC_TIM2_OC4_COMP3  (                      COMP_CSR_BLANKING_1 | COMP_CSR_BLANKING_0)   /*!< Comparator output blanking source TIM2 OC4 (specific to COMP instance: COMP3). Note: For COMPx & TIMx instances availability, please refer to datasheet */
215 #define COMP_BLANKINGSRC_TIM2_OC4_COMP6  (                      COMP_CSR_BLANKING_1                      )   /*!< Comparator output blanking source TIM2 OC4 (specific to COMP instance: COMP6). Note: For COMPx & TIMx instances availability, please refer to datasheet */
216 #define COMP_BLANKINGSRC_TIM3_OC3_COMP1  (                      COMP_CSR_BLANKING_1 | COMP_CSR_BLANKING_0)   /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP1). Note: For COMPx & TIMx instances availability, please refer to datasheet */
217 #define COMP_BLANKINGSRC_TIM3_OC3_COMP2  (                      COMP_CSR_BLANKING_1 | COMP_CSR_BLANKING_0)   /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP2). Note: For COMPx & TIMx instances availability, please refer to datasheet */
218 #define COMP_BLANKINGSRC_TIM3_OC3_COMP3  (                      COMP_CSR_BLANKING_1                      )   /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP3). Note: For COMPx & TIMx instances availability, please refer to datasheet */
219 #define COMP_BLANKINGSRC_TIM3_OC3_COMP5  (                      COMP_CSR_BLANKING_1 | COMP_CSR_BLANKING_0)   /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP5). Note: For COMPx & TIMx instances availability, please refer to datasheet */
220 #define COMP_BLANKINGSRC_TIM3_OC3_COMP7  (                      COMP_CSR_BLANKING_1 | COMP_CSR_BLANKING_0)   /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP7). Note: For COMPx & TIMx instances availability, please refer to datasheet */
221 #define COMP_BLANKINGSRC_TIM3_OC4_COMP4  (                                            COMP_CSR_BLANKING_0)   /*!< Comparator output blanking source TIM3 OC4 (specific to COMP instance: COMP4). Note: For COMPx & TIMx instances availability, please refer to datasheet */
222 #define COMP_BLANKINGSRC_TIM8_OC5_COMP1  (COMP_CSR_BLANKING_2                                            )   /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP1). Note: For COMPx & TIMx instances availability, please refer to datasheet */
223 #define COMP_BLANKINGSRC_TIM8_OC5_COMP2  (COMP_CSR_BLANKING_2                                            )   /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP2). Note: For COMPx & TIMx instances availability, please refer to datasheet */
224 #define COMP_BLANKINGSRC_TIM8_OC5_COMP3  (COMP_CSR_BLANKING_2                                            )   /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP3). Note: For COMPx & TIMx instances availability, please refer to datasheet */
225 #define COMP_BLANKINGSRC_TIM8_OC5_COMP4  (                      COMP_CSR_BLANKING_1                      )   /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP4). Note: For COMPx & TIMx instances availability, please refer to datasheet */
226 #define COMP_BLANKINGSRC_TIM8_OC5_COMP5  (                      COMP_CSR_BLANKING_1                      )   /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP5). Note: For COMPx & TIMx instances availability, please refer to datasheet */
227 #define COMP_BLANKINGSRC_TIM8_OC5_COMP6  (                                            COMP_CSR_BLANKING_0)   /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP6). Note: For COMPx & TIMx instances availability, please refer to datasheet */
228 #define COMP_BLANKINGSRC_TIM8_OC5_COMP7  (                      COMP_CSR_BLANKING_1                      )   /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP7). Note: For COMPx & TIMx instances availability, please refer to datasheet */
229 #define COMP_BLANKINGSRC_TIM15_OC1_COMP4 (                      COMP_CSR_BLANKING_1 | COMP_CSR_BLANKING_0)   /*!< Comparator output blanking source TIM15 OC1 (specific to COMP instance: COMP4). Note: For COMPx & TIMx instances availability, please refer to datasheet */
230 #define COMP_BLANKINGSRC_TIM15_OC2_COMP6 (                      COMP_CSR_BLANKING_1 | COMP_CSR_BLANKING_0)   /*!< Comparator output blanking source TIM15 OC2 (specific to COMP instance: COMP6). Note: For COMPx & TIMx instances availability, please refer to datasheet */
231 #define COMP_BLANKINGSRC_TIM15_OC2_COMP7 (COMP_CSR_BLANKING_2                                            )   /*!< Comparator output blanking source TIM15 OC3 (specific to COMP instance: COMP7). Note: For COMPx & TIMx instances availability, please refer to datasheet */
232 #define COMP_BLANKINGSRC_TIM20_OC5       (COMP_CSR_BLANKING_2 |                       COMP_CSR_BLANKING_0)   /*!< Comparator output blanking source TIM20 OC5 (Common to all COMP instances) */
233 #define COMP_BLANKINGSRC_TIM15_OC1       (COMP_CSR_BLANKING_2 | COMP_CSR_BLANKING_1                      )   /*!< Comparator output blanking source TIM15 OC1 (Common to all COMP instances) */
234 #define COMP_BLANKINGSRC_TIM4_OC3        (COMP_CSR_BLANKING_2 | COMP_CSR_BLANKING_1 | COMP_CSR_BLANKING_0)   /*!< Comparator output blanking source TIM4 OC3 (Common to all COMP instances) */
235 
236 /**
237   * @}
238   */
239 
240 /** @defgroup COMP_OutputLevel COMP Output Level
241   * @{
242   */
243 /* Note: Comparator output level values are fixed to "0" and "1",             */
244 /* corresponding COMP register bit is managed by HAL function to match        */
245 /* with these values (independently of bit position in register).             */
246 
247 /* When output polarity is not inverted, comparator output is low when
248    the input plus is at a lower voltage than the input minus */
249 #define COMP_OUTPUT_LEVEL_LOW              (0x00000000UL)
250 /* When output polarity is not inverted, comparator output is high when
251    the input plus is at a higher voltage than the input minus */
252 #define COMP_OUTPUT_LEVEL_HIGH             (0x00000001UL)
253 /**
254   * @}
255   */
256 
257 /** @defgroup COMP_EXTI_TriggerMode COMP output to EXTI
258   * @{
259   */
260 #define COMP_TRIGGERMODE_NONE                 (0x00000000UL)                                            /*!< Comparator output triggering no External Interrupt Line */
261 #define COMP_TRIGGERMODE_IT_RISING            (COMP_EXTI_IT | COMP_EXTI_RISING)                         /*!< Comparator output triggering External Interrupt Line event with interruption, on rising edge */
262 #define COMP_TRIGGERMODE_IT_FALLING           (COMP_EXTI_IT | COMP_EXTI_FALLING)                        /*!< Comparator output triggering External Interrupt Line event with interruption, on falling edge */
263 #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 */
264 #define COMP_TRIGGERMODE_EVENT_RISING         (COMP_EXTI_EVENT | COMP_EXTI_RISING)                      /*!< Comparator output triggering External Interrupt Line event only (without interruption), on rising edge */
265 #define COMP_TRIGGERMODE_EVENT_FALLING        (COMP_EXTI_EVENT | COMP_EXTI_FALLING)                     /*!< Comparator output triggering External Interrupt Line event only (without interruption), on falling edge */
266 #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 */
267 /**
268   * @}
269   */
270 
271 /**
272   * @}
273   */
274 
275 /* Exported macro ------------------------------------------------------------*/
276 /** @defgroup COMP_Exported_Macros COMP Exported Macros
277   * @{
278   */
279 
280 /** @defgroup COMP_Handle_Management  COMP Handle Management
281   * @{
282   */
283 
284 /** @brief  Reset COMP handle state.
285   * @param  __HANDLE__  COMP handle
286   * @retval None
287   */
288 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
289 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) do{                                                  \
290                                                       (__HANDLE__)->State = HAL_COMP_STATE_RESET;      \
291                                                       (__HANDLE__)->MspInitCallback = NULL;            \
292                                                       (__HANDLE__)->MspDeInitCallback = NULL;          \
293                                                     } while(0)
294 #else
295 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
296 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
297 
298 /**
299   * @brief Clear COMP error code (set it to no error code "HAL_COMP_ERROR_NONE").
300   * @param __HANDLE__ COMP handle
301   * @retval None
302   */
303 #define COMP_CLEAR_ERRORCODE(__HANDLE__) ((__HANDLE__)->ErrorCode = HAL_COMP_ERROR_NONE)
304 
305 /**
306   * @brief  Enable the specified comparator.
307   * @param  __HANDLE__  COMP handle
308   * @retval None
309   */
310 #define __HAL_COMP_ENABLE(__HANDLE__)       SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN)
311 
312 /**
313   * @brief  Disable the specified comparator.
314   * @param  __HANDLE__  COMP handle
315   * @retval None
316   */
317 #define __HAL_COMP_DISABLE(__HANDLE__)      CLEAR_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN)
318 
319 /**
320   * @brief  Lock the specified comparator configuration.
321   * @note   Using this macro induce HAL COMP handle state machine being no
322   *         more in line with COMP instance state.
323   *         To keep HAL COMP handle state machine updated, it is recommended
324   *         to use function "HAL_COMP_Lock')".
325   * @param  __HANDLE__  COMP handle
326   * @retval None
327   */
328 #define __HAL_COMP_LOCK(__HANDLE__)         SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK)
329 
330 /**
331   * @brief  Check whether the specified comparator is locked.
332   * @param  __HANDLE__  COMP handle
333   * @retval Value 0 if COMP instance is not locked, value 1 if COMP instance is locked
334   */
335 #define __HAL_COMP_IS_LOCKED(__HANDLE__)    (READ_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK) == COMP_CSR_LOCK)
336 
337 /**
338   * @}
339   */
340 
341 /** @defgroup COMP_Exti_Management  COMP external interrupt line management
342   * @{
343   */
344 /**
345   * @brief  Enable the COMP1 EXTI line rising edge trigger.
346   * @retval None
347   */
348 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE()    LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP1)
349 
350 /**
351   * @brief  Disable the COMP1 EXTI line rising edge trigger.
352   * @retval None
353   */
354 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE()   LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP1)
355 
356 /**
357   * @brief  Enable the COMP1 EXTI line falling edge trigger.
358   * @retval None
359   */
360 #define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE()   LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP1)
361 
362 /**
363   * @brief  Disable the COMP1 EXTI line falling edge trigger.
364   * @retval None
365   */
366 #define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE()  LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP1)
367 
368 /**
369   * @brief  Enable the COMP1 EXTI line rising & falling edge trigger.
370   * @retval None
371   */
372 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE() do {                                                        \
373                                                                 LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP1);   \
374                                                                 LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP1);  \
375                                                               } while(0)
376 
377 /**
378   * @brief  Disable the COMP1 EXTI line rising & falling edge trigger.
379   * @retval None
380   */
381 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE() do {                                                       \
382                                                                  LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP1); \
383                                                                  LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP1);\
384                                                                } while(0)
385 
386 /**
387   * @brief  Enable the COMP1 EXTI line in interrupt mode.
388   * @retval None
389   */
390 #define __HAL_COMP_COMP1_EXTI_ENABLE_IT()             LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP1)
391 
392 /**
393   * @brief  Disable the COMP1 EXTI line in interrupt mode.
394   * @retval None
395   */
396 #define __HAL_COMP_COMP1_EXTI_DISABLE_IT()            LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP1)
397 
398 /**
399   * @brief  Generate a software interrupt on the COMP1 EXTI line.
400   * @retval None
401   */
402 #define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT()         LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP1)
403 
404 /**
405   * @brief  Enable the COMP1 EXTI line in event mode.
406   * @retval None
407   */
408 #define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT()          LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP1)
409 
410 /**
411   * @brief  Disable the COMP1 EXTI line in event mode.
412   * @retval None
413   */
414 #define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT()         LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP1)
415 
416 /**
417   * @brief  Check whether the COMP1 EXTI line flag is set.
418   * @retval RESET or SET
419   */
420 #define __HAL_COMP_COMP1_EXTI_GET_FLAG()              LL_EXTI_IsActiveFlag_0_31(COMP_EXTI_LINE_COMP1)
421 
422 /**
423   * @brief  Clear the COMP1 EXTI flag.
424   * @retval None
425   */
426 #define __HAL_COMP_COMP1_EXTI_CLEAR_FLAG()            LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP1)
427 
428 /**
429   * @brief  Enable the COMP2 EXTI line rising edge trigger.
430   * @retval None
431   */
432 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE()    LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP2)
433 
434 /**
435   * @brief  Disable the COMP2 EXTI line rising edge trigger.
436   * @retval None
437   */
438 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE()   LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP2)
439 
440 /**
441   * @brief  Enable the COMP2 EXTI line falling edge trigger.
442   * @retval None
443   */
444 #define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE()   LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP2)
445 
446 /**
447   * @brief  Disable the COMP2 EXTI line falling edge trigger.
448   * @retval None
449   */
450 #define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE()  LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP2)
451 
452 /**
453   * @brief  Enable the COMP2 EXTI line rising & falling edge trigger.
454   * @retval None
455   */
456 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE() do {                                                        \
457                                                                 LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP2);   \
458                                                                 LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP2);  \
459                                                               } while(0)
460 
461 /**
462   * @brief  Disable the COMP2 EXTI line rising & falling edge trigger.
463   * @retval None
464   */
465 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE() do {                                                       \
466                                                                  LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP2); \
467                                                                  LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP2);\
468                                                                } while(0)
469 
470 /**
471   * @brief  Enable the COMP2 EXTI line in interrupt mode.
472   * @retval None
473   */
474 #define __HAL_COMP_COMP2_EXTI_ENABLE_IT()             LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP2)
475 
476 /**
477   * @brief  Disable the COMP2 EXTI line in interrupt mode.
478   * @retval None
479   */
480 #define __HAL_COMP_COMP2_EXTI_DISABLE_IT()            LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP2)
481 
482 /**
483   * @brief  Generate a software interrupt on the COMP2 EXTI line.
484   * @retval None
485   */
486 #define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT()         LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP2)
487 
488 /**
489   * @brief  Enable the COMP2 EXTI line in event mode.
490   * @retval None
491   */
492 #define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT()          LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP2)
493 
494 /**
495   * @brief  Disable the COMP2 EXTI line in event mode.
496   * @retval None
497   */
498 #define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT()         LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP2)
499 
500 /**
501   * @brief  Check whether the COMP2 EXTI line flag is set.
502   * @retval RESET or SET
503   */
504 #define __HAL_COMP_COMP2_EXTI_GET_FLAG()              LL_EXTI_IsActiveFlag_0_31(COMP_EXTI_LINE_COMP2)
505 
506 /**
507   * @brief  Clear the COMP2 EXTI flag.
508   * @retval None
509   */
510 #define __HAL_COMP_COMP2_EXTI_CLEAR_FLAG()            LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP2)
511 
512 /**
513   * @brief  Enable the COMP3 EXTI line rising edge trigger.
514   * @retval None
515   */
516 #define __HAL_COMP_COMP3_EXTI_ENABLE_RISING_EDGE()    LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP3)
517 
518 /**
519   * @brief  Disable the COMP3 EXTI line rising edge trigger.
520   * @retval None
521   */
522 #define __HAL_COMP_COMP3_EXTI_DISABLE_RISING_EDGE()   LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP3)
523 
524 /**
525   * @brief  Enable the COMP3 EXTI line falling edge trigger.
526   * @retval None
527   */
528 #define __HAL_COMP_COMP3_EXTI_ENABLE_FALLING_EDGE()   LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP3)
529 
530 /**
531   * @brief  Disable the COMP3 EXTI line falling edge trigger.
532   * @retval None
533   */
534 #define __HAL_COMP_COMP3_EXTI_DISABLE_FALLING_EDGE()  LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP3)
535 
536 /**
537   * @brief  Enable the COMP3 EXTI line rising & falling edge trigger.
538   * @retval None
539   */
540 #define __HAL_COMP_COMP3_EXTI_ENABLE_RISING_FALLING_EDGE() do {                                                        \
541                                                                 LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP3);   \
542                                                                 LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP3);  \
543                                                               } while(0)
544 
545 /**
546   * @brief  Disable the COMP3 EXTI line rising & falling edge trigger.
547   * @retval None
548   */
549 #define __HAL_COMP_COMP3_EXTI_DISABLE_RISING_FALLING_EDGE() do {                                                       \
550                                                                  LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP3); \
551                                                                  LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP3);\
552                                                                } while(0)
553 
554 /**
555   * @brief  Enable the COMP3 EXTI line in interrupt mode.
556   * @retval None
557   */
558 #define __HAL_COMP_COMP3_EXTI_ENABLE_IT()             LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP3)
559 
560 /**
561   * @brief  Disable the COMP3 EXTI line in interrupt mode.
562   * @retval None
563   */
564 #define __HAL_COMP_COMP3_EXTI_DISABLE_IT()            LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP3)
565 
566 /**
567   * @brief  Generate a software interrupt on the COMP3 EXTI line.
568   * @retval None
569   */
570 #define __HAL_COMP_COMP3_EXTI_GENERATE_SWIT()         LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP3)
571 
572 /**
573   * @brief  Enable the COMP3 EXTI line in event mode.
574   * @retval None
575   */
576 #define __HAL_COMP_COMP3_EXTI_ENABLE_EVENT()          LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP3)
577 
578 /**
579   * @brief  Disable the COMP3 EXTI line in event mode.
580   * @retval None
581   */
582 #define __HAL_COMP_COMP3_EXTI_DISABLE_EVENT()         LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP3)
583 
584 /**
585   * @brief  Check whether the COMP3 EXTI line flag is set.
586   * @retval RESET or SET
587   */
588 #define __HAL_COMP_COMP3_EXTI_GET_FLAG()              LL_EXTI_IsActiveFlag_0_31(COMP_EXTI_LINE_COMP3)
589 
590 /**
591   * @brief  Clear the COMP3 EXTI flag.
592   * @retval None
593   */
594 #define __HAL_COMP_COMP3_EXTI_CLEAR_FLAG()            LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP3)
595 
596 /**
597   * @brief  Enable the COMP4 EXTI line rising edge trigger.
598   * @retval None
599   */
600 #define __HAL_COMP_COMP4_EXTI_ENABLE_RISING_EDGE()    LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP4)
601 
602 /**
603   * @brief  Disable the COMP4 EXTI line rising edge trigger.
604   * @retval None
605   */
606 #define __HAL_COMP_COMP4_EXTI_DISABLE_RISING_EDGE()   LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP4)
607 
608 /**
609   * @brief  Enable the COMP4 EXTI line falling edge trigger.
610   * @retval None
611   */
612 #define __HAL_COMP_COMP4_EXTI_ENABLE_FALLING_EDGE()   LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP4)
613 
614 /**
615   * @brief  Disable the COMP4 EXTI line falling edge trigger.
616   * @retval None
617   */
618 #define __HAL_COMP_COMP4_EXTI_DISABLE_FALLING_EDGE()  LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP4)
619 
620 /**
621   * @brief  Enable the COMP4 EXTI line rising & falling edge trigger.
622   * @retval None
623   */
624 #define __HAL_COMP_COMP4_EXTI_ENABLE_RISING_FALLING_EDGE() do {                                                        \
625                                                                 LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP4);   \
626                                                                 LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP4);  \
627                                                               } while(0)
628 
629 /**
630   * @brief  Disable the COMP4 EXTI line rising & falling edge trigger.
631   * @retval None
632   */
633 #define __HAL_COMP_COMP4_EXTI_DISABLE_RISING_FALLING_EDGE() do {                                                       \
634                                                                  LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP4); \
635                                                                  LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP4);\
636                                                                } while(0)
637 
638 /**
639   * @brief  Enable the COMP4 EXTI line in interrupt mode.
640   * @retval None
641   */
642 #define __HAL_COMP_COMP4_EXTI_ENABLE_IT()             LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP4)
643 
644 /**
645   * @brief  Disable the COMP4 EXTI line in interrupt mode.
646   * @retval None
647   */
648 #define __HAL_COMP_COMP4_EXTI_DISABLE_IT()            LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP4)
649 
650 /**
651   * @brief  Generate a software interrupt on the COMP4 EXTI line.
652   * @retval None
653   */
654 #define __HAL_COMP_COMP4_EXTI_GENERATE_SWIT()         LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP4)
655 
656 /**
657   * @brief  Enable the COMP4 EXTI line in event mode.
658   * @retval None
659   */
660 #define __HAL_COMP_COMP4_EXTI_ENABLE_EVENT()          LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP4)
661 
662 /**
663   * @brief  Disable the COMP4 EXTI line in event mode.
664   * @retval None
665   */
666 #define __HAL_COMP_COMP4_EXTI_DISABLE_EVENT()         LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP4)
667 
668 /**
669   * @brief  Check whether the COMP4 EXTI line flag is set.
670   * @retval RESET or SET
671   */
672 #define __HAL_COMP_COMP4_EXTI_GET_FLAG()              LL_EXTI_IsActiveFlag_0_31(COMP_EXTI_LINE_COMP4)
673 
674 /**
675   * @brief  Clear the COMP4 EXTI flag.
676   * @retval None
677   */
678 #define __HAL_COMP_COMP4_EXTI_CLEAR_FLAG()            LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP4)
679 
680 #if  defined(STM32G414xx) || defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx) || defined(STM32G483xx)
681 /**
682   * @brief  Enable the COMP5 EXTI line rising edge trigger.
683   * @retval None
684   */
685 #define __HAL_COMP_COMP5_EXTI_ENABLE_RISING_EDGE()    LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP5)
686 
687 /**
688   * @brief  Disable the COMP5 EXTI line rising edge trigger.
689   * @retval None
690   */
691 #define __HAL_COMP_COMP5_EXTI_DISABLE_RISING_EDGE()   LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP5)
692 
693 /**
694   * @brief  Enable the COMP5 EXTI line falling edge trigger.
695   * @retval None
696   */
697 #define __HAL_COMP_COMP5_EXTI_ENABLE_FALLING_EDGE()   LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP5)
698 
699 /**
700   * @brief  Disable the COMP5 EXTI line falling edge trigger.
701   * @retval None
702   */
703 #define __HAL_COMP_COMP5_EXTI_DISABLE_FALLING_EDGE()  LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP5)
704 
705 /**
706   * @brief  Enable the COMP5 EXTI line rising & falling edge trigger.
707   * @retval None
708   */
709 #define __HAL_COMP_COMP5_EXTI_ENABLE_RISING_FALLING_EDGE() do {                                                        \
710                                                                 LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP5);   \
711                                                                 LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP5);  \
712                                                               } while(0)
713 
714 /**
715   * @brief  Disable the COMP5 EXTI line rising & falling edge trigger.
716   * @retval None
717   */
718 #define __HAL_COMP_COMP5_EXTI_DISABLE_RISING_FALLING_EDGE() do {                                                       \
719                                                                  LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP5); \
720                                                                  LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP5);\
721                                                                } while(0)
722 
723 /**
724   * @brief  Enable the COMP5 EXTI line in interrupt mode.
725   * @retval None
726   */
727 #define __HAL_COMP_COMP5_EXTI_ENABLE_IT()             LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP5)
728 
729 /**
730   * @brief  Disable the COMP5 EXTI line in interrupt mode.
731   * @retval None
732   */
733 #define __HAL_COMP_COMP5_EXTI_DISABLE_IT()            LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP5)
734 
735 /**
736   * @brief  Generate a software interrupt on the COMP5 EXTI line.
737   * @retval None
738   */
739 #define __HAL_COMP_COMP5_EXTI_GENERATE_SWIT()         LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP5)
740 
741 /**
742   * @brief  Enable the COMP5 EXTI line in event mode.
743   * @retval None
744   */
745 #define __HAL_COMP_COMP5_EXTI_ENABLE_EVENT()          LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP5)
746 
747 /**
748   * @brief  Disable the COMP5 EXTI line in event mode.
749   * @retval None
750   */
751 #define __HAL_COMP_COMP5_EXTI_DISABLE_EVENT()         LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP5)
752 
753 /**
754   * @brief  Check whether the COMP5 EXTI line flag is set.
755   * @retval RESET or SET
756   */
757 #define __HAL_COMP_COMP5_EXTI_GET_FLAG()              LL_EXTI_IsActiveFlag_0_31(COMP_EXTI_LINE_COMP5)
758 
759 /**
760   * @brief  Clear the COMP5 EXTI flag.
761   * @retval None
762   */
763 #define __HAL_COMP_COMP5_EXTI_CLEAR_FLAG()            LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP5)
764 
765 #endif /* STM32G414xx || STM32G474xx || STM32G484xx || STM32G473xx || STM32G483xx*/
766 #if  defined(STM32G414xx) || defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx) || defined(STM32G483xx)
767 /**
768   * @brief  Enable the COMP6 EXTI line rising edge trigger.
769   * @retval None
770   */
771 #define __HAL_COMP_COMP6_EXTI_ENABLE_RISING_EDGE()    LL_EXTI_EnableRisingTrig_32_63(COMP_EXTI_LINE_COMP6)
772 
773 /**
774   * @brief  Disable the COMP6 EXTI line rising edge trigger.
775   * @retval None
776   */
777 #define __HAL_COMP_COMP6_EXTI_DISABLE_RISING_EDGE()   LL_EXTI_DisableRisingTrig_32_63(COMP_EXTI_LINE_COMP6)
778 
779 /**
780   * @brief  Enable the COMP6 EXTI line falling edge trigger.
781   * @retval None
782   */
783 #define __HAL_COMP_COMP6_EXTI_ENABLE_FALLING_EDGE()   LL_EXTI_EnableFallingTrig_32_63(COMP_EXTI_LINE_COMP6)
784 
785 /**
786   * @brief  Disable the COMP6 EXTI line falling edge trigger.
787   * @retval None
788   */
789 #define __HAL_COMP_COMP6_EXTI_DISABLE_FALLING_EDGE()  LL_EXTI_DisableFallingTrig_32_63(COMP_EXTI_LINE_COMP6)
790 
791 /**
792   * @brief  Enable the COMP6 EXTI line rising & falling edge trigger.
793   * @retval None
794   */
795 #define __HAL_COMP_COMP6_EXTI_ENABLE_RISING_FALLING_EDGE() do {                                                        \
796                                                                 LL_EXTI_EnableRisingTrig_32_63(COMP_EXTI_LINE_COMP6);  \
797                                                                 LL_EXTI_EnableFallingTrig_32_63(COMP_EXTI_LINE_COMP6); \
798                                                               } while(0)
799 
800 /**
801   * @brief  Disable the COMP6 EXTI line rising & falling edge trigger.
802   * @retval None
803   */
804 #define __HAL_COMP_COMP6_EXTI_DISABLE_RISING_FALLING_EDGE() do {                                                       \
805                                                                  LL_EXTI_DisableRisingTrig_32_63(COMP_EXTI_LINE_COMP6);\
806                                                                  LL_EXTI_DisableFallingTrig_32_63(COMP_EXTI_LINE_COMP6);\
807                                                                } while(0)
808 
809 /**
810   * @brief  Enable the COMP6 EXTI line in interrupt mode.
811   * @retval None
812   */
813 #define __HAL_COMP_COMP6_EXTI_ENABLE_IT()             LL_EXTI_EnableIT_32_63(COMP_EXTI_LINE_COMP6)
814 
815 /**
816   * @brief  Disable the COMP6 EXTI line in interrupt mode.
817   * @retval None
818   */
819 #define __HAL_COMP_COMP6_EXTI_DISABLE_IT()            LL_EXTI_DisableIT_32_63(COMP_EXTI_LINE_COMP6)
820 
821 /**
822   * @brief  Generate a software interrupt on the COMP6 EXTI line.
823   * @retval None
824   */
825 #define __HAL_COMP_COMP6_EXTI_GENERATE_SWIT()         LL_EXTI_GenerateSWI_32_63(COMP_EXTI_LINE_COMP6)
826 
827 /**
828   * @brief  Enable the COMP6 EXTI line in event mode.
829   * @retval None
830   */
831 #define __HAL_COMP_COMP6_EXTI_ENABLE_EVENT()          LL_EXTI_EnableEvent_32_63(COMP_EXTI_LINE_COMP6)
832 
833 /**
834   * @brief  Disable the COMP6 EXTI line in event mode.
835   * @retval None
836   */
837 #define __HAL_COMP_COMP6_EXTI_DISABLE_EVENT()         LL_EXTI_DisableEvent_32_63(COMP_EXTI_LINE_COMP6)
838 
839 /**
840   * @brief  Check whether the COMP6 EXTI line flag is set.
841   * @retval RESET or SET
842   */
843 #define __HAL_COMP_COMP6_EXTI_GET_FLAG()              LL_EXTI_IsActiveFlag_32_63(COMP_EXTI_LINE_COMP6)
844 
845 /**
846   * @brief  Clear the COMP6 EXTI flag.
847   * @retval None
848   */
849 #define __HAL_COMP_COMP6_EXTI_CLEAR_FLAG()            LL_EXTI_ClearFlag_32_63(COMP_EXTI_LINE_COMP6)
850 
851 #endif /* STM32G414xx || STM32G474xx || STM32G484xx || STM32G473xx || STM32G483xx*/
852 #if  defined(STM32G414xx) || defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx) || defined(STM32G483xx)
853 /**
854   * @brief  Enable the COMP7 EXTI line rising edge trigger.
855   * @retval None
856   */
857 #define __HAL_COMP_COMP7_EXTI_ENABLE_RISING_EDGE()    LL_EXTI_EnableRisingTrig_32_63(COMP_EXTI_LINE_COMP7)
858 
859 /**
860   * @brief  Disable the COMP7 EXTI line rising edge trigger.
861   * @retval None
862   */
863 #define __HAL_COMP_COMP7_EXTI_DISABLE_RISING_EDGE()   LL_EXTI_DisableRisingTrig_32_63(COMP_EXTI_LINE_COMP7)
864 
865 /**
866   * @brief  Enable the COMP7 EXTI line falling edge trigger.
867   * @retval None
868   */
869 #define __HAL_COMP_COMP7_EXTI_ENABLE_FALLING_EDGE()   LL_EXTI_EnableFallingTrig_32_63(COMP_EXTI_LINE_COMP7)
870 
871 /**
872   * @brief  Disable the COMP7 EXTI line falling edge trigger.
873   * @retval None
874   */
875 #define __HAL_COMP_COMP7_EXTI_DISABLE_FALLING_EDGE()  LL_EXTI_DisableFallingTrig_32_63(COMP_EXTI_LINE_COMP7)
876 
877 /**
878   * @brief  Enable the COMP7 EXTI line rising & falling edge trigger.
879   * @retval None
880   */
881 #define __HAL_COMP_COMP7_EXTI_ENABLE_RISING_FALLING_EDGE() do {                                                        \
882                                                                 LL_EXTI_EnableRisingTrig_32_63(COMP_EXTI_LINE_COMP7);  \
883                                                                 LL_EXTI_EnableFallingTrig_32_63(COMP_EXTI_LINE_COMP7); \
884                                                               } while(0)
885 
886 /**
887   * @brief  Disable the COMP7 EXTI line rising & falling edge trigger.
888   * @retval None
889   */
890 #define __HAL_COMP_COMP7_EXTI_DISABLE_RISING_FALLING_EDGE() do {                                                       \
891                                                                  LL_EXTI_DisableRisingTrig_32_63(COMP_EXTI_LINE_COMP7);\
892                                                                  LL_EXTI_DisableFallingTrig_32_63(COMP_EXTI_LINE_COMP7);\
893                                                                } while(0)
894 
895 /**
896   * @brief  Enable the COMP7 EXTI line in interrupt mode.
897   * @retval None
898   */
899 #define __HAL_COMP_COMP7_EXTI_ENABLE_IT()             LL_EXTI_EnableIT_32_63(COMP_EXTI_LINE_COMP7)
900 
901 /**
902   * @brief  Disable the COMP7 EXTI line in interrupt mode.
903   * @retval None
904   */
905 #define __HAL_COMP_COMP7_EXTI_DISABLE_IT()            LL_EXTI_DisableIT_32_63(COMP_EXTI_LINE_COMP7)
906 
907 /**
908   * @brief  Generate a software interrupt on the COMP7 EXTI line.
909   * @retval None
910   */
911 #define __HAL_COMP_COMP7_EXTI_GENERATE_SWIT()         LL_EXTI_GenerateSWI_32_63(COMP_EXTI_LINE_COMP7)
912 
913 /**
914   * @brief  Enable the COMP7 EXTI line in event mode.
915   * @retval None
916   */
917 #define __HAL_COMP_COMP7_EXTI_ENABLE_EVENT()          LL_EXTI_EnableEvent_32_63(COMP_EXTI_LINE_COMP7)
918 
919 /**
920   * @brief  Disable the COMP7 EXTI line in event mode.
921   * @retval None
922   */
923 #define __HAL_COMP_COMP7_EXTI_DISABLE_EVENT()         LL_EXTI_DisableEvent_32_63(COMP_EXTI_LINE_COMP7)
924 
925 /**
926   * @brief  Check whether the COMP7 EXTI line flag is set.
927   * @retval RESET or SET
928   */
929 #define __HAL_COMP_COMP7_EXTI_GET_FLAG()              LL_EXTI_IsActiveFlag_32_63(COMP_EXTI_LINE_COMP7)
930 
931 /**
932   * @brief  Clear the COMP7 EXTI flag.
933   * @retval None
934   */
935 #define __HAL_COMP_COMP7_EXTI_CLEAR_FLAG()            LL_EXTI_ClearFlag_32_63(COMP_EXTI_LINE_COMP7)
936 
937 #endif /* STM32G414xx ||  STM32G474xx || STM32G484xx || STM32G473xx || STM32G483xx */
938 /**
939   * @}
940   */
941 
942 /**
943   * @}
944   */
945 
946 
947 /* Private types -------------------------------------------------------------*/
948 /* Private constants ---------------------------------------------------------*/
949 /** @defgroup COMP_Private_Constants COMP Private Constants
950   * @{
951   */
952 
953 /** @defgroup COMP_ExtiLine COMP EXTI Lines
954   * @{
955   */
956 #if defined(STM32G414xx) || defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx) || defined(STM32G483xx) || defined(STM32GBK1CB) || defined(STM32G431xx) || defined(STM32G441xx) || defined(STM32G471xx) || defined(STM32G491xx) || defined(STM32G4A1xx)
957 #define COMP_EXTI_LINE_COMP1           (LL_EXTI_LINE_21)  /*!< EXTI line 21 connected to COMP1 output. Note: For COMPx instance availability, please refer to datasheet */
958 #define COMP_EXTI_LINE_COMP2           (LL_EXTI_LINE_22)  /*!< EXTI line 22 connected to COMP2 output. Note: For COMPx instance availability, please refer to datasheet */
959 #define COMP_EXTI_LINE_COMP3           (LL_EXTI_LINE_29)  /*!< EXTI line 29 connected to COMP3 output. Note: For COMPx instance availability, please refer to datasheet */
960 #define COMP_EXTI_LINE_COMP4           (LL_EXTI_LINE_30)  /*!< EXTI line 30 connected to COMP4 output. Note: For COMPx instance availability, please refer to datasheet */
961 #elif defined(STM32G411xB) || defined(STM32G411xC)
962 #define COMP_EXTI_LINE_COMP1           (LL_EXTI_LINE_21)  /*!< EXTI line 21 connected to COMP1 output. Note: For COMPx instance availability, please refer to datasheet */
963 #define COMP_EXTI_LINE_COMP2           (LL_EXTI_LINE_22)  /*!< EXTI line 22 connected to COMP2 output. Note: For COMPx instance availability, please refer to datasheet */
964 #define COMP_EXTI_LINE_COMP3           (LL_EXTI_LINE_29)  /*!< EXTI line 29 connected to COMP3 output. Note: For COMPx instance availability, please refer to datasheet */
965 #endif /* STM32G414xx || STM32G474xx || STM32G484xx || STM32G473xx || STM32G483xx || STM32GBK1CB || STM32G431xx || STM32G441xx || STM32G471xx || STM32G491xx || STM32G4A1xx */
966 #if defined(STM32G414xx) || defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx) || defined(STM32G483xx)
967 #define COMP_EXTI_LINE_COMP5           (LL_EXTI_LINE_31)  /*!< EXTI line 31 connected to COMP5 output. Note: For COMPx instance availability, please refer to datasheet */
968 #define COMP_EXTI_LINE_COMP6           (LL_EXTI_LINE_32)  /*!< EXTI line 32 connected to COMP6 output. Note: For COMPx instance availability, please refer to datasheet */
969 #define COMP_EXTI_LINE_COMP7           (LL_EXTI_LINE_33)  /*!< EXTI line 33 connected to COMP7 output. Note: For COMPx instance availability, please refer to datasheet */
970 #endif /* STM32G414xx || STM32G474xx || STM32G484xx || STM32G473xx || STM32G483xx */
971 /**
972   * @}
973   */
974 
975 /** @defgroup COMP_ExtiLine COMP EXTI Lines
976   * @{
977   */
978 #define COMP_EXTI_IT                        (0x00000001UL)  /*!< EXTI line event with interruption */
979 #define COMP_EXTI_EVENT                     (0x00000002UL)  /*!< EXTI line event only (without interruption) */
980 #define COMP_EXTI_RISING                    (0x00000010UL)  /*!< EXTI line event on rising edge */
981 #define COMP_EXTI_FALLING                   (0x00000020UL)  /*!< EXTI line event on falling edge */
982 /**
983   * @}
984   */
985 
986 /**
987   * @}
988   */
989 
990 /* Private macros ------------------------------------------------------------*/
991 /** @defgroup COMP_Private_Macros COMP Private Macros
992   * @{
993   */
994 
995 /** @defgroup COMP_GET_EXTI_LINE COMP private macros to get EXTI line associated with comparators
996   * @{
997   */
998 /**
999   * @brief  Get the specified EXTI line for a comparator instance.
1000   * @param  __INSTANCE__  specifies the COMP instance.
1001   * @retval value of @ref COMP_ExtiLine
1002   */
1003 #if  defined(STM32G414xx) || defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx) || defined(STM32G483xx)
1004 #define COMP_GET_EXTI_LINE(__INSTANCE__)    (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1  \
1005                                              :((__INSTANCE__) == COMP2) ? COMP_EXTI_LINE_COMP2 \
1006                                              :((__INSTANCE__) == COMP3) ? COMP_EXTI_LINE_COMP3 \
1007                                              :((__INSTANCE__) == COMP4) ? COMP_EXTI_LINE_COMP4 \
1008                                              :((__INSTANCE__) == COMP5) ? COMP_EXTI_LINE_COMP5 \
1009                                              :((__INSTANCE__) == COMP6) ? COMP_EXTI_LINE_COMP6 \
1010                                              : COMP_EXTI_LINE_COMP7)
1011 #elif defined(STM32GBK1CB) || defined(STM32G431xx) || defined(STM32G441xx) || defined(STM32G471xx) || defined(STM32G491xx) || defined(STM32G4A1xx)
1012 #define COMP_GET_EXTI_LINE(__INSTANCE__)    (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1  \
1013                                              :((__INSTANCE__) == COMP2) ? COMP_EXTI_LINE_COMP2 \
1014                                              :((__INSTANCE__) == COMP3) ? COMP_EXTI_LINE_COMP3 \
1015                                              : COMP_EXTI_LINE_COMP4)
1016 #elif defined(STM32G411xB) || defined(STM32G411xC)
1017 #define COMP_GET_EXTI_LINE(__INSTANCE__)    (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1  \
1018                                              :((__INSTANCE__) == COMP2) ? COMP_EXTI_LINE_COMP2 \
1019                                              : COMP_EXTI_LINE_COMP3)
1020 #endif /* STM32G414xx || STM32G474xx || STM32G484xx || STM32G473xx || STM32G483xx */
1021 /**
1022   * @}
1023   */
1024 
1025 /** @defgroup COMP_IS_COMP_Private_Definitions COMP private macros to check input parameters
1026   * @{
1027   */
1028 #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
1029                                                                ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2))
1030 
1031 #if defined(STM32G414xx) || defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx) || defined(STM32G483xx)
1032 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT)  || \
1033                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT)  || \
1034                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT)  || \
1035                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT)     || \
1036                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1)         || \
1037                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2)         || \
1038                                                                  (((__COMP_INSTANCE__) == COMP1)                        && \
1039                                                                   (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1)  || \
1040                                                                    ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH1))    \
1041                                                                  )                                                      || \
1042                                                                  (((__COMP_INSTANCE__) == COMP2)                        && \
1043                                                                   (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2)  || \
1044                                                                    ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH2))    \
1045                                                                  )                                                      || \
1046                                                                  (((__COMP_INSTANCE__) == COMP3)                        && \
1047                                                                   (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1)  || \
1048                                                                    ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH1))    \
1049                                                                  )                                                      || \
1050                                                                  (((__COMP_INSTANCE__) == COMP4)                        && \
1051                                                                   (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1)  || \
1052                                                                    ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH2))    \
1053                                                                  )                                                      || \
1054                                                                  (((__COMP_INSTANCE__) == COMP5)                        && \
1055                                                                   (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2)  || \
1056                                                                    ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC4_CH1))    \
1057                                                                  )                                                      || \
1058                                                                  (((__COMP_INSTANCE__) == COMP6)                        && \
1059                                                                   (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC2_CH1)  || \
1060                                                                    ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC4_CH2))    \
1061                                                                  )                                                      || \
1062                                                                  (((__COMP_INSTANCE__) == COMP7)                        && \
1063                                                                   (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC2_CH1)  || \
1064                                                                    ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC4_CH1))    \
1065                                                                  ))
1066 #elif defined(STM32GBK1CB) || defined(STM32G431xx) || defined(STM32G441xx) || defined(STM32G471xx) || defined(STM32G491xx) || defined(STM32G4A1xx)
1067 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT)  || \
1068                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT)  || \
1069                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT)  || \
1070                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT)     || \
1071                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1)         || \
1072                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2)         || \
1073                                                                  (((__COMP_INSTANCE__) == COMP1)                        && \
1074                                                                   (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1)  || \
1075                                                                    ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH1))    \
1076                                                                  )                                                      || \
1077                                                                  (((__COMP_INSTANCE__) == COMP2)                        && \
1078                                                                   (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2)  || \
1079                                                                    ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH2))    \
1080                                                                  )                                                      || \
1081                                                                  (((__COMP_INSTANCE__) == COMP3)                        && \
1082                                                                   (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1)  || \
1083                                                                    ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH1))    \
1084                                                                  )                                                      || \
1085                                                                  (((__COMP_INSTANCE__) == COMP4)                        && \
1086                                                                   (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1)  || \
1087                                                                    ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH2))    \
1088                                                                  ))
1089 #elif defined(STM32G411xB) || defined(STM32G411xC)
1090 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT)  || \
1091                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT)  || \
1092                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT)  || \
1093                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT)     || \
1094                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1)         || \
1095                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2)         || \
1096                                                                  (((__COMP_INSTANCE__) == COMP1)                        && \
1097                                                                   (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1)  || \
1098                                                                    ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH1))    \
1099                                                                  )                                                      || \
1100                                                                  (((__COMP_INSTANCE__) == COMP2)                        && \
1101                                                                   (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2)  || \
1102                                                                    ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH2))    \
1103                                                                  )                                                      || \
1104                                                                  (((__COMP_INSTANCE__) == COMP3)                        && \
1105                                                                   (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1)  || \
1106                                                                    ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH1))    \
1107                                                                  ))
1108 #endif
1109 
1110 
1111 #define IS_COMP_HYSTERESIS(__HYSTERESIS__)  (((__HYSTERESIS__) == COMP_HYSTERESIS_NONE)   || \
1112                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_10MV)   || \
1113                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_20MV)   || \
1114                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_30MV)   || \
1115                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_40MV)   || \
1116                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_50MV)   || \
1117                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_60MV)   || \
1118                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_70MV)   || \
1119                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_LOW)    || \
1120                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_MEDIUM) || \
1121                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_HIGH))
1122 
1123 #define IS_COMP_OUTPUTPOL(__POL__)          (((__POL__) == COMP_OUTPUTPOL_NONINVERTED) || \
1124                                              ((__POL__) == COMP_OUTPUTPOL_INVERTED))
1125 
1126 /* Note: Output blanking source depends on COMP instances     */
1127 /*       Better use IS_COMP_BLANKINGSRC_INSTANCE instead      */
1128 /*       Macro kept for compatibility with other STM32 series */
1129 #define IS_COMP_BLANKINGSRCE(__OUTPUT_BLANKING_SOURCE__)                    \
1130   (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)                  \
1131    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1)     \
1132    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP2)     \
1133    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP3)     \
1134    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP4)     \
1135    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP5)     \
1136    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP6)     \
1137    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP7)     \
1138    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1)     \
1139    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP2)     \
1140    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP5)     \
1141    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP3)     \
1142    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP6)     \
1143    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1)     \
1144    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP2)     \
1145    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP3)     \
1146    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP5)     \
1147    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP7)     \
1148    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4_COMP4)     \
1149    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP1)     \
1150    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2)     \
1151    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP3)     \
1152    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP4)     \
1153    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP5)     \
1154    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP6)     \
1155    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP7)     \
1156    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1_COMP4)    \
1157    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC2_COMP6)    \
1158    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC2_COMP7)    \
1159    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM20_OC5)          \
1160    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1)          \
1161    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM4_OC3)           \
1162   )
1163 #if defined(STM32G414xx) || defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx) || defined(STM32G483xx)
1164 #define IS_COMP_BLANKINGSRC_INSTANCE(__INSTANCE__, __OUTPUT_BLANKING_SOURCE__)  \
1165   ((((__INSTANCE__) == COMP1) &&                                                \
1166     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1167      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1)  ||      \
1168      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1)  ||      \
1169      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1)  ||      \
1170      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP1)))        \
1171    ||                                                                           \
1172    (((__INSTANCE__) == COMP2) &&                                                \
1173     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1174      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP2)  ||      \
1175      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP2)  ||      \
1176      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP2)  ||      \
1177      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2)))        \
1178    ||                                                                           \
1179    (((__INSTANCE__) == COMP3) &&                                                \
1180     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1181      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP3)  ||      \
1182      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP3)  ||      \
1183      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP3)  ||      \
1184      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP3)))        \
1185    ||                                                                           \
1186    (((__INSTANCE__) == COMP4) &&                                                \
1187     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1188      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP4)  ||      \
1189      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4_COMP4)  ||      \
1190      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP4)  ||      \
1191      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1_COMP4)))       \
1192    ||                                                                           \
1193    (((__INSTANCE__) == COMP5) &&                                                \
1194     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1195      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP5)  ||      \
1196      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP5)  ||      \
1197      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP5)  ||      \
1198      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP5)))        \
1199    ||                                                                           \
1200    (((__INSTANCE__) == COMP6) &&                                                \
1201     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1202      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP6)  ||      \
1203      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP6)  ||      \
1204      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP6)  ||      \
1205      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC2_COMP6)))       \
1206    ||                                                                           \
1207    (((__INSTANCE__) == COMP7) &&                                                \
1208     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1209      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP7)  ||      \
1210      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP7)  ||      \
1211      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP7)  ||      \
1212      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC2_COMP7)))       \
1213    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM20_OC5)              \
1214    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1)              \
1215    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM4_OC3)               \
1216   )
1217 #elif defined(STM32GBK1CB) || defined(STM32G431xx) || defined(STM32G441xx) || defined(STM32G471xx)
1218 #define IS_COMP_BLANKINGSRC_INSTANCE(__INSTANCE__, __OUTPUT_BLANKING_SOURCE__)  \
1219   ((((__INSTANCE__) == COMP1) &&                                                \
1220     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1221      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1)  ||      \
1222      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1)  ||      \
1223      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1)  ||      \
1224      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP1)))        \
1225    ||                                                                           \
1226    (((__INSTANCE__) == COMP2) &&                                                \
1227     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1228      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP2)  ||      \
1229      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP2)  ||      \
1230      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP2)  ||      \
1231      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2)))        \
1232    ||                                                                           \
1233    (((__INSTANCE__) == COMP3) &&                                                \
1234     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1235      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP3)  ||      \
1236      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP3)  ||      \
1237      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP3)  ||      \
1238      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP3)))        \
1239    ||                                                                           \
1240    (((__INSTANCE__) == COMP4) &&                                                \
1241     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1242      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP4)  ||      \
1243      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4_COMP4)  ||      \
1244      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP4)  ||      \
1245      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1_COMP4)))       \
1246    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1)              \
1247    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM4_OC3)               \
1248   )
1249 #elif defined(STM32G491xx) || defined(STM32G4A1xx)
1250 #define IS_COMP_BLANKINGSRC_INSTANCE(__INSTANCE__, __OUTPUT_BLANKING_SOURCE__)  \
1251   ((((__INSTANCE__) == COMP1) &&                                                \
1252     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1253      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1)  ||      \
1254      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1)  ||      \
1255      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1)  ||      \
1256      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP1)))        \
1257    ||                                                                           \
1258    (((__INSTANCE__) == COMP2) &&                                                \
1259     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1260      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP2)  ||      \
1261      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP2)  ||      \
1262      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP2)  ||      \
1263      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2)))        \
1264    ||                                                                           \
1265    (((__INSTANCE__) == COMP3) &&                                                \
1266     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1267      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP3)  ||      \
1268      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP3)  ||      \
1269      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP3)  ||      \
1270      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP3)))        \
1271    ||                                                                           \
1272    (((__INSTANCE__) == COMP4) &&                                                \
1273     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1274      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP4)  ||      \
1275      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4_COMP4)  ||      \
1276      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP4)  ||      \
1277      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1_COMP4)))       \
1278    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM20_OC5)              \
1279    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1)              \
1280    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM4_OC3)               \
1281   )
1282 #elif defined(STM32G411xB) || defined(STM32G411xC)
1283 #define IS_COMP_BLANKINGSRC_INSTANCE(__INSTANCE__, __OUTPUT_BLANKING_SOURCE__)  \
1284   ((((__INSTANCE__) == COMP1) &&                                                \
1285     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1286      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1)  ||      \
1287      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1)  ||      \
1288      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1)  ||      \
1289      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP1)))        \
1290    ||                                                                           \
1291     (((__INSTANCE__) == COMP2) &&                                               \
1292     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1293      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP2)  ||      \
1294      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP2)  ||      \
1295      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP2)  ||      \
1296      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2)))        \
1297    ||                                                                           \
1298    (((__INSTANCE__) == COMP3) &&                                                \
1299     (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE)            ||      \
1300      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP3)  ||      \
1301      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP3)  ||      \
1302      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP3)  ||      \
1303      ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP3)))        \
1304    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM20_OC5)              \
1305    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1)              \
1306    || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM4_OC3)               \
1307   )
1308 #endif /* STM32G414xx || STM32G474xx || STM32G484xx || STM32G473xx || STM32G483xx */
1309 
1310 #define IS_COMP_TRIGGERMODE(__MODE__)       (((__MODE__) == COMP_TRIGGERMODE_NONE)                 || \
1311                                              ((__MODE__) == COMP_TRIGGERMODE_IT_RISING)            || \
1312                                              ((__MODE__) == COMP_TRIGGERMODE_IT_FALLING)           || \
1313                                              ((__MODE__) == COMP_TRIGGERMODE_IT_RISING_FALLING)    || \
1314                                              ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING)         || \
1315                                              ((__MODE__) == COMP_TRIGGERMODE_EVENT_FALLING)        || \
1316                                              ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING_FALLING))
1317 
1318 #define IS_COMP_OUTPUT_LEVEL(__OUTPUT_LEVEL__) (((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_LOW)     || \
1319                                                 ((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_HIGH))
1320 
1321 /**
1322   * @}
1323   */
1324 
1325 /**
1326   * @}
1327   */
1328 
1329 
1330 /* Exported functions --------------------------------------------------------*/
1331 /** @addtogroup COMP_Exported_Functions
1332   * @{
1333   */
1334 
1335 /** @addtogroup COMP_Exported_Functions_Group1
1336   * @{
1337   */
1338 
1339 /* Initialization and de-initialization functions  **********************************/
1340 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
1341 HAL_StatusTypeDef HAL_COMP_DeInit(COMP_HandleTypeDef *hcomp);
1342 void              HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
1343 void              HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
1344 
1345 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
1346 /* Callbacks Register/UnRegister functions  ***********************************/
1347 HAL_StatusTypeDef HAL_COMP_RegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID,
1348                                             pCOMP_CallbackTypeDef pCallback);
1349 HAL_StatusTypeDef HAL_COMP_UnRegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID);
1350 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
1351 /**
1352   * @}
1353   */
1354 
1355 /* IO operation functions  *****************************************************/
1356 /** @addtogroup COMP_Exported_Functions_Group2
1357   * @{
1358   */
1359 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
1360 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
1361 void              HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
1362 /**
1363   * @}
1364   */
1365 
1366 /* Peripheral Control functions  ************************************************/
1367 /** @addtogroup COMP_Exported_Functions_Group3
1368   * @{
1369   */
1370 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
1371 uint32_t          HAL_COMP_GetOutputLevel(const COMP_HandleTypeDef *hcomp);
1372 /* Callback in interrupt mode */
1373 void              HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
1374 /**
1375   * @}
1376   */
1377 
1378 /* Peripheral State functions  **************************************************/
1379 /** @addtogroup COMP_Exported_Functions_Group4
1380   * @{
1381   */
1382 HAL_COMP_StateTypeDef HAL_COMP_GetState(const COMP_HandleTypeDef *hcomp);
1383 uint32_t              HAL_COMP_GetError(const COMP_HandleTypeDef *hcomp);
1384 /**
1385   * @}
1386   */
1387 
1388 /**
1389   * @}
1390   */
1391 
1392 /**
1393   * @}
1394   */
1395 
1396 /**
1397   * @}
1398   */
1399 
1400 #ifdef __cplusplus
1401 }
1402 #endif
1403 
1404 #endif /* STM32G4xx_HAL_COMP_H */
1405