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   *         This parameter must be a value between Min_Data = 0x0001 and Max_Data = 0xFFFF.
457   * @retval None
458   * @note   The ARR register can only be modified when the LPTIM instance is enabled.
459   */
460 #define __HAL_LPTIM_AUTORELOAD_SET(__HANDLE__ , __VALUE__)  ((__HANDLE__)->Instance->ARR =  (__VALUE__))
461 
462 /**
463   * @brief  Write the passed parameter in the Compare register.
464   * @param  __HANDLE__ LPTIM handle
465   * @param  __VALUE__ Compare value
466   * @retval None
467   * @note   The CMP register can only be modified when the LPTIM instance is enabled.
468   */
469 #define __HAL_LPTIM_COMPARE_SET(__HANDLE__ , __VALUE__)     ((__HANDLE__)->Instance->CMP =  (__VALUE__))
470 
471 /**
472   * @brief  Write the passed parameter in the Repetition register.
473   * @param  __HANDLE__ LPTIM handle
474   * @param  __VALUE__ Repetition value
475   * @retval None
476   */
477 #define __HAL_LPTIM_REPETITIONCOUNTER_SET(__HANDLE__ , __VALUE__)  ((__HANDLE__)->Instance->RCR =  (__VALUE__))
478 
479 /**
480   * @brief  Return the current Repetition value.
481   * @param  __HANDLE__ LPTIM handle
482   * @retval Repetition register value
483   * @note   The RCR register can only be modified when the LPTIM instance is enabled.
484   */
485 #define __HAL_LPTIM_REPETITIONCOUNTER_GET(__HANDLE__)  ((__HANDLE__)->Instance->RCR)
486 
487 /**
488   * @brief  Check whether the specified LPTIM flag is set or not.
489   * @param  __HANDLE__ LPTIM handle
490   * @param  __FLAG__ LPTIM flag to check
491   *            This parameter can be a value of:
492   *            @arg LPTIM_FLAG_REPOK   : Repetition register update OK Flag.
493   *            @arg LPTIM_FLAG_UPDATE  : Update event Flag.
494   *            @arg LPTIM_FLAG_DOWN    : Counter direction change up Flag.
495   *            @arg LPTIM_FLAG_UP      : Counter direction change down to up Flag.
496   *            @arg LPTIM_FLAG_ARROK   : Autoreload register update OK Flag.
497   *            @arg LPTIM_FLAG_CMPOK   : Compare register update OK Flag.
498   *            @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
499   *            @arg LPTIM_FLAG_ARRM    : Autoreload match Flag.
500   *            @arg LPTIM_FLAG_CMPM    : Compare match Flag.
501   * @retval The state of the specified flag (SET or RESET).
502   */
503 #define __HAL_LPTIM_GET_FLAG(__HANDLE__, __FLAG__)          (((__HANDLE__)->Instance->ISR &(__FLAG__)) == (__FLAG__))
504 
505 /**
506   * @brief  Clear the specified LPTIM flag.
507   * @param  __HANDLE__ LPTIM handle.
508   * @param  __FLAG__ LPTIM flag to clear.
509   *            This parameter can be a value of:
510   *            @arg LPTIM_FLAG_REPOK   : Repetition register update OK Flag.
511   *            @arg LPTIM_FLAG_UPDATE  : Update event Flag.
512   *            @arg LPTIM_FLAG_DOWN    : Counter direction change up Flag.
513   *            @arg LPTIM_FLAG_UP      : Counter direction change down to up Flag.
514   *            @arg LPTIM_FLAG_ARROK   : Autoreload register update OK Flag.
515   *            @arg LPTIM_FLAG_CMPOK   : Compare register update OK Flag.
516   *            @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
517   *            @arg LPTIM_FLAG_ARRM    : Autoreload match Flag.
518   *            @arg LPTIM_FLAG_CMPM    : Compare match Flag.
519   * @retval None.
520   */
521 #define __HAL_LPTIM_CLEAR_FLAG(__HANDLE__, __FLAG__)        ((__HANDLE__)->Instance->ICR  = (__FLAG__))
522 
523 /**
524   * @brief  Enable the specified LPTIM interrupt.
525   * @param  __HANDLE__ LPTIM handle.
526   * @param  __INTERRUPT__ LPTIM interrupt to set.
527   *            This parameter can be a value of:
528   *            @arg LPTIM_IT_REPOK   : Repetition register update OK Interrupt.
529   *            @arg LPTIM_IT_UPDATE  : Update event register Interrupt.
530   *            @arg LPTIM_IT_DOWN    : Counter direction change up Interrupt.
531   *            @arg LPTIM_IT_UP      : Counter direction change down to up Interrupt.
532   *            @arg LPTIM_IT_ARROK   : Autoreload register update OK Interrupt.
533   *            @arg LPTIM_IT_CMPOK   : Compare register update OK Interrupt.
534   *            @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
535   *            @arg LPTIM_IT_ARRM    : Autoreload match Interrupt.
536   *            @arg LPTIM_IT_CMPM    : Compare match Interrupt.
537   * @retval None.
538   * @note   The LPTIM interrupts can only be enabled when the LPTIM instance is disabled.
539   */
540 #define __HAL_LPTIM_ENABLE_IT(__HANDLE__, __INTERRUPT__)    ((__HANDLE__)->Instance->IER  |= (__INTERRUPT__))
541 
542 /**
543   * @brief  Disable the specified LPTIM interrupt.
544   * @param  __HANDLE__ LPTIM handle.
545   * @param  __INTERRUPT__ LPTIM interrupt to set.
546   *            This parameter can be a value of:
547   *            @arg LPTIM_IT_REPOK   : Repetition register update OK Interrupt.
548   *            @arg LPTIM_IT_UPDATE  : Update event register Interrupt.
549   *            @arg LPTIM_IT_DOWN    : Counter direction change up Interrupt.
550   *            @arg LPTIM_IT_UP      : Counter direction change down to up Interrupt.
551   *            @arg LPTIM_IT_ARROK   : Autoreload register update OK Interrupt.
552   *            @arg LPTIM_IT_CMPOK   : Compare register update OK Interrupt.
553   *            @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
554   *            @arg LPTIM_IT_ARRM    : Autoreload match Interrupt.
555   *            @arg LPTIM_IT_CMPM    : Compare match Interrupt.
556   * @retval None.
557   * @note   The LPTIM interrupts can only be disabled when the LPTIM instance is disabled.
558   */
559 #define __HAL_LPTIM_DISABLE_IT(__HANDLE__, __INTERRUPT__)   ((__HANDLE__)->Instance->IER  &= (~(__INTERRUPT__)))
560 
561 /**
562   * @brief  Check whether the specified LPTIM interrupt source is enabled or not.
563   * @param  __HANDLE__ LPTIM handle.
564   * @param  __INTERRUPT__ LPTIM interrupt to check.
565   *            This parameter can be a value of:
566   *            @arg LPTIM_IT_REPOK   : Repetition register update OK Interrupt.
567   *            @arg LPTIM_IT_UPDATE  : Update event register Interrupt.
568   *            @arg LPTIM_IT_DOWN    : Counter direction change up Interrupt.
569   *            @arg LPTIM_IT_UP      : Counter direction change down to up Interrupt.
570   *            @arg LPTIM_IT_ARROK   : Autoreload register update OK Interrupt.
571   *            @arg LPTIM_IT_CMPOK   : Compare register update OK Interrupt.
572   *            @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
573   *            @arg LPTIM_IT_ARRM    : Autoreload match Interrupt.
574   *            @arg LPTIM_IT_CMPM    : Compare match Interrupt.
575   * @retval Interrupt status.
576   */
577 
578 #define __HAL_LPTIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER\
579                                                                 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
580 
581 /**
582   * @brief  Enable the LPTIM1 EXTI line in interrupt mode.
583   * @retval None
584   */
585 #define __HAL_LPTIM_LPTIM1_EXTI_ENABLE_IT()            (EXTI->IMR2 |= LPTIM_EXTI_LINE_LPTIM1)
586 
587 /**
588   * @brief  Disable the LPTIM1 EXTI line in interrupt mode.
589   * @retval None
590   */
591 #define __HAL_LPTIM_LPTIM1_EXTI_DISABLE_IT()           (EXTI->IMR2\
592                                                         &= ~(LPTIM_EXTI_LINE_LPTIM1))
593 
594 /**
595   * @brief  Enable the LPTIM1 EXTI line in event mode.
596   * @retval None
597   */
598 #define __HAL_LPTIM_LPTIM1_EXTI_ENABLE_EVENT()         (EXTI->EMR2 |= LPTIM_EXTI_LINE_LPTIM1)
599 
600 /**
601   * @brief  Disable the LPTIM1 EXTI line in event mode.
602   * @retval None
603   */
604 #define __HAL_LPTIM_LPTIM1_EXTI_DISABLE_EVENT()        (EXTI->EMR2\
605                                                         &= ~(LPTIM_EXTI_LINE_LPTIM1))
606 
607 /**
608   * @brief  Enable the LPTIM2 EXTI line in interrupt mode.
609   * @retval None
610   */
611 #define __HAL_LPTIM_LPTIM2_EXTI_ENABLE_IT()            (EXTI->IMR2 |= LPTIM_EXTI_LINE_LPTIM2)
612 
613 /**
614   * @brief  Disable the LPTIM2 EXTI line in interrupt mode.
615   * @retval None
616   */
617 #define __HAL_LPTIM_LPTIM2_EXTI_DISABLE_IT()           (EXTI->IMR2\
618                                                         &= ~(LPTIM_EXTI_LINE_LPTIM2))
619 
620 /**
621   * @brief  Enable the LPTIM2 EXTI line in event mode.
622   * @retval None
623   */
624 #define __HAL_LPTIM_LPTIM2_EXTI_ENABLE_EVENT()         (EXTI->EMR2 |= LPTIM_EXTI_LINE_LPTIM2)
625 
626 /**
627   * @brief  Disable the LPTIM2 EXTI line in event mode.
628   * @retval None
629   */
630 #define __HAL_LPTIM_LPTIM2_EXTI_DISABLE_EVENT()        (EXTI->EMR2\
631                                                         &= ~(LPTIM_EXTI_LINE_LPTIM2))
632 
633 /**
634   * @brief  Enable the LPTIM3 EXTI line in interrupt mode.
635   * @retval None
636   */
637 #define __HAL_LPTIM_LPTIM3_EXTI_ENABLE_IT()            (EXTI->IMR2 |= LPTIM_EXTI_LINE_LPTIM3)
638 
639 /**
640   * @brief  Disable the LPTIM3 EXTI line in interrupt mode.
641   * @retval None
642   */
643 #define __HAL_LPTIM_LPTIM3_EXTI_DISABLE_IT()           (EXTI->IMR2\
644                                                         &= ~(LPTIM_EXTI_LINE_LPTIM3))
645 
646 /**
647   * @brief  Enable the LPTIM3 EXTI line in event mode.
648   * @retval None
649   */
650 #define __HAL_LPTIM_LPTIM3_EXTI_ENABLE_EVENT()         (EXTI->EMR2 |= LPTIM_EXTI_LINE_LPTIM3)
651 
652 /**
653   * @brief  Disable the LPTIM3 EXTI line in event mode.
654   * @retval None
655   */
656 #define __HAL_LPTIM_LPTIM3_EXTI_DISABLE_EVENT()        (EXTI->EMR2\
657                                                         &= ~(LPTIM_EXTI_LINE_LPTIM3))
658 
659 /**
660   * @}
661   */
662 
663 /* Exported functions --------------------------------------------------------*/
664 /** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions
665   * @{
666   */
667 
668 /** @addtogroup LPTIM_Exported_Functions_Group1
669   *  @brief    Initialization and Configuration functions.
670   * @{
671   */
672 /* Initialization/de-initialization functions  ********************************/
673 HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
674 HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim);
675 
676 /* MSP functions  *************************************************************/
677 void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim);
678 void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim);
679 /**
680   * @}
681   */
682 
683 /** @addtogroup LPTIM_Exported_Functions_Group2
684   *  @brief   Start-Stop operation functions.
685   * @{
686   */
687 /* Start/Stop operation functions  *********************************************/
688 /* ################################# PWM Mode ################################*/
689 /* Blocking mode: Polling */
690 HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
691 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim);
692 /* Non-Blocking mode: Interrupt */
693 HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
694 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim);
695 
696 /* ############################# One Pulse Mode ##############################*/
697 /* Blocking mode: Polling */
698 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
699 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim);
700 /* Non-Blocking mode: Interrupt */
701 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
702 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim);
703 
704 /* ############################## Set once Mode ##############################*/
705 /* Blocking mode: Polling */
706 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
707 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim);
708 /* Non-Blocking mode: Interrupt */
709 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
710 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim);
711 
712 /* ############################### Encoder Mode ##############################*/
713 /* Blocking mode: Polling */
714 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
715 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim);
716 /* Non-Blocking mode: Interrupt */
717 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
718 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim);
719 
720 /* ############################# Time out  Mode ##############################*/
721 /* Blocking mode: Polling */
722 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
723 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim);
724 /* Non-Blocking mode: Interrupt */
725 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
726 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim);
727 
728 /* ############################## Counter Mode ###############################*/
729 /* Blocking mode: Polling */
730 HAL_StatusTypeDef HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
731 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef *hlptim);
732 /* Non-Blocking mode: Interrupt */
733 HAL_StatusTypeDef HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
734 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef *hlptim);
735 /**
736   * @}
737   */
738 
739 /** @addtogroup LPTIM_Exported_Functions_Group3
740   *  @brief  Read operation functions.
741   * @{
742   */
743 /* Reading operation functions ************************************************/
744 uint32_t HAL_LPTIM_ReadCounter(const LPTIM_HandleTypeDef *hlptim);
745 uint32_t HAL_LPTIM_ReadAutoReload(const LPTIM_HandleTypeDef *hlptim);
746 uint32_t HAL_LPTIM_ReadCompare(const LPTIM_HandleTypeDef *hlptim);
747 /**
748   * @}
749   */
750 
751 /** @addtogroup LPTIM_Exported_Functions_Group4
752   *  @brief  LPTIM IRQ handler and callback functions.
753   * @{
754   */
755 /* LPTIM IRQ functions  *******************************************************/
756 void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim);
757 
758 /* CallBack functions  ********************************************************/
759 void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim);
760 void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim);
761 void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef *hlptim);
762 void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef *hlptim);
763 void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef *hlptim);
764 void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef *hlptim);
765 void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef *hlptim);
766 void HAL_LPTIM_UpdateEventCallback(LPTIM_HandleTypeDef *hlptim);
767 void HAL_LPTIM_RepCounterWriteCallback(LPTIM_HandleTypeDef *hlptim);
768 
769 /* Callbacks Register/UnRegister functions  ***********************************/
770 #if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
771 HAL_StatusTypeDef HAL_LPTIM_RegisterCallback(LPTIM_HandleTypeDef *lphtim, HAL_LPTIM_CallbackIDTypeDef CallbackID,
772                                              pLPTIM_CallbackTypeDef pCallback);
773 HAL_StatusTypeDef HAL_LPTIM_UnRegisterCallback(LPTIM_HandleTypeDef *lphtim, HAL_LPTIM_CallbackIDTypeDef CallbackID);
774 #endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
775 /**
776   * @}
777   */
778 
779 /** @addtogroup LPTIM_Group5
780   *  @brief   Peripheral State functions.
781   * @{
782   */
783 /* Peripheral State functions  ************************************************/
784 HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(const LPTIM_HandleTypeDef *hlptim);
785 /**
786   * @}
787   */
788 
789 /**
790   * @}
791   */
792 
793 /* Private types -------------------------------------------------------------*/
794 /** @defgroup LPTIM_Private_Types LPTIM Private Types
795   * @{
796   */
797 
798 /**
799   * @}
800   */
801 
802 /* Private variables ---------------------------------------------------------*/
803 /** @defgroup LPTIM_Private_Variables LPTIM Private Variables
804   * @{
805   */
806 
807 /**
808   * @}
809   */
810 
811 /* Private constants ---------------------------------------------------------*/
812 /** @defgroup LPTIM_Private_Constants LPTIM Private Constants
813   * @{
814   */
815 
816 /**
817   * @}
818   */
819 
820 /* Private macros ------------------------------------------------------------*/
821 /** @defgroup LPTIM_Private_Macros LPTIM Private Macros
822   * @{
823   */
824 
825 #define IS_LPTIM_CLOCK_SOURCE(__SOURCE__)       (((__SOURCE__) == LPTIM_CLOCKSOURCE_ULPTIM) || \
826                                                  ((__SOURCE__) == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC))
827 
828 
829 #define IS_LPTIM_CLOCK_PRESCALER(__PRESCALER__) (((__PRESCALER__) ==  LPTIM_PRESCALER_DIV1  ) || \
830                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV2  ) || \
831                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV4  ) || \
832                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV8  ) || \
833                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV16 ) || \
834                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV32 ) || \
835                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV64 ) || \
836                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV128))
837 
838 #define IS_LPTIM_CLOCK_PRESCALERDIV1(__PRESCALER__) ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV1)
839 
840 #define IS_LPTIM_OUTPUT_POLARITY(__POLARITY__)  (((__POLARITY__) == LPTIM_OUTPUTPOLARITY_LOW ) || \
841                                                  ((__POLARITY__) == LPTIM_OUTPUTPOLARITY_HIGH))
842 
843 #define IS_LPTIM_CLOCK_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION) || \
844                                                     ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_2TRANSITIONS)     || \
845                                                     ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_4TRANSITIONS)     || \
846                                                     ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_8TRANSITIONS))
847 
848 #define IS_LPTIM_CLOCK_POLARITY(__POLARITY__)   (((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING)  || \
849                                                  ((__POLARITY__) == LPTIM_CLOCKPOLARITY_FALLING) || \
850                                                  ((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING_FALLING))
851 
852 #define IS_LPTIM_TRG_SOURCE(__TRIG__)           (((__TRIG__) == LPTIM_TRIGSOURCE_SOFTWARE) || \
853                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_0) || \
854                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_1) || \
855                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_2) || \
856                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_3) || \
857                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_4) || \
858                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_5) || \
859                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_6) || \
860                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_7))
861 
862 #define IS_LPTIM_EXT_TRG_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING         ) || \
863                                                  ((__POLARITY__) == LPTIM_ACTIVEEDGE_FALLING        ) || \
864                                                  ((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING_FALLING ))
865 
866 #define IS_LPTIM_TRIG_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION) || \
867                                                    ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_2TRANSITIONS    ) || \
868                                                    ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_4TRANSITIONS    ) || \
869                                                    ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_8TRANSITIONS    ))
870 
871 #define IS_LPTIM_UPDATE_MODE(__MODE__)          (((__MODE__) == LPTIM_UPDATE_IMMEDIATE) || \
872                                                  ((__MODE__) == LPTIM_UPDATE_ENDOFPERIOD))
873 
874 #define IS_LPTIM_COUNTER_SOURCE(__SOURCE__)     (((__SOURCE__) == LPTIM_COUNTERSOURCE_INTERNAL) || \
875                                                  ((__SOURCE__) == LPTIM_COUNTERSOURCE_EXTERNAL))
876 
877 #define IS_LPTIM_COMPARE(__COMPARE__)           ((__COMPARE__) <= 0x0000FFFFUL)
878 
879 #define IS_LPTIM_PERIOD(__PERIOD__)             ((0x00000001UL <= (__PERIOD__)) &&\
880                                                  ((__PERIOD__) <= 0x0000FFFFUL))
881 
882 #define IS_LPTIM_PULSE(__PULSE__)               ((__PULSE__) <= 0x0000FFFFUL)
883 
884 #define IS_LPTIM_REPETITION(__REPETITION__)     ((__REPETITION__) <= 0x000000FFUL)
885 
886 #define IS_LPTIM_INPUT1_SOURCE(__INSTANCE__, __SOURCE__)     \
887   ((((__INSTANCE__) == LPTIM1) &&                          \
888     (((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO) ||           \
889      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1)))           \
890    ||                                                      \
891    (((__INSTANCE__) == LPTIM2) &&                          \
892     (((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO) ||           \
893      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1) ||          \
894      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP2) ||          \
895      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1_COMP2)))     \
896    ||                                                      \
897    (((__INSTANCE__) == LPTIM3) &&                          \
898     (((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO)  ||          \
899      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1) ||          \
900      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP2) ||          \
901      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1_COMP2))))
902 
903 #define IS_LPTIM_INPUT2_SOURCE(__INSTANCE__, __SOURCE__)  \
904   (((__INSTANCE__) == LPTIM1) &&                       \
905    (((__SOURCE__) == LPTIM_INPUT2SOURCE_GPIO) ||        \
906     ((__SOURCE__) == LPTIM_INPUT2SOURCE_COMP2)))
907 
908 /**
909   * @}
910   */
911 
912 /* Private functions ---------------------------------------------------------*/
913 /** @defgroup LPTIM_Private_Functions LPTIM Private Functions
914   * @{
915   */
916 void LPTIM_Disable(LPTIM_HandleTypeDef *hlptim);
917 /**
918   * @}
919   */
920 
921 /**
922   * @}
923   */
924 
925 #endif /* LPTIM1 || LPTIM2 || LPTIM3 */
926 /**
927   * @}
928   */
929 
930 #ifdef __cplusplus
931 }
932 #endif
933 
934 #endif /* STM32L5xx_HAL_LPTIM_H */
935