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