2 ******************************************************************************
3 * @file stm32g4xx_hal_comp.h
4 * @author MCD Application Team
5 * @brief Header file of COMP HAL module.
6 ******************************************************************************
9 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
10 * All rights reserved.</center></h2>
12 * This software component is licensed by ST under BSD 3-Clause license,
13 * the "License"; You may not use this file except in compliance with the
14 * License. You may obtain a copy of the License at:
15 * opensource.org/licenses/BSD-3-Clause
17 ******************************************************************************
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef STM32G4xx_HAL_COMP_H
22 #define STM32G4xx_HAL_COMP_H
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32g4xx_hal_def.h"
30 #include "stm32g4xx_ll_exti.h"
32 /** @addtogroup STM32G4xx_HAL_Driver
41 /* Exported types ------------------------------------------------------------*/
42 /** @defgroup COMP_Exported_Types COMP Exported Types
47 * @brief COMP Init structure definition
52 uint32_t InputPlus
; /*!< Set comparator input plus (non-inverting input).
53 This parameter can be a value of @ref COMP_InputPlus */
55 uint32_t InputMinus
; /*!< Set comparator input minus (inverting input).
56 This parameter can be a value of @ref COMP_InputMinus */
58 uint32_t Hysteresis
; /*!< Set comparator hysteresis mode of the input minus.
59 This parameter can be a value of @ref COMP_Hysteresis */
61 uint32_t OutputPol
; /*!< Set comparator output polarity.
62 This parameter can be a value of @ref COMP_OutputPolarity */
64 uint32_t BlankingSrce
; /*!< Set comparator blanking source.
65 This parameter can be a value of @ref COMP_BlankingSrce */
67 uint32_t TriggerMode
; /*!< Set the comparator output triggering External Interrupt Line (EXTI).
68 This parameter can be a value of @ref COMP_EXTI_TriggerMode */
70 uint32_t DeglitcherMode
; /*!< Set comparator deglitcher mode.
71 This parameter can be a value of @ref COMP_DeglitcherMode */
76 * @brief HAL COMP state machine: HAL COMP states definition
78 #define COMP_STATE_BITFIELD_LOCK (0x10U)
81 HAL_COMP_STATE_RESET
= 0x00U
, /*!< COMP not yet initialized */
82 HAL_COMP_STATE_RESET_LOCKED
= (HAL_COMP_STATE_RESET
| COMP_STATE_BITFIELD_LOCK
), /*!< COMP not yet initialized and configuration is locked */
83 HAL_COMP_STATE_READY
= 0x01U
, /*!< COMP initialized and ready for use */
84 HAL_COMP_STATE_READY_LOCKED
= (HAL_COMP_STATE_READY
| COMP_STATE_BITFIELD_LOCK
), /*!< COMP initialized but configuration is locked */
85 HAL_COMP_STATE_BUSY
= 0x02U
, /*!< COMP is running */
86 HAL_COMP_STATE_BUSY_LOCKED
= (HAL_COMP_STATE_BUSY
| COMP_STATE_BITFIELD_LOCK
) /*!< COMP is running and configuration is locked */
87 } HAL_COMP_StateTypeDef
;
90 * @brief COMP Handle Structure definition
92 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
93 typedef struct __COMP_HandleTypeDef
98 COMP_TypeDef
*Instance
; /*!< Register base address */
99 COMP_InitTypeDef Init
; /*!< COMP required parameters */
100 HAL_LockTypeDef Lock
; /*!< Locking object */
101 __IO HAL_COMP_StateTypeDef State
; /*!< COMP communication state */
102 __IO
uint32_t ErrorCode
; /*!< COMP error code */
103 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
104 void (* TriggerCallback
)(struct __COMP_HandleTypeDef
*hcomp
); /*!< COMP trigger callback */
105 void (* MspInitCallback
)(struct __COMP_HandleTypeDef
*hcomp
); /*!< COMP Msp Init callback */
106 void (* MspDeInitCallback
)(struct __COMP_HandleTypeDef
*hcomp
); /*!< COMP Msp DeInit callback */
107 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
108 } COMP_HandleTypeDef
;
110 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
112 * @brief HAL COMP Callback ID enumeration definition
116 HAL_COMP_TRIGGER_CB_ID
= 0x00U
, /*!< COMP trigger callback ID */
117 HAL_COMP_MSPINIT_CB_ID
= 0x01U
, /*!< COMP Msp Init callback ID */
118 HAL_COMP_MSPDEINIT_CB_ID
= 0x02U
/*!< COMP Msp DeInit callback ID */
119 } HAL_COMP_CallbackIDTypeDef
;
122 * @brief HAL COMP Callback pointer definition
124 typedef void (*pCOMP_CallbackTypeDef
)(COMP_HandleTypeDef
*hcomp
); /*!< pointer to a COMP callback function */
126 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
132 /* Exported constants --------------------------------------------------------*/
133 /** @defgroup COMP_Exported_Constants COMP Exported Constants
137 /** @defgroup COMP_Error_Code COMP Error Code
140 #define HAL_COMP_ERROR_NONE (0x00UL) /*!< No error */
141 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
142 #define HAL_COMP_ERROR_INVALID_CALLBACK (0x01UL) /*!< Invalid Callback error */
143 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
148 /** @defgroup COMP_InputPlus COMP input plus (non-inverting input)
151 #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 */
152 #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 */
157 /** @defgroup COMP_InputMinus COMP input minus (inverting input)
160 #define COMP_INPUT_MINUS_1_4VREFINT ( COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/4 VrefInt */
161 #define COMP_INPUT_MINUS_1_2VREFINT ( COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/2 VrefInt */
162 #define COMP_INPUT_MINUS_3_4VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 3/4 VrefInt */
163 #define COMP_INPUT_MINUS_VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN ) /*!< Comparator input minus connected to VrefInt */
164 #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 */
165 #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 */
166 #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 */
167 #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 */
168 #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 */
169 #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 */
170 #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 */
171 #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 */
172 #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 */
177 /** @defgroup COMP_Hysteresis COMP hysteresis
180 #define COMP_HYSTERESIS_NONE (0x00000000UL) /*!< No hysteresis */
181 #define COMP_HYSTERESIS_10MV ( COMP_CSR_HYST_0) /*!< Hysteresis level 10mV */
182 #define COMP_HYSTERESIS_20MV ( COMP_CSR_HYST_1 ) /*!< Hysteresis level 20mV */
183 #define COMP_HYSTERESIS_30MV ( COMP_CSR_HYST_1 | COMP_CSR_HYST_0) /*!< Hysteresis level 30mV */
184 #define COMP_HYSTERESIS_40MV (COMP_CSR_HYST_2 ) /*!< Hysteresis level 40mV */
185 #define COMP_HYSTERESIS_50MV (COMP_CSR_HYST_2 | COMP_CSR_HYST_0) /*!< Hysteresis level 50mV */
186 #define COMP_HYSTERESIS_60MV (COMP_CSR_HYST_2 | COMP_CSR_HYST_1 ) /*!< Hysteresis level 60mV */
187 #define COMP_HYSTERESIS_70MV (COMP_CSR_HYST_2 | COMP_CSR_HYST_1 | COMP_CSR_HYST_0) /*!< Hysteresis level 70mV */
188 #define COMP_HYSTERESIS_LOW COMP_HYSTERESIS_10MV /*!< Hysteresis level low */
189 #define COMP_HYSTERESIS_MEDIUM COMP_HYSTERESIS_40MV /*!< Hysteresis level medium */
190 #define COMP_HYSTERESIS_HIGH COMP_HYSTERESIS_70MV /*!< Hysteresis level high */
195 /** @defgroup COMP_OutputPolarity COMP output Polarity
198 #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) */
199 #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) */
204 /** @defgroup COMP_BlankingSrce COMP blanking source
207 #define COMP_BLANKINGSRC_NONE (0x00000000UL) /*!<Comparator output without blanking */
208 #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 */
209 #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 */
210 #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 */
211 #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 */
212 #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 */
213 #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 */
214 #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 */
215 #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 */
216 #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 */
217 #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 */
218 #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 */
219 #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 */
220 #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 */
221 #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 */
222 #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 */
223 #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 */
224 #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 */
225 #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 */
226 #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 */
227 #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 */
228 #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 */
229 #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 */
230 #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 */
231 #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 */
232 #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 */
233 #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 */
234 #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 */
235 #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 */
236 #define COMP_BLANKINGSRC_TIM20_OC5 (COMP_CSR_BLANKING_2 | COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM20 OC5 (Common to all COMP instances) */
237 #define COMP_BLANKINGSRC_TIM15_OC1 (COMP_CSR_BLANKING_2 | COMP_CSR_BLANKING_1 ) /*!< Comparator output blanking source TIM15 OC1 (Common to all COMP instances) */
238 #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) */
244 /** @defgroup COMP_OutputLevel COMP Output Level
247 /* Note: Comparator output level values are fixed to "0" and "1", */
248 /* corresponding COMP register bit is managed by HAL function to match */
249 /* with these values (independently of bit position in register). */
251 /* When output polarity is not inverted, comparator output is low when
252 the input plus is at a lower voltage than the input minus */
253 #define COMP_OUTPUT_LEVEL_LOW (0x00000000UL)
254 /* When output polarity is not inverted, comparator output is high when
255 the input plus is at a higher voltage than the input minus */
256 #define COMP_OUTPUT_LEVEL_HIGH (0x00000001UL)
261 /** @defgroup COMP_EXTI_TriggerMode COMP output to EXTI
264 #define COMP_TRIGGERMODE_NONE (0x00000000UL) /*!< Comparator output triggering no External Interrupt Line */
265 #define COMP_TRIGGERMODE_IT_RISING (COMP_EXTI_IT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event with interruption, on rising edge */
266 #define COMP_TRIGGERMODE_IT_FALLING (COMP_EXTI_IT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event with interruption, on falling edge */
267 #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 */
268 #define COMP_TRIGGERMODE_EVENT_RISING (COMP_EXTI_EVENT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on rising edge */
269 #define COMP_TRIGGERMODE_EVENT_FALLING (COMP_EXTI_EVENT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on falling edge */
270 #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 */
275 /** @defgroup COMP_DeglitcherMode COMP deglitcher mode
278 #define COMP_DEGLITCHER_DISABLED (0x00000000UL) /*!< Comparator deglitcher disabled */
279 #define COMP_DEGLITCHER_ENABLED (COMP_CSR_DEGLITCHEN) /*!< Comparator deglitcher enabled */
288 /* Exported macro ------------------------------------------------------------*/
289 /** @defgroup COMP_Exported_Macros COMP Exported Macros
293 /** @defgroup COMP_Handle_Management COMP Handle Management
297 /** @brief Reset COMP handle state.
298 * @param __HANDLE__ COMP handle
301 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
302 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) do{ \
303 (__HANDLE__)->State = HAL_COMP_STATE_RESET; \
304 (__HANDLE__)->MspInitCallback = NULL; \
305 (__HANDLE__)->MspDeInitCallback = NULL; \
308 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
312 * @brief Clear COMP error code (set it to no error code "HAL_COMP_ERROR_NONE").
313 * @param __HANDLE__ COMP handle
316 #define COMP_CLEAR_ERRORCODE(__HANDLE__) ((__HANDLE__)->ErrorCode = HAL_COMP_ERROR_NONE)
319 * @brief Enable the specified comparator.
320 * @param __HANDLE__ COMP handle
323 #define __HAL_COMP_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN)
326 * @brief Disable the specified comparator.
327 * @param __HANDLE__ COMP handle
330 #define __HAL_COMP_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN)
333 * @brief Lock the specified comparator configuration.
334 * @note Using this macro induce HAL COMP handle state machine being no
335 * more in line with COMP instance state.
336 * To keep HAL COMP handle state machine updated, it is recommended
337 * to use function "HAL_COMP_Lock')".
338 * @param __HANDLE__ COMP handle
341 #define __HAL_COMP_LOCK(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK)
344 * @brief Check whether the specified comparator is locked.
345 * @param __HANDLE__ COMP handle
346 * @retval Value 0 if COMP instance is not locked, value 1 if COMP instance is locked
348 #define __HAL_COMP_IS_LOCKED(__HANDLE__) (READ_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK) == COMP_CSR_LOCK)
354 /** @defgroup COMP_Exti_Management COMP external interrupt line management
359 * @brief Enable the COMP1 EXTI line rising edge trigger.
362 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP1)
365 * @brief Disable the COMP1 EXTI line rising edge trigger.
368 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP1)
371 * @brief Enable the COMP1 EXTI line falling edge trigger.
374 #define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP1)
377 * @brief Disable the COMP1 EXTI line falling edge trigger.
380 #define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP1)
383 * @brief Enable the COMP1 EXTI line rising & falling edge trigger.
386 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
387 LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP1); \
388 LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP1); \
392 * @brief Disable the COMP1 EXTI line rising & falling edge trigger.
395 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
396 LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP1); \
397 LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP1); \
401 * @brief Enable the COMP1 EXTI line in interrupt mode.
404 #define __HAL_COMP_COMP1_EXTI_ENABLE_IT() LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP1)
407 * @brief Disable the COMP1 EXTI line in interrupt mode.
410 #define __HAL_COMP_COMP1_EXTI_DISABLE_IT() LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP1)
413 * @brief Generate a software interrupt on the COMP1 EXTI line.
416 #define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP1)
419 * @brief Enable the COMP1 EXTI line in event mode.
422 #define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP1)
425 * @brief Disable the COMP1 EXTI line in event mode.
428 #define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP1)
431 * @brief Check whether the COMP1 EXTI line flag is set.
432 * @retval RESET or SET
434 #define __HAL_COMP_COMP1_EXTI_GET_FLAG() LL_EXTI_IsActiveFlag_0_31(COMP_EXTI_LINE_COMP1)
437 * @brief Clear the COMP1 EXTI flag.
440 #define __HAL_COMP_COMP1_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP1)
443 * @brief Enable the COMP2 EXTI line rising edge trigger.
446 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP2)
449 * @brief Disable the COMP2 EXTI line rising edge trigger.
452 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP2)
455 * @brief Enable the COMP2 EXTI line falling edge trigger.
458 #define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP2)
461 * @brief Disable the COMP2 EXTI line falling edge trigger.
464 #define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP2)
467 * @brief Enable the COMP2 EXTI line rising & falling edge trigger.
470 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
471 LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP2); \
472 LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP2); \
476 * @brief Disable the COMP2 EXTI line rising & falling edge trigger.
479 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
480 LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP2); \
481 LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP2); \
485 * @brief Enable the COMP2 EXTI line in interrupt mode.
488 #define __HAL_COMP_COMP2_EXTI_ENABLE_IT() LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP2)
491 * @brief Disable the COMP2 EXTI line in interrupt mode.
494 #define __HAL_COMP_COMP2_EXTI_DISABLE_IT() LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP2)
497 * @brief Generate a software interrupt on the COMP2 EXTI line.
500 #define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP2)
503 * @brief Enable the COMP2 EXTI line in event mode.
506 #define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP2)
509 * @brief Disable the COMP2 EXTI line in event mode.
512 #define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP2)
515 * @brief Check whether the COMP2 EXTI line flag is set.
516 * @retval RESET or SET
518 #define __HAL_COMP_COMP2_EXTI_GET_FLAG() LL_EXTI_IsActiveFlag_0_31(COMP_EXTI_LINE_COMP2)
521 * @brief Clear the COMP2 EXTI flag.
524 #define __HAL_COMP_COMP2_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP2)
527 * @brief Enable the COMP3 EXTI line rising edge trigger.
530 #define __HAL_COMP_COMP3_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP3)
533 * @brief Disable the COMP3 EXTI line rising edge trigger.
536 #define __HAL_COMP_COMP3_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP3)
539 * @brief Enable the COMP3 EXTI line falling edge trigger.
542 #define __HAL_COMP_COMP3_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP3)
545 * @brief Disable the COMP3 EXTI line falling edge trigger.
548 #define __HAL_COMP_COMP3_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP3)
551 * @brief Enable the COMP3 EXTI line rising & falling edge trigger.
554 #define __HAL_COMP_COMP3_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
555 LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP3); \
556 LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP3); \
560 * @brief Disable the COMP3 EXTI line rising & falling edge trigger.
563 #define __HAL_COMP_COMP3_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
564 LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP3); \
565 LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP3); \
569 * @brief Enable the COMP3 EXTI line in interrupt mode.
572 #define __HAL_COMP_COMP3_EXTI_ENABLE_IT() LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP3)
575 * @brief Disable the COMP3 EXTI line in interrupt mode.
578 #define __HAL_COMP_COMP3_EXTI_DISABLE_IT() LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP3)
581 * @brief Generate a software interrupt on the COMP3 EXTI line.
584 #define __HAL_COMP_COMP3_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP3)
587 * @brief Enable the COMP3 EXTI line in event mode.
590 #define __HAL_COMP_COMP3_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP3)
593 * @brief Disable the COMP3 EXTI line in event mode.
596 #define __HAL_COMP_COMP3_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP3)
599 * @brief Check whether the COMP3 EXTI line flag is set.
600 * @retval RESET or SET
602 #define __HAL_COMP_COMP3_EXTI_GET_FLAG() LL_EXTI_IsActiveFlag_0_31(COMP_EXTI_LINE_COMP3)
605 * @brief Clear the COMP3 EXTI flag.
608 #define __HAL_COMP_COMP3_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP3)
611 * @brief Enable the COMP4 EXTI line rising edge trigger.
614 #define __HAL_COMP_COMP4_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP4)
617 * @brief Disable the COMP4 EXTI line rising edge trigger.
620 #define __HAL_COMP_COMP4_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP4)
623 * @brief Enable the COMP4 EXTI line falling edge trigger.
626 #define __HAL_COMP_COMP4_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP4)
629 * @brief Disable the COMP4 EXTI line falling edge trigger.
632 #define __HAL_COMP_COMP4_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP4)
635 * @brief Enable the COMP4 EXTI line rising & falling edge trigger.
638 #define __HAL_COMP_COMP4_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
639 LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP4); \
640 LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP4); \
644 * @brief Disable the COMP4 EXTI line rising & falling edge trigger.
647 #define __HAL_COMP_COMP4_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
648 LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP4); \
649 LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP4); \
653 * @brief Enable the COMP4 EXTI line in interrupt mode.
656 #define __HAL_COMP_COMP4_EXTI_ENABLE_IT() LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP4)
659 * @brief Disable the COMP4 EXTI line in interrupt mode.
662 #define __HAL_COMP_COMP4_EXTI_DISABLE_IT() LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP4)
665 * @brief Generate a software interrupt on the COMP4 EXTI line.
668 #define __HAL_COMP_COMP4_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP4)
671 * @brief Enable the COMP4 EXTI line in event mode.
674 #define __HAL_COMP_COMP4_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP4)
677 * @brief Disable the COMP4 EXTI line in event mode.
680 #define __HAL_COMP_COMP4_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP4)
683 * @brief Check whether the COMP4 EXTI line flag is set.
684 * @retval RESET or SET
686 #define __HAL_COMP_COMP4_EXTI_GET_FLAG() LL_EXTI_IsActiveFlag_0_31(COMP_EXTI_LINE_COMP4)
689 * @brief Clear the COMP4 EXTI flag.
692 #define __HAL_COMP_COMP4_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP4)
694 #if defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx)
696 * @brief Enable the COMP5 EXTI line rising edge trigger.
699 #define __HAL_COMP_COMP5_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP5)
702 * @brief Disable the COMP5 EXTI line rising edge trigger.
705 #define __HAL_COMP_COMP5_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP5)
708 * @brief Enable the COMP5 EXTI line falling edge trigger.
711 #define __HAL_COMP_COMP5_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP5)
714 * @brief Disable the COMP5 EXTI line falling edge trigger.
717 #define __HAL_COMP_COMP5_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP5)
720 * @brief Enable the COMP5 EXTI line rising & falling edge trigger.
723 #define __HAL_COMP_COMP5_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
724 LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP5); \
725 LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP5); \
729 * @brief Disable the COMP5 EXTI line rising & falling edge trigger.
732 #define __HAL_COMP_COMP5_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
733 LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP5); \
734 LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP5); \
738 * @brief Enable the COMP5 EXTI line in interrupt mode.
741 #define __HAL_COMP_COMP5_EXTI_ENABLE_IT() LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP5)
744 * @brief Disable the COMP5 EXTI line in interrupt mode.
747 #define __HAL_COMP_COMP5_EXTI_DISABLE_IT() LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP5)
750 * @brief Generate a software interrupt on the COMP5 EXTI line.
753 #define __HAL_COMP_COMP5_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP5)
756 * @brief Enable the COMP5 EXTI line in event mode.
759 #define __HAL_COMP_COMP5_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP5)
762 * @brief Disable the COMP5 EXTI line in event mode.
765 #define __HAL_COMP_COMP5_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP5)
768 * @brief Check whether the COMP5 EXTI line flag is set.
769 * @retval RESET or SET
771 #define __HAL_COMP_COMP5_EXTI_GET_FLAG() LL_EXTI_IsActiveFlag_0_31(COMP_EXTI_LINE_COMP5)
774 * @brief Clear the COMP5 EXTI flag.
777 #define __HAL_COMP_COMP5_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP5)
779 #endif /* STM32G474xx || STM32G484xx || STM32G473xx */
780 #if defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx)
782 * @brief Enable the COMP6 EXTI line rising edge trigger.
785 #define __HAL_COMP_COMP6_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_32_63(COMP_EXTI_LINE_COMP6)
788 * @brief Disable the COMP6 EXTI line rising edge trigger.
791 #define __HAL_COMP_COMP6_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_32_63(COMP_EXTI_LINE_COMP6)
794 * @brief Enable the COMP6 EXTI line falling edge trigger.
797 #define __HAL_COMP_COMP6_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_32_63(COMP_EXTI_LINE_COMP6)
800 * @brief Disable the COMP6 EXTI line falling edge trigger.
803 #define __HAL_COMP_COMP6_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_32_63(COMP_EXTI_LINE_COMP6)
806 * @brief Enable the COMP6 EXTI line rising & falling edge trigger.
809 #define __HAL_COMP_COMP6_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
810 LL_EXTI_EnableRisingTrig_32_63(COMP_EXTI_LINE_COMP6); \
811 LL_EXTI_EnableFallingTrig_32_63(COMP_EXTI_LINE_COMP6); \
815 * @brief Disable the COMP6 EXTI line rising & falling edge trigger.
818 #define __HAL_COMP_COMP6_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
819 LL_EXTI_DisableRisingTrig_32_63(COMP_EXTI_LINE_COMP6); \
820 LL_EXTI_DisableFallingTrig_32_63(COMP_EXTI_LINE_COMP6); \
824 * @brief Enable the COMP6 EXTI line in interrupt mode.
827 #define __HAL_COMP_COMP6_EXTI_ENABLE_IT() LL_EXTI_EnableIT_32_63(COMP_EXTI_LINE_COMP6)
830 * @brief Disable the COMP6 EXTI line in interrupt mode.
833 #define __HAL_COMP_COMP6_EXTI_DISABLE_IT() LL_EXTI_DisableIT_32_63(COMP_EXTI_LINE_COMP6)
836 * @brief Generate a software interrupt on the COMP6 EXTI line.
839 #define __HAL_COMP_COMP6_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_32_63(COMP_EXTI_LINE_COMP6)
842 * @brief Enable the COMP6 EXTI line in event mode.
845 #define __HAL_COMP_COMP6_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_32_63(COMP_EXTI_LINE_COMP6)
848 * @brief Disable the COMP6 EXTI line in event mode.
851 #define __HAL_COMP_COMP6_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_32_63(COMP_EXTI_LINE_COMP6)
854 * @brief Check whether the COMP6 EXTI line flag is set.
855 * @retval RESET or SET
857 #define __HAL_COMP_COMP6_EXTI_GET_FLAG() LL_EXTI_IsActiveFlag_32_63(COMP_EXTI_LINE_COMP6)
860 * @brief Clear the COMP6 EXTI flag.
863 #define __HAL_COMP_COMP6_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_32_63(COMP_EXTI_LINE_COMP6)
865 #endif /* STM32G474xx || STM32G484xx || STM32G473xx */
866 #if defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx)
868 * @brief Enable the COMP7 EXTI line rising edge trigger.
871 #define __HAL_COMP_COMP7_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_32_63(COMP_EXTI_LINE_COMP7)
874 * @brief Disable the COMP7 EXTI line rising edge trigger.
877 #define __HAL_COMP_COMP7_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_32_63(COMP_EXTI_LINE_COMP7)
880 * @brief Enable the COMP7 EXTI line falling edge trigger.
883 #define __HAL_COMP_COMP7_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_32_63(COMP_EXTI_LINE_COMP7)
886 * @brief Disable the COMP7 EXTI line falling edge trigger.
889 #define __HAL_COMP_COMP7_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_32_63(COMP_EXTI_LINE_COMP7)
892 * @brief Enable the COMP7 EXTI line rising & falling edge trigger.
895 #define __HAL_COMP_COMP7_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
896 LL_EXTI_EnableRisingTrig_32_63(COMP_EXTI_LINE_COMP7); \
897 LL_EXTI_EnableFallingTrig_32_63(COMP_EXTI_LINE_COMP7); \
901 * @brief Disable the COMP7 EXTI line rising & falling edge trigger.
904 #define __HAL_COMP_COMP7_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
905 LL_EXTI_DisableRisingTrig_32_63(COMP_EXTI_LINE_COMP7); \
906 LL_EXTI_DisableFallingTrig_32_63(COMP_EXTI_LINE_COMP7); \
910 * @brief Enable the COMP7 EXTI line in interrupt mode.
913 #define __HAL_COMP_COMP7_EXTI_ENABLE_IT() LL_EXTI_EnableIT_32_63(COMP_EXTI_LINE_COMP7)
916 * @brief Disable the COMP7 EXTI line in interrupt mode.
919 #define __HAL_COMP_COMP7_EXTI_DISABLE_IT() LL_EXTI_DisableIT_32_63(COMP_EXTI_LINE_COMP7)
922 * @brief Generate a software interrupt on the COMP7 EXTI line.
925 #define __HAL_COMP_COMP7_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_32_63(COMP_EXTI_LINE_COMP7)
928 * @brief Enable the COMP7 EXTI line in event mode.
931 #define __HAL_COMP_COMP7_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_32_63(COMP_EXTI_LINE_COMP7)
934 * @brief Disable the COMP7 EXTI line in event mode.
937 #define __HAL_COMP_COMP7_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_32_63(COMP_EXTI_LINE_COMP7)
940 * @brief Check whether the COMP7 EXTI line flag is set.
941 * @retval RESET or SET
943 #define __HAL_COMP_COMP7_EXTI_GET_FLAG() LL_EXTI_IsActiveFlag_32_63(COMP_EXTI_LINE_COMP7)
946 * @brief Clear the COMP7 EXTI flag.
949 #define __HAL_COMP_COMP7_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_32_63(COMP_EXTI_LINE_COMP7)
951 #endif /* STM32G474xx || STM32G484xx || STM32G473xx */
961 /* Private types -------------------------------------------------------------*/
962 /* Private constants ---------------------------------------------------------*/
963 /** @defgroup COMP_Private_Constants COMP Private Constants
967 /** @defgroup COMP_ExtiLine COMP EXTI Lines
970 #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 */
971 #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 */
972 #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 */
973 #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 */
974 #if defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx)
975 #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 */
976 #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 */
977 #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 */
983 /** @defgroup COMP_ExtiLine COMP EXTI Lines
986 #define COMP_EXTI_IT (0x00000001UL) /*!< EXTI line event with interruption */
987 #define COMP_EXTI_EVENT (0x00000002UL) /*!< EXTI line event only (without interruption) */
988 #define COMP_EXTI_RISING (0x00000010UL) /*!< EXTI line event on rising edge */
989 #define COMP_EXTI_FALLING (0x00000020UL) /*!< EXTI line event on falling edge */
998 /* Private macros ------------------------------------------------------------*/
999 /** @defgroup COMP_Private_Macros COMP Private Macros
1003 /** @defgroup COMP_GET_EXTI_LINE COMP private macros to get EXTI line associated with comparators
1007 * @brief Get the specified EXTI line for a comparator instance.
1008 * @param __INSTANCE__ specifies the COMP instance.
1009 * @retval value of @ref COMP_ExtiLine
1011 #if defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx)
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 :((__INSTANCE__) == COMP4) ? COMP_EXTI_LINE_COMP4 \
1016 :((__INSTANCE__) == COMP5) ? COMP_EXTI_LINE_COMP5 \
1017 :((__INSTANCE__) == COMP6) ? COMP_EXTI_LINE_COMP6 \
1018 : COMP_EXTI_LINE_COMP7)
1019 #elif defined(STM32GBK1CB) || defined(STM32G431xx) || defined(STM32G441xx) || defined(STM32G471xx)
1020 #define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 \
1021 :((__INSTANCE__) == COMP2) ? COMP_EXTI_LINE_COMP2 \
1022 :((__INSTANCE__) == COMP3) ? COMP_EXTI_LINE_COMP3 \
1023 : COMP_EXTI_LINE_COMP4)
1029 /** @defgroup COMP_IS_COMP_Definitions COMP private macros to check input parameters
1032 #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
1033 ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2))
1035 #if defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx)
1036 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \
1037 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \
1038 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \
1039 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \
1040 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \
1041 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2) || \
1042 (((__COMP_INSTANCE__) == COMP1) && \
1043 (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
1044 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH1)) \
1046 (((__COMP_INSTANCE__) == COMP2) && \
1047 (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) || \
1048 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH2)) \
1050 (((__COMP_INSTANCE__) == COMP3) && \
1051 (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
1052 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH1)) \
1054 (((__COMP_INSTANCE__) == COMP4) && \
1055 (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
1056 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH2)) \
1058 (((__COMP_INSTANCE__) == COMP5) && \
1059 (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) || \
1060 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC4_CH1)) \
1062 (((__COMP_INSTANCE__) == COMP6) && \
1063 (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC2_CH1) || \
1064 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC4_CH2)) \
1066 (((__COMP_INSTANCE__) == COMP7) && \
1067 (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC2_CH1) || \
1068 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC4_CH1)) \
1070 #elif defined(STM32GBK1CB) || defined(STM32G431xx) || defined(STM32G441xx) || defined(STM32G471xx)
1071 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \
1072 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \
1073 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \
1074 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \
1075 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \
1076 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2) || \
1077 (((__COMP_INSTANCE__) == COMP1) && \
1078 (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
1079 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH1)) \
1081 (((__COMP_INSTANCE__) == COMP2) && \
1082 (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) || \
1083 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH2)) \
1085 (((__COMP_INSTANCE__) == COMP3) && \
1086 (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
1087 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH1)) \
1089 (((__COMP_INSTANCE__) == COMP4) && \
1090 (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
1091 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH2)) \
1096 #define IS_COMP_HYSTERESIS(__HYSTERESIS__) (((__HYSTERESIS__) == COMP_HYSTERESIS_NONE) || \
1097 ((__HYSTERESIS__) == COMP_HYSTERESIS_10MV) || \
1098 ((__HYSTERESIS__) == COMP_HYSTERESIS_20MV) || \
1099 ((__HYSTERESIS__) == COMP_HYSTERESIS_30MV) || \
1100 ((__HYSTERESIS__) == COMP_HYSTERESIS_40MV) || \
1101 ((__HYSTERESIS__) == COMP_HYSTERESIS_50MV) || \
1102 ((__HYSTERESIS__) == COMP_HYSTERESIS_60MV) || \
1103 ((__HYSTERESIS__) == COMP_HYSTERESIS_70MV) || \
1104 ((__HYSTERESIS__) == COMP_HYSTERESIS_LOW) || \
1105 ((__HYSTERESIS__) == COMP_HYSTERESIS_MEDIUM) || \
1106 ((__HYSTERESIS__) == COMP_HYSTERESIS_HIGH))
1108 #define IS_COMP_OUTPUTPOL(__POL__) (((__POL__) == COMP_OUTPUTPOL_NONINVERTED) || \
1109 ((__POL__) == COMP_OUTPUTPOL_INVERTED))
1111 /* Note: Output blanking source depends on COMP instances */
1112 /* Better use IS_COMP_BLANKINGSRC_INSTANCE instead */
1113 /* Macro kept for compatibility with other STM32 series */
1114 #define IS_COMP_BLANKINGSRCE(__OUTPUT_BLANKING_SOURCE__) \
1115 ( ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) \
1116 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1) \
1117 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP2) \
1118 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP3) \
1119 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP4) \
1120 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP5) \
1121 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP6) \
1122 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP7) \
1123 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1) \
1124 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP2) \
1125 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP5) \
1126 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP3) \
1127 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP6) \
1128 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1) \
1129 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP2) \
1130 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP3) \
1131 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP5) \
1132 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP7) \
1133 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4_COMP4) \
1134 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP1) \
1135 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2) \
1136 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP3) \
1137 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP4) \
1138 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP5) \
1139 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP6) \
1140 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP7) \
1141 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1_COMP4) \
1142 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC2_COMP6) \
1143 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC2_COMP7) \
1144 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM20_OC5) \
1145 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1) \
1146 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM4_OC3) \
1148 #if defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx)
1149 #define IS_COMP_BLANKINGSRC_INSTANCE(__INSTANCE__, __OUTPUT_BLANKING_SOURCE__) \
1150 ((((__INSTANCE__) == COMP1) && \
1151 (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
1152 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1) || \
1153 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1) || \
1154 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1) || \
1155 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP1))) \
1157 (((__INSTANCE__) == COMP2) && \
1158 (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
1159 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP2) || \
1160 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP2) || \
1161 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP2) || \
1162 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2))) \
1164 (((__INSTANCE__) == COMP3) && \
1165 (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
1166 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP3) || \
1167 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP3) || \
1168 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP3) || \
1169 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP3))) \
1171 (((__INSTANCE__) == COMP4) && \
1172 (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
1173 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP4) || \
1174 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4_COMP4) || \
1175 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP4) || \
1176 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1_COMP4))) \
1178 (((__INSTANCE__) == COMP5) && \
1179 (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
1180 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP5) || \
1181 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP5) || \
1182 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP5) || \
1183 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP5))) \
1185 (((__INSTANCE__) == COMP6) && \
1186 (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
1187 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP6) || \
1188 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP6) || \
1189 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP6) || \
1190 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC2_COMP6))) \
1192 (((__INSTANCE__) == COMP7) && \
1193 (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
1194 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP7) || \
1195 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP7) || \
1196 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP7) || \
1197 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC2_COMP7))) \
1198 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM20_OC5) \
1199 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1) \
1200 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM4_OC3) \
1202 #elif defined(STM32GBK1CB) || defined(STM32G431xx) || defined(STM32G441xx) || defined(STM32G471xx)
1203 #define IS_COMP_BLANKINGSRC_INSTANCE(__INSTANCE__, __OUTPUT_BLANKING_SOURCE__) \
1204 ((((__INSTANCE__) == COMP1) && \
1205 (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
1206 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1) || \
1207 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1) || \
1208 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1) || \
1209 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP1))) \
1211 (((__INSTANCE__) == COMP2) && \
1212 (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
1213 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP2) || \
1214 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP2) || \
1215 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP2) || \
1216 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2))) \
1218 (((__INSTANCE__) == COMP3) && \
1219 (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
1220 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP3) || \
1221 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP3) || \
1222 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP3) || \
1223 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP3))) \
1225 (((__INSTANCE__) == COMP4) && \
1226 (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
1227 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP4) || \
1228 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4_COMP4) || \
1229 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP4) || \
1230 ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1_COMP4))) \
1231 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1) \
1232 || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM4_OC3) \
1236 #define IS_COMP_TRIGGERMODE(__MODE__) (((__MODE__) == COMP_TRIGGERMODE_NONE) || \
1237 ((__MODE__) == COMP_TRIGGERMODE_IT_RISING) || \
1238 ((__MODE__) == COMP_TRIGGERMODE_IT_FALLING) || \
1239 ((__MODE__) == COMP_TRIGGERMODE_IT_RISING_FALLING) || \
1240 ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING) || \
1241 ((__MODE__) == COMP_TRIGGERMODE_EVENT_FALLING) || \
1242 ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING_FALLING))
1244 #define IS_COMP_OUTPUT_LEVEL(__OUTPUT_LEVEL__) (((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_LOW) || \
1245 ((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_HIGH))
1247 #define IS_COMP_DEGLITCHER_MODE(__MODE__) (((__MODE__) == COMP_DEGLITCHER_DISABLED) || \
1248 ((__MODE__) == COMP_DEGLITCHER_ENABLED))
1258 /* Exported functions --------------------------------------------------------*/
1259 /** @addtogroup COMP_Exported_Functions
1263 /** @addtogroup COMP_Exported_Functions_Group1
1267 /* Initialization and de-initialization functions **********************************/
1268 HAL_StatusTypeDef
HAL_COMP_Init(COMP_HandleTypeDef
*hcomp
);
1269 HAL_StatusTypeDef
HAL_COMP_DeInit(COMP_HandleTypeDef
*hcomp
);
1270 void HAL_COMP_MspInit(COMP_HandleTypeDef
*hcomp
);
1271 void HAL_COMP_MspDeInit(COMP_HandleTypeDef
*hcomp
);
1273 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
1274 /* Callbacks Register/UnRegister functions ***********************************/
1275 HAL_StatusTypeDef
HAL_COMP_RegisterCallback(COMP_HandleTypeDef
*hcomp
, HAL_COMP_CallbackIDTypeDef CallbackID
,
1276 pCOMP_CallbackTypeDef pCallback
);
1277 HAL_StatusTypeDef
HAL_COMP_UnRegisterCallback(COMP_HandleTypeDef
*hcomp
, HAL_COMP_CallbackIDTypeDef CallbackID
);
1278 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
1283 /* IO operation functions *****************************************************/
1284 /** @addtogroup COMP_Exported_Functions_Group2
1287 HAL_StatusTypeDef
HAL_COMP_Start(COMP_HandleTypeDef
*hcomp
);
1288 HAL_StatusTypeDef
HAL_COMP_Stop(COMP_HandleTypeDef
*hcomp
);
1289 void HAL_COMP_IRQHandler(COMP_HandleTypeDef
*hcomp
);
1294 /* Peripheral Control functions ************************************************/
1295 /** @addtogroup COMP_Exported_Functions_Group3
1298 HAL_StatusTypeDef
HAL_COMP_Lock(COMP_HandleTypeDef
*hcomp
);
1299 uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef
*hcomp
);
1300 /* Callback in interrupt mode */
1301 void HAL_COMP_TriggerCallback(COMP_HandleTypeDef
*hcomp
);
1306 /* Peripheral State functions **************************************************/
1307 /** @addtogroup COMP_Exported_Functions_Group4
1310 HAL_COMP_StateTypeDef
HAL_COMP_GetState(COMP_HandleTypeDef
*hcomp
);
1311 uint32_t HAL_COMP_GetError(COMP_HandleTypeDef
*hcomp
);
1332 #endif /* STM32G4xx_HAL_COMP_H */
1334 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/