1 /**
2   ******************************************************************************
3   * @file    stm32g4xx_hal_lptim.h
4   * @author  MCD Application Team
5   * @brief   Header file of LPTIM HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2019 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32G4xx_HAL_LPTIM_H
21 #define STM32G4xx_HAL_LPTIM_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32g4xx_hal_def.h"
29 
30 /** @addtogroup STM32G4xx_HAL_Driver
31   * @{
32   */
33 
34 
35 
36 /** @addtogroup LPTIM
37   * @{
38   */
39 
40 /* Exported types ------------------------------------------------------------*/
41 /** @defgroup LPTIM_Exported_Types LPTIM Exported Types
42   * @{
43   */
44 #define LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT  EXTI_IMR2_IM37  /*!< External interrupt line 37 Connected to the LPTIM EXTI Line */
45 
46 /**
47   * @brief  LPTIM Clock configuration definition
48   */
49 typedef struct
50 {
51   uint32_t Source;         /*!< Selects the clock source.
52                            This parameter can be a value of @ref LPTIM_Clock_Source   */
53 
54   uint32_t Prescaler;      /*!< Specifies the counter clock Prescaler.
55                            This parameter can be a value of @ref LPTIM_Clock_Prescaler */
56 
57 } LPTIM_ClockConfigTypeDef;
58 
59 /**
60   * @brief  LPTIM Clock configuration definition
61   */
62 typedef struct
63 {
64   uint32_t Polarity;      /*!< Selects the polarity of the active edge for the counter unit
65                            if the ULPTIM input is selected.
66                            Note: This parameter is used only when Ultra low power clock source is used.
67                            Note: If the polarity is configured on 'both edges', an auxiliary clock
68                            (one of the Low power oscillator) must be active.
69                            This parameter can be a value of @ref LPTIM_Clock_Polarity */
70 
71   uint32_t SampleTime;     /*!< Selects the clock sampling time to configure the clock glitch filter.
72                            Note: This parameter is used only when Ultra low power clock source is used.
73                            This parameter can be a value of @ref LPTIM_Clock_Sample_Time */
74 
75 } LPTIM_ULPClockConfigTypeDef;
76 
77 /**
78   * @brief  LPTIM Trigger configuration definition
79   */
80 typedef struct
81 {
82   uint32_t Source;        /*!< Selects the Trigger source.
83                           This parameter can be a value of @ref LPTIM_Trigger_Source */
84 
85   uint32_t ActiveEdge;    /*!< Selects the Trigger active edge.
86                           Note: This parameter is used only when an external trigger is used.
87                           This parameter can be a value of @ref LPTIM_External_Trigger_Polarity */
88 
89   uint32_t SampleTime;    /*!< Selects the trigger sampling time to configure the clock glitch filter.
90                           Note: This parameter is used only when an external trigger is used.
91                           This parameter can be a value of @ref LPTIM_Trigger_Sample_Time  */
92 } LPTIM_TriggerConfigTypeDef;
93 
94 /**
95   * @brief  LPTIM Initialization Structure definition
96   */
97 typedef struct
98 {
99   LPTIM_ClockConfigTypeDef     Clock;             /*!< Specifies the clock parameters */
100 
101   LPTIM_ULPClockConfigTypeDef  UltraLowPowerClock;/*!< Specifies the Ultra Low Power clock parameters */
102 
103   LPTIM_TriggerConfigTypeDef   Trigger;           /*!< Specifies the Trigger parameters */
104 
105   uint32_t                     OutputPolarity;    /*!< Specifies the Output polarity.
106                                                   This parameter can be a value of @ref LPTIM_Output_Polarity */
107 
108   uint32_t                     UpdateMode;        /*!< Specifies whether the update of the autoreload and the compare
109                                                   values is done immediately or after the end of current period.
110                                                   This parameter can be a value of @ref LPTIM_Updating_Mode */
111 
112   uint32_t                     CounterSource;     /*!< Specifies whether the counter is incremented each internal event
113                                                   or each external event.
114                                                   This parameter can be a value of @ref LPTIM_Counter_Source */
115 
116   uint32_t                     Input1Source;      /*!< Specifies source selected for input1 (GPIO or comparator output).
117                                                   This parameter can be a value of @ref LPTIM_Input1_Source */
118 
119   uint32_t                     Input2Source;      /*!< Specifies source selected for input2 (GPIO or comparator output).
120                                                   Note: This parameter is used only for encoder feature so is used only
121                                                   for LPTIM1 instance.
122                                                   This parameter can be a value of @ref LPTIM_Input2_Source */
123 } LPTIM_InitTypeDef;
124 
125 /**
126   * @brief  HAL LPTIM State structure definition
127   */
128 typedef enum
129 {
130   HAL_LPTIM_STATE_RESET            = 0x00U,    /*!< Peripheral not yet initialized or disabled  */
131   HAL_LPTIM_STATE_READY            = 0x01U,    /*!< Peripheral Initialized and ready for use    */
132   HAL_LPTIM_STATE_BUSY             = 0x02U,    /*!< An internal process is ongoing              */
133   HAL_LPTIM_STATE_TIMEOUT          = 0x03U,    /*!< Timeout state                               */
134   HAL_LPTIM_STATE_ERROR            = 0x04U     /*!< Internal Process is ongoing                 */
135 } HAL_LPTIM_StateTypeDef;
136 
137 /**
138   * @brief  LPTIM handle Structure definition
139   */
140 #if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
141 typedef struct __LPTIM_HandleTypeDef
142 #else
143 typedef struct
144 #endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
145 {
146   LPTIM_TypeDef                 *Instance;         /*!< Register base address     */
147 
148   LPTIM_InitTypeDef              Init;             /*!< LPTIM required parameters */
149 
150   HAL_StatusTypeDef              Status;           /*!< LPTIM peripheral status   */
151 
152   HAL_LockTypeDef                Lock;             /*!< LPTIM locking object      */
153 
154   __IO  HAL_LPTIM_StateTypeDef   State;            /*!< LPTIM peripheral state    */
155 
156 #if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
157   void (* MspInitCallback)(struct __LPTIM_HandleTypeDef *hlptim);            /*!< LPTIM Base Msp Init Callback                 */
158   void (* MspDeInitCallback)(struct __LPTIM_HandleTypeDef *hlptim);          /*!< LPTIM Base Msp DeInit Callback               */
159   void (* CompareMatchCallback)(struct __LPTIM_HandleTypeDef *hlptim);       /*!< Compare match Callback                       */
160   void (* AutoReloadMatchCallback)(struct __LPTIM_HandleTypeDef *hlptim);    /*!< Auto-reload match Callback                   */
161   void (* TriggerCallback)(struct __LPTIM_HandleTypeDef *hlptim);            /*!< External trigger event detection Callback    */
162   void (* CompareWriteCallback)(struct __LPTIM_HandleTypeDef *hlptim);       /*!< Compare register write complete Callback     */
163   void (* AutoReloadWriteCallback)(struct __LPTIM_HandleTypeDef *hlptim);    /*!< Auto-reload register write complete Callback */
164   void (* DirectionUpCallback)(struct __LPTIM_HandleTypeDef *hlptim);        /*!< Up-counting direction change Callback        */
165   void (* DirectionDownCallback)(struct __LPTIM_HandleTypeDef *hlptim);      /*!< Down-counting direction change Callback      */
166 #endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
167 } LPTIM_HandleTypeDef;
168 
169 #if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
170 /**
171   * @brief  HAL LPTIM Callback ID enumeration definition
172   */
173 typedef enum
174 {
175   HAL_LPTIM_MSPINIT_CB_ID          = 0x00U,    /*!< LPTIM Base Msp Init Callback ID                  */
176   HAL_LPTIM_MSPDEINIT_CB_ID        = 0x01U,    /*!< LPTIM Base Msp DeInit Callback ID                */
177   HAL_LPTIM_COMPARE_MATCH_CB_ID    = 0x02U,    /*!< Compare match Callback ID                        */
178   HAL_LPTIM_AUTORELOAD_MATCH_CB_ID = 0x03U,    /*!< Auto-reload match Callback ID                    */
179   HAL_LPTIM_TRIGGER_CB_ID          = 0x04U,    /*!< External trigger event detection Callback ID     */
180   HAL_LPTIM_COMPARE_WRITE_CB_ID    = 0x05U,    /*!< Compare register write complete Callback ID      */
181   HAL_LPTIM_AUTORELOAD_WRITE_CB_ID = 0x06U,    /*!< Auto-reload register write complete Callback ID  */
182   HAL_LPTIM_DIRECTION_UP_CB_ID     = 0x07U,    /*!< Up-counting direction change Callback ID         */
183   HAL_LPTIM_DIRECTION_DOWN_CB_ID   = 0x08U,    /*!< Down-counting direction change Callback ID       */
184 } HAL_LPTIM_CallbackIDTypeDef;
185 
186 /**
187   * @brief  HAL TIM Callback pointer definition
188   */
189 typedef  void (*pLPTIM_CallbackTypeDef)(LPTIM_HandleTypeDef *hlptim);  /*!< pointer to the LPTIM callback function */
190 
191 #endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
192 /**
193   * @}
194   */
195 
196 /* Exported constants --------------------------------------------------------*/
197 /** @defgroup LPTIM_Exported_Constants LPTIM Exported Constants
198   * @{
199   */
200 
201 /** @defgroup LPTIM_Clock_Source LPTIM Clock Source
202   * @{
203   */
204 #define LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC        0x00000000U
205 #define LPTIM_CLOCKSOURCE_ULPTIM                LPTIM_CFGR_CKSEL
206 /**
207   * @}
208   */
209 
210 /** @defgroup LPTIM_Clock_Prescaler LPTIM Clock Prescaler
211   * @{
212   */
213 #define LPTIM_PRESCALER_DIV1                    0x00000000U
214 #define LPTIM_PRESCALER_DIV2                    LPTIM_CFGR_PRESC_0
215 #define LPTIM_PRESCALER_DIV4                    LPTIM_CFGR_PRESC_1
216 #define LPTIM_PRESCALER_DIV8                    (LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_1)
217 #define LPTIM_PRESCALER_DIV16                   LPTIM_CFGR_PRESC_2
218 #define LPTIM_PRESCALER_DIV32                   (LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_2)
219 #define LPTIM_PRESCALER_DIV64                   (LPTIM_CFGR_PRESC_1 | LPTIM_CFGR_PRESC_2)
220 #define LPTIM_PRESCALER_DIV128                  LPTIM_CFGR_PRESC
221 /**
222   * @}
223   */
224 
225 /** @defgroup LPTIM_Output_Polarity LPTIM Output Polarity
226   * @{
227   */
228 
229 #define LPTIM_OUTPUTPOLARITY_HIGH               0x00000000U
230 #define LPTIM_OUTPUTPOLARITY_LOW                LPTIM_CFGR_WAVPOL
231 /**
232   * @}
233   */
234 
235 /** @defgroup LPTIM_Clock_Sample_Time LPTIM Clock Sample Time
236   * @{
237   */
238 #define LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION  0x00000000U
239 #define LPTIM_CLOCKSAMPLETIME_2TRANSITIONS      LPTIM_CFGR_CKFLT_0
240 #define LPTIM_CLOCKSAMPLETIME_4TRANSITIONS      LPTIM_CFGR_CKFLT_1
241 #define LPTIM_CLOCKSAMPLETIME_8TRANSITIONS      LPTIM_CFGR_CKFLT
242 /**
243   * @}
244   */
245 
246 /** @defgroup LPTIM_Clock_Polarity LPTIM Clock Polarity
247   * @{
248   */
249 #define LPTIM_CLOCKPOLARITY_RISING              0x00000000U
250 #define LPTIM_CLOCKPOLARITY_FALLING             LPTIM_CFGR_CKPOL_0
251 #define LPTIM_CLOCKPOLARITY_RISING_FALLING      LPTIM_CFGR_CKPOL_1
252 /**
253   * @}
254   */
255 
256 /** @defgroup LPTIM_Trigger_Source LPTIM Trigger Source
257   * @{
258   */
259 #define LPTIM_TRIGSOURCE_SOFTWARE               0x0000FFFFU
260 #define LPTIM_TRIGSOURCE_0                      0x00000000U
261 #define LPTIM_TRIGSOURCE_1                      LPTIM_CFGR_TRIGSEL_0
262 #define LPTIM_TRIGSOURCE_2                      LPTIM_CFGR_TRIGSEL_1
263 #define LPTIM_TRIGSOURCE_3                      (LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_1)
264 #define LPTIM_TRIGSOURCE_4                      LPTIM_CFGR_TRIGSEL_2
265 #define LPTIM_TRIGSOURCE_5                      (LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_2)
266 #define LPTIM_TRIGSOURCE_6                      (LPTIM_CFGR_TRIGSEL_1 | LPTIM_CFGR_TRIGSEL_2)
267 #define LPTIM_TRIGSOURCE_7                      (LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_1 | LPTIM_CFGR_TRIGSEL_2)
268 #define LPTIM_TRIGSOURCE_8                      LPTIM_CFGR_TRIGSEL_3
269 #define LPTIM_TRIGSOURCE_9                      (LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_3)
270 #define LPTIM_TRIGSOURCE_10                     (LPTIM_CFGR_TRIGSEL_1 | LPTIM_CFGR_TRIGSEL_3)
271 #define LPTIM_TRIGSOURCE_11                     (LPTIM_CFGR_TRIGSEL_0 |LPTIM_CFGR_TRIGSEL_1 | LPTIM_CFGR_TRIGSEL_3)
272 #define LPTIM_TRIGSOURCE_12                     (LPTIM_CFGR_TRIGSEL_2 | LPTIM_CFGR_TRIGSEL_3)
273 /**
274   * @}
275   */
276 
277 /** @defgroup LPTIM_External_Trigger_Polarity LPTIM External Trigger Polarity
278   * @{
279   */
280 #define LPTIM_ACTIVEEDGE_RISING                LPTIM_CFGR_TRIGEN_0
281 #define LPTIM_ACTIVEEDGE_FALLING               LPTIM_CFGR_TRIGEN_1
282 #define LPTIM_ACTIVEEDGE_RISING_FALLING        LPTIM_CFGR_TRIGEN
283 /**
284   * @}
285   */
286 
287 /** @defgroup LPTIM_Trigger_Sample_Time LPTIM Trigger Sample Time
288   * @{
289   */
290 #define LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION  0x00000000U
291 #define LPTIM_TRIGSAMPLETIME_2TRANSITIONS      LPTIM_CFGR_TRGFLT_0
292 #define LPTIM_TRIGSAMPLETIME_4TRANSITIONS      LPTIM_CFGR_TRGFLT_1
293 #define LPTIM_TRIGSAMPLETIME_8TRANSITIONS      LPTIM_CFGR_TRGFLT
294 /**
295   * @}
296   */
297 
298 /** @defgroup LPTIM_Updating_Mode LPTIM Updating Mode
299   * @{
300   */
301 
302 #define LPTIM_UPDATE_IMMEDIATE                  0x00000000U
303 #define LPTIM_UPDATE_ENDOFPERIOD                LPTIM_CFGR_PRELOAD
304 /**
305   * @}
306   */
307 
308 /** @defgroup LPTIM_Counter_Source LPTIM Counter Source
309   * @{
310   */
311 
312 #define LPTIM_COUNTERSOURCE_INTERNAL            0x00000000U
313 #define LPTIM_COUNTERSOURCE_EXTERNAL            LPTIM_CFGR_COUNTMODE
314 /**
315   * @}
316   */
317 
318 /** @defgroup LPTIM_Input1_Source LPTIM Input1 Source
319   * @{
320   */
321 
322 #define LPTIM_INPUT1SOURCE_GPIO         0x00000000U
323 #define LPTIM_INPUT1SOURCE_COMP1        LPTIM_OR_IN1_0
324 #define LPTIM_INPUT1SOURCE_COMP3        (LPTIM_OR_IN1_1 | LPTIM_OR_IN1_0)
325 #if defined(COMP5)
326 #define LPTIM_INPUT1SOURCE_COMP5        (LPTIM_OR_IN1_2 | LPTIM_OR_IN1_0)
327 #endif /* COMP5 */
328 #if defined(COMP7)
329 #define LPTIM_INPUT1SOURCE_COMP7        (LPTIM_OR_IN1_2 | LPTIM_OR_IN1_1 | LPTIM_OR_IN1_0)
330 #endif /* COMP7 */
331 /**
332   * @}
333   */
334 
335 /** @defgroup LPTIM_Input2_Source LPTIM Input2 Source
336   * @{
337   */
338 
339 #define LPTIM_INPUT2SOURCE_GPIO         0x00000000U
340 #define LPTIM_INPUT2SOURCE_COMP2        LPTIM_OR_IN2_0
341 #define LPTIM_INPUT2SOURCE_COMP4        (LPTIM_OR_IN2_1 | LPTIM_OR_IN2_0)
342 #if defined(COMP6)
343 #define LPTIM_INPUT2SOURCE_COMP6        (LPTIM_OR_IN2_2 | LPTIM_OR_IN2_0)
344 #endif /* COMP6 */
345 /**
346   * @}
347   */
348 
349 /** @defgroup LPTIM_Flag_Definition LPTIM Flags Definition
350   * @{
351   */
352 
353 #define LPTIM_FLAG_DOWN                          LPTIM_ISR_DOWN
354 #define LPTIM_FLAG_UP                            LPTIM_ISR_UP
355 #define LPTIM_FLAG_ARROK                         LPTIM_ISR_ARROK
356 #define LPTIM_FLAG_CMPOK                         LPTIM_ISR_CMPOK
357 #define LPTIM_FLAG_EXTTRIG                       LPTIM_ISR_EXTTRIG
358 #define LPTIM_FLAG_ARRM                          LPTIM_ISR_ARRM
359 #define LPTIM_FLAG_CMPM                          LPTIM_ISR_CMPM
360 /**
361   * @}
362   */
363 
364 /** @defgroup LPTIM_Interrupts_Definition LPTIM Interrupts Definition
365   * @{
366   */
367 #define LPTIM_IT_DOWN                            LPTIM_IER_DOWNIE
368 #define LPTIM_IT_UP                              LPTIM_IER_UPIE
369 #define LPTIM_IT_ARROK                           LPTIM_IER_ARROKIE
370 #define LPTIM_IT_CMPOK                           LPTIM_IER_CMPOKIE
371 #define LPTIM_IT_EXTTRIG                         LPTIM_IER_EXTTRIGIE
372 #define LPTIM_IT_ARRM                            LPTIM_IER_ARRMIE
373 #define LPTIM_IT_CMPM                            LPTIM_IER_CMPMIE
374 /**
375   * @}
376   */
377 
378 /**
379   * @}
380   */
381 
382 /* Exported macros -----------------------------------------------------------*/
383 /** @defgroup LPTIM_Exported_Macros LPTIM Exported Macros
384   * @{
385   */
386 
387 /** @brief Reset LPTIM handle state.
388   * @param  __HANDLE__ LPTIM handle
389   * @retval None
390   */
391 #if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
392 #define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) do {                                                        \
393                                                         (__HANDLE__)->State             = HAL_LPTIM_STATE_RESET; \
394                                                         (__HANDLE__)->MspInitCallback   = NULL;                  \
395                                                         (__HANDLE__)->MspDeInitCallback = NULL;                  \
396                                                       } while(0)
397 #else
398 #define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LPTIM_STATE_RESET)
399 #endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
400 
401 /**
402   * @brief  Enable the LPTIM peripheral.
403   * @param  __HANDLE__ LPTIM handle
404   * @retval None
405   */
406 #define __HAL_LPTIM_ENABLE(__HANDLE__)   ((__HANDLE__)->Instance->CR |= (LPTIM_CR_ENABLE))
407 
408 /**
409   * @brief  Disable the LPTIM peripheral.
410   * @param  __HANDLE__ LPTIM handle
411   * @note   The following sequence is required to solve LPTIM disable HW limitation.
412   *         Please check Errata Sheet ES0335 for more details under "MCU may remain
413   *         stuck in LPTIM interrupt when entering Stop mode" section.
414   * @note   Please call @ref HAL_LPTIM_GetState() after a call to __HAL_LPTIM_DISABLE to
415   *         check for TIMEOUT.
416   * @retval None
417   */
418 #define __HAL_LPTIM_DISABLE(__HANDLE__)   LPTIM_Disable(__HANDLE__)
419 
420 /**
421   * @brief  Start the LPTIM peripheral in Continuous mode.
422   * @param  __HANDLE__ LPTIM handle
423   * @retval None
424   */
425 #define __HAL_LPTIM_START_CONTINUOUS(__HANDLE__)  ((__HANDLE__)->Instance->CR |=  LPTIM_CR_CNTSTRT)
426 /**
427   * @brief  Start the LPTIM peripheral in single mode.
428   * @param  __HANDLE__ LPTIM handle
429   * @retval None
430   */
431 #define __HAL_LPTIM_START_SINGLE(__HANDLE__)      ((__HANDLE__)->Instance->CR |=  LPTIM_CR_SNGSTRT)
432 
433 /**
434   * @brief  Reset the LPTIM Counter register in synchronous mode.
435   * @param  __HANDLE__ LPTIM handle
436   * @retval None
437   */
438 #define __HAL_LPTIM_RESET_COUNTER(__HANDLE__)      ((__HANDLE__)->Instance->CR |=  LPTIM_CR_COUNTRST)
439 
440 /**
441   * @brief  Reset after read of the LPTIM Counter register in asynchronous mode.
442   * @param  __HANDLE__ LPTIM handle
443   * @retval None
444   */
445 #define __HAL_LPTIM_RESET_COUNTER_AFTERREAD(__HANDLE__)      ((__HANDLE__)->Instance->CR |=  LPTIM_CR_RSTARE)
446 
447 /**
448   * @brief  Write the passed parameter in the Autoreload register.
449   * @param  __HANDLE__ LPTIM handle
450   * @param  __VALUE__ Autoreload value
451   * @retval None
452   * @note   The ARR register can only be modified when the LPTIM instance is enabled.
453   */
454 #define __HAL_LPTIM_AUTORELOAD_SET(__HANDLE__ , __VALUE__)  ((__HANDLE__)->Instance->ARR =  (__VALUE__))
455 
456 /**
457   * @brief  Write the passed parameter in the Compare register.
458   * @param  __HANDLE__ LPTIM handle
459   * @param  __VALUE__ Compare value
460   * @retval None
461   * @note   The CMP register can only be modified when the LPTIM instance is enabled.
462   */
463 #define __HAL_LPTIM_COMPARE_SET(__HANDLE__ , __VALUE__)     ((__HANDLE__)->Instance->CMP =  (__VALUE__))
464 
465 /**
466   * @brief  Check whether the specified LPTIM flag is set or not.
467   * @param  __HANDLE__ LPTIM handle
468   * @param  __FLAG__ LPTIM flag to check
469   *            This parameter can be a value of:
470   *            @arg LPTIM_FLAG_DOWN    : Counter direction change up Flag.
471   *            @arg LPTIM_FLAG_UP      : Counter direction change down to up Flag.
472   *            @arg LPTIM_FLAG_ARROK   : Autoreload register update OK Flag.
473   *            @arg LPTIM_FLAG_CMPOK   : Compare register update OK Flag.
474   *            @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
475   *            @arg LPTIM_FLAG_ARRM    : Autoreload match Flag.
476   *            @arg LPTIM_FLAG_CMPM    : Compare match Flag.
477   * @retval The state of the specified flag (SET or RESET).
478   */
479 #define __HAL_LPTIM_GET_FLAG(__HANDLE__, __FLAG__)          (((__HANDLE__)->Instance->ISR &(__FLAG__)) == (__FLAG__))
480 
481 /**
482   * @brief  Clear the specified LPTIM flag.
483   * @param  __HANDLE__ LPTIM handle.
484   * @param  __FLAG__ LPTIM flag to clear.
485   *            This parameter can be a value of:
486   *            @arg LPTIM_FLAG_DOWN    : Counter direction change up Flag.
487   *            @arg LPTIM_FLAG_UP      : Counter direction change down to up Flag.
488   *            @arg LPTIM_FLAG_ARROK   : Autoreload register update OK Flag.
489   *            @arg LPTIM_FLAG_CMPOK   : Compare register update OK Flag.
490   *            @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
491   *            @arg LPTIM_FLAG_ARRM    : Autoreload match Flag.
492   *            @arg LPTIM_FLAG_CMPM    : Compare match Flag.
493   * @retval None.
494   */
495 #define __HAL_LPTIM_CLEAR_FLAG(__HANDLE__, __FLAG__)        ((__HANDLE__)->Instance->ICR  = (__FLAG__))
496 
497 /**
498   * @brief  Enable the specified LPTIM interrupt.
499   * @param  __HANDLE__ LPTIM handle.
500   * @param  __INTERRUPT__ LPTIM interrupt to set.
501   *            This parameter can be a value of:
502   *            @arg LPTIM_IT_DOWN    : Counter direction change up Interrupt.
503   *            @arg LPTIM_IT_UP      : Counter direction change down to up Interrupt.
504   *            @arg LPTIM_IT_ARROK   : Autoreload register update OK Interrupt.
505   *            @arg LPTIM_IT_CMPOK   : Compare register update OK Interrupt.
506   *            @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
507   *            @arg LPTIM_IT_ARRM    : Autoreload match Interrupt.
508   *            @arg LPTIM_IT_CMPM    : Compare match Interrupt.
509   * @retval None.
510   * @note   The LPTIM interrupts can only be enabled when the LPTIM instance is disabled.
511   */
512 #define __HAL_LPTIM_ENABLE_IT(__HANDLE__, __INTERRUPT__)    ((__HANDLE__)->Instance->IER  |= (__INTERRUPT__))
513 
514 /**
515   * @brief  Disable the specified LPTIM interrupt.
516   * @param  __HANDLE__ LPTIM handle.
517   * @param  __INTERRUPT__ LPTIM interrupt to set.
518   *            This parameter can be a value of:
519   *            @arg LPTIM_IT_DOWN    : Counter direction change up Interrupt.
520   *            @arg LPTIM_IT_UP      : Counter direction change down to up Interrupt.
521   *            @arg LPTIM_IT_ARROK   : Autoreload register update OK Interrupt.
522   *            @arg LPTIM_IT_CMPOK   : Compare register update OK Interrupt.
523   *            @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
524   *            @arg LPTIM_IT_ARRM    : Autoreload match Interrupt.
525   *            @arg LPTIM_IT_CMPM    : Compare match Interrupt.
526   * @retval None.
527   * @note   The LPTIM interrupts can only be disabled when the LPTIM instance is disabled.
528   */
529 #define __HAL_LPTIM_DISABLE_IT(__HANDLE__, __INTERRUPT__)   ((__HANDLE__)->Instance->IER  &= (~(__INTERRUPT__)))
530 
531 /**
532   * @brief  Check whether the specified LPTIM interrupt source is enabled or not.
533   * @param  __HANDLE__ LPTIM handle.
534   * @param  __INTERRUPT__ LPTIM interrupt to check.
535   *            This parameter can be a value of:
536   *            @arg LPTIM_IT_DOWN    : Counter direction change up Interrupt.
537   *            @arg LPTIM_IT_UP      : Counter direction change down to up Interrupt.
538   *            @arg LPTIM_IT_ARROK   : Autoreload register update OK Interrupt.
539   *            @arg LPTIM_IT_CMPOK   : Compare register update OK Interrupt.
540   *            @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
541   *            @arg LPTIM_IT_ARRM    : Autoreload match Interrupt.
542   *            @arg LPTIM_IT_CMPM    : Compare match Interrupt.
543   * @retval Interrupt status.
544   */
545 
546 #define __HAL_LPTIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER\
547                                                                 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
548 
549 /**
550   * @brief  Enable interrupt on the LPTIM Wake-up Timer associated Exti line.
551   * @retval None
552   */
553 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_IT()       (EXTI->IMR2\
554                                                         |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
555 
556 /**
557   * @brief  Disable interrupt on the LPTIM Wake-up Timer associated Exti line.
558   * @retval None
559   */
560 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_IT()      (EXTI->IMR2\
561                                                         &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
562 
563 /**
564   * @brief  Enable event on the LPTIM Wake-up Timer associated Exti line.
565   * @retval None.
566   */
567 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_EVENT()    (EXTI->EMR2\
568                                                         |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
569 
570 /**
571   * @brief  Disable event on the LPTIM Wake-up Timer associated Exti line.
572   * @retval None.
573   */
574 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_EVENT()   (EXTI->EMR2\
575                                                         &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
576 
577 /**
578   * @}
579   */
580 
581 /* Exported functions --------------------------------------------------------*/
582 /** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions
583   * @{
584   */
585 
586 /** @addtogroup LPTIM_Exported_Functions_Group1
587   *  @brief    Initialization and Configuration functions.
588   * @{
589   */
590 /* Initialization/de-initialization functions  ********************************/
591 HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
592 HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim);
593 
594 /* MSP functions  *************************************************************/
595 void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim);
596 void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim);
597 /**
598   * @}
599   */
600 
601 /** @addtogroup LPTIM_Exported_Functions_Group2
602   *  @brief   Start-Stop operation functions.
603   * @{
604   */
605 /* Start/Stop operation functions  *********************************************/
606 /* ################################# PWM Mode ################################*/
607 /* Blocking mode: Polling */
608 HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
609 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim);
610 /* Non-Blocking mode: Interrupt */
611 HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
612 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim);
613 
614 /* ############################# One Pulse Mode ##############################*/
615 /* Blocking mode: Polling */
616 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
617 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim);
618 /* Non-Blocking mode: Interrupt */
619 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
620 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim);
621 
622 /* ############################## Set once Mode ##############################*/
623 /* Blocking mode: Polling */
624 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
625 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim);
626 /* Non-Blocking mode: Interrupt */
627 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
628 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim);
629 
630 /* ############################### Encoder Mode ##############################*/
631 /* Blocking mode: Polling */
632 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
633 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim);
634 /* Non-Blocking mode: Interrupt */
635 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
636 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim);
637 
638 /* ############################# Time out  Mode ##############################*/
639 /* Blocking mode: Polling */
640 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
641 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim);
642 /* Non-Blocking mode: Interrupt */
643 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
644 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim);
645 
646 /* ############################## Counter Mode ###############################*/
647 /* Blocking mode: Polling */
648 HAL_StatusTypeDef HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
649 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef *hlptim);
650 /* Non-Blocking mode: Interrupt */
651 HAL_StatusTypeDef HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
652 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef *hlptim);
653 /**
654   * @}
655   */
656 
657 /** @addtogroup LPTIM_Exported_Functions_Group3
658   *  @brief  Read operation functions.
659   * @{
660   */
661 /* Reading operation functions ************************************************/
662 uint32_t HAL_LPTIM_ReadCounter(LPTIM_HandleTypeDef *hlptim);
663 uint32_t HAL_LPTIM_ReadAutoReload(LPTIM_HandleTypeDef *hlptim);
664 uint32_t HAL_LPTIM_ReadCompare(LPTIM_HandleTypeDef *hlptim);
665 /**
666   * @}
667   */
668 
669 /** @addtogroup LPTIM_Exported_Functions_Group4
670   *  @brief  LPTIM IRQ handler and callback functions.
671   * @{
672   */
673 /* LPTIM IRQ functions  *******************************************************/
674 void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim);
675 
676 /* CallBack functions  ********************************************************/
677 void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim);
678 void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim);
679 void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef *hlptim);
680 void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef *hlptim);
681 void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef *hlptim);
682 void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef *hlptim);
683 void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef *hlptim);
684 
685 /* Callbacks Register/UnRegister functions  ***********************************/
686 #if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
687 HAL_StatusTypeDef HAL_LPTIM_RegisterCallback(LPTIM_HandleTypeDef *lphtim, HAL_LPTIM_CallbackIDTypeDef CallbackID,
688                                              pLPTIM_CallbackTypeDef pCallback);
689 HAL_StatusTypeDef HAL_LPTIM_UnRegisterCallback(LPTIM_HandleTypeDef *lphtim, HAL_LPTIM_CallbackIDTypeDef CallbackID);
690 #endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
691 /**
692   * @}
693   */
694 
695 /** @addtogroup LPTIM_Group5
696   *  @brief   Peripheral State functions.
697   * @{
698   */
699 /* Peripheral State functions  ************************************************/
700 HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(LPTIM_HandleTypeDef *hlptim);
701 /**
702   * @}
703   */
704 
705 /**
706   * @}
707   */
708 
709 /* Private types -------------------------------------------------------------*/
710 /** @defgroup LPTIM_Private_Types LPTIM Private Types
711   * @{
712   */
713 
714 /**
715   * @}
716   */
717 
718 /* Private variables ---------------------------------------------------------*/
719 /** @defgroup LPTIM_Private_Variables LPTIM Private Variables
720   * @{
721   */
722 
723 /**
724   * @}
725   */
726 
727 /* Private constants ---------------------------------------------------------*/
728 /** @defgroup LPTIM_Private_Constants LPTIM Private Constants
729   * @{
730   */
731 
732 /**
733   * @}
734   */
735 
736 /* Private macros ------------------------------------------------------------*/
737 /** @defgroup LPTIM_Private_Macros LPTIM Private Macros
738   * @{
739   */
740 
741 #define IS_LPTIM_CLOCK_SOURCE(__SOURCE__)       (((__SOURCE__) == LPTIM_CLOCKSOURCE_ULPTIM) || \
742                                                  ((__SOURCE__) == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC))
743 
744 
745 #define IS_LPTIM_CLOCK_PRESCALER(__PRESCALER__) (((__PRESCALER__) ==  LPTIM_PRESCALER_DIV1  ) || \
746                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV2  ) || \
747                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV4  ) || \
748                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV8  ) || \
749                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV16 ) || \
750                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV32 ) || \
751                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV64 ) || \
752                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV128))
753 
754 #define IS_LPTIM_CLOCK_PRESCALERDIV1(__PRESCALER__) ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV1)
755 
756 #define IS_LPTIM_OUTPUT_POLARITY(__POLARITY__)  (((__POLARITY__) == LPTIM_OUTPUTPOLARITY_LOW ) || \
757                                                  ((__POLARITY__) == LPTIM_OUTPUTPOLARITY_HIGH))
758 
759 #define IS_LPTIM_CLOCK_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION) || \
760                                                     ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_2TRANSITIONS)     || \
761                                                     ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_4TRANSITIONS)     || \
762                                                     ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_8TRANSITIONS))
763 
764 #define IS_LPTIM_CLOCK_POLARITY(__POLARITY__)   (((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING)  || \
765                                                  ((__POLARITY__) == LPTIM_CLOCKPOLARITY_FALLING) || \
766                                                  ((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING_FALLING))
767 
768 #if defined(STM32G473xx) || defined(STM32G483xx) || defined(STM32G474xx) || defined(STM32G484xx)
769 #define IS_LPTIM_TRG_SOURCE(__TRIG__)           (((__TRIG__) == LPTIM_TRIGSOURCE_SOFTWARE) || \
770                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_0) || \
771                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_1) || \
772                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_2) || \
773                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_3) || \
774                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_4) || \
775                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_5) || \
776                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_6) || \
777                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_7) || \
778                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_8) || \
779                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_9) || \
780                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_10)|| \
781                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_11)|| \
782                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_12))
783 #else
784 #define IS_LPTIM_TRG_SOURCE(__TRIG__)           (((__TRIG__) == LPTIM_TRIGSOURCE_SOFTWARE) || \
785                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_0) || \
786                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_1) || \
787                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_2) || \
788                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_3) || \
789                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_4) || \
790                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_5) || \
791                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_6) || \
792                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_7) || \
793                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_8) || \
794                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_9))
795 #endif /* STM32G473xx || STM32G483xx || STM32G474xx || STM32G484xx */
796 
797 #define IS_LPTIM_EXT_TRG_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING         ) || \
798                                                  ((__POLARITY__) == LPTIM_ACTIVEEDGE_FALLING        ) || \
799                                                  ((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING_FALLING ))
800 
801 #define IS_LPTIM_TRIG_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION) || \
802                                                    ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_2TRANSITIONS    ) || \
803                                                    ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_4TRANSITIONS    ) || \
804                                                    ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_8TRANSITIONS    ))
805 
806 #define IS_LPTIM_UPDATE_MODE(__MODE__)          (((__MODE__) == LPTIM_UPDATE_IMMEDIATE) || \
807                                                  ((__MODE__) == LPTIM_UPDATE_ENDOFPERIOD))
808 
809 #define IS_LPTIM_COUNTER_SOURCE(__SOURCE__)     (((__SOURCE__) == LPTIM_COUNTERSOURCE_INTERNAL) || \
810                                                  ((__SOURCE__) == LPTIM_COUNTERSOURCE_EXTERNAL))
811 
812 #define IS_LPTIM_AUTORELOAD(__AUTORELOAD__)     ((__AUTORELOAD__) <= 0x0000FFFFUL)
813 
814 #define IS_LPTIM_COMPARE(__COMPARE__)           ((__COMPARE__) <= 0x0000FFFFUL)
815 
816 #define IS_LPTIM_PERIOD(__PERIOD__)             ((__PERIOD__) <= 0x0000FFFFUL)
817 
818 #define IS_LPTIM_PULSE(__PULSE__)               ((__PULSE__) <= 0x0000FFFFUL)
819 
820 #if defined(COMP5) && defined(COMP6) && defined(COMP7)
821 #define IS_LPTIM_INPUT1_SOURCE(__INSTANCE__, __SOURCE__)  \
822   ((((__INSTANCE__) == LPTIM1) &&                       \
823     (((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO) ||        \
824      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1) ||        \
825      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP3) ||        \
826      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP5) ||        \
827      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP7))))
828 
829 #define IS_LPTIM_INPUT2_SOURCE(__INSTANCE__, __SOURCE__)  \
830   (((__INSTANCE__) == LPTIM1) &&                       \
831    (((__SOURCE__) == LPTIM_INPUT2SOURCE_GPIO) ||        \
832     ((__SOURCE__) == LPTIM_INPUT2SOURCE_COMP2) ||        \
833     ((__SOURCE__) == LPTIM_INPUT2SOURCE_COMP4) ||        \
834     ((__SOURCE__) == LPTIM_INPUT2SOURCE_COMP6)))
835 #else
836 #define IS_LPTIM_INPUT1_SOURCE(__INSTANCE__, __SOURCE__)  \
837   ((((__INSTANCE__) == LPTIM1) &&                       \
838     (((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO) ||        \
839      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1) ||        \
840      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP3))))
841 
842 #define IS_LPTIM_INPUT2_SOURCE(__INSTANCE__, __SOURCE__)  \
843   (((__INSTANCE__) == LPTIM1) &&                       \
844    (((__SOURCE__) == LPTIM_INPUT2SOURCE_GPIO) ||        \
845     ((__SOURCE__) == LPTIM_INPUT2SOURCE_COMP2) ||        \
846     ((__SOURCE__) == LPTIM_INPUT2SOURCE_COMP4)))
847 #endif /* COMP5 && COMP6 && COMP7 */
848 
849 /**
850   * @}
851   */
852 
853 /* Private functions ---------------------------------------------------------*/
854 /** @defgroup LPTIM_Private_Functions LPTIM Private Functions
855   * @{
856   */
857 void LPTIM_Disable(LPTIM_HandleTypeDef *hlptim);
858 /**
859   * @}
860   */
861 
862 /**
863   * @}
864   */
865 
866 
867 /**
868   * @}
869   */
870 
871 #ifdef __cplusplus
872 }
873 #endif
874 
875 #endif /* STM32G4xx_HAL_LPTIM_H */
876