1 /**
2   ******************************************************************************
3   * @file    stm32f3xx_ll_comp.h
4   * @author  MCD Application Team
5   * @brief   Header file of COMP LL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2016 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 __STM32F3xx_LL_COMP_H
21 #define __STM32F3xx_LL_COMP_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32f3xx.h"
29 
30 /** @addtogroup STM32F3xx_LL_Driver
31   * @{
32   */
33 
34 /* Note: Devices of STM32F3 series embed 1 out of 2 different comparator IP.   */
35 /*       - STM32F30x, STM32F31x, STM32F32x, STM32F33x, STM32F35x, STM32F39x:  */
36 /*         COMP IP from 3 to 7 instances and other specific features          */
37 /*         (comparator output blanking, ...) (refer to reference manual).     */
38 /*       - STM32F37x:                                                         */
39 /*         COMP IP with 2 instances                                           */
40 /*       This file contains the drivers of these COMP IP, located in 2 area    */
41 /*       delimited by compilation switches.                                   */
42 
43 #if defined(COMP_V1_3_0_0)
44 
45 #if defined (COMP1) || defined (COMP2) || defined (COMP3) || defined (COMP4) || defined (COMP5) || defined (COMP6) || defined (COMP7)
46 
47 /** @defgroup COMP_LL COMP
48   * @{
49   */
50 
51 /* Private types -------------------------------------------------------------*/
52 /* Private variables ---------------------------------------------------------*/
53 /* Private constants ---------------------------------------------------------*/
54 /** @defgroup COMP_LL_Private_Constants COMP Private Constants
55   * @{
56   */
57 
58 /* COMP registers bits positions */
59 #define LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS ((uint32_t)30U) /* Value equivalent to POSITION_VAL(COMPxOUT) */
60 
61 /**
62   * @}
63   */
64 
65 /* Private macros ------------------------------------------------------------*/
66 /* Exported types ------------------------------------------------------------*/
67 #if defined(USE_FULL_LL_DRIVER)
68 /** @defgroup COMP_LL_ES_INIT COMP Exported Init structure
69   * @{
70   */
71 
72 /**
73   * @brief  Structure definition of some features of COMP instance.
74   */
75 typedef struct
76 {
77   uint32_t PowerMode;                   /*!< Set comparator operating mode to adjust power and speed.
78                                              This parameter can be a value of @ref COMP_LL_EC_POWERMODE
79 
80                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetPowerMode(). */
81 
82   uint32_t InputPlus;                   /*!< Set comparator input plus (non-inverting input).
83                                              This parameter can be a value of @ref COMP_LL_EC_INPUT_PLUS
84 
85                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputPlus(). */
86 
87   uint32_t InputMinus;                  /*!< Set comparator input minus (inverting input).
88                                              This parameter can be a value of @ref COMP_LL_EC_INPUT_MINUS
89 
90                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputMinus(). */
91 
92   uint32_t InputHysteresis;             /*!< Set comparator hysteresis mode of the input minus.
93                                              This parameter can be a value of @ref COMP_LL_EC_INPUT_HYSTERESIS
94 
95                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputHysteresis(). */
96 
97   uint32_t OutputSelection;             /*!< Set comparator output selection.
98                                              This parameter can be a value of @ref COMP_LL_EC_OUTPUT_SELECTION
99 
100                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputSelection(). */
101 
102   uint32_t OutputPolarity;              /*!< Set comparator output polarity.
103                                              This parameter can be a value of @ref COMP_LL_EC_OUTPUT_POLARITY
104 
105                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputPolarity(). */
106 
107   uint32_t OutputBlankingSource;        /*!< Set comparator blanking source.
108                                              This parameter can be a value of @ref COMP_LL_EC_OUTPUT_BLANKING_SOURCE
109 
110                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputBlankingSource(). */
111 
112 } LL_COMP_InitTypeDef;
113 
114 /**
115   * @}
116   */
117 #endif /* USE_FULL_LL_DRIVER */
118 
119 /* Exported constants --------------------------------------------------------*/
120 /** @defgroup COMP_LL_Exported_Constants COMP Exported Constants
121   * @{
122   */
123 
124 /** @defgroup COMP_LL_EC_COMMON_WINDOWMODE Comparator common modes - Window mode
125   * @{
126   */
127 #define LL_COMP_WINDOWMODE_DISABLE                 ((uint32_t)0x00000000U) /*!< Window mode disable: Comparators 1 and 2 are independent */
128 #if defined(COMP2_CSR_COMP2WNDWEN)
129 #define LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP2_CSR_COMP2WNDWEN) /*!< 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). */
130 #endif
131 #if defined(COMP4_CSR_COMP4WNDWEN)
132 #define LL_COMP_WINDOWMODE_COMP3_INPUT_PLUS_COMMON (COMP4_CSR_COMP4WNDWEN) /*!< Window mode enable: Comparators instances pair COMP3 and COMP4 have their input plus connected together. The common input is COMP3 input plus (COMP4 input plus is no more accessible). */
133 #endif
134 #if defined(COMP6_CSR_COMP6WNDWEN)
135 #define LL_COMP_WINDOWMODE_COMP5_INPUT_PLUS_COMMON (COMP6_CSR_COMP6WNDWEN) /*!< Window mode enable: Comparators instances pair COMP5 and COMP6 have their input plus connected together. The common input is COMP5 input plus (COMP6 input plus is no more accessible). */
136 #endif
137 /**
138   * @}
139   */
140 
141 /** @defgroup COMP_LL_EC_POWERMODE Comparator modes - Power mode
142   * @{
143   */
144 #define LL_COMP_POWERMODE_HIGHSPEED     ((uint32_t)0x00000000U)                       /*!< COMP power mode to high speed */
145 #if defined(COMP_CSR_COMPxMODE)
146 #define LL_COMP_POWERMODE_MEDIUMSPEED   (COMP_CSR_COMPxMODE_0)                        /*!< COMP power mode to medium speed */
147 #define LL_COMP_POWERMODE_LOWPOWER      (COMP_CSR_COMPxMODE_1)                        /*!< COMP power mode to low power */
148 #define LL_COMP_POWERMODE_ULTRALOWPOWER (COMP_CSR_COMPxMODE_1 | COMP_CSR_COMPxMODE_0) /*!< COMP power mode to ultra-low power */
149 #endif
150 /**
151   * @}
152   */
153 
154 /** @defgroup COMP_LL_EC_INPUT_PLUS Comparator inputs - Input plus (input non-inverting) selection
155   * @{
156   */
157 #if !defined(COMP_CSR_COMPxNONINSEL)
158 #define LL_COMP_INPUT_PLUS_IO1          ((uint32_t)0x00000000U)  /*!< Comparator input plus connected to IO1 (pin PA1 for COMP1, PA3 for COMP2 (except STM32F334xx: PA7), PB14 for COMP3, PB0 for COMP4, PD12 for COMP5, PD11 for COMP6, PA0  for COMP7) (COMP instance availability depends on the selected device) */
159 #define LL_COMP_INPUT_PLUS_IO2          ((uint32_t)0x00000000U)  /*!< Comparator input plus connected to IO2: Same as IO1 */
160 #else
161 #define LL_COMP_INPUT_PLUS_IO1          ((uint32_t)0x00000000U)  /*!< Comparator input plus connected to IO1 (pin PA7 for COMP2, PB14 for COMP3, PB0 for COMP4, PD12 for COMP5, PD11 for COMP6, PA0  for COMP7) (COMP instance availability depends on the selected device) */
162 #define LL_COMP_INPUT_PLUS_IO2          (COMP_CSR_COMPxNONINSEL) /*!< Comparator input plus connected to IO2 (pin PA3 for COMP2, PD14 for COMP3, PE7 for COMP4, PB13 for COMP5, PB11 for COMP6, PC1 for COMP7) (COMP instance availability depends on the selected device) */
163 #endif
164 #if defined(STM32F302xC) || defined(STM32F302xE) || defined(STM32F303xC) || defined(STM32F303xE) || defined(STM32F358xx) || defined(STM32F398xx)
165 #define LL_COMP_INPUT_PLUS_DAC1_CH1_COMP1 (COMP_CSR_COMPxSW1)    /*!< Comparator input plus connected to DAC1 channel 1 (DAC_OUT1), through dedicated switch (Note: this switch is solely intended to redirect signals onto high impedance input, such as COMP1 input plus (highly resistive switch)) (specific to COMP instance: COMP1) */
166 
167 /* Note: Comparator input plus specific to COMP instances, defined with       */
168 /*       generic naming not taking into account COMP instance constraints.    */
169 /*       Refer to literal definitions above for COMP instance constraints.    */
170 #define LL_COMP_INPUT_PLUS_DAC1_CH1     LL_COMP_INPUT_PLUS_DAC1_CH1_COMP1      /*!< Comparator input plus connected to DAC1 channel 1 (DAC_OUT1), through dedicated switch. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
171 
172 #elif defined(STM32F301x8) || defined(STM32F318xx) || defined(STM32F302x8)
173 #define LL_COMP_INPUT_PLUS_DAC1_CH1_COMP2 (COMP_CSR_COMPxSW1)    /*!< Comparator input plus connected to DAC1 channel 1 (DAC_OUT1), through dedicated switch (Note: this switch is solely intended to redirect signals onto high impedance input, such as COMP2 input plus (highly resistive switch)) (specific to COMP instance: COMP2) */
174 
175 /* Note: Comparator input plus specific to COMP instances, defined with       */
176 /*       generic naming not taking into account COMP instance constraints.    */
177 /*       Refer to literal definitions above for COMP instance constraints.    */
178 #define LL_COMP_INPUT_PLUS_DAC1_CH1     LL_COMP_INPUT_PLUS_DAC1_CH1_COMP2      /*!< Comparator input plus connected to DAC1 channel 1 (DAC_OUT1), through dedicated switch. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
179 
180 #endif
181 /**
182   * @}
183   */
184 
185 /** @defgroup COMP_LL_EC_INPUT_MINUS Comparator inputs - Input minus (input inverting) selection
186   * @{
187   */
188 #define LL_COMP_INPUT_MINUS_1_4VREFINT  ((uint32_t)0x00000000U)                                                /*!< Comparator input minus connected to 1/4 VrefInt  */
189 #define LL_COMP_INPUT_MINUS_1_2VREFINT  (                                               COMP_CSR_COMPxINSEL_0) /*!< Comparator input minus connected to 1/2 VrefInt  */
190 #define LL_COMP_INPUT_MINUS_3_4VREFINT  (                       COMP_CSR_COMPxINSEL_1                        ) /*!< Comparator input minus connected to 3/4 VrefInt  */
191 #define LL_COMP_INPUT_MINUS_VREFINT     (                       COMP_CSR_COMPxINSEL_1 | COMP_CSR_COMPxINSEL_0) /*!< Comparator input minus connected to VrefInt */
192 #define LL_COMP_INPUT_MINUS_DAC1_CH1    (COMP_CSR_COMPxINSEL_2                                               ) /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1)  */
193 #if defined(STM32F301x8) || defined(STM32F318xx) || defined(STM32F302x8) || defined(STM32F302xC) || defined(STM32F302xE)
194 /* This device has no comparator input minus DAC1_CH2 */
195 #else
196 #define LL_COMP_INPUT_MINUS_DAC1_CH2    (COMP_CSR_COMPxINSEL_2                        | COMP_CSR_COMPxINSEL_0) /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2)  */
197 #endif
198 #if defined(STM32F301x8) || defined(STM32F318xx) || defined(STM32F334x8)
199 #define LL_COMP_INPUT_MINUS_IO1         (COMP_CSR_COMPxINSEL_2 | COMP_CSR_COMPxINSEL_1                        ) /*!< Comparator input minus connected to IO1 (pin PA2 for COMP2) */
200 #else
201 #define LL_COMP_INPUT_MINUS_IO1         (COMP_CSR_COMPxINSEL_2 | COMP_CSR_COMPxINSEL_1                        ) /*!< Comparator input minus connected to IO1 (pin PA0 for COMP1, pin PA2 for COMP2, PD15 for COMP3, PE8 for COMP4, PD13 for COMP5, PD10 for COMP6, PC0 for COMP7 (COMP instance availability depends on the selected device)) */
202 #endif
203 #define LL_COMP_INPUT_MINUS_IO2         (COMP_CSR_COMPxINSEL_2 | COMP_CSR_COMPxINSEL_1 | COMP_CSR_COMPxINSEL_0) /*!< Comparator input minus connected to IO2 (PB12 for COMP3, PB2 for COMP4, PB10 for COMP5, PB15 for COMP6 (COMP instance availability depends on the selected device)) */
204 #if defined(STM32F301x8) || defined(STM32F318xx) || defined(STM32F334x8) || defined(STM32F302x8) || defined(STM32F303x8) || defined(STM32F328xx)
205 /* This device has no comparator input minus IO3 */
206 #else
207 #define LL_COMP_INPUT_MINUS_IO3         (COMP_CSR_COMPxINSEL_2                         | COMP_CSR_COMPxINSEL_0) /*!< Comparator input minus connected to IO3 (pin PA5 for COMP1/2/3/4/5/6/7 (COMP instance availability depends on the selected device)) */
208 #endif
209 #define LL_COMP_INPUT_MINUS_IO4         (COMP_CSR_COMPxINSEL_2                                                ) /*!< Comparator input minus connected to IO4 (pin PA4 for COMP1/2/3/4/5/6/7 (COMP instance availability depends on the selected device)) */
210 #if defined(STM32F303x8) || defined(STM32F328xx) || defined(STM32F334x8)
211 #define LL_COMP_INPUT_MINUS_DAC2_CH1    (COMP_CSR_COMPxINSEL_3                                                ) /*!< Comparator input minus connected to DAC2 channel 1 (DAC2_OUT1)  */
212 #else
213 /* This device has no comparator input minus DAC2_CH1 */
214 #endif
215 /**
216   * @}
217   */
218 
219 /** @defgroup COMP_LL_EC_INPUT_HYSTERESIS Comparator input - Hysteresis
220   * @{
221   */
222 #define LL_COMP_HYSTERESIS_NONE         ((uint32_t)0x00000000U)                       /*!< No hysteresis */
223 #if defined(COMP_CSR_COMPxHYST)
224 #define LL_COMP_HYSTERESIS_LOW          (                       COMP_CSR_COMPxHYST_0) /*!< Hysteresis level low (available only on devices: STM32F303xB/C, STM32F358xC) */
225 #define LL_COMP_HYSTERESIS_MEDIUM       (COMP_CSR_COMPxHYST_1                       ) /*!< Hysteresis level medium (available only on devices: STM32F303xB/C, STM32F358xC) */
226 #define LL_COMP_HYSTERESIS_HIGH         (COMP_CSR_COMPxHYST_1 | COMP_CSR_COMPxHYST_0) /*!< Hysteresis level high (available only on devices: STM32F303xB/C, STM32F358xC) */
227 #endif
228 /**
229   * @}
230   */
231 
232 /** @defgroup COMP_LL_EC_OUTPUT_SELECTION Comparator output - Output selection
233   * @{
234   */
235 #define LL_COMP_OUTPUT_NONE             ((uint32_t)0x00000000)                                                      /*!< COMP output is not connected to other peripherals (except GPIO and EXTI that are always connected to COMP output) (specific to COMP instance: COMP2) */
236 #if defined(COMP_CSR_COMPxOUT)
237 /* Note: Output redirection common to all COMP instances, all STM32F3 series   */
238 /*       devices.                                                             */
239 #define LL_COMP_OUTPUT_TIM1_BKIN        (COMP_CSR_COMPxOUTSEL_0)                                                    /*!< COMP output connected to TIM1 break input (BKIN) */
240 #define LL_COMP_OUTPUT_TIM1_BKIN2       (COMP_CSR_COMPxOUTSEL_1)                                                    /*!< COMP output connected to TIM1 break input 2 (BKIN2) */
241 
242 #if defined(STM32F301x8) || defined(STM32F318xx)
243 /* Note: Output redirection specific to COMP instance: COMP2 */
244 #define LL_COMP_OUTPUT_TIM1_IC1_COMP2    (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM1 input capture 1 (specific to COMP instance: COMP2) */
245 #define LL_COMP_OUTPUT_TIM2_IC4_COMP2    (COMP_CSR_COMPxOUTSEL_3)                                                   /*!< COMP output connected to TIM1 input capture 4 (specific to COMP instance: COMP2) */
246 #define LL_COMP_OUTPUT_TIM1_OCCLR_COMP2  (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM1 OCREF clear (specific to COMP instance: COMP2) */
247 #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP2  (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0)                          /*!< COMP output connected to TIM2 OCREF clear (specific to COMP instance: COMP2) */
248 /* Note: Output redirection specific to COMP instance: COMP4 */
249 #define LL_COMP_OUTPUT_TIM15_IC2_COMP4   (COMP_CSR_COMPxOUTSEL_3)                                                   /*!< COMP output connected to TIM15 input capture 1 (specific to COMP instance: COMP4) */
250 #define LL_COMP_OUTPUT_TIM15_OCCLR_COMP4 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM15 OCREF clear (specific to COMP instance: COMP4) */
251 /* Note: Output redirection specific to COMP instance: COMP6 */
252 #define LL_COMP_OUTPUT_TIM2_IC2_COMP6    (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM2 input capture 2 (specific to COMP instance: COMP6) */
253 #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP6  (COMP_CSR_COMPxOUTSEL_3)                                                   /*!< COMP output connected to TIM2 OCREF clear (specific to COMP instance: COMP6) */
254 #define LL_COMP_OUTPUT_TIM16_IC1_COMP6   (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM16 input capture 1 (specific to COMP instance: COMP6) */
255 #define LL_COMP_OUTPUT_TIM16_OCCLR_COMP6 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0)                          /*!< COMP output connected to TIM16 OCREF clear (specific to COMP instance: COMP6) */
256 
257 /* Note: Output redirection specific to COMP instances, defined with          */
258 /*       generic naming not taking into account COMP instance constraints.    */
259 /*       Refer to literal definitions above for COMP instance constraints.    */
260 /* Note: Some output redirections cannot have a generic naming,               */
261 /*       due to literal value different depending on COMP instance.           */
262 /*       (For example: LL_COMP_OUTPUT_TIM2_OCCLR_COMP2 and                    */
263 /*       LL_COMP_OUTPUT_TIM2_OCCLR_COMP6).                                    */
264 #define LL_COMP_OUTPUT_TIM1_IC1          LL_COMP_OUTPUT_TIM1_IC1_COMP2         /*!< COMP output connected to TIM1 input capture 1.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
265 #define LL_COMP_OUTPUT_TIM1_OCCLR        LL_COMP_OUTPUT_TIM1_OCCLR_COMP2       /*!< COMP output connected to TIM1 OCREF clear.         Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
266 #define LL_COMP_OUTPUT_TIM2_IC2          LL_COMP_OUTPUT_TIM2_IC2_COMP6         /*!< COMP output connected to TIM2 input capture 2.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
267 #define LL_COMP_OUTPUT_TIM2_IC4          LL_COMP_OUTPUT_TIM2_IC4_COMP2         /*!< COMP output connected to TIM2 input capture 4.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
268 #define LL_COMP_OUTPUT_TIM15_IC2         LL_COMP_OUTPUT_TIM15_IC2_COMP4        /*!< COMP output connected to TIM15 input capture 1.    Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
269 #define LL_COMP_OUTPUT_TIM15_OCCLR       LL_COMP_OUTPUT_TIM15_OCCLR_COMP4      /*!< COMP output connected to TIM15 OCREF clear.        Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
270 #define LL_COMP_OUTPUT_TIM16_IC1         LL_COMP_OUTPUT_TIM16_IC1_COMP6        /*!< COMP output connected to TIM16 input capture 1.    Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
271 #define LL_COMP_OUTPUT_TIM16_OCCLR       LL_COMP_OUTPUT_TIM16_OCCLR_COMP6      /*!< COMP output connected to TIM16 OCREF clear.        Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
272 /* Note: Output redirection specific to COMP instances, defined with          */
273 /*       partially generic naming grouping COMP instance constraints.         */
274 /*       Refer to literal definitions above for COMP instance constraints.    */
275 #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3  LL_COMP_OUTPUT_TIM2_OCCLR_COMP2   /*!< COMP output connected to TIM2 OCREF clear.         Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
276 
277 #elif defined(STM32F303x8) || defined(STM32F328xx) || defined(STM32F334x8)|| defined(STM32F302x8)
278 /* Note: Output redirection specific to COMP instance: COMP2, COMP4 */
279 #define LL_COMP_OUTPUT_TIM3_OCCLR_COMP2_4 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM3 OCREF clear (specific to COMP instance: COMP2, COMP4) */
280 /* Note: Output redirection specific to COMP instance: COMP2 */
281 #define LL_COMP_OUTPUT_TIM1_IC1_COMP2    (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM1 input capture 1 (specific to COMP instance: COMP2) */
282 #define LL_COMP_OUTPUT_TIM2_IC4_COMP2    (COMP_CSR_COMPxOUTSEL_3)                                                   /*!< COMP output connected to TIM1 input capture 4 (specific to COMP instance: COMP2) */
283 #define LL_COMP_OUTPUT_TIM1_OCCLR_COMP2  (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM1 OCREF clear (specific to COMP instance: COMP2) */
284 #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP2  (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0)                          /*!< COMP output connected to TIM2 OCREF clear (specific to COMP instance: COMP2) */
285 #define LL_COMP_OUTPUT_TIM3_IC1_COMP2    (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM3 input capture 1 (specific to COMP instance: COMP2) */
286 /* Note: Output redirection specific to COMP instance: COMP4 */
287 #define LL_COMP_OUTPUT_TIM3_IC3_COMP4    (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM3 input capture 3 (specific to COMP instance: COMP4) */
288 #define LL_COMP_OUTPUT_TIM15_IC2_COMP4   (COMP_CSR_COMPxOUTSEL_3)                                                   /*!< COMP output connected to TIM15 input capture 1 (specific to COMP instance: COMP4) */
289 #define LL_COMP_OUTPUT_TIM15_OCCLR_COMP4 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM15 OCREF clear (specific to COMP instance: COMP4) */
290 /* Note: Output redirection specific to COMP instance: COMP6 */
291 #define LL_COMP_OUTPUT_TIM2_IC2_COMP6    (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM2 input capture 2 (specific to COMP instance: COMP6) */
292 #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP6  (COMP_CSR_COMPxOUTSEL_3)                                                   /*!< COMP output connected to TIM2 OCREF clear (specific to COMP instance: COMP6) */
293 #define LL_COMP_OUTPUT_TIM16_IC1_COMP6   (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM16 input capture 1 (specific to COMP instance: COMP6) */
294 #define LL_COMP_OUTPUT_TIM16_OCCLR_COMP6 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0)                          /*!< COMP output connected to TIM16 OCREF clear (specific to COMP instance: COMP6) */
295 
296 /* Note: Output redirection specific to COMP instances, defined with          */
297 /*       generic naming not taking into account COMP instance constraints.    */
298 /*       Refer to literal definitions above for COMP instance constraints.    */
299 /* Note: Some output redirections cannot have a generic naming,               */
300 /*       due to literal value different depending on COMP instance.           */
301 /*       (For example: LL_COMP_OUTPUT_TIM2_OCCLR_COMP2 and                    */
302 /*       LL_COMP_OUTPUT_TIM2_OCCLR_COMP6).                                    */
303 #define LL_COMP_OUTPUT_TIM1_IC1          LL_COMP_OUTPUT_TIM1_IC1_COMP2         /*!< COMP output connected to TIM1 input capture 1.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
304 #define LL_COMP_OUTPUT_TIM1_OCCLR        LL_COMP_OUTPUT_TIM1_OCCLR_COMP2       /*!< COMP output connected to TIM1 OCREF clear.         Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
305 #define LL_COMP_OUTPUT_TIM2_IC2          LL_COMP_OUTPUT_TIM2_IC2_COMP6         /*!< COMP output connected to TIM2 input capture 2.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
306 #define LL_COMP_OUTPUT_TIM2_IC4          LL_COMP_OUTPUT_TIM2_IC4_COMP2         /*!< COMP output connected to TIM2 input capture 4.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
307 #define LL_COMP_OUTPUT_TIM3_IC1          LL_COMP_OUTPUT_TIM3_IC1_COMP2         /*!< COMP output connected to TIM3 input capture 1.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
308 #define LL_COMP_OUTPUT_TIM3_IC3          LL_COMP_OUTPUT_TIM3_IC3_COMP4         /*!< COMP output connected to TIM3 input capture 3.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
309 #define LL_COMP_OUTPUT_TIM3_OCCLR        LL_COMP_OUTPUT_TIM3_OCCLR_COMP2_4     /*!< COMP output connected to TIM3 OCREF clear.         Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
310 #define LL_COMP_OUTPUT_TIM15_IC2         LL_COMP_OUTPUT_TIM15_IC2_COMP4        /*!< COMP output connected to TIM15 input capture 1.    Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
311 #define LL_COMP_OUTPUT_TIM15_OCCLR       LL_COMP_OUTPUT_TIM15_OCCLR_COMP4      /*!< COMP output connected to TIM15 OCREF clear.        Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
312 #define LL_COMP_OUTPUT_TIM16_IC1         LL_COMP_OUTPUT_TIM16_IC1_COMP6        /*!< COMP output connected to TIM16 input capture 1.    Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
313 #define LL_COMP_OUTPUT_TIM16_OCCLR       LL_COMP_OUTPUT_TIM16_OCCLR_COMP6      /*!< COMP output connected to TIM16 OCREF clear.        Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
314 /* Note: Output redirection specific to COMP instances, defined with          */
315 /*       partially generic naming grouping COMP instance constraints.         */
316 /*       Refer to literal definitions above for COMP instance constraints.    */
317 #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3  LL_COMP_OUTPUT_TIM2_OCCLR_COMP2   /*!< COMP output connected to TIM2 OCREF clear.         Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
318 
319 #elif defined(STM32F302xC) || defined(STM32F302xE)
320 /* Note: Output redirection specific to COMP instance: COMP1, COMP2, COMP4 */
321 #define LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM3 OCREF clear (specific to COMP instance: COMP2, COMP4) */
322 /* Note: Output redirection specific to COMP instance: COMP1, COMP2 */
323 #define LL_COMP_OUTPUT_TIM1_IC1_COMP1_2    (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM1 input capture 1 (specific to COMP instance: COMP2) */
324 #define LL_COMP_OUTPUT_TIM2_IC4_COMP1_2    (COMP_CSR_COMPxOUTSEL_3)                                                   /*!< COMP output connected to TIM2 input capture 4 (specific to COMP instance: COMP2) */
325 #define LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2  (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM1 OCREF clear (specific to COMP instance: COMP2) */
326 #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2  (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0)                          /*!< COMP output connected to TIM2 OCREF clear (specific to COMP instance: COMP2) */
327 #define LL_COMP_OUTPUT_TIM3_IC1_COMP1_2    (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM3 input capture 1 (specific to COMP instance: COMP2) */
328 /* Note: Output redirection specific to COMP instance: COMP4 */
329 #define LL_COMP_OUTPUT_TIM3_IC3_COMP4      (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM3 input capture 3 (specific to COMP instance: COMP4) */
330 #define LL_COMP_OUTPUT_TIM4_IC2_COMP4      (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0)                          /*!< COMP output connected to TIM4 input capture 2 (specific to COMP instance: COMP4) */
331 #define LL_COMP_OUTPUT_TIM15_IC2_COMP4     (COMP_CSR_COMPxOUTSEL_3)                                                   /*!< COMP output connected to TIM15 input capture 1 (specific to COMP instance: COMP4) */
332 #define LL_COMP_OUTPUT_TIM15_OCCLR_COMP4   (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM15 OCREF clear (specific to COMP instance: COMP4) */
333 /* Note: Output redirection specific to COMP instance: COMP6 */
334 #define LL_COMP_OUTPUT_TIM2_IC2_COMP6      (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM2 input capture 2 (specific to COMP instance: COMP6) */
335 #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP6    (COMP_CSR_COMPxOUTSEL_3)                                                   /*!< COMP output connected to TIM2 OCREF clear (specific to COMP instance: COMP6) */
336 #define LL_COMP_OUTPUT_TIM4_IC4_COMP6      (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM4 input capture 4 (specific to COMP instance: COMP6) */
337 #define LL_COMP_OUTPUT_TIM16_IC1_COMP6     (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM16 input capture 1 (specific to COMP instance: COMP6) */
338 #define LL_COMP_OUTPUT_TIM16_OCCLR_COMP6   (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM16 OCREF clear (specific to COMP instance: COMP6) */
339 
340 /* Note: Output redirection specific to COMP instances, defined with          */
341 /*       generic naming not taking into account COMP instance constraints.    */
342 /*       Refer to literal definitions above for COMP instance constraints.    */
343 /* Note: Some output redirections cannot have a generic naming,               */
344 /*       due to literal value different depending on COMP instance.           */
345 /*       (For example: LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2 and                  */
346 /*       LL_COMP_OUTPUT_TIM2_OCCLR_COMP6).                                    */
347 #define LL_COMP_OUTPUT_TIM1_IC1          LL_COMP_OUTPUT_TIM1_IC1_COMP1_2       /*!< COMP output connected to TIM1 input capture 1.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
348 #define LL_COMP_OUTPUT_TIM1_OCCLR        LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2     /*!< COMP output connected to TIM1 OCREF clear.         Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
349 #define LL_COMP_OUTPUT_TIM2_IC2          LL_COMP_OUTPUT_TIM2_IC2_COMP6         /*!< COMP output connected to TIM2 input capture 2.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
350 #define LL_COMP_OUTPUT_TIM2_IC4          LL_COMP_OUTPUT_TIM2_IC4_COMP1_2       /*!< COMP output connected to TIM2 input capture 4.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
351 #define LL_COMP_OUTPUT_TIM3_IC1          LL_COMP_OUTPUT_TIM3_IC1_COMP1_2       /*!< COMP output connected to TIM3 input capture 1.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
352 #define LL_COMP_OUTPUT_TIM3_IC3          LL_COMP_OUTPUT_TIM3_IC3_COMP4         /*!< COMP output connected to TIM3 input capture 3.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
353 #define LL_COMP_OUTPUT_TIM3_OCCLR        LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4   /*!< COMP output connected to TIM3 OCREF clear.         Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
354 #define LL_COMP_OUTPUT_TIM4_IC2          LL_COMP_OUTPUT_TIM4_IC2_COMP4         /*!< COMP output connected to TIM4 input capture 2.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
355 #define LL_COMP_OUTPUT_TIM4_IC4          LL_COMP_OUTPUT_TIM4_IC4_COMP6         /*!< COMP output connected to TIM4 input capture 4.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
356 #define LL_COMP_OUTPUT_TIM15_IC2         LL_COMP_OUTPUT_TIM15_IC2_COMP4        /*!< COMP output connected to TIM15 input capture 1.    Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
357 #define LL_COMP_OUTPUT_TIM15_OCCLR       LL_COMP_OUTPUT_TIM15_OCCLR_COMP4      /*!< COMP output connected to TIM15 OCREF clear.        Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
358 #define LL_COMP_OUTPUT_TIM16_IC1         LL_COMP_OUTPUT_TIM16_IC1_COMP6        /*!< COMP output connected to TIM16 input capture 1.    Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
359 #define LL_COMP_OUTPUT_TIM16_OCCLR       LL_COMP_OUTPUT_TIM16_OCCLR_COMP6      /*!< COMP output connected to TIM16 OCREF clear.        Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
360 /* Note: Output redirection specific to COMP instances, defined with          */
361 /*       partially generic naming grouping COMP instance constraints.         */
362 /*       Refer to literal definitions above for COMP instance constraints.    */
363 #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3  LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2   /*!< COMP output connected to TIM2 OCREF clear.         Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
364 
365 #elif defined(STM32F303xC) || defined(STM32F358xx) || defined(STM32F303xE) || defined(STM32F398xx)
366 /* Note: Output redirection common to all COMP instances */
367 #define LL_COMP_OUTPUT_TIM8_BKIN         (COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0)                          /*!< COMP output connected to TIM8 break input (BKIN) */
368 #define LL_COMP_OUTPUT_TIM8_BKIN2        (COMP_CSR_COMPxOUTSEL_2)                                                   /*!< COMP output connected to TIM8 break input 2 (BKIN2) */
369 #define LL_COMP_OUTPUT_TIM1_TIM8_BKIN2   (COMP_CSR_COMPxOUTSEL_2| COMP_CSR_COMPxOUTSEL_0)                           /*!< COMP output connected to TIM1 break input 2 and TIM8 break input 2 (BKIN2) */
370 #if defined(STM32F303xE) || defined(STM32F398xx)
371 #define LL_COMP_OUTPUT_TIM20_BKIN        (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_2)                          /*!< COMP output connected to TIM8 break input (BKIN) */
372 #define LL_COMP_OUTPUT_TIM20_BKIN2       (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM8 break input 2 (BKIN2) */
373 #define LL_COMP_OUTPUT_TIM1_TIM8_TIM20_BKIN2 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_2| COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM1 break input 2, TIM8 break input 2 and TIM20 break input 2 (BKIN2) */
374 #endif
375 /* Note: Output redirection specific to COMP instance: COMP1, COMP2, COMP3, COMP7 */
376 #define LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2_3_7 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM1 OCREF clear (specific to COMP instance: COMP1, COMP2, COMP3, COMP7) */
377 /* Note: Output redirection specific to COMP instance: COMP1, COMP2, COMP3 */
378 #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0)                          /*!< COMP output connected to TIM2 OCREF clear (specific to COMP instance: COMP1, COMP2, COMP3) */
379 /* Note: Output redirection specific to COMP instance: COMP1, COMP2, COMP4, COMP5 */
380 #define LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4_5 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM3 OCREF clear (specific to COMP instance: COMP1, COMP2, COMP4, COMP5) */
381 /* Note: Output redirection specific to COMP instance: COMP4, COMP5, COMP6, COMP7 */
382 #define LL_COMP_OUTPUT_TIM8_OCCLR_COMP4_5_6_7 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM8 OCREF clear (specific to COMP instance: COMP4, COMP5, COMP6, COMP7) */
383 /* Note: Output redirection specific to COMP instance: COMP1, COMP2 */
384 #define LL_COMP_OUTPUT_TIM1_IC1_COMP1_2  (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM1 input capture 1 (specific to COMP instance: COMP2) */
385 #define LL_COMP_OUTPUT_TIM2_IC4_COMP1_2  (COMP_CSR_COMPxOUTSEL_3)                                                   /*!< COMP output connected to TIM2 input capture 4 (specific to COMP instance: COMP2) */
386 #define LL_COMP_OUTPUT_TIM3_IC1_COMP1_2  (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM3 input capture 1 (specific to COMP instance: COMP2) */
387 #if defined(STM32F303xE) || defined(STM32F398xx)
388 #define LL_COMP_OUTPUT_TIM20_OCCLR_COMP2 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM20 OCREF clear (specific to COMP instance: COMP2) */
389 #endif
390 /* Note: Output redirection specific to COMP instance: COMP3 */
391 #define LL_COMP_OUTPUT_TIM3_IC2_COMP3    (COMP_CSR_COMPxOUTSEL_3)                                                   /*!< COMP output connected to TIM3 input capture 2 (specific to COMP instance: COMP3) */
392 #define LL_COMP_OUTPUT_TIM4_IC1_COMP3    (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM4 input capture 1 (specific to COMP instance: COMP3) */
393 #define LL_COMP_OUTPUT_TIM15_IC1_COMP3   (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM15 input capture 1 (specific to COMP instance: COMP3) */
394 #define LL_COMP_OUTPUT_TIM15_BKIN_COMP3  (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM15 break input (BKIN) */
395 /* Note: Output redirection specific to COMP instance: COMP4 */
396 #define LL_COMP_OUTPUT_TIM3_IC3_COMP4    (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM3 input capture 3 (specific to COMP instance: COMP4) */
397 #define LL_COMP_OUTPUT_TIM4_IC2_COMP4    (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0)                          /*!< COMP output connected to TIM4 input capture 2 (specific to COMP instance: COMP4) */
398 #define LL_COMP_OUTPUT_TIM15_IC2_COMP4   (COMP_CSR_COMPxOUTSEL_3)                                                   /*!< COMP output connected to TIM15 input capture 1 (specific to COMP instance: COMP4) */
399 #define LL_COMP_OUTPUT_TIM15_OCCLR_COMP4 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM15 OCREF clear (specific to COMP instance: COMP4) */
400 /* Note: Output redirection specific to COMP instance: COMP5 */
401 #define LL_COMP_OUTPUT_TIM2_IC1_COMP5    (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM2 input capture 1 (specific to COMP instance: COMP5) */
402 #define LL_COMP_OUTPUT_TIM4_IC3_COMP5    (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0)                          /*!< COMP output connected to TIM4 input capture 3 (specific to COMP instance: COMP5) */
403 #define LL_COMP_OUTPUT_TIM17_IC1_COMP5   (COMP_CSR_COMPxOUTSEL_3)                                                   /*!< COMP output connected to TIM17 input capture 1 (specific to COMP instance: COMP5) */
404 #define LL_COMP_OUTPUT_TIM16_BKIN_COMP5  (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM16 break input (BKIN) */
405 /* Note: Output redirection specific to COMP instance: COMP6 */
406 #define LL_COMP_OUTPUT_TIM2_IC2_COMP6    (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM2 input capture 2 (specific to COMP instance: COMP6) */
407 #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP6  (COMP_CSR_COMPxOUTSEL_3)                                                   /*!< COMP output connected to TIM2 OCREF clear (specific to COMP instance: COMP6) */
408 #define LL_COMP_OUTPUT_TIM4_IC4_COMP6    (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM4 input capture 4 (specific to COMP instance: COMP6) */
409 #define LL_COMP_OUTPUT_TIM16_IC1_COMP6   (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM16 input capture 1 (specific to COMP instance: COMP6) */
410 #define LL_COMP_OUTPUT_TIM16_OCCLR_COMP6 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM16 OCREF clear (specific to COMP instance: COMP6) */
411 /* Note: Output redirection specific to COMP instance: COMP7 */
412 #define LL_COMP_OUTPUT_TIM1_IC2_COMP7    (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0)                          /*!< COMP output connected to TIM2 input capture 1 (specific to COMP instance: COMP7) */
413 #define LL_COMP_OUTPUT_TIM2_IC3_COMP7    (COMP_CSR_COMPxOUTSEL_3)                                                   /*!< COMP output connected to TIM4 input capture 3 (specific to COMP instance: COMP7) */
414 #define LL_COMP_OUTPUT_TIM17_OCCLR_COMP7 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1)                          /*!< COMP output connected to TIM17 OCREF clear (specific to COMP instance: COMP7) */
415 #define LL_COMP_OUTPUT_TIM17_BKIN_COMP7  (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM17 break input (BKIN) */
416 
417 /* Note: Output redirection specific to COMP instances, defined with          */
418 /*       generic naming not taking into account COMP instance constraints.    */
419 /*       Refer to literal definitions above for COMP instance constraints.    */
420 /* Note: Some output redirections cannot have a generic naming,               */
421 /*       due to literal value different depending on COMP instance.           */
422 /*       (For example: LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3 and                */
423 /*       LL_COMP_OUTPUT_TIM2_OCCLR_COMP6).                                    */
424 #define LL_COMP_OUTPUT_TIM1_IC1          LL_COMP_OUTPUT_TIM1_IC1_COMP1_2       /*!< COMP output connected to TIM1 input capture 1.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
425 #define LL_COMP_OUTPUT_TIM1_IC2          LL_COMP_OUTPUT_TIM1_IC2_COMP7         /*!< COMP output connected to TIM2 input capture 1.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
426 #define LL_COMP_OUTPUT_TIM1_OCCLR        LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2_3_7 /*!< COMP output connected to TIM1 OCREF clear.         Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
427 #define LL_COMP_OUTPUT_TIM2_IC1          LL_COMP_OUTPUT_TIM2_IC1_COMP5         /*!< COMP output connected to TIM2 input capture 1.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
428 #define LL_COMP_OUTPUT_TIM2_IC2          LL_COMP_OUTPUT_TIM2_IC2_COMP6         /*!< COMP output connected to TIM2 input capture 2.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
429 #define LL_COMP_OUTPUT_TIM2_IC3          LL_COMP_OUTPUT_TIM2_IC3_COMP7         /*!< COMP output connected to TIM4 input capture 3.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
430 #define LL_COMP_OUTPUT_TIM2_IC4          LL_COMP_OUTPUT_TIM2_IC4_COMP1_2       /*!< COMP output connected to TIM2 input capture 4.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
431 #define LL_COMP_OUTPUT_TIM3_IC1          LL_COMP_OUTPUT_TIM3_IC1_COMP1_2       /*!< COMP output connected to TIM3 input capture 1.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
432 #define LL_COMP_OUTPUT_TIM3_IC2          LL_COMP_OUTPUT_TIM3_IC2_COMP3         /*!< COMP output connected to TIM3 input capture 2.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
433 #define LL_COMP_OUTPUT_TIM3_IC3          LL_COMP_OUTPUT_TIM3_IC3_COMP4         /*!< COMP output connected to TIM3 input capture 3.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
434 #define LL_COMP_OUTPUT_TIM3_OCCLR        LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4_5 /*!< COMP output connected to TIM3 OCREF clear.         Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
435 #define LL_COMP_OUTPUT_TIM4_IC1          LL_COMP_OUTPUT_TIM4_IC1_COMP3         /*!< COMP output connected to TIM4 input capture 1.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
436 #define LL_COMP_OUTPUT_TIM4_IC2          LL_COMP_OUTPUT_TIM4_IC2_COMP4         /*!< COMP output connected to TIM4 input capture 2.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
437 #define LL_COMP_OUTPUT_TIM4_IC3          LL_COMP_OUTPUT_TIM4_IC3_COMP5         /*!< COMP output connected to TIM4 input capture 3.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
438 #define LL_COMP_OUTPUT_TIM4_IC4          LL_COMP_OUTPUT_TIM4_IC4_COMP6         /*!< COMP output connected to TIM4 input capture 4.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
439 #define LL_COMP_OUTPUT_TIM8_OCCLR        LL_COMP_OUTPUT_TIM8_OCCLR_COMP4_5_6_7 /*!< COMP output connected to TIM8 OCREF clear.         Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
440 #define LL_COMP_OUTPUT_TIM15_IC1         LL_COMP_OUTPUT_TIM15_IC1_COMP3        /*!< COMP output connected to TIM15 input capture 1.    Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
441 #define LL_COMP_OUTPUT_TIM15_IC2         LL_COMP_OUTPUT_TIM15_IC2_COMP4        /*!< COMP output connected to TIM15 input capture 1.    Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
442 #define LL_COMP_OUTPUT_TIM15_BKIN        LL_COMP_OUTPUT_TIM15_BKIN_COMP3       /*!< COMP output connected to TIM15 break input (BKIN). Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
443 #define LL_COMP_OUTPUT_TIM15_OCCLR       LL_COMP_OUTPUT_TIM15_OCCLR_COMP4      /*!< COMP output connected to TIM15 OCREF clear.        Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
444 #define LL_COMP_OUTPUT_TIM16_IC1         LL_COMP_OUTPUT_TIM16_IC1_COMP6        /*!< COMP output connected to TIM16 input capture 1.    Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
445 #define LL_COMP_OUTPUT_TIM16_BKIN        LL_COMP_OUTPUT_TIM16_BKIN_COMP5       /*!< COMP output connected to TIM16 break input (BKIN). Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
446 #define LL_COMP_OUTPUT_TIM16_OCCLR       LL_COMP_OUTPUT_TIM16_OCCLR_COMP6      /*!< COMP output connected to TIM16 OCREF clear.        Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
447 #define LL_COMP_OUTPUT_TIM17_IC1         LL_COMP_OUTPUT_TIM17_IC1_COMP5        /*!< COMP output connected to TIM17 input capture 1.    Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
448 #define LL_COMP_OUTPUT_TIM17_BKIN        LL_COMP_OUTPUT_TIM17_BKIN_COMP7       /*!< COMP output connected to TIM17 break input (BKIN). Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
449 #define LL_COMP_OUTPUT_TIM17_OCCLR       LL_COMP_OUTPUT_TIM17_OCCLR_COMP7      /*!< COMP output connected to TIM17 OCREF clear.        Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
450 #if defined(STM32F303xE) || defined(STM32F398xx)
451 #define LL_COMP_OUTPUT_TIM20_OCCLR       LL_COMP_OUTPUT_TIM20_OCCLR_COMP2      /*!< COMP output connected to TIM20 OCREF clear.        Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
452 #endif
453 
454 #endif
455 #endif
456 /**
457   * @}
458   */
459 
460 /** @defgroup COMP_LL_EC_OUTPUT_POLARITY Comparator output - Output polarity
461   * @{
462   */
463 #define LL_COMP_OUTPUTPOL_NONINVERTED   ((uint32_t)0x00000000U) /*!< 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 */
464 #define LL_COMP_OUTPUTPOL_INVERTED      (COMP_CSR_COMPxPOL)     /*!< 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 */
465 /**
466   * @}
467   */
468 
469 /** @defgroup COMP_LL_EC_OUTPUT_BLANKING_SOURCE Comparator output - Blanking source
470   * @{
471   */
472 #define LL_COMP_BLANKINGSRC_NONE        ((uint32_t)0x00000000U)                                   /*!<Comparator output without blanking */
473 #if defined(COMP_CSR_COMPxBLANKING)
474 #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx) || defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
475 /* Note: Output blanking source specific to COMP instance: COMP2 */
476 #define LL_COMP_BLANKINGSRC_TIM1_OC5_COMP2  (COMP_CSR_COMPxBLANKING_0)                            /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP2) */
477 #define LL_COMP_BLANKINGSRC_TIM2_OC3_COMP2  (COMP_CSR_COMPxBLANKING_1)                            /*!< Comparator output blanking source TIM2 OC3 (specific to COMP instance: COMP2) */
478 #define LL_COMP_BLANKINGSRC_TIM3_OC3_COMP2  (COMP_CSR_COMPxBLANKING_1 | COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP2) */
479 /* Note: Output blanking source specific to COMP instance: COMP4 */
480 #define LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4  (COMP_CSR_COMPxBLANKING_0)                            /*!< Comparator output blanking source TIM3 OC4 (specific to COMP instance: COMP4) */
481 #define LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4 (COMP_CSR_COMPxBLANKING_0 | COMP_CSR_COMPxBLANKING_1) /*!< Comparator output blanking source TIM15 OC1 (specific to COMP instance: COMP4) */
482 /* Note: Output blanking source specific to COMP instance: COMP6 */
483 #define LL_COMP_BLANKINGSRC_TIM2_OC4_COMP6  (COMP_CSR_COMPxBLANKING_0 | COMP_CSR_COMPxBLANKING_1) /*!< Comparator output blanking source TIM2 OC4 (specific to COMP instance: COMP6) */
484 #define LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6 (COMP_CSR_COMPxBLANKING_0)                            /*!< Comparator output blanking source TIM15 OC2 (specific to COMP instance: COMP6) */
485 
486 /* Note: Output blanking source specific to COMP instances, defined with      */
487 /*       generic naming not taking into account COMP instance constraints.    */
488 /*       Refer to literal definitions above for COMP instance constraints.    */
489 #define LL_COMP_BLANKINGSRC_TIM1_OC5     LL_COMP_BLANKINGSRC_TIM1_OC5_COMP2                        /*!< Comparator output blanking source TIM1 OC5.  Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
490 #define LL_COMP_BLANKINGSRC_TIM2_OC3     LL_COMP_BLANKINGSRC_TIM2_OC3_COMP2                        /*!< Comparator output blanking source TIM2 OC3.  Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
491 #define LL_COMP_BLANKINGSRC_TIM2_OC4     LL_COMP_BLANKINGSRC_TIM2_OC4_COMP6                        /*!< Comparator output blanking source TIM2 OC4.  Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
492 #define LL_COMP_BLANKINGSRC_TIM3_OC3     LL_COMP_BLANKINGSRC_TIM3_OC3_COMP2                        /*!< Comparator output blanking source TIM3 OC3.  Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
493 #define LL_COMP_BLANKINGSRC_TIM3_OC4     LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4                        /*!< Comparator output blanking source TIM3 OC4.  Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
494 #define LL_COMP_BLANKINGSRC_TIM15_OC1    LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4                       /*!< Comparator output blanking source TIM15 OC1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
495 #define LL_COMP_BLANKINGSRC_TIM15_OC2    LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6                       /*!< Comparator output blanking source TIM15 OC2. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
496 
497 #elif defined(STM32F302xE) || defined(STM32F302xC)
498 /* Note: Output blanking source specific to COMP instance: COMP1, COMP2 */
499 #define LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2 (COMP_CSR_COMPxBLANKING_0)                            /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP1, COMP2) */
500 #define LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1_2 (COMP_CSR_COMPxBLANKING_1)                            /*!< Comparator output blanking source TIM2 OC3 (specific to COMP instance: COMP1, COMP2) */
501 #define LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1_2 (COMP_CSR_COMPxBLANKING_1 | COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP1, COMP2) */
502 /* Note: Output blanking source specific to COMP instance: COMP4 */
503 #define LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4  (COMP_CSR_COMPxBLANKING_0)                             /*!< Comparator output blanking source TIM3 OC4 (specific to COMP instance: COMP4) */
504 #define LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4 (COMP_CSR_COMPxBLANKING_0 | COMP_CSR_COMPxBLANKING_1)  /*!< Comparator output blanking source TIM15 OC1 (specific to COMP instance: COMP4) */
505 /* Note: Output blanking source specific to COMP instance: COMP6 */
506 #define LL_COMP_BLANKINGSRC_TIM2_OC4_COMP6  (COMP_CSR_COMPxBLANKING_0 | COMP_CSR_COMPxBLANKING_1)  /*!< Comparator output blanking source TIM2 OC4 (specific to COMP instance: COMP6) */
507 #define LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6 (COMP_CSR_COMPxBLANKING_0)                             /*!< Comparator output blanking source TIM15 OC2 (specific to COMP instance: COMP6) */
508 
509 /* Note: Output blanking source specific to COMP instances, defined with      */
510 /*       generic naming not taking into account COMP instance constraints.    */
511 /*       Refer to literal definitions above for COMP instance constraints.    */
512 #define LL_COMP_BLANKINGSRC_TIM1_OC5     LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2                      /*!< Comparator output blanking source TIM1 OC5.  Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
513 #define LL_COMP_BLANKINGSRC_TIM2_OC3     LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1_2                      /*!< Comparator output blanking source TIM2 OC3.  Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
514 #define LL_COMP_BLANKINGSRC_TIM2_OC4     LL_COMP_BLANKINGSRC_TIM2_OC4_COMP6                        /*!< Comparator output blanking source TIM2 OC4.  Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
515 #define LL_COMP_BLANKINGSRC_TIM3_OC3     LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1_2                      /*!< Comparator output blanking source TIM3 OC3.  Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
516 #define LL_COMP_BLANKINGSRC_TIM3_OC4     LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4                        /*!< Comparator output blanking source TIM3 OC4.  Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
517 #define LL_COMP_BLANKINGSRC_TIM15_OC1    LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4                       /*!< Comparator output blanking source TIM15 OC1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
518 #define LL_COMP_BLANKINGSRC_TIM15_OC2    LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6                       /*!< Comparator output blanking source TIM15 OC2. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
519 
520 #elif defined(STM32F303xE) || defined(STM32F398xx) || defined(STM32F303xC) || defined(STM32F358xx)
521 /* Note: Output blanking source specific to COMP instance: COMP1, COMP2, COMP7 */
522 #define LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2_7 (COMP_CSR_COMPxBLANKING_0)                          /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP1, COMP2, COMP7) */
523 /* Note: Output blanking source specific to COMP instance: COMP1, COMP2 */
524 #define LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1_2 (COMP_CSR_COMPxBLANKING_1)                            /*!< Comparator output blanking source TIM2 OC3 (specific to COMP instance: COMP1, COMP2) */
525 #define LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1_2 (COMP_CSR_COMPxBLANKING_1 | COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP1, COMP2) */
526 /* Note: Output blanking source specific to COMP instance: COMP3, COMP6 */
527 #define LL_COMP_BLANKINGSRC_TIM2_OC4_COMP3_6 (COMP_CSR_COMPxBLANKING_1 | COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM2 OC4 (specific to COMP instance: COMP3, COMP6) */
528 /* Note: Output blanking source specific to COMP instance: COMP4, COMP5, COMP6, COMP7 */
529 #define LL_COMP_BLANKINGSRC_TIM8_OC5_COMP4_5_6_7 (COMP_CSR_COMPxBLANKING_1)                        /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP4, COMP5, COMP6, COMP7) */
530 /* Note: Output blanling source specific to COMP instance: COMP6, COMP7 */
531 #define LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6_7 (COMP_CSR_COMPxBLANKING_2)                           /*!< Comparator output blanking source TIM15 OC2 (specific to COMP instance: COMP6, COMP7) */
532 /* Note: Output blanking source specific to COMP instance: COMP4 */
533 #define LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4   (COMP_CSR_COMPxBLANKING_0)                            /*!< Comparator output blanking source TIM3 OC4 (specific to COMP instance: COMP4) */
534 #define LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4  (COMP_CSR_COMPxBLANKING_1 | COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM15 OC1 (specific to COMP instance: COMP4) */
535 
536 /* Note: Output blanking source specific to COMP instances, defined with      */
537 /*       generic naming not taking into account COMP instance constraints.    */
538 /*       Refer to literal definitions above for COMP instance constraints.    */
539 #define LL_COMP_BLANKINGSRC_TIM1_OC5     LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2_7                    /*!< Comparator output blanking source TIM1 OC5.  Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
540 #define LL_COMP_BLANKINGSRC_TIM2_OC3     LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1_2                      /*!< Comparator output blanking source TIM2 OC3.  Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
541 #define LL_COMP_BLANKINGSRC_TIM2_OC4     LL_COMP_BLANKINGSRC_TIM2_OC4_COMP3_6                      /*!< Comparator output blanking source TIM2 OC4.  Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
542 #define LL_COMP_BLANKINGSRC_TIM3_OC3     LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1_2                      /*!< Comparator output blanking source TIM3 OC3.  Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
543 #define LL_COMP_BLANKINGSRC_TIM3_OC4     LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4                        /*!< Comparator output blanking source TIM3 OC4.  Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
544 #define LL_COMP_BLANKINGSRC_TIM8_OC5     LL_COMP_BLANKINGSRC_TIM8_OC5_COMP4_5_6_7                  /*!< Comparator output blanking source TIM8 OC5.  Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
545 #define LL_COMP_BLANKINGSRC_TIM15_OC1    LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4                       /*!< Comparator output blanking source TIM15 OC1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
546 #define LL_COMP_BLANKINGSRC_TIM15_OC2    LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6_7                     /*!< Comparator output blanking source TIM15 OC2. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
547 
548 #endif
549 #endif
550 /**
551   * @}
552   */
553 
554 /** @defgroup COMP_LL_EC_OUTPUT_LEVEL Comparator output - Output level
555   * @{
556   */
557 #define LL_COMP_OUTPUT_LEVEL_LOW        ((uint32_t)0x00000000U) /*!< Comparator output level low (if the polarity is not inverted, otherwise to be complemented) */
558 #define LL_COMP_OUTPUT_LEVEL_HIGH       ((uint32_t)0x00000001U) /*!< Comparator output level high (if the polarity is not inverted, otherwise to be complemented) */
559 /**
560   * @}
561   */
562 
563 /** @defgroup COMP_LL_EC_HW_DELAYS  Definitions of COMP hardware constraints delays
564   * @note   Only COMP IP HW delays are defined in COMP LL driver driver,
565   *         not timeout values.
566   *         For details on delays values, refer to descriptions in source code
567   *         above each literal definition.
568   * @{
569   */
570 
571 /* Delay for comparator startup time.                                         */
572 /* Note: Delay required to reach propagation delay specification.             */
573 /* Literal set to maximum value (refer to device datasheet,                   */
574 /* parameter "tSTART").                                                       */
575 /* Unit: us                                                                   */
576 #if defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx)
577 #define LL_COMP_DELAY_STARTUP_US          ((uint32_t) 60U)  /*!< Delay for COMP startup time */
578 #else
579 #define LL_COMP_DELAY_STARTUP_US          ((uint32_t) 10U)  /*!< Delay for COMP startup time */
580 #endif
581 
582 /* Delay for comparator voltage scaler stabilization time.                    */
583 /* Note: Voltage scaler is used when selecting comparator input               */
584 /*       based on VrefInt: VrefInt or subdivision of VrefInt.                 */
585 /* Literal set to maximum value (refer to device datasheet,                   */
586 /* parameter "tS_SC").                                                        */
587 /* Unit: us                                                                   */
588 #define LL_COMP_DELAY_VOLTAGE_SCALER_STAB_US ((uint32_t) 200U)  /*!< Delay for COMP voltage scaler stabilization time */
589 
590 /**
591   * @}
592   */
593 
594 /**
595   * @}
596   */
597 
598 /* Exported macro ------------------------------------------------------------*/
599 /** @defgroup COMP_LL_Exported_Macros COMP Exported Macros
600   * @{
601   */
602 /** @defgroup COMP_LL_EM_WRITE_READ Common write and read registers macro
603   * @{
604   */
605 
606 /**
607   * @brief  Write a value in COMP register
608   * @param  __INSTANCE__ comparator instance
609   * @param  __REG__ Register to be written
610   * @param  __VALUE__ Value to be written in the register
611   * @retval None
612   */
613 #define LL_COMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
614 
615 /**
616   * @brief  Read a value in COMP register
617   * @param  __INSTANCE__ comparator instance
618   * @param  __REG__ Register to be read
619   * @retval Register value
620   */
621 #define LL_COMP_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
622 /**
623   * @}
624   */
625 
626 /** @defgroup COMP_LL_EM_HELPER_MACRO COMP helper macro
627   * @{
628   */
629 
630 /**
631   * @brief  Helper macro to select the COMP common instance
632   *         to which is belonging the selected COMP instance.
633   * @note   COMP common register instance can be used to
634   *         set parameters common to several COMP instances.
635   *         Refer to functions having argument "COMPxy_COMMON" as parameter.
636   * @param  __COMPx__ COMP instance
637   * @retval COMP common instance or value "0" if there is no COMP common instance.
638   */
639 #if defined(COMP1) && defined(COMP2) && defined(COMP3) && defined(COMP4) && defined(COMP5) && defined(COMP6) && defined(COMP7)
640 /* Note: On STM32F3 series devices with 7 comparator instances,                */
641 /*       COMP instance COMP7 has no other comparator instance to work         */
642 /*       in pair with: window mode is not available for COMP7.                */
643 #define __LL_COMP_COMMON_INSTANCE(__COMPx__)                                   \
644   ((((__COMPx__) == COMP1) || ((__COMPx__) == COMP2))                          \
645     ? (                                                                        \
646        (COMP12_COMMON)                                                         \
647       )                                                                        \
648       :                                                                        \
649       ((((__COMPx__) == COMP3) || ((__COMPx__) == COMP4))                      \
650         ? (                                                                    \
651            (COMP34_COMMON)                                                     \
652           )                                                                    \
653           :                                                                    \
654           ((((__COMPx__) == COMP5) || ((__COMPx__) == COMP6))                  \
655             ? (                                                                \
656                (COMP56_COMMON)                                                 \
657               )                                                                \
658               :                                                                \
659               (                                                                \
660                ((uint32_t)0U)                                                  \
661               )                                                                \
662           )                                                                    \
663       )                                                                        \
664   )
665 #elif defined(COMP1) && defined(COMP2) && defined(COMP4) && defined(COMP6)
666 #define __LL_COMP_COMMON_INSTANCE(__COMPx__)                                   \
667   ((((__COMPx__) == COMP1) || ((__COMPx__) == COMP2))                          \
668     ? (                                                                        \
669        (COMP12_COMMON)                                                         \
670       )                                                                        \
671       :                                                                        \
672       (                                                                        \
673        ((uint32_t)0U)                                                          \
674       )                                                                        \
675   )
676 #elif defined(COMP2) && defined(COMP4) && defined(COMP6)
677 /* Note: On STM32F3 series devices with 3 comparator instances (COMP2, 4, 6)   */
678 /*       COMP instances have no other comparator instance to work             */
679 /*       in pair with: window mode is not available for all COMP instances.   */
680 #define __LL_COMP_COMMON_INSTANCE(__COMPx__)                                   \
681   ((uint32_t)0U)
682 #endif
683 
684 /**
685   * @}
686   */
687 
688 /**
689   * @}
690   */
691 
692 /* Exported functions --------------------------------------------------------*/
693 /** @defgroup COMP_LL_Exported_Functions COMP Exported Functions
694   * @{
695   */
696 
697 /** @defgroup COMP_LL_EF_Configuration_comparator_common Configuration of COMP hierarchical scope: common to several COMP instances
698   * @{
699   */
700 
701 /**
702   * @brief  Set window mode of a pair of comparators instances
703   *         (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
704   * @rmtoll CSR      COMPxWNDWEN    LL_COMP_SetCommonWindowMode
705   * @param  COMPxy_COMMON Comparator common instance
706   *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
707   * @param  WindowMode This parameter can be one of the following values:
708   *         @arg @ref LL_COMP_WINDOWMODE_DISABLE
709   *         @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (1)
710   *         @arg @ref LL_COMP_WINDOWMODE_COMP3_INPUT_PLUS_COMMON (2)
711   *         @arg @ref LL_COMP_WINDOWMODE_COMP5_INPUT_PLUS_COMMON (2)
712   *
713   *         (1) Parameter available on devices: STM32F302xB/C, STM32F303xB/C, STM32F358xC
714   *         (2) Parameter available on devices: STM32F303xB/C, STM32F358xC
715   * @retval None
716   */
LL_COMP_SetCommonWindowMode(COMP_Common_TypeDef * COMPxy_COMMON,uint32_t WindowMode)717 __STATIC_INLINE void LL_COMP_SetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON, uint32_t WindowMode)
718 {
719 #if defined(COMP_CSR_COMPxWNDWEN)
720   MODIFY_REG(COMPxy_COMMON->CSR, COMP_CSR_COMPxWNDWEN, WindowMode);
721 #else
722   /* Device without pair of comparator working in window mode */
723   /* No update of comparator register (corresponds to setting                 */
724   /* "LL_COMP_WINDOWMODE_DISABLE").                                           */
725 #endif
726 }
727 
728 /**
729   * @brief  Get window mode of a pair of comparators instances
730   *         (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
731   * @rmtoll CSR      COMPxWNDWEN    LL_COMP_GetCommonWindowMode
732   * @param  COMPxy_COMMON Comparator common instance
733   *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
734   * @retval Returned value can be one of the following values:
735   *         @arg @ref LL_COMP_WINDOWMODE_DISABLE
736   *         @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (1)
737   *         @arg @ref LL_COMP_WINDOWMODE_COMP3_INPUT_PLUS_COMMON (2)
738   *         @arg @ref LL_COMP_WINDOWMODE_COMP5_INPUT_PLUS_COMMON (2)
739   *
740   *         (1) Parameter available on devices: STM32F302xB/C, STM32F303xB/C, STM32F358xC
741   *         (2) Parameter available on devices: STM32F303xB/C, STM32F358xC
742   */
LL_COMP_GetCommonWindowMode(COMP_Common_TypeDef * COMPxy_COMMON)743 __STATIC_INLINE uint32_t LL_COMP_GetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON)
744 {
745 #if defined(COMP_CSR_COMPxWNDWEN)
746   return (uint32_t)(READ_BIT(COMPxy_COMMON->CSR, COMP_CSR_COMPxWNDWEN));
747 #else
748   /* Device without pair of comparator working in window mode */
749   return (LL_COMP_WINDOWMODE_DISABLE);
750 #endif
751 }
752 
753 /**
754   * @}
755   */
756 
757 /** @defgroup COMP_LL_EF_Configuration_comparator_modes Configuration of comparator modes
758   * @{
759   */
760 
761 /**
762   * @brief  Set comparator instance operating mode to adjust power and speed.
763   * @rmtoll CSR      COMPxMODE      LL_COMP_SetPowerMode
764   * @param  COMPx Comparator instance
765   * @param  PowerMode This parameter can be one of the following values:
766   *         @arg @ref LL_COMP_POWERMODE_HIGHSPEED
767   *         @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED   (1)
768   *         @arg @ref LL_COMP_POWERMODE_LOWPOWER      (1)
769   *         @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER (1)
770   *
771   *         (1) Parameter available only on devices: STM32F302xB/C, STM32F303xB/C, STM32F358xC
772   * @retval None
773   */
LL_COMP_SetPowerMode(COMP_TypeDef * COMPx,uint32_t PowerMode)774 __STATIC_INLINE void LL_COMP_SetPowerMode(COMP_TypeDef *COMPx, uint32_t PowerMode)
775 {
776 #if defined(COMP_CSR_COMPxMODE)
777   MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxMODE, PowerMode);
778 #else
779   /* Device without comparator power mode configurable */
780   /* No update of comparator register (corresponds to setting                 */
781   /* "LL_COMP_POWERMODE_HIGHSPEED").                                          */
782 #endif
783 }
784 
785 /**
786   * @brief  Get comparator instance operating mode to adjust power and speed.
787   * @rmtoll CSR      COMPxMODE      LL_COMP_GetPowerMode
788   * @param  COMPx Comparator instance
789   * @retval Returned value can be one of the following values:
790   *         @arg @ref LL_COMP_POWERMODE_HIGHSPEED
791   *         @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED   (1)
792   *         @arg @ref LL_COMP_POWERMODE_LOWPOWER      (1)
793   *         @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER (1)
794   *
795   *         (1) Parameter available only on devices: STM32F302xB/C, STM32F303xB/C, STM32F358xC
796   */
LL_COMP_GetPowerMode(COMP_TypeDef * COMPx)797 __STATIC_INLINE uint32_t LL_COMP_GetPowerMode(COMP_TypeDef *COMPx)
798 {
799 #if defined(COMP_CSR_COMPxMODE)
800   return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxMODE));
801 #else
802   /* Device without comparator power mode configurable */
803   return (LL_COMP_POWERMODE_HIGHSPEED);
804 #endif
805 }
806 
807 /**
808   * @}
809   */
810 
811 /** @defgroup COMP_LL_EF_Configuration_comparator_inputs Configuration of comparator inputs
812   * @{
813   */
814 
815 /**
816   * @brief  Set comparator inputs minus (inverting) and plus (non-inverting).
817   * @note   In case of comparator input selected to be connected to IO:
818   *         GPIO pins are specific to each comparator instance.
819   *         Refer to description of parameters or to reference manual.
820   * @note   On this STM32 series, a voltage scaler is used
821   *         when COMP input is based on VrefInt (VrefInt or subdivision
822   *         of VrefInt):
823   *         Voltage scaler requires a delay for voltage stabilization.
824   *         Refer to device datasheet, parameter "tS_SC".
825   * @rmtoll CSR      INMSEL         LL_COMP_ConfigInputs\n
826   *         CSR      NONINSEL       LL_COMP_ConfigInputs
827   * @param  COMPx Comparator instance
828   * @param  InputMinus This parameter can be one of the following values:
829   *         @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
830   *         @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
831   *         @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
832   *         @arg @ref LL_COMP_INPUT_MINUS_VREFINT
833   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
834   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2   (3)
835   *         @arg @ref LL_COMP_INPUT_MINUS_DAC2_CH1   (2)
836   *         @arg @ref LL_COMP_INPUT_MINUS_IO1
837   *         @arg @ref LL_COMP_INPUT_MINUS_IO2
838   *         @arg @ref LL_COMP_INPUT_MINUS_IO3        (1)
839   *         @arg @ref LL_COMP_INPUT_MINUS_IO4
840   *         (1) Parameter available on all devices except STM32F301x6/8, STM32F318x8, STM32F302x6/8, STM32F303x6/8, STM32F328xx, STM32F334xx.\n
841   *         (2) Parameter available only on devices STM32F303x6/8, STM32F328x8, STM32F334xx.\n
842   *         (3) Parameter available on all devices except STM32F301x6/8, STM32F318x8, STM32F302xx.\n
843   * @param  InputPlus This parameter can be one of the following values:
844   *         @arg @ref LL_COMP_INPUT_PLUS_IO1
845   *         @arg @ref LL_COMP_INPUT_PLUS_IO2            (1)
846   *         @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1_COMP1 (2)
847   *         @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1_COMP2 (3)
848   *
849   *         (1) Parameter available only on devices STM32F302xB/C, STM32F303xB/C, STM32F358xC.\n
850   *         (2) Parameter available on devices: STM32F302xB/C, STM32F302xD/E, STM32F303xB/C/D/E, STM32F358xC, STM32F398xE.\n
851   *         (3) Parameter available on devices: STM32F301x6/8, STM32F318xx, STM32F302x6/8.
852   * @retval None
853   */
LL_COMP_ConfigInputs(COMP_TypeDef * COMPx,uint32_t InputMinus,uint32_t InputPlus)854 __STATIC_INLINE void LL_COMP_ConfigInputs(COMP_TypeDef *COMPx, uint32_t InputMinus, uint32_t InputPlus)
855 {
856 #if defined(COMP_CSR_COMPxNONINSEL) && defined(COMP_CSR_COMPxSW1)
857   MODIFY_REG(COMPx->CSR,
858              COMP_CSR_COMPxINSEL | COMP_CSR_COMPxNONINSEL | COMP_CSR_COMPxSW1,
859              InputMinus | InputPlus);
860 #elif defined(COMP_CSR_COMPxNONINSEL)
861   MODIFY_REG(COMPx->CSR,
862              COMP_CSR_COMPxINSEL | COMP_CSR_COMPxNONINSEL,
863              InputMinus | InputPlus);
864 #elif defined(COMP_CSR_COMPxSW1)
865   MODIFY_REG(COMPx->CSR,
866              COMP_CSR_COMPxINSEL | COMP_CSR_COMPxSW1,
867              InputMinus | InputPlus);
868 #else
869   /* Device without comparator input plus configurable */
870   /* No update of comparator register (corresponds to setting                 */
871   /* "LL_COMP_INPUT_PLUS_IO1" or "LL_COMP_INPUT_PLUS_IO2" compared to         */
872   /* other STM32F3 devices, depending on comparator instance                  */
873   /* (refer to reference manual)).                                            */
874   MODIFY_REG(COMPx->CSR,
875              COMP_CSR_COMPxINSEL,
876              InputMinus);
877 #endif
878 }
879 
880 /**
881   * @brief  Set comparator input plus (non-inverting).
882   * @note   In case of comparator input selected to be connected to IO:
883   *         GPIO pins are specific to each comparator instance.
884   *         Refer to description of parameters or to reference manual.
885   * @rmtoll CSR      NONINSEL       LL_COMP_SetInputPlus
886   * @param  COMPx Comparator instance
887   * @param  InputPlus This parameter can be one of the following values:
888   *         @arg @ref LL_COMP_INPUT_PLUS_IO1
889   *         @arg @ref LL_COMP_INPUT_PLUS_IO2            (1)
890   *         @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1_COMP1 (2)
891   *         @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1_COMP2 (3)
892   *
893   *         (1) Parameter available only on devices STM32F302xB/C, STM32F303xB/C, STM32F358xC.\n
894   *         (2) Parameter available on devices: STM32F302xB/C, STM32F302xD/E, STM32F303xB/C/D/E, STM32F358xC, STM32F398xE.\n
895   *         (3) Parameter available on devices: STM32F301x6/8, STM32F318xx, STM32F302x6/8.
896   * @retval None
897   */
LL_COMP_SetInputPlus(COMP_TypeDef * COMPx,uint32_t InputPlus)898 __STATIC_INLINE void LL_COMP_SetInputPlus(COMP_TypeDef *COMPx, uint32_t InputPlus)
899 {
900 #if defined(COMP_CSR_COMPxNONINSEL) && defined(COMP_CSR_COMPxSW1)
901   MODIFY_REG(COMPx->CSR, (COMP_CSR_COMPxNONINSEL | COMP_CSR_COMPxSW1), InputPlus);
902 #elif defined(COMP_CSR_COMPxNONINSEL)
903   MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxNONINSEL, InputPlus);
904 #elif defined(COMP_CSR_COMPxSW1)
905   MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxSW1, InputPlus);
906 #else
907   /* Device without comparator input plus configurable */
908   /* No update of comparator register (corresponds to setting                 */
909   /* "LL_COMP_INPUT_PLUS_IO1" or "LL_COMP_INPUT_PLUS_IO2" compared to         */
910   /* other STM32F3 devices, depending on comparator instance                  */
911   /* (refer to reference manual)).                                            */
912 #endif
913 }
914 
915 /**
916   * @brief  Get comparator input plus (non-inverting).
917   * @note   In case of comparator input selected to be connected to IO:
918   *         GPIO pins are specific to each comparator instance.
919   *         Refer to description of parameters or to reference manual.
920   * @rmtoll CSR      NONINSEL       LL_COMP_GetInputPlus
921   * @param  COMPx Comparator instance
922   * @retval Returned value can be one of the following values:
923   *         @arg @ref LL_COMP_INPUT_PLUS_IO1
924   *         @arg @ref LL_COMP_INPUT_PLUS_IO2            (1)
925   *         @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1_COMP1 (2)
926   *         @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1_COMP2 (3)
927   *
928   *         (1) Parameter available only on devices STM32F302xB/C, STM32F303xB/C, STM32F358xC.\n
929   *         (2) Parameter available on devices: STM32F302xB/C, STM32F302xD/E, STM32F303xB/C/D/E, STM32F358xC, STM32F398xE.\n
930   *         (3) Parameter available on devices: STM32F301x6/8, STM32F318xx, STM32F302x6/8.
931   */
LL_COMP_GetInputPlus(COMP_TypeDef * COMPx)932 __STATIC_INLINE uint32_t LL_COMP_GetInputPlus(COMP_TypeDef *COMPx)
933 {
934 #if defined(COMP_CSR_COMPxNONINSEL) && defined(COMP_CSR_COMPxSW1)
935   return (uint32_t)(READ_BIT(COMPx->CSR, (COMP_CSR_COMPxNONINSEL | COMP_CSR_COMPxSW1)));
936 #elif defined(COMP_CSR_COMPxNONINSEL)
937   return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxNONINSEL));
938 #elif defined(COMP_CSR_COMPxSW1)
939   return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxSW1));
940 #else
941   /* Device without comparator input plus configurable */
942   /* No update of comparator register (corresponds to setting                 */
943   /* "LL_COMP_INPUT_PLUS_IO1" or "LL_COMP_INPUT_PLUS_IO2" compared to         */
944   /* other STM32F3 devices, depending on comparator instance                  */
945   /* (refer to reference manual)).                                            */
946   return (LL_COMP_INPUT_PLUS_IO1);
947 #endif
948 }
949 
950 /**
951   * @brief  Set comparator input minus (inverting).
952   * @note   In case of comparator input selected to be connected to IO:
953   *         GPIO pins are specific to each comparator instance.
954   *         Refer to description of parameters or to reference manual.
955   * @note   On this STM32 series, a voltage scaler is used
956   *         when COMP input is based on VrefInt (VrefInt or subdivision
957   *         of VrefInt):
958   *         Voltage scaler requires a delay for voltage stabilization.
959   *         Refer to device datasheet, parameter "tS_SC".
960   * @rmtoll CSR      INMSEL         LL_COMP_SetInputMinus
961   * @param  COMPx Comparator instance
962   * @param  InputMinus This parameter can be one of the following values:
963   *         @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
964   *         @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
965   *         @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
966   *         @arg @ref LL_COMP_INPUT_MINUS_VREFINT
967   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
968   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2   (3)
969   *         @arg @ref LL_COMP_INPUT_MINUS_DAC2_CH1   (2)
970   *         @arg @ref LL_COMP_INPUT_MINUS_IO1
971   *         @arg @ref LL_COMP_INPUT_MINUS_IO2
972   *         @arg @ref LL_COMP_INPUT_MINUS_IO3        (1)
973   *         @arg @ref LL_COMP_INPUT_MINUS_IO4
974   *         (1) Parameter available on all devices except STM32F301x6/8, STM32F318x8, STM32F302x6/8, STM32F303x6/8, STM32F328xx, STM32F334xx.\n
975   *         (2) Parameter available only on devices STM32F303x6/8, STM32F328x8, STM32F334xx.\n
976   *         (3) Parameter available on all devices except STM32F301x6/8, STM32F318x8, STM32F302xx.\n
977   * @retval None
978   */
LL_COMP_SetInputMinus(COMP_TypeDef * COMPx,uint32_t InputMinus)979 __STATIC_INLINE void LL_COMP_SetInputMinus(COMP_TypeDef *COMPx, uint32_t InputMinus)
980 {
981   MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxINSEL, InputMinus);
982 }
983 
984 /**
985   * @brief  Get comparator input minus (inverting).
986   * @note   In case of comparator input selected to be connected to IO:
987   *         GPIO pins are specific to each comparator instance.
988   *         Refer to description of parameters or to reference manual.
989   * @rmtoll CSR      INMSEL         LL_COMP_GetInputMinus
990   * @param  COMPx Comparator instance
991   * @retval Returned value can be one of the following values:
992   *         @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
993   *         @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
994   *         @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
995   *         @arg @ref LL_COMP_INPUT_MINUS_VREFINT
996   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
997   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2   (3)
998   *         @arg @ref LL_COMP_INPUT_MINUS_DAC2_CH1   (2)
999   *         @arg @ref LL_COMP_INPUT_MINUS_IO1
1000   *         @arg @ref LL_COMP_INPUT_MINUS_IO2
1001   *         @arg @ref LL_COMP_INPUT_MINUS_IO3        (1)
1002   *         @arg @ref LL_COMP_INPUT_MINUS_IO4
1003   *         (1) Parameter available on all devices except STM32F301x6/8, STM32F318x8, STM32F302x6/8, STM32F303x6/8, STM32F328xx, STM32F334xx.\n
1004   *         (2) Parameter available only on devices STM32F303x6/8, STM32F328x8, STM32F334xx.\n
1005   *         (3) Parameter available on all devices except STM32F301x6/8, STM32F318x8, STM32F302xx.\n
1006   */
LL_COMP_GetInputMinus(COMP_TypeDef * COMPx)1007 __STATIC_INLINE uint32_t LL_COMP_GetInputMinus(COMP_TypeDef *COMPx)
1008 {
1009   return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxINSEL));
1010 }
1011 
1012 /**
1013   * @brief  Set comparator instance hysteresis mode of the input minus (inverting input).
1014   * @rmtoll CSR      COMPxHYST      LL_COMP_SetInputHysteresis
1015   * @param  COMPx Comparator instance
1016   * @param  InputHysteresis This parameter can be one of the following values:
1017   *         @arg @ref LL_COMP_HYSTERESIS_NONE
1018   *         @arg @ref LL_COMP_HYSTERESIS_LOW         (1)
1019   *         @arg @ref LL_COMP_HYSTERESIS_MEDIUM      (1)
1020   *         @arg @ref LL_COMP_HYSTERESIS_HIGH        (1)
1021   *
1022   *         (1) Parameter available only on devices: STM32F302xB/C, STM32F303xB/C, STM32F358xC
1023   * @retval None
1024   */
LL_COMP_SetInputHysteresis(COMP_TypeDef * COMPx,uint32_t InputHysteresis)1025 __STATIC_INLINE void LL_COMP_SetInputHysteresis(COMP_TypeDef *COMPx, uint32_t InputHysteresis)
1026 {
1027 #if defined(COMP_CSR_COMPxHYST)
1028   MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxHYST, InputHysteresis);
1029 #else
1030   /* Device without comparator input hysteresis */
1031   /* No update of comparator register (corresponds to setting                 */
1032   /* "LL_COMP_HYSTERESIS_NONE").                                              */
1033 #endif
1034 }
1035 
1036 /**
1037   * @brief  Get comparator instance hysteresis mode of the minus (inverting) input.
1038   * @rmtoll CSR      COMPxHYST      LL_COMP_GetInputHysteresis
1039   * @param  COMPx Comparator instance
1040   * @retval Returned value can be one of the following values:
1041   *         @arg @ref LL_COMP_HYSTERESIS_NONE
1042   *         @arg @ref LL_COMP_HYSTERESIS_LOW         (1)
1043   *         @arg @ref LL_COMP_HYSTERESIS_MEDIUM      (1)
1044   *         @arg @ref LL_COMP_HYSTERESIS_HIGH        (1)
1045   *
1046   *         (1) Parameter available only on devices: STM32F302xB/C, STM32F303xB/C, STM32F358xC
1047   */
LL_COMP_GetInputHysteresis(COMP_TypeDef * COMPx)1048 __STATIC_INLINE uint32_t LL_COMP_GetInputHysteresis(COMP_TypeDef *COMPx)
1049 {
1050 #if defined(COMP_CSR_COMPxHYST)
1051   return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxHYST));
1052 #else
1053   /* Device without comparator input hysteresis */
1054   return (LL_COMP_HYSTERESIS_NONE);
1055 #endif
1056 }
1057 
1058 /**
1059   * @}
1060   */
1061 
1062 /** @defgroup COMP_LL_EF_Configuration_comparator_output Configuration of comparator output
1063   * @{
1064   */
1065 
1066 /**
1067   * @brief  Set comparator output selection.
1068   * @note   Availability of parameters of output selection to timer
1069   *         depends on timers availability on the selected device.
1070   * @rmtoll CSR      COMPxOUTSEL    LL_COMP_SetOutputSelection
1071   * @param  COMPx Comparator instance
1072   * @param  OutputSelection This parameter can be one of the following values:
1073   *         @arg @ref LL_COMP_OUTPUT_NONE
1074   *         @arg @ref LL_COMP_OUTPUT_TIM1_BKIN
1075   *         @arg @ref LL_COMP_OUTPUT_TIM1_BKIN2
1076   *         @arg @ref LL_COMP_OUTPUT_TIM1_TIM8_BKIN2
1077   *         @arg @ref LL_COMP_OUTPUT_TIM8_BKIN              (4)
1078   *         @arg @ref LL_COMP_OUTPUT_TIM8_BKIN2             (4)
1079   *         @arg @ref LL_COMP_OUTPUT_TIM1_TIM8_BKIN2        (4)
1080   *         @arg @ref LL_COMP_OUTPUT_TIM20_BKIN             (5)
1081   *         @arg @ref LL_COMP_OUTPUT_TIM20_BKIN2            (5)
1082   *         @arg @ref LL_COMP_OUTPUT_TIM1_TIM8_TIM20_BKIN2  (5)
1083   *         @arg @ref LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2_3_7 (4)
1084   *         @arg @ref LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3   (4)
1085   *         @arg @ref LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4_5 (4)
1086   *         @arg @ref LL_COMP_OUTPUT_TIM8_OCCLR_COMP4_5_6_7 (4)
1087   *         @arg @ref LL_COMP_OUTPUT_TIM3_OCCLR_COMP2_4     (6)
1088   *         @arg @ref LL_COMP_OUTPUT_TIM1_IC1_COMP2         (2)
1089   *         @arg @ref LL_COMP_OUTPUT_TIM2_IC4_COMP2         (2)
1090   *         @arg @ref LL_COMP_OUTPUT_TIM3_IC1_COMP2         (1)
1091   *         @arg @ref LL_COMP_OUTPUT_TIM1_IC1_COMP1_2       (3)
1092   *         @arg @ref LL_COMP_OUTPUT_TIM2_IC4_COMP1_2       (3)
1093   *         @arg @ref LL_COMP_OUTPUT_TIM3_IC1_COMP1_2       (3)
1094   *         @arg @ref LL_COMP_OUTPUT_TIM20_OCCLR_COMP2      (5)
1095   *         @arg @ref LL_COMP_OUTPUT_TIM3_IC2_COMP3         (4)
1096   *         @arg @ref LL_COMP_OUTPUT_TIM4_IC1_COMP3         (4)
1097   *         @arg @ref LL_COMP_OUTPUT_TIM15_IC1_COMP3        (4)
1098   *         @arg @ref LL_COMP_OUTPUT_TIM15_BKIN
1099   *         @arg @ref LL_COMP_OUTPUT_TIM3_IC3_COMP4         (1)
1100   *         @arg @ref LL_COMP_OUTPUT_TIM4_IC2_COMP4
1101   *         @arg @ref LL_COMP_OUTPUT_TIM15_IC2_COMP4
1102   *         @arg @ref LL_COMP_OUTPUT_TIM15_OCCLR_COMP4
1103   *         @arg @ref LL_COMP_OUTPUT_TIM2_IC1_COMP5         (4)
1104   *         @arg @ref LL_COMP_OUTPUT_TIM4_IC3_COMP5         (4)
1105   *         @arg @ref LL_COMP_OUTPUT_TIM17_IC1_COMP5        (4)
1106   *         @arg @ref LL_COMP_OUTPUT_TIM16_BKIN
1107   *         @arg @ref LL_COMP_OUTPUT_TIM2_IC2_COMP6
1108   *         @arg @ref LL_COMP_OUTPUT_TIM2_OCCLR_COMP6
1109   *         @arg @ref LL_COMP_OUTPUT_TIM4_IC4_COMP6
1110   *         @arg @ref LL_COMP_OUTPUT_TIM16_IC1_COMP6
1111   *         @arg @ref LL_COMP_OUTPUT_TIM16_OCCLR_COMP6
1112   *         @arg @ref LL_COMP_OUTPUT_TIM1_IC2_COMP7         (4)
1113   *         @arg @ref LL_COMP_OUTPUT_TIM2_IC3_COMP7         (4)
1114   *         @arg @ref LL_COMP_OUTPUT_TIM17_OCCLR_COMP7      (4)
1115   *         @arg @ref LL_COMP_OUTPUT_TIM17_BKIN             (4)
1116   *
1117   *         (1) Parameter available on devices: STM32F302x8, STM32F318xx, STM32F303x8, STM32F328xx, STM32F334x8, STM32F302xC, STM32F302xE, STM32F303xC, STM32F358xx, STM32F303xE, STM32F398xx.\n
1118   *         (2) Parameter available on devices: STM32F301x8, STM32F302x8, STM32F318xx, STM32F303x8, STM32F328xx, STM32F334x8.\n
1119   *         (3) Parameter available on devices: STM32F302xC, STM32F302xE, STM32F303xC, STM32F358xx, STM32F303xE, STM32F398xx.\n
1120   *         (4) Parameter available on devices: STM32F303xC, STM32F358xx, STM32F303xE, STM32F398xx.\n
1121   *         (5) Parameter available on devices: STM32F303xE, STM32F398xx.\n
1122   *         (6) Parameter available on devices: STM32F303x8, STM32F328xx, STM32F334x8.
1123   * @retval None
1124   */
LL_COMP_SetOutputSelection(COMP_TypeDef * COMPx,uint32_t OutputSelection)1125 __STATIC_INLINE void LL_COMP_SetOutputSelection(COMP_TypeDef *COMPx, uint32_t OutputSelection)
1126 {
1127   MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxOUTSEL, OutputSelection);
1128 }
1129 
1130 /**
1131   * @brief  Get comparator output selection.
1132   * @note   Availability of parameters of output selection to timer
1133   *         depends on timers availability on the selected device.
1134   * @rmtoll CSR      COMPxOUTSEL    LL_COMP_GetOutputSelection
1135   * @param  COMPx Comparator instance
1136   * @retval Returned value can be one of the following values:
1137   *         @arg @ref LL_COMP_OUTPUT_NONE
1138   *         @arg @ref LL_COMP_OUTPUT_TIM1_BKIN
1139   *         @arg @ref LL_COMP_OUTPUT_TIM1_BKIN2
1140   *         @arg @ref LL_COMP_OUTPUT_TIM1_TIM8_BKIN2
1141   *         @arg @ref LL_COMP_OUTPUT_TIM8_BKIN              (4)
1142   *         @arg @ref LL_COMP_OUTPUT_TIM8_BKIN2             (4)
1143   *         @arg @ref LL_COMP_OUTPUT_TIM1_TIM8_BKIN2        (4)
1144   *         @arg @ref LL_COMP_OUTPUT_TIM20_BKIN             (5)
1145   *         @arg @ref LL_COMP_OUTPUT_TIM20_BKIN2            (5)
1146   *         @arg @ref LL_COMP_OUTPUT_TIM1_TIM8_TIM20_BKIN2  (5)
1147   *         @arg @ref LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2_3_7 (4)
1148   *         @arg @ref LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3   (4)
1149   *         @arg @ref LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4_5 (4)
1150   *         @arg @ref LL_COMP_OUTPUT_TIM8_OCCLR_COMP4_5_6_7 (4)
1151   *         @arg @ref LL_COMP_OUTPUT_TIM3_OCCLR_COMP2_4     (6)
1152   *         @arg @ref LL_COMP_OUTPUT_TIM1_IC1_COMP2         (2)
1153   *         @arg @ref LL_COMP_OUTPUT_TIM2_IC4_COMP2         (2)
1154   *         @arg @ref LL_COMP_OUTPUT_TIM3_IC1_COMP2         (1)
1155   *         @arg @ref LL_COMP_OUTPUT_TIM1_IC1_COMP1_2       (3)
1156   *         @arg @ref LL_COMP_OUTPUT_TIM2_IC4_COMP1_2       (3)
1157   *         @arg @ref LL_COMP_OUTPUT_TIM3_IC1_COMP1_2       (3)
1158   *         @arg @ref LL_COMP_OUTPUT_TIM20_OCCLR_COMP2      (5)
1159   *         @arg @ref LL_COMP_OUTPUT_TIM3_IC2_COMP3         (4)
1160   *         @arg @ref LL_COMP_OUTPUT_TIM4_IC1_COMP3         (4)
1161   *         @arg @ref LL_COMP_OUTPUT_TIM15_IC1_COMP3        (4)
1162   *         @arg @ref LL_COMP_OUTPUT_TIM15_BKIN
1163   *         @arg @ref LL_COMP_OUTPUT_TIM3_IC3_COMP4         (1)
1164   *         @arg @ref LL_COMP_OUTPUT_TIM4_IC2_COMP4
1165   *         @arg @ref LL_COMP_OUTPUT_TIM15_IC2_COMP4
1166   *         @arg @ref LL_COMP_OUTPUT_TIM15_OCCLR_COMP4
1167   *         @arg @ref LL_COMP_OUTPUT_TIM2_IC1_COMP5         (4)
1168   *         @arg @ref LL_COMP_OUTPUT_TIM4_IC3_COMP5         (4)
1169   *         @arg @ref LL_COMP_OUTPUT_TIM17_IC1_COMP5        (4)
1170   *         @arg @ref LL_COMP_OUTPUT_TIM16_BKIN
1171   *         @arg @ref LL_COMP_OUTPUT_TIM2_IC2_COMP6
1172   *         @arg @ref LL_COMP_OUTPUT_TIM2_OCCLR_COMP6
1173   *         @arg @ref LL_COMP_OUTPUT_TIM4_IC4_COMP6
1174   *         @arg @ref LL_COMP_OUTPUT_TIM16_IC1_COMP6
1175   *         @arg @ref LL_COMP_OUTPUT_TIM16_OCCLR_COMP6
1176   *         @arg @ref LL_COMP_OUTPUT_TIM1_IC2_COMP7         (4)
1177   *         @arg @ref LL_COMP_OUTPUT_TIM2_IC3_COMP7         (4)
1178   *         @arg @ref LL_COMP_OUTPUT_TIM17_OCCLR_COMP7      (4)
1179   *         @arg @ref LL_COMP_OUTPUT_TIM17_BKIN             (4)
1180   *
1181   *         (1) Parameter available on devices: STM32F302x8, STM32F318xx, STM32F303x8, STM32F328xx, STM32F334x8, STM32F302xC, STM32F302xE, STM32F303xC, STM32F358xx, STM32F303xE, STM32F398xx.\n
1182   *         (2) Parameter available on devices: STM32F301x8, STM32F302x8, STM32F318xx, STM32F303x8, STM32F328xx, STM32F334x8.\n
1183   *         (3) Parameter available on devices: STM32F302xC, STM32F302xE, STM32F303xC, STM32F358xx, STM32F303xE, STM32F398xx.\n
1184   *         (4) Parameter available on devices: STM32F303xC, STM32F358xx, STM32F303xE, STM32F398xx.\n
1185   *         (5) Parameter available on devices: STM32F303xE, STM32F398xx.\n
1186   *         (6) Parameter available on devices: STM32F303x8, STM32F328xx, STM32F334x8.
1187   */
LL_COMP_GetOutputSelection(COMP_TypeDef * COMPx)1188 __STATIC_INLINE uint32_t LL_COMP_GetOutputSelection(COMP_TypeDef *COMPx)
1189 {
1190   return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxOUTSEL));
1191 }
1192 
1193 /**
1194   * @brief  Set comparator instance output polarity.
1195   * @rmtoll CSR      COMPxPOL       LL_COMP_SetOutputPolarity
1196   * @param  COMPx Comparator instance
1197   * @param  OutputPolarity This parameter can be one of the following values:
1198   *         @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
1199   *         @arg @ref LL_COMP_OUTPUTPOL_INVERTED
1200   * @retval None
1201   */
LL_COMP_SetOutputPolarity(COMP_TypeDef * COMPx,uint32_t OutputPolarity)1202 __STATIC_INLINE void LL_COMP_SetOutputPolarity(COMP_TypeDef *COMPx, uint32_t OutputPolarity)
1203 {
1204   MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxPOL, OutputPolarity);
1205 }
1206 
1207 /**
1208   * @brief  Get comparator instance output polarity.
1209   * @rmtoll CSR      COMPxPOL       LL_COMP_GetOutputPolarity
1210   * @param  COMPx Comparator instance
1211   * @retval Returned value can be one of the following values:
1212   *         @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
1213   *         @arg @ref LL_COMP_OUTPUTPOL_INVERTED
1214   */
LL_COMP_GetOutputPolarity(COMP_TypeDef * COMPx)1215 __STATIC_INLINE uint32_t LL_COMP_GetOutputPolarity(COMP_TypeDef *COMPx)
1216 {
1217   return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxPOL));
1218 }
1219 
1220 /**
1221   * @brief  Set comparator instance blanking source.
1222   * @note   Blanking source may be specific to each comparator instance.
1223   *         Refer to description of parameters or to reference manual.
1224   * @note   Availability of parameters of blanking source from timer
1225   *         depends on timers availability on the selected device.
1226   * @rmtoll CSR      COMPxBLANKING  LL_COMP_SetOutputBlankingSource
1227   * @param  COMPx Comparator instance
1228   * @param  BlankingSource This parameter can be one of the following values:
1229   *         @arg @ref LL_COMP_BLANKINGSRC_NONE
1230   *         @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5_COMP2       (1)
1231   *         @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3_COMP2       (1)
1232   *         @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3_COMP2       (1)
1233   *         @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2     (2)(3)
1234   *         @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1_2     (2)(3)
1235   *         @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1_2     (2)(3)
1236   *         @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4
1237   *         @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4
1238   *         @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC4_COMP6       (2)
1239   *         @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6      (1)(2)
1240   *         @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2_7   (3)
1241   *         @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC4_COMP3_6     (3)
1242   *         @arg @ref LL_COMP_BLANKINGSRC_TIM8_OC5_COMP4_5_6_7 (3)
1243   *         @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6_7    (3)
1244   *
1245   *         (1) Parameter available on devices: STM32F301x8, STM32F302x8, STM32F318xx, STM32F303x8, STM32F334x8, STM32F328xx.\n
1246   *         (2) Parameter available on devices: STM32F302xE, STM32F302xC.\n
1247   *         (3) Parameter available on devices: STM32F303xE, STM32F398xx, STM32F303xC, STM32F358xx.
1248   * @retval None
1249   */
LL_COMP_SetOutputBlankingSource(COMP_TypeDef * COMPx,uint32_t BlankingSource)1250 __STATIC_INLINE void LL_COMP_SetOutputBlankingSource(COMP_TypeDef *COMPx, uint32_t BlankingSource)
1251 {
1252   MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxBLANKING, BlankingSource);
1253 }
1254 
1255 /**
1256   * @brief  Get comparator instance blanking source.
1257   * @note   Availability of parameters of blanking source from timer
1258   *         depends on timers availability on the selected device.
1259   * @note   Blanking source may be specific to each comparator instance.
1260   *         Refer to description of parameters or to reference manual.
1261   * @rmtoll CSR      COMPxBLANKING  LL_COMP_GetOutputBlankingSource
1262   * @param  COMPx Comparator instance
1263   * @retval Returned value can be one of the following values:
1264   *         @arg @ref LL_COMP_BLANKINGSRC_NONE
1265   *         @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5_COMP2       (1)
1266   *         @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3_COMP2       (1)
1267   *         @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3_COMP2       (1)
1268   *         @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2     (2)(3)
1269   *         @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1_2     (2)(3)
1270   *         @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1_2     (2)(3)
1271   *         @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4
1272   *         @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4
1273   *         @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC4_COMP6       (2)
1274   *         @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6      (1)(2)
1275   *         @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2_7   (3)
1276   *         @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC4_COMP3_6     (3)
1277   *         @arg @ref LL_COMP_BLANKINGSRC_TIM8_OC5_COMP4_5_6_7 (3)
1278   *         @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6_7    (3)
1279   *
1280   *         (1) Parameter available on devices: STM32F301x8, STM32F302x8, STM32F318xx, STM32F303x8, STM32F334x8, STM32F328xx.\n
1281   *         (2) Parameter available on devices: STM32F302xE, STM32F302xC.\n
1282   *         (3) Parameter available on devices: STM32F303xE, STM32F398xx, STM32F303xC, STM32F358xx.
1283   */
LL_COMP_GetOutputBlankingSource(COMP_TypeDef * COMPx)1284 __STATIC_INLINE uint32_t LL_COMP_GetOutputBlankingSource(COMP_TypeDef *COMPx)
1285 {
1286   return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxBLANKING));
1287 }
1288 
1289 /**
1290   * @}
1291   */
1292 
1293 /** @defgroup COMP_LL_EF_Operation Operation on comparator instance
1294   * @{
1295   */
1296 
1297 /**
1298   * @brief  Enable comparator instance.
1299   * @note   After enable from off state, comparator requires a delay
1300   *         to reach reach propagation delay specification.
1301   *         Refer to device datasheet, parameter "tSTART".
1302   * @rmtoll CSR      COMPxEN        LL_COMP_Enable
1303   * @param  COMPx Comparator instance
1304   * @retval None
1305   */
LL_COMP_Enable(COMP_TypeDef * COMPx)1306 __STATIC_INLINE void LL_COMP_Enable(COMP_TypeDef *COMPx)
1307 {
1308   SET_BIT(COMPx->CSR, COMP_CSR_COMPxEN);
1309 }
1310 
1311 /**
1312   * @brief  Disable comparator instance.
1313   * @rmtoll CSR      COMPxEN        LL_COMP_Disable
1314   * @param  COMPx Comparator instance
1315   * @retval None
1316   */
LL_COMP_Disable(COMP_TypeDef * COMPx)1317 __STATIC_INLINE void LL_COMP_Disable(COMP_TypeDef *COMPx)
1318 {
1319   CLEAR_BIT(COMPx->CSR, COMP_CSR_COMPxEN);
1320 }
1321 
1322 /**
1323   * @brief  Get comparator enable state
1324   *         (0: COMP is disabled, 1: COMP is enabled)
1325   * @rmtoll CSR      COMPxEN        LL_COMP_IsEnabled
1326   * @param  COMPx Comparator instance
1327   * @retval State of bit (1 or 0).
1328   */
LL_COMP_IsEnabled(COMP_TypeDef * COMPx)1329 __STATIC_INLINE uint32_t LL_COMP_IsEnabled(COMP_TypeDef *COMPx)
1330 {
1331   return (READ_BIT(COMPx->CSR, COMP_CSR_COMPxEN) == (COMP_CSR_COMPxEN));
1332 }
1333 
1334 /**
1335   * @brief  Lock comparator instance.
1336   * @note   Once locked, comparator configuration can be accessed in read-only.
1337   * @note   The only way to unlock the comparator is a device hardware reset.
1338   * @rmtoll CSR      COMPxLOCK      LL_COMP_Lock
1339   * @param  COMPx Comparator instance
1340   * @retval None
1341   */
LL_COMP_Lock(COMP_TypeDef * COMPx)1342 __STATIC_INLINE void LL_COMP_Lock(COMP_TypeDef *COMPx)
1343 {
1344   SET_BIT(COMPx->CSR, COMP_CSR_COMPxLOCK);
1345 }
1346 
1347 /**
1348   * @brief  Get comparator lock state
1349   *         (0: COMP is unlocked, 1: COMP is locked).
1350   * @note   Once locked, comparator configuration can be accessed in read-only.
1351   * @note   The only way to unlock the comparator is a device hardware reset.
1352   * @rmtoll CSR      COMPxLOCK      LL_COMP_IsLocked
1353   * @param  COMPx Comparator instance
1354   * @retval State of bit (1 or 0).
1355   */
LL_COMP_IsLocked(COMP_TypeDef * COMPx)1356 __STATIC_INLINE uint32_t LL_COMP_IsLocked(COMP_TypeDef *COMPx)
1357 {
1358   return (READ_BIT(COMPx->CSR, COMP_CSR_COMPxLOCK) == (COMP_CSR_COMPxLOCK));
1359 }
1360 
1361 /**
1362   * @brief  Read comparator instance output level.
1363   * @note   The comparator output level depends on the selected polarity
1364   *         (Refer to function @ref LL_COMP_SetOutputPolarity()).
1365   *         If the comparator polarity is not inverted:
1366   *          - Comparator output is low when the input plus
1367   *            is at a lower voltage than the input minus
1368   *          - Comparator output is high when the input plus
1369   *            is at a higher voltage than the input minus
1370   *         If the comparator polarity is inverted:
1371   *          - Comparator output is high when the input plus
1372   *            is at a lower voltage than the input minus
1373   *          - Comparator output is low when the input plus
1374   *            is at a higher voltage than the input minus
1375   * @rmtoll CSR      COMPxOUT       LL_COMP_ReadOutputLevel
1376   * @param  COMPx Comparator instance
1377   * @retval Returned value can be one of the following values:
1378   *         @arg @ref LL_COMP_OUTPUT_LEVEL_LOW
1379   *         @arg @ref LL_COMP_OUTPUT_LEVEL_HIGH
1380   */
LL_COMP_ReadOutputLevel(COMP_TypeDef * COMPx)1381 __STATIC_INLINE uint32_t LL_COMP_ReadOutputLevel(COMP_TypeDef *COMPx)
1382 {
1383   return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxOUT)
1384                     >> LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS);
1385 }
1386 
1387 /**
1388   * @}
1389   */
1390 
1391 #if defined(USE_FULL_LL_DRIVER)
1392 /** @defgroup COMP_LL_EF_Init Initialization and de-initialization functions
1393   * @{
1394   */
1395 
1396 ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx);
1397 ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct);
1398 void        LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct);
1399 
1400 /**
1401   * @}
1402   */
1403 #endif /* USE_FULL_LL_DRIVER */
1404 
1405 /**
1406   * @}
1407   */
1408 
1409 /**
1410   * @}
1411   */
1412 
1413 #endif /* COMP1 || COMP2 || COMP3 || COMP4 || COMP5 || COMP6 || COMP7 */
1414 
1415 
1416 #endif /* STM32F301x8 || STM32F302x8 || STM32F302xC || STM32F302xE || STM32F303x8 || STM32F303xC || STM32F303xE || STM32F318xx || STM32F328xx || STM32F334x8 || STM32F358xx || STM32F398xx */
1417 
1418 #if defined (COMP_V1_1_0_0)
1419 
1420 #if defined (COMP1) || defined (COMP2)
1421 
1422 /** @defgroup COMP_LL COMP
1423   * @{
1424   */
1425 
1426 /* Private types -------------------------------------------------------------*/
1427 /* Private variables ---------------------------------------------------------*/
1428 /* Private constants ---------------------------------------------------------*/
1429 /** @defgroup COMP_LL_Private_Constants COMP Private Constants
1430   * @{
1431   */
1432 
1433 /* Differentiation between COMP instances */
1434 /* Note: Value not corresponding to a register offset since both              */
1435 /*       COMP instances are sharing the same register) .                      */
1436 #define COMPX_BASE  COMP_BASE
1437 #define COMPX       (COMP1 - COMP2)
1438 
1439 /* COMP registers bits positions */
1440 #define LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS ((uint32_t)14U) /* Value equivalent to POSITION_VAL(COMP_CSR_COMP1OUT) */
1441 
1442 /**
1443   * @}
1444   */
1445 
1446 /* Private macros ------------------------------------------------------------*/
1447 /** @defgroup COMP_LL_Private_Macros COMP Private Macros
1448   * @{
1449   */
1450 
1451 /**
1452   * @brief  Driver macro reserved for internal use: if COMP instance selected
1453   *         is odd (COMP1, COMP3, ...), return value '1', else return '0'.
1454   * @param  __COMP_INSTANCE__ COMP instance
1455   * @retval If COMP instance is odd, value '1'. Else, value '0'.
1456 */
1457 #define __COMP_IS_INSTANCE_ODD(__COMP_INSTANCE__)                              \
1458   ((~(((uint32_t)(__COMP_INSTANCE__) - COMP_BASE) >> 1U)) & 0x00000001)
1459 
1460 /**
1461   * @brief  Driver macro reserved for internal use: if COMP instance selected
1462   *         is even (COMP2, COMP4, ...), return value '1', else return '0'.
1463   * @param  __COMP_INSTANCE__ COMP instance
1464   * @retval If COMP instance is even, value '1'. Else, value '0'.
1465 */
1466 #define __COMP_IS_INSTANCE_EVEN(__COMP_INSTANCE__)                             \
1467   (((uint32_t)(__COMP_INSTANCE__) - COMP_BASE) >> 1U)
1468 
1469 /**
1470   * @brief  Driver macro reserved for internal use: from COMP instance
1471   *         selected, set offset of bits into COMP register.
1472   * @note   Since both COMP instances are sharing the same register
1473   *         with 2 area of bits with an offset of 16 bits, this function
1474   *         returns value "0" if COMP1 is selected and "16" if COMP2 is
1475   *         selected.
1476   * @param  __COMP_INSTANCE__ COMP instance
1477   * @retval Bits offset in register 32 bits
1478 */
1479 #define __COMP_BITOFFSET_INSTANCE(__COMP_INSTANCE__)                           \
1480   (((uint32_t)(__COMP_INSTANCE__) - COMP_BASE) << 3U)
1481 
1482 /**
1483   * @}
1484   */
1485 
1486 /* Exported types ------------------------------------------------------------*/
1487 #if defined(USE_FULL_LL_DRIVER)
1488 /** @defgroup COMP_LL_ES_INIT COMP Exported Init structure
1489   * @{
1490   */
1491 
1492 /**
1493   * @brief  Structure definition of some features of COMP instance.
1494   */
1495 typedef struct
1496 {
1497   uint32_t PowerMode;                   /*!< Set comparator operating mode to adjust power and speed.
1498                                              This parameter can be a value of @ref COMP_LL_EC_POWERMODE
1499 
1500                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetPowerMode(). */
1501 
1502   uint32_t InputPlus;                   /*!< Set comparator input plus (non-inverting input).
1503                                              This parameter can be a value of @ref COMP_LL_EC_INPUT_PLUS
1504 
1505                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputPlus(). */
1506 
1507   uint32_t InputMinus;                  /*!< Set comparator input minus (inverting input).
1508                                              This parameter can be a value of @ref COMP_LL_EC_INPUT_MINUS
1509 
1510                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputMinus(). */
1511 
1512   uint32_t InputHysteresis;             /*!< Set comparator hysteresis mode of the input minus.
1513                                              This parameter can be a value of @ref COMP_LL_EC_INPUT_HYSTERESIS
1514 
1515                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputHysteresis(). */
1516 
1517   uint32_t OutputSelection;             /*!< Set comparator output selection.
1518                                              This parameter can be a value of @ref COMP_LL_EC_OUTPUT_SELECTION
1519 
1520                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputSelection(). */
1521 
1522   uint32_t OutputPolarity;              /*!< Set comparator output polarity.
1523                                              This parameter can be a value of @ref COMP_LL_EC_OUTPUT_POLARITY
1524 
1525                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputPolarity(). */
1526 
1527 } LL_COMP_InitTypeDef;
1528 
1529 /**
1530   * @}
1531   */
1532 #endif /* USE_FULL_LL_DRIVER */
1533 
1534 /* Exported constants --------------------------------------------------------*/
1535 /** @defgroup COMP_LL_Exported_Constants COMP Exported Constants
1536   * @{
1537   */
1538 
1539 /** @defgroup COMP_LL_EC_COMMON_WINDOWMODE Comparator common modes - Window mode
1540   * @{
1541   */
1542 #define LL_COMP_WINDOWMODE_DISABLE                 ((uint32_t)0x00000000U) /*!< Window mode disable: Comparators 1 and 2 are independent */
1543 #define LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP_CSR_WNDWEN)       /*!< 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). */
1544 /**
1545   * @}
1546   */
1547 
1548 /** @defgroup COMP_LL_EC_POWERMODE Comparator modes - Power mode
1549   * @{
1550   */
1551 #define LL_COMP_POWERMODE_HIGHSPEED     ((uint32_t)0x00000000U)                       /*!< COMP power mode to high speed */
1552 #define LL_COMP_POWERMODE_MEDIUMSPEED   (COMP_CSR_COMP1MODE_0)                        /*!< COMP power mode to medium speed */
1553 #define LL_COMP_POWERMODE_LOWPOWER      (COMP_CSR_COMP1MODE_1)                        /*!< COMP power mode to low power */
1554 #define LL_COMP_POWERMODE_ULTRALOWPOWER (COMP_CSR_COMP1MODE_1 | COMP_CSR_COMP1MODE_0) /*!< COMP power mode to ultra-low power */
1555 /**
1556   * @}
1557   */
1558 
1559 /** @defgroup COMP_LL_EC_INPUT_PLUS Comparator inputs - Input plus (input non-inverting) selection
1560   * @{
1561   */
1562 #define LL_COMP_INPUT_PLUS_IO1          ((uint32_t)0x00000000U) /*!< Comparator input plus connected to IO1 (pin PA1 for COMP1, pin PA3 for COMP2) */
1563 #define LL_COMP_INPUT_PLUS_DAC1_CH1     (COMP_CSR_COMP1SW1)     /*!< Comparator input plus connected to DAC1 channel 1 (DAC_OUT1), through dedicated switch (Note: this switch is solely intended to redirect signals onto high impedance input, such as COMP1 input plus (highly resistive switch)) (specific to COMP instance: COMP1) */
1564 /**
1565   * @}
1566   */
1567 
1568 /** @defgroup COMP_LL_EC_INPUT_MINUS Comparator inputs - Input minus (input inverting) selection
1569   * @{
1570   */
1571 #define LL_COMP_INPUT_MINUS_1_4VREFINT  ((uint32_t)0x00000000U)                                                 /*!< Comparator input minus connected to 1/4 VrefInt  */
1572 #define LL_COMP_INPUT_MINUS_1_2VREFINT  (                                                COMP_CSR_COMP1INSEL_0) /*!< Comparator input minus connected to 1/2 VrefInt  */
1573 #define LL_COMP_INPUT_MINUS_3_4VREFINT  (                        COMP_CSR_COMP1INSEL_1                        ) /*!< Comparator input minus connected to 3/4 VrefInt  */
1574 #define LL_COMP_INPUT_MINUS_VREFINT     (                        COMP_CSR_COMP1INSEL_1 | COMP_CSR_COMP1INSEL_0) /*!< Comparator input minus connected to VrefInt */
1575 #define LL_COMP_INPUT_MINUS_DAC1_CH1    (COMP_CSR_COMP1INSEL_2                                                ) /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1)  */
1576 #define LL_COMP_INPUT_MINUS_DAC1_CH2    (COMP_CSR_COMP1INSEL_2                         | COMP_CSR_COMP1INSEL_0) /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2)  */
1577 #define LL_COMP_INPUT_MINUS_IO1         (COMP_CSR_COMP1INSEL_2 | COMP_CSR_COMP1INSEL_1                        ) /*!< Comparator input minus connected to IO1 (pin PA0 for COMP1, pin PA2 for COMP2) */
1578 #define LL_COMP_INPUT_MINUS_IO2         (COMP_CSR_COMP1INSEL_2 | COMP_CSR_COMP1INSEL_1 | COMP_CSR_COMP1INSEL_0) /*!< Comparator input minus connected to IO2 (pin PA6 for COMP1 & COMP2) */
1579 #define LL_COMP_INPUT_MINUS_IO3         (COMP_CSR_COMP1INSEL_2 |                         COMP_CSR_COMP1INSEL_0) /*!< Comparator input minus connected to IO3 (pin PA5 for COMP1 & COMP2) */
1580 #define LL_COMP_INPUT_MINUS_IO4         (COMP_CSR_COMP1INSEL_2                                                ) /*!< Comparator input minus connected to IO4 (pin PA4 for COMP1 & COMP2) */
1581 #define LL_COMP_INPUT_MINUS_DAC2_CH1    (COMP_CSR_COMP1INSEL_2 | COMP_CSR_COMP1INSEL_1 | COMP_CSR_COMP1INSEL_0) /*!< Comparator input minus connected to DAC2 channel 1 (DAC2_OUT1)  */
1582 /**
1583   * @}
1584   */
1585 
1586 /** @defgroup COMP_LL_EC_INPUT_HYSTERESIS Comparator input - Hysteresis
1587   * @{
1588   */
1589 #define LL_COMP_HYSTERESIS_NONE         ((uint32_t)0x00000000U)                       /*!< No hysteresis */
1590 #define LL_COMP_HYSTERESIS_LOW          (                       COMP_CSR_COMP1HYST_0) /*!< Hysteresis level low */
1591 #define LL_COMP_HYSTERESIS_MEDIUM       (COMP_CSR_COMP1HYST_1                       ) /*!< Hysteresis level medium */
1592 #define LL_COMP_HYSTERESIS_HIGH         (COMP_CSR_COMP1HYST_1 | COMP_CSR_COMP1HYST_0) /*!< Hysteresis level high */
1593 /**
1594   * @}
1595   */
1596 
1597 /** @defgroup COMP_LL_EC_OUTPUT_SELECTION Comparator output - Output selection
1598   * @{
1599   */
1600 /* Note: Output redirection is common for COMP1 and COMP2 */
1601 #define LL_COMP_OUTPUT_NONE             ((uint32_t)0x00000000U)                                                    /*!< COMP output is not connected to other peripherals (except GPIO and EXTI that are always connected to COMP output) */
1602 #define LL_COMP_OUTPUT_TIM2_IC4         (COMP_CSR_COMP1OUTSEL_2)                                                   /*!< COMP output connected to TIM2 input capture 4 */
1603 #define LL_COMP_OUTPUT_TIM2_OCCLR       (COMP_CSR_COMP1OUTSEL_2 | COMP_CSR_COMP1OUTSEL_0)                          /*!< COMP output connected to TIM2 OCREF clear */
1604 
1605 /* Note: Output redirection specific to COMP instance: COMP1 */
1606 #define LL_COMP_OUTPUT_TIM15_BKIN_COMP1 (COMP_CSR_COMP1OUTSEL_0)                                                   /*!< COMP output connected to TIM15 break input (BKIN) (specific to COMP instance: COMP1) */
1607 #define LL_COMP_OUTPUT_TIM3_IC1_COMP1   (COMP_CSR_COMP1OUTSEL_1)                                                   /*!< COMP output connected to TIM3 input capture 1 (specific to COMP instance: COMP1) */
1608 #define LL_COMP_OUTPUT_TIM3_OCCLR_COMP1 (COMP_CSR_COMP1OUTSEL_1 | COMP_CSR_COMP1OUTSEL_0)                          /*!< COMP output connected to TIM3 OCREF clear (specific to COMP instance: COMP1) */
1609 #define LL_COMP_OUTPUT_TIM5_IC4_COMP1   (COMP_CSR_COMP1OUTSEL_2 | COMP_CSR_COMP1OUTSEL_1)                          /*!< COMP output connected to TIM5 input capture 4 (specific to COMP instance: COMP1) */
1610 #define LL_COMP_OUTPUT_TIM5_OCCLR_COMP1 (COMP_CSR_COMP1OUTSEL_2 | COMP_CSR_COMP1OUTSEL_1 | COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM5 OCREF clear (specific to COMP instance: COMP1) */
1611 
1612 /* Note: Output redirection specific to COMP instance: COMP2 */
1613 #define LL_COMP_OUTPUT_TIM16_BKIN_COMP2 (COMP_CSR_COMP1OUTSEL_0)                                                   /*!< COMP output connected to TIM16 break input (BKIN) (specific to COMP instance: COMP2) */
1614 #define LL_COMP_OUTPUT_TIM4_IC1_COMP2   (COMP_CSR_COMP1OUTSEL_1)                                                   /*!< COMP output connected to TIM4 input capture 1 (specific to COMP instance: COMP2) */
1615 #define LL_COMP_OUTPUT_TIM4_OCCLR_COMP2 (COMP_CSR_COMP1OUTSEL_1 | COMP_CSR_COMP1OUTSEL_0)                          /*!< COMP output connected to TIM4 OCREF clear (specific to COMP instance: COMP2) */
1616 #define LL_COMP_OUTPUT_TIM3_IC1_COMP2   (COMP_CSR_COMP1OUTSEL_2 | COMP_CSR_COMP1OUTSEL_1)                          /*!< COMP output connected to TIM3 input capture 1 (specific to COMP instance: COMP2) */
1617 #define LL_COMP_OUTPUT_TIM3_OCCLR_COMP2 (COMP_CSR_COMP1OUTSEL_2 | COMP_CSR_COMP1OUTSEL_1 | COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM3 OCREF clear (specific to COMP instance: COMP2) */
1618 
1619 /* Note: Output redirection specific to COMP instances, defined with          */
1620 /*       generic naming not taking into account COMP instance constraints.    */
1621 /*       Refer to literal definitions above for COMP instance constraints.    */
1622 /* Note: Some output redirections cannot have a generic naming,               */
1623 /*       due to literal value different depending on COMP instance.           */
1624 /*       (For example: LL_COMP_OUTPUT_TIM3_IC1_COMP1 and                      */
1625 /*       LL_COMP_OUTPUT_TIM3_IC1_COMP2).                                      */
1626 #define LL_COMP_OUTPUT_TIM15_BKIN       LL_COMP_OUTPUT_TIM15_BKIN_COMP1       /*!< COMP output connected to TIM15 break input (BKIN). Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
1627 #define LL_COMP_OUTPUT_TIM16_BKIN       LL_COMP_OUTPUT_TIM16_BKIN_COMP2       /*!< COMP output connected to TIM16 break input (BKIN). Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
1628 #define LL_COMP_OUTPUT_TIM4_IC1         LL_COMP_OUTPUT_TIM4_IC1_COMP2         /*!< COMP output connected to TIM4 input capture 1.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
1629 #define LL_COMP_OUTPUT_TIM4_OCCLR       LL_COMP_OUTPUT_TIM4_OCCLR_COMP2       /*!< COMP output connected to TIM4 OCREF clear.         Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
1630 #define LL_COMP_OUTPUT_TIM5_IC4         LL_COMP_OUTPUT_TIM5_IC1_COMP1         /*!< COMP output connected to TIM5 input capture 4.     Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
1631 #define LL_COMP_OUTPUT_TIM5_OCCLR       LL_COMP_OUTPUT_TIM5_OCCLR_COMP1       /*!< COMP output connected to TIM5 OCREF clear.         Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
1632 /**
1633   * @}
1634   */
1635 
1636 /** @defgroup COMP_LL_EC_OUTPUT_POLARITY Comparator output - Output polarity
1637   * @{
1638   */
1639 #define LL_COMP_OUTPUTPOL_NONINVERTED   ((uint32_t)0x00000000U)  /*!< 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 */
1640 #define LL_COMP_OUTPUTPOL_INVERTED      (COMP_CSR_COMP1POL)      /*!< 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 */
1641 /**
1642   * @}
1643   */
1644 
1645 /** @defgroup COMP_LL_EC_OUTPUT_LEVEL Comparator output - Output level
1646   * @{
1647   */
1648 #define LL_COMP_OUTPUT_LEVEL_LOW        ((uint32_t)0x00000000U) /*!< Comparator output level low (if the polarity is not inverted, otherwise to be complemented) */
1649 #define LL_COMP_OUTPUT_LEVEL_HIGH       ((uint32_t)0x00000001U) /*!< Comparator output level high (if the polarity is not inverted, otherwise to be complemented) */
1650 /**
1651   * @}
1652   */
1653 
1654 /** @defgroup COMP_LL_EC_HW_DELAYS  Definitions of COMP hardware constraints delays
1655   * @note   Only COMP IP HW delays are defined in COMP LL driver driver,
1656   *         not timeout values.
1657   *         For details on delays values, refer to descriptions in source code
1658   *         above each literal definition.
1659   * @{
1660   */
1661 
1662 /* Delay for comparator startup time.                                         */
1663 /* Note: Delay required to reach propagation delay specification.             */
1664 /* Literal set to maximum value (refer to device datasheet,                   */
1665 /* parameter "tSTART").                                                       */
1666 /* Unit: us                                                                   */
1667 #define LL_COMP_DELAY_STARTUP_US          ((uint32_t) 60U)  /*!< Delay for COMP startup time */
1668 
1669 /* Delay for comparator voltage scaler stabilization time                     */
1670 /* (voltage from VrefInt, delay based on VrefInt startup time).               */
1671 /* Literal set to maximum value (refer to device datasheet,                   */
1672 /* parameter "tS_SC").                                                        */
1673 /* Unit: us                                                                   */
1674 #define LL_COMP_DELAY_VOLTAGE_SCALER_STAB_US ((uint32_t) 200U)  /*!< Delay for COMP voltage scaler stabilization time */
1675 
1676 
1677 /**
1678   * @}
1679   */
1680 
1681 /**
1682   * @}
1683   */
1684 
1685 /* Exported macro ------------------------------------------------------------*/
1686 /** @defgroup COMP_LL_Exported_Macros COMP Exported Macros
1687   * @{
1688   */
1689 /** @defgroup COMP_LL_EM_WRITE_READ Common write and read registers macro
1690   * @{
1691   */
1692 
1693 /**
1694   * @brief  Write a value in COMP register
1695   * @param  __INSTANCE__ comparator instance
1696   * @param  __REG__ Register to be written
1697   * @param  __VALUE__ Value to be written in the register
1698   * @retval None
1699   */
1700 #define LL_COMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
1701 
1702 /**
1703   * @brief  Read a value in COMP register
1704   * @param  __INSTANCE__ comparator instance
1705   * @param  __REG__ Register to be read
1706   * @retval Register value
1707   */
1708 #define LL_COMP_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
1709 /**
1710   * @}
1711   */
1712 
1713 /** @defgroup COMP_LL_EM_HELPER_MACRO COMP helper macro
1714   * @{
1715   */
1716 
1717 /**
1718   * @brief  Helper macro to select the COMP common instance
1719   *         to which is belonging the selected COMP instance.
1720   * @note   COMP common register instance can be used to
1721   *         set parameters common to several COMP instances.
1722   *         Refer to functions having argument "COMPxy_COMMON" as parameter.
1723   * @param  __COMPx__ COMP instance
1724   * @retval COMP common instance or value "0" if there is no COMP common instance.
1725   */
1726 #define __LL_COMP_COMMON_INSTANCE(__COMPx__)                                   \
1727   (COMP12_COMMON)
1728 
1729 /**
1730   * @}
1731   */
1732 
1733 /**
1734   * @}
1735   */
1736 
1737 /* Exported functions --------------------------------------------------------*/
1738 /** @defgroup COMP_LL_Exported_Functions COMP Exported Functions
1739   * @{
1740   */
1741 
1742 /** @defgroup COMP_LL_EF_Configuration_comparator_common Configuration of COMP hierarchical scope: common to several COMP instances
1743   * @{
1744   */
1745 
1746 /**
1747   * @brief  Set window mode of a pair of comparators instances
1748   *         (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
1749   * @rmtoll CSR         WNDWEN          LL_COMP_SetCommonWindowMode
1750   * @param  COMPxy_COMMON Comparator common instance
1751   *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
1752   * @param  WindowMode This parameter can be one of the following values:
1753   *         @arg @ref LL_COMP_WINDOWMODE_DISABLE
1754   *         @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
1755   * @retval None
1756   */
LL_COMP_SetCommonWindowMode(COMP_Common_TypeDef * COMPxy_COMMON,uint32_t WindowMode)1757 __STATIC_INLINE void LL_COMP_SetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON, uint32_t WindowMode)
1758 {
1759   MODIFY_REG(COMPxy_COMMON->CSR, COMP_CSR_WNDWEN, WindowMode);
1760 }
1761 
1762 /**
1763   * @brief  Get window mode of a pair of comparators instances
1764   *         (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
1765   * @rmtoll CSR         WNDWEN          LL_COMP_GetCommonWindowMode
1766   * @param  COMPxy_COMMON Comparator common instance
1767   *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
1768   * @retval Returned value can be one of the following values:
1769   *         @arg @ref LL_COMP_WINDOWMODE_DISABLE
1770   *         @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
1771   */
LL_COMP_GetCommonWindowMode(COMP_Common_TypeDef * COMPxy_COMMON)1772 __STATIC_INLINE uint32_t LL_COMP_GetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON)
1773 {
1774   return (uint32_t)(READ_BIT(COMPxy_COMMON->CSR, COMP_CSR_WNDWEN));
1775 }
1776 
1777 /**
1778   * @}
1779   */
1780 
1781 /** @defgroup COMP_LL_EF_Configuration_comparator_modes Configuration of comparator modes
1782   * @{
1783   */
1784 
1785 /**
1786   * @brief  Set comparator instance operating mode to adjust power and speed.
1787   * @rmtoll CSR         COMP1MODE       LL_COMP_SetPowerMode\n
1788   *                     COMP2MODE       LL_COMP_SetPowerMode
1789   * @param  COMPx Comparator instance
1790   * @param  PowerMode This parameter can be one of the following values:
1791   *         @arg @ref LL_COMP_POWERMODE_HIGHSPEED
1792   *         @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED
1793   *         @arg @ref LL_COMP_POWERMODE_LOWPOWER
1794   *         @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER
1795   * @retval None
1796   */
LL_COMP_SetPowerMode(COMP_TypeDef * COMPx,uint32_t PowerMode)1797 __STATIC_INLINE void LL_COMP_SetPowerMode(COMP_TypeDef *COMPx, uint32_t PowerMode)
1798 {
1799   MODIFY_REG(COMP->CSR,
1800              COMP_CSR_COMP1MODE << __COMP_BITOFFSET_INSTANCE(COMPx),
1801              PowerMode          << __COMP_BITOFFSET_INSTANCE(COMPx));
1802 }
1803 
1804 /**
1805   * @brief  Get comparator instance operating mode to adjust power and speed.
1806   * @rmtoll CSR         COMP1MODE       LL_COMP_GetPowerMode\n
1807   *                     COMP2MODE       LL_COMP_GetPowerMode
1808   * @param  COMPx Comparator instance
1809   * @retval Returned value can be one of the following values:
1810   *         @arg @ref LL_COMP_POWERMODE_HIGHSPEED
1811   *         @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED
1812   *         @arg @ref LL_COMP_POWERMODE_LOWPOWER
1813   *         @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER
1814   */
LL_COMP_GetPowerMode(COMP_TypeDef * COMPx)1815 __STATIC_INLINE uint32_t LL_COMP_GetPowerMode(COMP_TypeDef *COMPx)
1816 {
1817   return (uint32_t)(READ_BIT(COMP->CSR,
1818                              COMP_CSR_COMP1MODE << __COMP_BITOFFSET_INSTANCE(COMPx))
1819                     >> __COMP_BITOFFSET_INSTANCE(COMPx)
1820                    );
1821 }
1822 
1823 /**
1824   * @}
1825   */
1826 
1827 /** @defgroup COMP_LL_EF_Configuration_comparator_inputs Configuration of comparator inputs
1828   * @{
1829   */
1830 
1831 /**
1832   * @brief  Set comparator inputs minus (inverting) and plus (non-inverting).
1833   * @note   In case of comparator input selected to be connected to IO:
1834   *         GPIO pins are specific to each comparator instance.
1835   *         Refer to description of parameters or to reference manual.
1836   * @rmtoll CSR         COMP1INSEL      LL_COMP_ConfigInputs\n
1837   *         CSR         COMP2INSEL      LL_COMP_ConfigInputs\n
1838   *         CSR         COMP1SW1        LL_COMP_ConfigInputs
1839   * @param  COMPx Comparator instance
1840   * @param  InputMinus This parameter can be one of the following values:
1841   *         @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
1842   *         @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
1843   *         @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
1844   *         @arg @ref LL_COMP_INPUT_MINUS_VREFINT
1845   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
1846   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
1847   *         @arg @ref LL_COMP_INPUT_MINUS_IO1
1848   *         @arg @ref LL_COMP_INPUT_MINUS_IO2
1849   *         @arg @ref LL_COMP_INPUT_MINUS_IO3
1850   *         @arg @ref LL_COMP_INPUT_MINUS_IO4
1851   *         @arg @ref LL_COMP_INPUT_MINUS_DAC2_CH1
1852   * @param  InputPlus This parameter can be one of the following values:
1853   *         @arg @ref LL_COMP_INPUT_PLUS_IO1
1854   *         @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1 (1)
1855   *
1856   *         (1) Parameter available only on COMP instance: COMP1.
1857   * @retval None
1858   */
LL_COMP_ConfigInputs(COMP_TypeDef * COMPx,uint32_t InputMinus,uint32_t InputPlus)1859 __STATIC_INLINE void LL_COMP_ConfigInputs(COMP_TypeDef *COMPx, uint32_t InputMinus, uint32_t InputPlus)
1860 {
1861   /* Note: Connection switch is applicable only to COMP instance COMP1,       */
1862   /*       therefore if COMP2 is selected the equivalent bit is               */
1863   /*       kept unmodified.                                                   */
1864   MODIFY_REG(COMP->CSR,
1865              (COMP_CSR_COMP1INSEL | (COMP_CSR_COMP1SW1 * __COMP_IS_INSTANCE_ODD(COMPx))) << __COMP_BITOFFSET_INSTANCE(COMPx),
1866              (InputMinus | InputPlus)                                        << __COMP_BITOFFSET_INSTANCE(COMPx));
1867 }
1868 
1869 /**
1870   * @brief  Set comparator input plus (non-inverting).
1871   * @note   In case of comparator input selected to be connected to IO:
1872   *         GPIO pins are specific to each comparator instance.
1873   *         Refer to description of parameters or to reference manual.
1874   * @rmtoll CSR         COMP1INSEL      LL_COMP_SetInputPlus\n
1875   *         CSR         COMP2INSEL      LL_COMP_SetInputPlus
1876   * @param  COMPx Comparator instance
1877   * @param  InputPlus This parameter can be one of the following values:
1878   *         @arg @ref LL_COMP_INPUT_PLUS_IO1
1879   *         @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1 (1)
1880   *
1881   *         (1) Parameter available only on COMP instance: COMP1.
1882   * @retval None
1883   */
LL_COMP_SetInputPlus(COMP_TypeDef * COMPx,uint32_t InputPlus)1884 __STATIC_INLINE void LL_COMP_SetInputPlus(COMP_TypeDef *COMPx, uint32_t InputPlus)
1885 {
1886   /* Note: Connection switch is applicable only to COMP instance COMP1,       */
1887   /*       therefore if COMP2 is selected the equivalent bit is               */
1888   /*       kept unmodified.                                                   */
1889   MODIFY_REG(COMP->CSR,
1890              (COMP_CSR_COMP1SW1 * __COMP_IS_INSTANCE_ODD(COMPx)) << __COMP_BITOFFSET_INSTANCE(COMPx),
1891              InputPlus                                           << __COMP_BITOFFSET_INSTANCE(COMPx));
1892 }
1893 
1894 /**
1895   * @brief  Get comparator input plus (non-inverting).
1896   * @note   In case of comparator input selected to be connected to IO:
1897   *         GPIO pins are specific to each comparator instance.
1898   *         Refer to description of parameters or to reference manual.
1899   * @rmtoll CSR         COMP1INSEL      LL_COMP_GetInputPlus\n
1900   *         CSR         COMP2INSEL      LL_COMP_GetInputPlus
1901   * @param  COMPx Comparator instance
1902   * @retval Returned value can be one of the following values:
1903   *         @arg @ref LL_COMP_INPUT_PLUS_IO1
1904   *         @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1 (1)
1905   *
1906   *         (1) Parameter available only on COMP instance: COMP1.
1907   */
LL_COMP_GetInputPlus(COMP_TypeDef * COMPx)1908 __STATIC_INLINE uint32_t LL_COMP_GetInputPlus(COMP_TypeDef *COMPx)
1909 {
1910   /* Note: Connection switch is applicable only to COMP instance COMP1,       */
1911   /*       therefore is COMP2 is selected the returned value will be null.    */
1912   return (uint32_t)(READ_BIT(COMP->CSR,
1913                              COMP_CSR_COMP1SW1 << __COMP_BITOFFSET_INSTANCE(COMPx))
1914                     >> __COMP_BITOFFSET_INSTANCE(COMPx)
1915                    );
1916 }
1917 
1918 /**
1919   * @brief  Set comparator input minus (inverting).
1920   * @note   In case of comparator input selected to be connected to IO:
1921   *         GPIO pins are specific to each comparator instance.
1922   *         Refer to description of parameters or to reference manual.
1923   * @rmtoll CSR         COMP1SW1        LL_COMP_SetInputMinus
1924   * @param  COMPx Comparator instance
1925   * @param  InputMinus This parameter can be one of the following values:
1926   *         @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
1927   *         @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
1928   *         @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
1929   *         @arg @ref LL_COMP_INPUT_MINUS_VREFINT
1930   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
1931   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
1932   *         @arg @ref LL_COMP_INPUT_MINUS_IO1
1933   *         @arg @ref LL_COMP_INPUT_MINUS_IO2
1934   *         @arg @ref LL_COMP_INPUT_MINUS_IO3
1935   *         @arg @ref LL_COMP_INPUT_MINUS_IO4
1936   *         @arg @ref LL_COMP_INPUT_MINUS_DAC2_CH1
1937   * @retval None
1938   */
LL_COMP_SetInputMinus(COMP_TypeDef * COMPx,uint32_t InputMinus)1939 __STATIC_INLINE void LL_COMP_SetInputMinus(COMP_TypeDef *COMPx, uint32_t InputMinus)
1940 {
1941   MODIFY_REG(COMP->CSR,
1942              COMP_CSR_COMP1INSEL << __COMP_BITOFFSET_INSTANCE(COMPx),
1943              InputMinus          << __COMP_BITOFFSET_INSTANCE(COMPx));
1944 }
1945 
1946 /**
1947   * @brief  Get comparator input minus (inverting).
1948   * @note   In case of comparator input selected to be connected to IO:
1949   *         GPIO pins are specific to each comparator instance.
1950   *         Refer to description of parameters or to reference manual.
1951   * @rmtoll CSR         COMP1SW1        LL_COMP_GetInputMinus
1952   * @param  COMPx Comparator instance
1953   * @retval Returned value can be one of the following values:
1954   *         @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
1955   *         @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
1956   *         @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
1957   *         @arg @ref LL_COMP_INPUT_MINUS_VREFINT
1958   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
1959   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
1960   *         @arg @ref LL_COMP_INPUT_MINUS_IO1
1961   *         @arg @ref LL_COMP_INPUT_MINUS_IO2
1962   *         @arg @ref LL_COMP_INPUT_MINUS_IO3
1963   *         @arg @ref LL_COMP_INPUT_MINUS_IO4
1964   *         @arg @ref LL_COMP_INPUT_MINUS_DAC2_CH1
1965   */
LL_COMP_GetInputMinus(COMP_TypeDef * COMPx)1966 __STATIC_INLINE uint32_t LL_COMP_GetInputMinus(COMP_TypeDef *COMPx)
1967 {
1968   return (uint32_t)(READ_BIT(COMP->CSR,
1969                              COMP_CSR_COMP1INSEL << __COMP_BITOFFSET_INSTANCE(COMPx))
1970                     >> __COMP_BITOFFSET_INSTANCE(COMPx)
1971                    );
1972 }
1973 
1974 /**
1975   * @brief  Set comparator instance hysteresis mode of the input minus (inverting input).
1976   * @rmtoll CSR     COMP1HYST       LL_COMP_SetInputHysteresis\n
1977   *                 COMP2HYST       LL_COMP_SetInputHysteresis
1978   * @param  COMPx Comparator instance
1979   * @param  InputHysteresis This parameter can be one of the following values:
1980   *         @arg @ref LL_COMP_HYSTERESIS_NONE
1981   *         @arg @ref LL_COMP_HYSTERESIS_LOW
1982   *         @arg @ref LL_COMP_HYSTERESIS_MEDIUM
1983   *         @arg @ref LL_COMP_HYSTERESIS_HIGH
1984   * @retval None
1985   */
LL_COMP_SetInputHysteresis(COMP_TypeDef * COMPx,uint32_t InputHysteresis)1986 __STATIC_INLINE void LL_COMP_SetInputHysteresis(COMP_TypeDef *COMPx, uint32_t InputHysteresis)
1987 {
1988   MODIFY_REG(COMP->CSR,
1989              COMP_CSR_COMP1HYST << __COMP_BITOFFSET_INSTANCE(COMPx),
1990              InputHysteresis    << __COMP_BITOFFSET_INSTANCE(COMPx));
1991 }
1992 
1993 /**
1994   * @brief  Get comparator instance hysteresis mode of the minus (inverting) input.
1995   * @rmtoll CSR     COMP1HYST       LL_COMP_GetInputHysteresis\n
1996   *                 COMP2HYST       LL_COMP_GetInputHysteresis
1997   * @param  COMPx Comparator instance
1998   * @retval Returned value can be one of the following values:
1999   *         @arg @ref LL_COMP_HYSTERESIS_NONE
2000   *         @arg @ref LL_COMP_HYSTERESIS_LOW
2001   *         @arg @ref LL_COMP_HYSTERESIS_MEDIUM
2002   *         @arg @ref LL_COMP_HYSTERESIS_HIGH
2003   */
LL_COMP_GetInputHysteresis(COMP_TypeDef * COMPx)2004 __STATIC_INLINE uint32_t LL_COMP_GetInputHysteresis(COMP_TypeDef *COMPx)
2005 {
2006   return (uint32_t)(READ_BIT(COMP->CSR,
2007                              COMP_CSR_COMP1HYST << __COMP_BITOFFSET_INSTANCE(COMPx))
2008                     >> __COMP_BITOFFSET_INSTANCE(COMPx)
2009                    );
2010 
2011 }
2012 
2013 /**
2014   * @}
2015   */
2016 
2017 /** @defgroup COMP_LL_EF_Configuration_comparator_output Configuration of comparator output
2018   * @{
2019   */
2020 
2021 /**
2022   * @brief  Set comparator output selection.
2023   * @note   Availability of parameters of output selection to timer
2024   *         depends on timers availability on the selected device.
2025   * @rmtoll CSR     COMP1OUTSEL     LL_COMP_SetOutputSelection\n
2026   *                 COMP2OUTSEL     LL_COMP_SetOutputSelection
2027   * @param  COMPx Comparator instance
2028   * @param  OutputSelection This parameter can be one of the following values:
2029   *         @arg @ref LL_COMP_OUTPUT_NONE
2030   *         @arg @ref LL_COMP_OUTPUT_TIM16_BKIN     (1)
2031   *         @arg @ref LL_COMP_OUTPUT_TIM4_IC1       (1)
2032   *         @arg @ref LL_COMP_OUTPUT_TIM4_OCCLR     (1)
2033   *         @arg @ref LL_COMP_OUTPUT_TIM2_IC4       (1)
2034   *         @arg @ref LL_COMP_OUTPUT_TIM2_OCCLR     (1)
2035   *         @arg @ref LL_COMP_OUTPUT_TIM3_IC1       (1)
2036   *         @arg @ref LL_COMP_OUTPUT_TIM3_OCCLR     (1)
2037   *
2038   *         (1) Parameter availability depending on timer availability
2039   *             on the selected device.
2040   * @retval None
2041   */
LL_COMP_SetOutputSelection(COMP_TypeDef * COMPx,uint32_t OutputSelection)2042 __STATIC_INLINE void LL_COMP_SetOutputSelection(COMP_TypeDef *COMPx, uint32_t OutputSelection)
2043 {
2044   MODIFY_REG(COMP->CSR,
2045              COMP_CSR_COMP1OUTSEL << __COMP_BITOFFSET_INSTANCE(COMPx),
2046              OutputSelection      << __COMP_BITOFFSET_INSTANCE(COMPx));
2047 }
2048 
2049 /**
2050   * @brief  Get comparator output selection.
2051   * @note   Availability of parameters of output selection to timer
2052   *         depends on timers availability on the selected device.
2053   * @rmtoll CSR     COMP1OUTSEL     LL_COMP_GetOutputSelection\n
2054   *                 COMP2OUTSEL     LL_COMP_GetOutputSelection
2055   * @param  COMPx Comparator instance
2056   * @retval Returned value can be one of the following values:
2057   *         @arg @ref LL_COMP_OUTPUT_NONE
2058   *         @arg @ref LL_COMP_OUTPUT_TIM16_BKIN     (1)
2059   *         @arg @ref LL_COMP_OUTPUT_TIM4_IC1       (1)
2060   *         @arg @ref LL_COMP_OUTPUT_TIM4_OCCLR     (1)
2061   *         @arg @ref LL_COMP_OUTPUT_TIM2_IC4       (1)
2062   *         @arg @ref LL_COMP_OUTPUT_TIM2_OCCLR     (1)
2063   *         @arg @ref LL_COMP_OUTPUT_TIM3_IC1       (1)
2064   *         @arg @ref LL_COMP_OUTPUT_TIM3_OCCLR     (1)
2065   *
2066   *         (1) Parameter availability depending on timer availability
2067   *             on the selected device.
2068   */
LL_COMP_GetOutputSelection(COMP_TypeDef * COMPx)2069 __STATIC_INLINE uint32_t LL_COMP_GetOutputSelection(COMP_TypeDef *COMPx)
2070 {
2071   return (uint32_t)(READ_BIT(COMP->CSR,
2072                              COMP_CSR_COMP1OUTSEL << __COMP_BITOFFSET_INSTANCE(COMPx))
2073                     >> __COMP_BITOFFSET_INSTANCE(COMPx)
2074                    );
2075 }
2076 
2077 /**
2078   * @brief  Set comparator instance output polarity.
2079   * @rmtoll CSR         COMP1POL        LL_COMP_SetOutputPolarity\n
2080   *                     COMP2POL        LL_COMP_SetOutputPolarity
2081   * @param  COMPx Comparator instance
2082   * @param  OutputPolarity This parameter can be one of the following values:
2083   *         @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
2084   *         @arg @ref LL_COMP_OUTPUTPOL_INVERTED
2085   * @retval None
2086   */
LL_COMP_SetOutputPolarity(COMP_TypeDef * COMPx,uint32_t OutputPolarity)2087 __STATIC_INLINE void LL_COMP_SetOutputPolarity(COMP_TypeDef *COMPx, uint32_t OutputPolarity)
2088 {
2089   MODIFY_REG(COMP->CSR,
2090              COMP_CSR_COMP1POL << __COMP_BITOFFSET_INSTANCE(COMPx),
2091              OutputPolarity    << __COMP_BITOFFSET_INSTANCE(COMPx));
2092 }
2093 
2094 /**
2095   * @brief  Get comparator instance output polarity.
2096   * @rmtoll CSR         COMP1POL        LL_COMP_GetOutputPolarity\n
2097   *                     COMP2POL        LL_COMP_GetOutputPolarity
2098   * @param  COMPx Comparator instance
2099   * @retval Returned value can be one of the following values:
2100   *         @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
2101   *         @arg @ref LL_COMP_OUTPUTPOL_INVERTED
2102   */
LL_COMP_GetOutputPolarity(COMP_TypeDef * COMPx)2103 __STATIC_INLINE uint32_t LL_COMP_GetOutputPolarity(COMP_TypeDef *COMPx)
2104 {
2105   return (uint32_t)(READ_BIT(COMP->CSR,
2106                              COMP_CSR_COMP1POL << __COMP_BITOFFSET_INSTANCE(COMPx))
2107                     >> __COMP_BITOFFSET_INSTANCE(COMPx)
2108                    );
2109 }
2110 
2111 /**
2112   * @}
2113   */
2114 
2115 /** @defgroup COMP_LL_EF_Operation Operation on comparator instance
2116   * @{
2117   */
2118 
2119 /**
2120   * @brief  Enable comparator instance.
2121   * @note   After enable from off state, comparator requires a delay
2122   *         to reach reach propagation delay specification.
2123   *         Refer to device datasheet, parameter "tSTART".
2124   * @rmtoll CSR         COMP1EN         LL_COMP_Enable\n
2125   *                     COMP2EN         LL_COMP_Enable
2126   * @param  COMPx Comparator instance
2127   * @retval None
2128   */
LL_COMP_Enable(COMP_TypeDef * COMPx)2129 __STATIC_INLINE void LL_COMP_Enable(COMP_TypeDef *COMPx)
2130 {
2131   SET_BIT(COMP->CSR, COMP_CSR_COMP1EN << __COMP_BITOFFSET_INSTANCE(COMPx));
2132 }
2133 
2134 /**
2135   * @brief  Disable comparator instance.
2136   * @rmtoll CSR         COMP1EN         LL_COMP_Disable\n
2137   *                     COMP2EN         LL_COMP_Disable
2138   * @param  COMPx Comparator instance
2139   * @retval None
2140   */
LL_COMP_Disable(COMP_TypeDef * COMPx)2141 __STATIC_INLINE void LL_COMP_Disable(COMP_TypeDef *COMPx)
2142 {
2143   CLEAR_BIT(COMP->CSR, COMP_CSR_COMP1EN << __COMP_BITOFFSET_INSTANCE(COMPx));
2144 }
2145 
2146 /**
2147   * @brief  Get comparator enable state
2148   *         (0: COMP is disabled, 1: COMP is enabled)
2149   * @rmtoll CSR         COMP1EN         LL_COMP_IsEnabled\n
2150   *                     COMP2EN         LL_COMP_IsEnabled
2151   * @param  COMPx Comparator instance
2152   * @retval State of bit (1 or 0).
2153   */
LL_COMP_IsEnabled(COMP_TypeDef * COMPx)2154 __STATIC_INLINE uint32_t LL_COMP_IsEnabled(COMP_TypeDef *COMPx)
2155 {
2156   return (READ_BIT(COMP->CSR, COMP_CSR_COMP1EN << __COMP_BITOFFSET_INSTANCE(COMPx)) == COMP_CSR_COMP1EN <<
2157           __COMP_BITOFFSET_INSTANCE(COMPx));
2158 }
2159 
2160 /**
2161   * @brief  Lock comparator instance.
2162   * @note   Once locked, comparator configuration can be accessed in read-only.
2163   * @note   The only way to unlock the comparator is a device hardware reset.
2164   * @rmtoll CSR         COMP1LOCK       LL_COMP_Lock\n
2165   *                     COMP2LOCK       LL_COMP_Lock
2166   * @param  COMPx Comparator instance
2167   * @retval None
2168   */
LL_COMP_Lock(COMP_TypeDef * COMPx)2169 __STATIC_INLINE void LL_COMP_Lock(COMP_TypeDef *COMPx)
2170 {
2171   SET_BIT(COMP->CSR, COMP_CSR_COMP1LOCK << __COMP_BITOFFSET_INSTANCE(COMPx));
2172 }
2173 
2174 /**
2175   * @brief  Get comparator lock state
2176   *         (0: COMP is unlocked, 1: COMP is locked).
2177   * @note   Once locked, comparator configuration can be accessed in read-only.
2178   * @note   The only way to unlock the comparator is a device hardware reset.
2179   * @rmtoll CSR         COMP1LOCK       LL_COMP_IsLocked\n
2180   *                     COMP2LOCK       LL_COMP_IsLocked
2181   * @param  COMPx Comparator instance
2182   * @retval State of bit (1 or 0).
2183   */
LL_COMP_IsLocked(COMP_TypeDef * COMPx)2184 __STATIC_INLINE uint32_t LL_COMP_IsLocked(COMP_TypeDef *COMPx)
2185 {
2186   return (READ_BIT(COMP->CSR, COMP_CSR_COMP1LOCK << __COMP_BITOFFSET_INSTANCE(COMPx)) == COMP_CSR_COMP1LOCK <<
2187           __COMP_BITOFFSET_INSTANCE(COMPx));
2188 }
2189 
2190 /**
2191   * @brief  Read comparator instance output level.
2192   * @note   The comparator output level depends on the selected polarity
2193   *         (Refer to function @ref LL_COMP_SetOutputPolarity()).
2194   *         If the comparator polarity is not inverted:
2195   *          - Comparator output is low when the input plus
2196   *            is at a lower voltage than the input minus
2197   *          - Comparator output is high when the input plus
2198   *            is at a higher voltage than the input minus
2199   *         If the comparator polarity is inverted:
2200   *          - Comparator output is high when the input plus
2201   *            is at a lower voltage than the input minus
2202   *          - Comparator output is low when the input plus
2203   *            is at a higher voltage than the input minus
2204   * @rmtoll CSR         COMP1OUT        LL_COMP_ReadOutputLevel\n
2205   *                     COMP2OUT        LL_COMP_ReadOutputLevel
2206   * @param  COMPx Comparator instance
2207   * @retval Returned value can be one of the following values:
2208   *         @arg @ref LL_COMP_OUTPUT_LEVEL_LOW
2209   *         @arg @ref LL_COMP_OUTPUT_LEVEL_HIGH
2210   */
LL_COMP_ReadOutputLevel(COMP_TypeDef * COMPx)2211 __STATIC_INLINE uint32_t LL_COMP_ReadOutputLevel(COMP_TypeDef *COMPx)
2212 {
2213   return (uint32_t)(READ_BIT(COMP->CSR,
2214                              COMP_CSR_COMP1OUT << __COMP_BITOFFSET_INSTANCE(COMPx))
2215                     >> (__COMP_BITOFFSET_INSTANCE(COMPx) + LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS)
2216                    );
2217 }
2218 
2219 /**
2220   * @}
2221   */
2222 
2223 #if defined(USE_FULL_LL_DRIVER)
2224 /** @defgroup COMP_LL_EF_Init Initialization and de-initialization functions
2225   * @{
2226   */
2227 
2228 ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx);
2229 ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct);
2230 void        LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct);
2231 
2232 /**
2233   * @}
2234   */
2235 #endif /* USE_FULL_LL_DRIVER */
2236 
2237 /**
2238   * @}
2239   */
2240 
2241 /**
2242   * @}
2243   */
2244 
2245 #endif /* COMP1 || COMP2 */
2246 
2247 
2248 #endif /* STM32F373xC || STM32F378xx */
2249 
2250 /**
2251   * @}
2252   */
2253 
2254 #ifdef __cplusplus
2255 }
2256 #endif
2257 
2258 #endif /* __STM32F3xx_LL_COMP_H */
2259 
2260