1 /**
2   ******************************************************************************
3   * @file    stm32u5xx_ll_comp.h
4   * @author  MCD Application Team
5   * @brief   Header file of COMP LL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2021 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 STM32U5xx_LL_COMP_H
21 #define STM32U5xx_LL_COMP_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32u5xx.h"
29 
30 /** @addtogroup STM32U5xx_LL_Driver
31   * @{
32   */
33 
34 #if defined (COMP1) || defined (COMP2)
35 
36 /** @defgroup COMP_LL COMP
37   * @{
38   */
39 
40 /* Private types -------------------------------------------------------------*/
41 /* Private variables ---------------------------------------------------------*/
42 /* Private constants ---------------------------------------------------------*/
43 /** @defgroup COMP_LL_Private_Constants COMP Private Constants
44   * @{
45   */
46 
47 /* Internal mask for pair of comparators instances window mode:               */
48 /* To select into literals LL_COMP_WINDOWMODE_COMPx_INPUT_PLUS_COMMON         */
49 /* the relevant bits for:                                                     */
50 /* (concatenation of multiple bits used in different registers)               */
51 /* - Comparator instance selected as master for window mode : register offset */
52 /* - Window mode enable or disable: bit value */
53 #define LL_COMP_WINDOWMODE_COMP_ODD_REGOFFSET_MASK  (0x00000000UL) /* Register of COMP instance odd (COMP1_CSR, ...)
54                                                                       defined as reference register */
55 #define LL_COMP_WINDOWMODE_COMP_EVEN_REGOFFSET_MASK (0x00000001UL) /* Register of COMP instance even (COMP2_CSR, ...)
56                                                                       offset vs register of COMP instance odd */
57 #define LL_COMP_WINDOWMODE_COMPX_REGOFFSET_MASK     (LL_COMP_WINDOWMODE_COMP_ODD_REGOFFSET_MASK  \
58                                                      | LL_COMP_WINDOWMODE_COMP_EVEN_REGOFFSET_MASK)
59 #define LL_COMP_WINDOWMODE_COMPX_SETTING_MASK       (COMP_CSR_WINMODE)
60 #define LL_COMP_WINDOWOUTPUT_COMPX_SETTING_MASK     (COMP_CSR_WINOUT)
61 #define LL_COMP_WINDOWOUTPUT_BOTH_SETTING_MASK      (COMP_CSR_WINOUT << 1UL)
62 #define LL_COMP_WINDOWOUTPUT_BOTH_POS_VS_WINDOW     (1UL)
63 
64 /* COMP registers bits positions */
65 #define LL_COMP_WINDOWMODE_BITOFFSET_POS   (11UL) /* Value equivalent to POSITION_VAL(COMP_CSR_WINMODE) */
66 #define LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS (30UL) /* Value equivalent to POSITION_VAL(COMP_CSR_VALUE) */
67 
68 /**
69   * @}
70   */
71 
72 /* Private macros ------------------------------------------------------------*/
73 /** @defgroup COMP_LL_Private_Macros COMP Private Macros
74   * @{
75   */
76 
77 /**
78   * @brief  Driver macro reserved for internal use: set a pointer to
79   *         a register from a register basis from which an offset
80   *         is applied.
81   * @param  __REG__ Register basis from which the offset is applied.
82   * @param  __REG_OFFFSET__ Offset to be applied (unit: number of registers).
83   * @retval Pointer to register address
84   */
85 #define __COMP_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__)                        \
86   ((__IO uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2UL))))
87 
88 /**
89   * @}
90   */
91 
92 /* Exported types ------------------------------------------------------------*/
93 #if defined(USE_FULL_LL_DRIVER)
94 /** @defgroup COMP_LL_ES_INIT COMP Exported Init structure
95   * @{
96   */
97 
98 /**
99   * @brief  Structure definition of some features of COMP instance.
100   */
101 typedef struct
102 {
103   uint32_t PowerMode;                   /*!< Set comparator operating mode to adjust power and speed.
104                                              This parameter can be a value of @ref COMP_LL_EC_POWERMODE
105                                              This feature can be modified afterwards using unitary
106                                              function @ref LL_COMP_SetPowerMode(). */
107 
108   uint32_t InputPlus;                   /*!< Set comparator input plus (non-inverting input).
109                                              This parameter can be a value of @ref COMP_LL_EC_INPUT_PLUS
110                                              This feature can be modified afterwards using unitary function
111                                              @ref LL_COMP_SetInputPlus(). */
112 
113   uint32_t InputMinus;                  /*!< Set comparator input minus (inverting input).
114                                              This parameter can be a value of @ref COMP_LL_EC_INPUT_MINUS
115                                              This feature can be modified afterwards using unitary function
116                                               @ref LL_COMP_SetInputMinus(). */
117 
118   uint32_t InputHysteresis;             /*!< Set comparator hysteresis mode of the input minus.
119                                              This parameter can be a value of @ref COMP_LL_EC_INPUT_HYSTERESIS
120                                              This feature can be modified afterwards using unitary function
121                                              @ref LL_COMP_SetInputHysteresis(). */
122 
123   uint32_t OutputPolarity;              /*!< Set comparator output polarity.
124                                              This parameter can be a value of @ref COMP_LL_EC_OUTPUT_POLARITY
125                                              This feature can be modified afterwards using unitary function
126                                              @ref LL_COMP_SetOutputPolarity(). */
127 
128   uint32_t OutputBlankingSource;        /*!< Set comparator blanking source.
129                                              This parameter can be a value of @ref COMP_LL_EC_OUTPUT_BLANKING_SOURCE
130                                              This feature can be modified afterwards using unitary function
131                                              @ref LL_COMP_SetOutputBlankingSource(). */
132 
133 } LL_COMP_InitTypeDef;
134 
135 /**
136   * @}
137   */
138 #endif /* USE_FULL_LL_DRIVER */
139 
140 /* Exported constants --------------------------------------------------------*/
141 /** @defgroup COMP_LL_Exported_Constants COMP Exported Constants
142   * @{
143   */
144 
145 #if defined(COMP_WINDOW_MODE_SUPPORT)
146 /** @defgroup COMP_LL_EC_COMMON_WINDOWMODE Comparator common modes - Window mode
147   * @{
148   */
149 #define LL_COMP_WINDOWMODE_DISABLE                 (0x00000000UL)                                                   /*!< Window mode disable: Comparators 1 and 2 are independent */
150 #define LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP_CSR_WINMODE | LL_COMP_WINDOWMODE_COMP_EVEN_REGOFFSET_MASK) /*!< Window mode enable: Comparators instances pair COMP1 and COMP2 have their input plus connected together. The common input is COMP1 input plus (COMP2 input plus is no more accessible). */
151 #define LL_COMP_WINDOWMODE_COMP2_INPUT_PLUS_COMMON (COMP_CSR_WINMODE | LL_COMP_WINDOWMODE_COMP_ODD_REGOFFSET_MASK)  /*!< Window mode enable: if used from COMP1 or COMP2 instance, comparators instances pair COMP1 and COMP2 have their input plus connected together, the common input is COMP2 input plus (COMP1 input plus is no more accessible). */
152 /**
153   * @}
154   */
155 
156 /** @defgroup COMP_LL_EC_COMMON_WINDOWOUTPUT Comparator common modes - Window output
157   * @{
158   */
159 #define LL_COMP_WINDOWOUTPUT_EACH_COMP               (0x00000000UL)                                                  /*!< Window output default mode: Comparators output are indicating each their own state. To know window mode state: each comparator output must be read, if "((COMPx exclusive or COMPy) == 1)" then monitored signal is within comparators window. The same way, if both comparators output are high, then monitored signal is below window. */
160 #define LL_COMP_WINDOWOUTPUT_COMP1                   (COMP_CSR_WINOUT | LL_COMP_WINDOWMODE_COMP_ODD_REGOFFSET_MASK)  /*!< Window output synthesized on COMP1 output: COMP1 output is no more indicating its own state, but global window mode state (logical high means monitored signal is within comparators window). Note: impacts only comparator output signal level (COMPx_OUT propagated to GPIO, EXTI lines, timers, ...), does not impact output digital state of comparator (COMPx_VALUE) always reflecting each comparator output state.*/
161 #define LL_COMP_WINDOWOUTPUT_COMP2                   (COMP_CSR_WINOUT | LL_COMP_WINDOWMODE_COMP_EVEN_REGOFFSET_MASK) /*!< Window output synthesized on COMP2 output: COMP2 output is no more indicating its own state, but global window mode state (logical high means monitored signal is within comparators window). Note: impacts only comparator output signal level (COMPx_OUT propagated to GPIO, EXTI lines, timers, ...), does not impact output digital state of comparator (COMPx_VALUE) always reflecting each comparator output state.*/
162 #define LL_COMP_WINDOWOUTPUT_BOTH                    (COMP_CSR_WINOUT | LL_COMP_WINDOWMODE_COMP_EVEN_REGOFFSET_MASK | LL_COMP_WINDOWOUTPUT_BOTH_SETTING_MASK)      /*!< Window output synthesized on both comparators output of pair of comparator selected (COMP1 and COMP2): both comparators outputs are no more indicating their own state, but global window mode state (logical high means monitored signal is within comparators window). This is a specific configuration (technically possible but not relevant from application point of view: 2 comparators output used for the same signal level), standard configuration for window mode is one of the settings above. */
163 /**
164   * @}
165   */
166 #endif /* COMP_WINDOW_MODE_SUPPORT */
167 
168 /** @defgroup COMP_LL_EC_POWERMODE Comparator modes - Power mode
169   * @{
170   */
171 #define LL_COMP_POWERMODE_HIGHSPEED     (0x00000000UL)                            /*!< COMP power mode to high speed */
172 #define LL_COMP_POWERMODE_MEDIUMSPEED   (COMP_CSR_PWRMODE_0)                      /*!< COMP power mode to medium speed */
173 #define LL_COMP_POWERMODE_ULTRALOWPOWER (COMP_CSR_PWRMODE_1 | COMP_CSR_PWRMODE_0) /*!< COMP power mode to ultra-low power */
174 /**
175   * @}
176   */
177 
178 /** @defgroup COMP_LL_EC_INPUT_PLUS Comparator inputs - Input plus (input non-inverting) selection
179   * @{
180   */
181 #define LL_COMP_INPUT_PLUS_IO1         (0x00000000UL)         /*!< Comparator input plus connected to IO1 (pin PC5 for COMP1, pin PB4 for COMP2) */
182 #define LL_COMP_INPUT_PLUS_IO2         (COMP_CSR_INPSEL_0)    /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PB6 for COMP2) */
183 #define LL_COMP_INPUT_PLUS_IO3         (COMP_CSR_INPSEL_1)    /*!< Comparator input plus connected to IO3 (pin PA2 for COMP1)                    */
184 #if defined(COMP_CSR_INPSEL_2)
185 #define LL_COMP_INPUT_PLUS_IO4         (COMP_CSR_INPSEL_1 | COMP_CSR_INPSEL_0) /*!< Comparator input plus connected to IO4 (pin PB3 for COMP1) */
186 #define LL_COMP_INPUT_PLUS_IO5         (COMP_CSR_INPSEL_2)                     /*!< Comparator input plus connected to IO5 (pin PB4 for COMP1) */
187 #define LL_COMP_INPUT_PLUS_IO6         (COMP_CSR_INPSEL_2 | COMP_CSR_INPSEL_0) /*!< Comparator input plus connected to IO6 (pin PB6 for COMP1) */
188 #endif /* COMP_CSR_INPSEL_2 */
189 /**
190   * @}
191   */
192 
193 /** @defgroup COMP_LL_EC_INPUT_MINUS Comparator inputs - Input minus (input inverting) selection
194   * @{
195   */
196 #define LL_COMP_INPUT_MINUS_1_4VREFINT  (0x00000000UL)                                                                  /*!< Comparator input minus connected to 1/4 VrefInt  */
197 #define LL_COMP_INPUT_MINUS_1_2VREFINT  (                                                            COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to 1/2 VrefInt  */
198 #define LL_COMP_INPUT_MINUS_3_4VREFINT  (                                        COMP_CSR_INMSEL_1                    ) /*!< Comparator input minus connected to 3/4 VrefInt  */
199 #define LL_COMP_INPUT_MINUS_VREFINT     (                                        COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to VrefInt */
200 #define LL_COMP_INPUT_MINUS_DAC1_CH1    (                    COMP_CSR_INMSEL_2                                        ) /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1)  */
201 #define LL_COMP_INPUT_MINUS_DAC1_CH2    (                    COMP_CSR_INMSEL_2                     | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2)  */
202 #define LL_COMP_INPUT_MINUS_IO1         (                    COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1                    ) /*!< Comparator input minus connected to IO1 (pin PB1 for COMP1, pin PB3 for COMP2) */
203 #define LL_COMP_INPUT_MINUS_IO2         (                    COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO2 (pin PC4 for COMP1, pin PB7 for COMP2) */
204 /**
205   * @}
206   */
207 
208 /** @defgroup COMP_LL_EC_INPUT_HYSTERESIS Comparator input - Hysteresis
209   * @{
210   */
211 #define LL_COMP_HYSTERESIS_NONE         (0x00000000UL)                      /*!< No hysteresis */
212 #define LL_COMP_HYSTERESIS_LOW          (                  COMP_CSR_HYST_0) /*!< Hysteresis level low */
213 #define LL_COMP_HYSTERESIS_MEDIUM       (COMP_CSR_HYST_1                  ) /*!< Hysteresis level medium */
214 #define LL_COMP_HYSTERESIS_HIGH         (COMP_CSR_HYST_1 | COMP_CSR_HYST_0) /*!< Hysteresis level high */
215 /**
216   * @}
217   */
218 
219 /** @defgroup COMP_LL_EC_OUTPUT_POLARITY Comparator output - Output polarity
220   * @{
221   */
222 #define LL_COMP_OUTPUTPOL_NONINVERTED   (0x00000000UL)          /*!< COMP output polarity is not inverted: comparator output is high when the plus (non-inverting) input is at a higher voltage than the minus (inverting) input */
223 #define LL_COMP_OUTPUTPOL_INVERTED      (COMP_CSR_POLARITY)     /*!< COMP output polarity is inverted: comparator output is low when the plus (non-inverting) input is at a lower voltage than the minus (inverting) input */
224 /**
225   * @}
226   */
227 
228 /** @defgroup COMP_LL_EC_OUTPUT_BLANKING_SOURCE Comparator output - Blanking source
229   * @{
230   */
231 #define LL_COMP_BLANKINGSRC_NONE            (0x00000000UL)          /*!<Comparator output without blanking */
232 #define LL_COMP_BLANKINGSRC_TIM1_OC5        (COMP_CSR_BLANKSEL_0)   /*!< Comparator output blanking source TIM1 OC5 for COMP1 Instance  */
233 #define LL_COMP_BLANKINGSRC_TIM2_OC3        (COMP_CSR_BLANKSEL_1)   /*!< Comparator output blanking source TIM2 OC3 for COMP1 Instance  */
234 #define LL_COMP_BLANKINGSRC_TIM3_OC3        (COMP_CSR_BLANKSEL_2)   /*!< Comparator output blanking source TIM3 OC3 for COMP1 Instance  */
235 #define LL_COMP_BLANKINGSRC_TIM3_OC4        (COMP_CSR_BLANKSEL_0)   /*!< Comparator output blanking source TIM3 OC4 for COMP2 Instance  */
236 #define LL_COMP_BLANKINGSRC_TIM8_OC5        (COMP_CSR_BLANKSEL_1)   /*!< Comparator output blanking source TIM8 OC5 for COMP2 Instance  */
237 #define LL_COMP_BLANKINGSRC_TIM15_OC1       (COMP_CSR_BLANKSEL_2)   /*!< Comparator output blanking source TIM15 OC1 for COMP2 Instance */
238 /**
239   * @}
240   */
241 
242 /** @defgroup COMP_LL_EC_OUTPUT_LEVEL Comparator output - Output level
243   * @{
244   */
245 #define LL_COMP_OUTPUT_LEVEL_LOW        (0x00000000UL)          /*!< Comparator output level low (if the polarity is not inverted, otherwise to be complemented) */
246 #define LL_COMP_OUTPUT_LEVEL_HIGH       (0x00000001UL)          /*!< Comparator output level high (if the polarity is not inverted, otherwise to be complemented) */
247 /**
248   * @}
249   */
250 
251 /** @defgroup COMP_LL_EC_HW_DELAYS  Definitions of COMP hardware constraints delays
252   * @note   Only COMP peripheral HW delays are defined in COMP LL driver driver,
253   *         not timeout values.
254   *         For details on delays values, refer to descriptions in source code
255   *         above each literal definition.
256   * @{
257   */
258 
259 /* Delay for comparator startup time.                                         */
260 /* Note: Delay required to reach propagation delay specification.             */
261 /* Literal set to maximum value (refer to device datasheet,                   */
262 /* parameter "tSTART").                                                       */
263 /* Unit: us                                                                   */
264 #define LL_COMP_DELAY_STARTUP_US          ( 80UL) /*!< Delay for COMP startup time */
265 
266 /* Delay for comparator voltage scaler stabilization time.                    */
267 /* Note: Voltage scaler is used when selecting comparator input               */
268 /*       based on VrefInt: VrefInt or subdivision of VrefInt.                 */
269 /* Literal set to maximum value (refer to device datasheet,                   */
270 /* parameter "tSTART_SCALER").                                                */
271 /* Unit: us                                                                   */
272 #define LL_COMP_DELAY_VOLTAGE_SCALER_STAB_US ( 200UL) /*!< Delay for COMP voltage scaler stabilization time */
273 
274 /**
275   * @}
276   */
277 
278 /**
279   * @}
280   */
281 
282 /* Exported macro ------------------------------------------------------------*/
283 /** @defgroup COMP_LL_Exported_Macros COMP Exported Macros
284   * @{
285   */
286 /** @defgroup COMP_LL_EM_WRITE_READ Common write and read registers macro
287   * @{
288   */
289 
290 /**
291   * @brief  Write a value in COMP register
292   * @param  __INSTANCE__ comparator instance
293   * @param  __REG__ Register to be written
294   * @param  __VALUE__ Value to be written in the register
295   * @retval None
296   */
297 #define LL_COMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG((__INSTANCE__)->__REG__, (__VALUE__))
298 
299 /**
300   * @brief  Read a value in COMP register
301   * @param  __INSTANCE__ comparator instance
302   * @param  __REG__ Register to be read
303   * @retval Register value
304   */
305 #define LL_COMP_ReadReg(__INSTANCE__, __REG__) READ_REG((__INSTANCE__)->__REG__)
306 /**
307   * @}
308   */
309 
310 /** @defgroup COMP_LL_EM_HELPER_MACRO COMP helper macro
311   * @{
312   */
313 
314 /**
315   * @brief  Helper macro to select the COMP common instance
316   *         to which is belonging the selected COMP instance.
317   * @note   COMP common register instance can be used to
318   *         set parameters common to several COMP instances.
319   *         Refer to functions having argument "COMPxy_COMMON" as parameter.
320   * @param  __COMPx__ COMP instance
321   * @retval COMP common instance or value "0" if there is no COMP common instance.
322   */
323 #define __LL_COMP_COMMON_INSTANCE(__COMPx__)          (COMP12_COMMON)
324 
325 /**
326   * @}
327   */
328 
329 /**
330   * @}
331   */
332 
333 /* Exported functions --------------------------------------------------------*/
334 /** @defgroup COMP_LL_Exported_Functions COMP Exported Functions
335   * @{
336   */
337 
338 #if defined(COMP2)
339 /** @defgroup COMP_LL_EF_Configuration_comparator_common Configuration of COMP hierarchical scope:
340   *           common to several COMP instances
341   * @{
342   */
343 
344 /**
345   * @brief  Set window mode of a pair of comparators instances
346   *         (2 consecutive COMP instances COMP<x> and COMP<x+1>).
347   * @rmtoll CSR      WINMODE        LL_COMP_SetCommonWindowMode
348   * @param  COMPxy_COMMON Comparator common instance
349   *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
350   * @param  WindowMode This parameter can be one of the following values:
351   *         @arg @ref LL_COMP_WINDOWMODE_DISABLE
352   *         @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
353   *         @arg @ref LL_COMP_WINDOWMODE_COMP2_INPUT_PLUS_COMMON (1)
354   *
355   *         (1) Parameter not available on all STM32U5 devices
356   * @retval None
357   */
LL_COMP_SetCommonWindowMode(COMP_Common_TypeDef * COMPxy_COMMON,uint32_t WindowMode)358 __STATIC_INLINE void LL_COMP_SetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON, uint32_t WindowMode)
359 {
360   /* Note: On this STM32 series, window mode can be set from any instance     */
361   /*       of the pair of comparator instances.                               */
362 
363   __IO uint32_t *preg = __COMP_PTR_REG_OFFSET(COMPxy_COMMON->CSR_ODD,
364                                               (WindowMode & LL_COMP_WINDOWMODE_COMPX_REGOFFSET_MASK));
365 
366   /* Clear the potential previous setting of window mode */
367   __IO uint32_t *preg_clear = __COMP_PTR_REG_OFFSET(COMPxy_COMMON->CSR_ODD,
368                                                     (~(WindowMode & LL_COMP_WINDOWMODE_COMPX_REGOFFSET_MASK) & 0x1UL)
369                                                    );
370   CLEAR_BIT(*preg_clear, COMP_CSR_WINMODE);
371 
372   /* Set window mode */
373   MODIFY_REG(*preg, COMP_CSR_WINMODE, (WindowMode & LL_COMP_WINDOWMODE_COMPX_SETTING_MASK));
374 }
375 
376 /**
377   * @brief  Get window mode of a pair of comparators instances
378   *         (2 consecutive COMP instances COMP<x> and COMP<x+1>).
379   * @rmtoll CSR      WINMODE        LL_COMP_GetCommonWindowMode
380   * @param  COMPxy_COMMON Comparator common instance
381   *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
382   * @retval Returned value can be one of the following values:
383   *         @arg @ref LL_COMP_WINDOWMODE_DISABLE
384   *         @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
385   *         @arg @ref LL_COMP_WINDOWMODE_COMP2_INPUT_PLUS_COMMON (1)
386   *
387   *         (1) Parameter not available on all STM32U5 devices
388   */
LL_COMP_GetCommonWindowMode(const COMP_Common_TypeDef * COMPxy_COMMON)389 __STATIC_INLINE uint32_t LL_COMP_GetCommonWindowMode(const COMP_Common_TypeDef *COMPxy_COMMON)
390 {
391   /* Note: On this STM32 series, window mode can be set from any instance      */
392   /*       of the pair of comparator instances.                               */
393 
394   const uint32_t window_mode_comp_odd = (uint32_t)READ_BIT(COMPxy_COMMON->CSR_ODD, COMP_CSR_WINMODE);
395   const uint32_t window_mode_comp_even = (uint32_t)READ_BIT(COMPxy_COMMON->CSR_EVEN, COMP_CSR_WINMODE);
396 
397   return (uint32_t)(window_mode_comp_odd
398                     | window_mode_comp_even
399                     | ((window_mode_comp_even >> LL_COMP_WINDOWMODE_BITOFFSET_POS)
400                        * LL_COMP_WINDOWMODE_COMP_EVEN_REGOFFSET_MASK)
401                    );
402 }
403 
404 /**
405   * @brief  Set window output of a pair of comparators instances
406   *         (2 consecutive COMP instances COMP<x> and COMP<x+1>).
407   * @rmtoll CSR      WINOUT         LL_COMP_SetCommonWindowOutput
408   * @param  COMPxy_COMMON Comparator common instance
409   *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
410   * @param  WindowOutput This parameter can be one of the following values:
411   *         @arg @ref LL_COMP_WINDOWOUTPUT_EACH_COMP
412   *         @arg @ref LL_COMP_WINDOWOUTPUT_COMP1 (1)
413   *         @arg @ref LL_COMP_WINDOWOUTPUT_COMP2 (1)
414   *         @arg @ref LL_COMP_WINDOWOUTPUT_BOTH
415   *
416   *         (1) Parameter available on all STM32U5 devices, must be used with comparator common instance COMP12_COMMON
417   * @retval None
418   */
LL_COMP_SetCommonWindowOutput(COMP_Common_TypeDef * COMPxy_COMMON,uint32_t WindowOutput)419 __STATIC_INLINE void LL_COMP_SetCommonWindowOutput(COMP_Common_TypeDef *COMPxy_COMMON, uint32_t WindowOutput)
420 {
421   __IO uint32_t *preg = __COMP_PTR_REG_OFFSET(COMPxy_COMMON->CSR_ODD,
422                                               (WindowOutput & LL_COMP_WINDOWMODE_COMPX_REGOFFSET_MASK));
423 
424   /* Clear the potential previous setting of window output on the relevant comparator instance */
425   /* (clear bit of window output unless specific case of setting of comparator both output selected) */
426   __IO uint32_t *preg_clear = __COMP_PTR_REG_OFFSET(COMPxy_COMMON->CSR_ODD,
427                                                     (~(WindowOutput & LL_COMP_WINDOWMODE_COMPX_REGOFFSET_MASK) & 0x1UL)
428                                                    );
429   MODIFY_REG(*preg_clear,
430              COMP_CSR_WINOUT,
431              ((WindowOutput & LL_COMP_WINDOWOUTPUT_BOTH_SETTING_MASK) >> LL_COMP_WINDOWOUTPUT_BOTH_POS_VS_WINDOW)
432             );
433 
434   /* Set window output */
435   MODIFY_REG(*preg,
436              COMP_CSR_WINOUT,
437              (WindowOutput & LL_COMP_WINDOWOUTPUT_COMPX_SETTING_MASK)
438             );
439 }
440 
441 /**
442   * @brief  Get window output of a pair of comparators instances
443   *         (2 consecutive COMP instances COMP<x> and COMP<x+1>).
444   * @rmtoll CSR      WINMODE        LL_COMP_GetCommonWindowOutput
445   * @param  COMPxy_COMMON Comparator common instance
446   *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
447   * @retval Returned value can be one of the following values:
448   *         @arg @ref LL_COMP_WINDOWOUTPUT_EACH_COMP
449   *         @arg @ref LL_COMP_WINDOWOUTPUT_COMP1 (1)
450   *         @arg @ref LL_COMP_WINDOWOUTPUT_COMP2 (1)
451   *         @arg @ref LL_COMP_WINDOWOUTPUT_BOTH
452   *
453   *         (1) Parameter available on all STM32U5 devices, must be used with comparator common instance COMP12_COMMON
454   */
LL_COMP_GetCommonWindowOutput(const COMP_Common_TypeDef * COMPxy_COMMON)455 __STATIC_INLINE uint32_t LL_COMP_GetCommonWindowOutput(const COMP_Common_TypeDef *COMPxy_COMMON)
456 {
457   const uint32_t window_output_comp_odd = (uint32_t)READ_BIT(COMPxy_COMMON->CSR_ODD, COMP_CSR_WINOUT);
458   const uint32_t window_output_comp_even = (uint32_t)READ_BIT(COMPxy_COMMON->CSR_EVEN, COMP_CSR_WINOUT);
459 
460   /* Construct value corresponding to LL_COMP_WINDOWOUTPUT_xxx */
461   return (uint32_t)(window_output_comp_odd
462                     | window_output_comp_even
463                     | ((window_output_comp_even >> COMP_CSR_WINOUT_Pos) * LL_COMP_WINDOWMODE_COMP_EVEN_REGOFFSET_MASK)
464                     | (window_output_comp_odd + window_output_comp_even));
465 }
466 /**
467   * @}
468   */
469 
470 #endif /* COMP2 */
471 /** @defgroup COMP_LL_EF_Configuration_comparator_modes Configuration of comparator modes
472   * @{
473   */
474 
475 /**
476   * @brief  Set comparator instance operating mode to adjust power and speed.
477   * @rmtoll CSR      PWRMODE        LL_COMP_SetPowerMode
478   * @param  COMPx Comparator instance
479   * @param  PowerMode This parameter can be one of the following values:
480   *         @arg @ref LL_COMP_POWERMODE_HIGHSPEED
481   *         @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED
482   *         @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER
483   * @retval None
484   */
LL_COMP_SetPowerMode(COMP_TypeDef * COMPx,uint32_t PowerMode)485 __STATIC_INLINE void LL_COMP_SetPowerMode(COMP_TypeDef *COMPx, uint32_t PowerMode)
486 {
487   MODIFY_REG(COMPx->CSR, COMP_CSR_PWRMODE, PowerMode);
488 }
489 
490 /**
491   * @brief  Get comparator instance operating mode to adjust power and speed.
492   * @rmtoll CSR      PWRMODE        LL_COMP_GetPowerMode
493   * @param  COMPx Comparator instance
494   * @retval Returned value can be one of the following values:
495   *         @arg @ref LL_COMP_POWERMODE_HIGHSPEED
496   *         @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED
497   *         @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER
498   */
LL_COMP_GetPowerMode(const COMP_TypeDef * COMPx)499 __STATIC_INLINE uint32_t LL_COMP_GetPowerMode(const COMP_TypeDef *COMPx)
500 {
501   return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_PWRMODE));
502 }
503 
504 /**
505   * @}
506   */
507 
508 /** @defgroup COMP_LL_EF_Configuration_comparator_inputs Configuration of comparator inputs
509   * @{
510   */
511 
512 /**
513   * @brief  Set comparator inputs minus (inverting) and plus (non-inverting).
514   * @note   In case of comparator input selected to be connected to IO:
515   *         GPIO pins are specific to each comparator instance.
516   *         Refer to description of parameters or to reference manual.
517   * @note   On this STM32 series, a voltage scaler is used
518   *         when COMP input is based on VrefInt (VrefInt or subdivision
519   *         of VrefInt):
520   *         Voltage scaler requires a delay for voltage stabilization.
521   *         Refer to device datasheet, parameter "tSTART_SCALER".
522   * @rmtoll CSR      INMSEL         LL_COMP_ConfigInputs\n
523   *         CSR      INPSEL         LL_COMP_ConfigInputs\n
524   * @param  COMPx Comparator instance
525   * @param  InputMinus This parameter can be one of the following values:
526   *         @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
527   *         @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
528   *         @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
529   *         @arg @ref LL_COMP_INPUT_MINUS_VREFINT
530   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
531   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
532   *         @arg @ref LL_COMP_INPUT_MINUS_IO1
533   *         @arg @ref LL_COMP_INPUT_MINUS_IO2
534   * @param  InputPlus This parameter can be one of the following values:
535   *         @arg @ref LL_COMP_INPUT_PLUS_IO1
536   *         @arg @ref LL_COMP_INPUT_PLUS_IO2
537   *         @arg @ref LL_COMP_INPUT_PLUS_IO3
538   * @retval None
539   */
LL_COMP_ConfigInputs(COMP_TypeDef * COMPx,uint32_t InputMinus,uint32_t InputPlus)540 __STATIC_INLINE void LL_COMP_ConfigInputs(COMP_TypeDef *COMPx, uint32_t InputMinus, uint32_t InputPlus)
541 {
542   MODIFY_REG(COMPx->CSR,
543              COMP_CSR_INMSEL | COMP_CSR_INPSEL,
544              InputMinus | InputPlus);
545 }
546 
547 /**
548   * @brief  Set comparator input plus (non-inverting).
549   * @note   In case of comparator input selected to be connected to IO:
550   *         GPIO pins are specific to each comparator instance.
551   *         Refer to description of parameters or to reference manual.
552   * @rmtoll CSR      INPSEL         LL_COMP_SetInputPlus
553   * @param  COMPx Comparator instance
554   * @param  InputPlus This parameter can be one of the following values:
555   *         @arg @ref LL_COMP_INPUT_PLUS_IO1
556   *         @arg @ref LL_COMP_INPUT_PLUS_IO2
557   *         @arg @ref LL_COMP_INPUT_PLUS_IO3
558   * @retval None
559   */
LL_COMP_SetInputPlus(COMP_TypeDef * COMPx,uint32_t InputPlus)560 __STATIC_INLINE void LL_COMP_SetInputPlus(COMP_TypeDef *COMPx, uint32_t InputPlus)
561 {
562   MODIFY_REG(COMPx->CSR, COMP_CSR_INPSEL, InputPlus);
563 }
564 
565 /**
566   * @brief  Get comparator input plus (non-inverting).
567   * @note   In case of comparator input selected to be connected to IO:
568   *         GPIO pins are specific to each comparator instance.
569   *         Refer to description of parameters or to reference manual.
570   * @rmtoll CSR      INPSEL         LL_COMP_GetInputPlus
571   * @param  COMPx Comparator instance
572   * @retval Returned value can be one of the following values:
573   *         @arg @ref LL_COMP_INPUT_PLUS_IO1
574   *         @arg @ref LL_COMP_INPUT_PLUS_IO2
575   *         @arg @ref LL_COMP_INPUT_PLUS_IO3
576   */
LL_COMP_GetInputPlus(const COMP_TypeDef * COMPx)577 __STATIC_INLINE uint32_t LL_COMP_GetInputPlus(const COMP_TypeDef *COMPx)
578 {
579   return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_INPSEL));
580 }
581 
582 /**
583   * @brief  Set comparator input minus (inverting).
584   * @note   In case of comparator input selected to be connected to IO:
585   *         GPIO pins are specific to each comparator instance.
586   *         Refer to description of parameters or to reference manual.
587   * @note   On this STM32 series, a voltage scaler is used
588   *         when COMP input is based on VrefInt (VrefInt or subdivision
589   *         of VrefInt):
590   *         Voltage scaler requires a delay for voltage stabilization.
591   *         Refer to device datasheet, parameter "tSTART_SCALER".
592   * @rmtoll CSR      INMSEL         LL_COMP_SetInputMinus
593   * @param  COMPx Comparator instance
594   * @param  InputMinus This parameter can be one of the following values:
595   *         @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
596   *         @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
597   *         @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
598   *         @arg @ref LL_COMP_INPUT_MINUS_VREFINT
599   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
600   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
601   *         @arg @ref LL_COMP_INPUT_MINUS_IO1
602   *         @arg @ref LL_COMP_INPUT_MINUS_IO2
603   * @retval None
604   */
LL_COMP_SetInputMinus(COMP_TypeDef * COMPx,uint32_t InputMinus)605 __STATIC_INLINE void LL_COMP_SetInputMinus(COMP_TypeDef *COMPx, uint32_t InputMinus)
606 {
607   MODIFY_REG(COMPx->CSR, COMP_CSR_INMSEL, InputMinus);
608 }
609 
610 /**
611   * @brief  Get comparator input minus (inverting).
612   * @note   In case of comparator input selected to be connected to IO:
613   *         GPIO pins are specific to each comparator instance.
614   *         Refer to description of parameters or to reference manual.
615   * @rmtoll CSR      INMSEL         LL_COMP_GetInputMinus
616   * @param  COMPx Comparator instance
617   * @retval Returned value can be one of the following values:
618   *         @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
619   *         @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
620   *         @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
621   *         @arg @ref LL_COMP_INPUT_MINUS_VREFINT
622   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
623   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
624   *         @arg @ref LL_COMP_INPUT_MINUS_IO1
625   *         @arg @ref LL_COMP_INPUT_MINUS_IO2
626   */
LL_COMP_GetInputMinus(const COMP_TypeDef * COMPx)627 __STATIC_INLINE uint32_t LL_COMP_GetInputMinus(const COMP_TypeDef *COMPx)
628 {
629   return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_INMSEL));
630 }
631 
632 /**
633   * @brief  Set comparator instance hysteresis mode of the input minus (inverting input).
634   * @rmtoll CSR      HYST           LL_COMP_SetInputHysteresis
635   * @param  COMPx Comparator instance
636   * @param  InputHysteresis This parameter can be one of the following values:
637   *         @arg @ref LL_COMP_HYSTERESIS_NONE
638   *         @arg @ref LL_COMP_HYSTERESIS_LOW
639   *         @arg @ref LL_COMP_HYSTERESIS_MEDIUM
640   *         @arg @ref LL_COMP_HYSTERESIS_HIGH
641   * @retval None
642   */
LL_COMP_SetInputHysteresis(COMP_TypeDef * COMPx,uint32_t InputHysteresis)643 __STATIC_INLINE void LL_COMP_SetInputHysteresis(COMP_TypeDef *COMPx, uint32_t InputHysteresis)
644 {
645   MODIFY_REG(COMPx->CSR, COMP_CSR_HYST, InputHysteresis);
646 }
647 
648 /**
649   * @brief  Get comparator instance hysteresis mode of the minus (inverting) input.
650   * @rmtoll CSR      HYST           LL_COMP_GetInputHysteresis
651   * @param  COMPx Comparator instance
652   * @retval Returned value can be one of the following values:
653   *         @arg @ref LL_COMP_HYSTERESIS_NONE
654   *         @arg @ref LL_COMP_HYSTERESIS_LOW
655   *         @arg @ref LL_COMP_HYSTERESIS_MEDIUM
656   *         @arg @ref LL_COMP_HYSTERESIS_HIGH
657   */
LL_COMP_GetInputHysteresis(const COMP_TypeDef * COMPx)658 __STATIC_INLINE uint32_t LL_COMP_GetInputHysteresis(const COMP_TypeDef *COMPx)
659 {
660   return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_HYST));
661 }
662 
663 /**
664   * @}
665   */
666 
667 /** @defgroup COMP_LL_EF_Configuration_comparator_output Configuration of comparator output
668   * @{
669   */
670 
671 /**
672   * @brief  Set comparator instance output polarity.
673   * @rmtoll CSR      POLARITY       LL_COMP_SetOutputPolarity
674   * @param  COMPx Comparator instance
675   * @param  OutputPolarity This parameter can be one of the following values:
676   *         @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
677   *         @arg @ref LL_COMP_OUTPUTPOL_INVERTED
678   * @retval None
679   */
LL_COMP_SetOutputPolarity(COMP_TypeDef * COMPx,uint32_t OutputPolarity)680 __STATIC_INLINE void LL_COMP_SetOutputPolarity(COMP_TypeDef *COMPx, uint32_t OutputPolarity)
681 {
682   MODIFY_REG(COMPx->CSR, COMP_CSR_POLARITY, OutputPolarity);
683 }
684 
685 /**
686   * @brief  Get comparator instance output polarity.
687   * @rmtoll CSR      POLARITY       LL_COMP_GetOutputPolarity
688   * @param  COMPx Comparator instance
689   * @retval Returned value can be one of the following values:
690   *         @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
691   *         @arg @ref LL_COMP_OUTPUTPOL_INVERTED
692   */
LL_COMP_GetOutputPolarity(const COMP_TypeDef * COMPx)693 __STATIC_INLINE uint32_t LL_COMP_GetOutputPolarity(const COMP_TypeDef *COMPx)
694 {
695   return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_POLARITY));
696 }
697 
698 /**
699   * @brief  Set comparator instance blanking source.
700   * @note   Blanking source may be specific to each comparator instance.
701   *         Refer to description of parameters or to reference manual.
702   * @note   Availability of parameters of blanking source from timer
703   *         depends on timers availability on the selected device.
704   * @rmtoll CSR      BLANKSEL       LL_COMP_SetOutputBlankingSource
705   * @param  COMPx Comparator instance
706   * @param  BlankingSource This parameter can be one of the following values:
707   *         @arg @ref LL_COMP_BLANKINGSRC_NONE
708   *         @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5
709   *         @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3
710   *         @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3
711   *         @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC4
712   *         @arg @ref LL_COMP_BLANKINGSRC_TIM8_OC5
713   *         @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC1
714   * @retval None
715   */
LL_COMP_SetOutputBlankingSource(COMP_TypeDef * COMPx,uint32_t BlankingSource)716 __STATIC_INLINE void LL_COMP_SetOutputBlankingSource(COMP_TypeDef *COMPx, uint32_t BlankingSource)
717 {
718   MODIFY_REG(COMPx->CSR, COMP_CSR_BLANKSEL, BlankingSource);
719 }
720 
721 /**
722   * @brief  Get comparator instance blanking source.
723   * @note   Availability of parameters of blanking source from timer
724   *         depends on timers availability on the selected device.
725   * @note   Blanking source may be specific to each comparator instance.
726   *         Refer to description of parameters or to reference manual.
727   * @rmtoll CSR      BLANKSEL       LL_COMP_GetOutputBlankingSource
728   * @param  COMPx Comparator instance
729   * @retval Returned value can be one of the following values:
730   *         @arg @ref LL_COMP_BLANKINGSRC_NONE
731   *         @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5
732   *         @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3
733   *         @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3
734   *         @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC4
735   *         @arg @ref LL_COMP_BLANKINGSRC_TIM8_OC5
736   *         @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC1
737   */
LL_COMP_GetOutputBlankingSource(const COMP_TypeDef * COMPx)738 __STATIC_INLINE uint32_t LL_COMP_GetOutputBlankingSource(const COMP_TypeDef *COMPx)
739 {
740   return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_BLANKSEL));
741 }
742 
743 /**
744   * @}
745   */
746 
747 /** @defgroup COMP_LL_EF_Operation Operation on comparator instance
748   * @{
749   */
750 
751 /**
752   * @brief  Enable comparator instance.
753   * @note   After enable from off state, comparator requires a delay
754   *         to reach reach propagation delay specification.
755   *         Refer to device datasheet, parameter "tSTART".
756   * @rmtoll CSR      EN             LL_COMP_Enable
757   * @param  COMPx Comparator instance
758   * @retval None
759   */
LL_COMP_Enable(COMP_TypeDef * COMPx)760 __STATIC_INLINE void LL_COMP_Enable(COMP_TypeDef *COMPx)
761 {
762   SET_BIT(COMPx->CSR, COMP_CSR_EN);
763 }
764 
765 /**
766   * @brief  Disable comparator instance.
767   * @rmtoll CSR      EN             LL_COMP_Disable
768   * @param  COMPx Comparator instance
769   * @retval None
770   */
LL_COMP_Disable(COMP_TypeDef * COMPx)771 __STATIC_INLINE void LL_COMP_Disable(COMP_TypeDef *COMPx)
772 {
773   CLEAR_BIT(COMPx->CSR, COMP_CSR_EN);
774 }
775 
776 /**
777   * @brief  Get comparator enable state
778   *         (0: COMP is disabled, 1: COMP is enabled)
779   * @rmtoll CSR      EN             LL_COMP_IsEnabled
780   * @param  COMPx Comparator instance
781   * @retval State of bit (1 or 0).
782   */
LL_COMP_IsEnabled(const COMP_TypeDef * COMPx)783 __STATIC_INLINE uint32_t LL_COMP_IsEnabled(const COMP_TypeDef *COMPx)
784 {
785   return ((READ_BIT(COMPx->CSR, COMP_CSR_EN) == (COMP_CSR_EN)) ? 1UL : 0UL);
786 }
787 
788 /**
789   * @brief  Lock comparator instance.
790   * @note   Once locked, comparator configuration can be accessed in read-only.
791   * @note   The only way to unlock the comparator is a device hardware reset.
792   * @rmtoll CSR      LOCK           LL_COMP_Lock
793   * @param  COMPx Comparator instance
794   * @retval None
795   */
LL_COMP_Lock(COMP_TypeDef * COMPx)796 __STATIC_INLINE void LL_COMP_Lock(COMP_TypeDef *COMPx)
797 {
798   SET_BIT(COMPx->CSR, COMP_CSR_LOCK);
799 }
800 
801 /**
802   * @brief  Get comparator lock state
803   *         (0: COMP is unlocked, 1: COMP is locked).
804   * @note   Once locked, comparator configuration can be accessed in read-only.
805   * @note   The only way to unlock the comparator is a device hardware reset.
806   * @rmtoll CSR      LOCK           LL_COMP_IsLocked
807   * @param  COMPx Comparator instance
808   * @retval State of bit (1 or 0).
809   */
LL_COMP_IsLocked(const COMP_TypeDef * COMPx)810 __STATIC_INLINE uint32_t LL_COMP_IsLocked(const COMP_TypeDef *COMPx)
811 {
812   return ((READ_BIT(COMPx->CSR, COMP_CSR_LOCK) == (COMP_CSR_LOCK)) ? 1UL : 0UL);
813 }
814 
815 /**
816   * @brief  Read comparator instance output level.
817   * @note   The comparator output level depends on the selected polarity
818   *         (Refer to function @ref LL_COMP_SetOutputPolarity()).
819   *         If the comparator polarity is not inverted:
820   *          - Comparator output is low when the input plus
821   *            is at a lower voltage than the input minus
822   *          - Comparator output is high when the input plus
823   *            is at a higher voltage than the input minus
824   *         If the comparator polarity is inverted:
825   *          - Comparator output is high when the input plus
826   *            is at a lower voltage than the input minus
827   *          - Comparator output is low when the input plus
828   *            is at a higher voltage than the input minus
829   * @rmtoll CSR      VALUE          LL_COMP_ReadOutputLevel
830   * @param  COMPx Comparator instance
831   * @retval Returned value can be one of the following values:
832   *         @arg @ref LL_COMP_OUTPUT_LEVEL_LOW
833   *         @arg @ref LL_COMP_OUTPUT_LEVEL_HIGH
834   */
LL_COMP_ReadOutputLevel(const COMP_TypeDef * COMPx)835 __STATIC_INLINE uint32_t LL_COMP_ReadOutputLevel(const COMP_TypeDef *COMPx)
836 {
837   return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_VALUE)
838                     >> LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS);
839 }
840 
841 /**
842   * @}
843   */
844 
845 #if defined(USE_FULL_LL_DRIVER)
846 /** @defgroup COMP_LL_EF_Init Initialization and de-initialization functions
847   * @{
848   */
849 
850 ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx);
851 ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, const LL_COMP_InitTypeDef *COMP_InitStruct);
852 void        LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct);
853 
854 /**
855   * @}
856   */
857 #endif /* USE_FULL_LL_DRIVER */
858 
859 /**
860   * @}
861   */
862 
863 /**
864   * @}
865   */
866 
867 /**
868   * @}
869   */
870 
871 #endif /* COMP1 || COMP2 */
872 
873 /**
874   * @}
875   */
876 
877 #ifdef __cplusplus
878 }
879 #endif
880 
881 #endif /* STM32U5xx_LL_COMP_H */
882