1 /**
2   ******************************************************************************
3   * @file    stm32wlxx_hal_lptim.h
4   * @author  MCD Application Team
5   * @brief   Header file of LPTIM HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2020 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 STM32WLxx_HAL_LPTIM_H
21 #define STM32WLxx_HAL_LPTIM_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32wlxx_hal_def.h"
29 
30 /** @addtogroup STM32WLxx_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_IMR1_IM29  /*!< External interrupt line 29 Connected to the LPTIM1 EXTI Line */
45 #define LPTIM_EXTI_LINE_LPTIM2  EXTI_IMR1_IM30  /*!< External interrupt line 30 Connected to the LPTIM2 EXTI Line */
46 #define LPTIM_EXTI_LINE_LPTIM3  EXTI_IMR1_IM31  /*!< External interrupt line 31 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 #if defined(CORE_CM0PLUS)
581 #define __HAL_LPTIM_LPTIM1_EXTI_ENABLE_IT()            (EXTI->C2IMR1\
582                                                         |= LPTIM_EXTI_LINE_LPTIM1)
583 #define __HAL_LPTIM_LPTIM1_EXTI_DISABLE_IT()           (EXTI->C2IMR1\
584                                                         &= ~(LPTIM_EXTI_LINE_LPTIM1))
585 
586 #define __HAL_LPTIM_LPTIM2_EXTI_ENABLE_IT()            (EXTI->C2IMR1\
587                                                         |= LPTIM_EXTI_LINE_LPTIM2)
588 #define __HAL_LPTIM_LPTIM2_EXTI_DISABLE_IT()           (EXTI->C2IMR1\
589                                                         &= ~(LPTIM_EXTI_LINE_LPTIM2))
590 
591 #define __HAL_LPTIM_LPTIM3_EXTI_ENABLE_IT()            (EXTI->C2IMR1\
592                                                         |= LPTIM_EXTI_LINE_LPTIM3)
593 #define __HAL_LPTIM_LPTIM3_EXTI_DISABLE_IT()           (EXTI->C2IMR1\
594                                                         &= ~(LPTIM_EXTI_LINE_LPTIM3))
595 #else
596 #define __HAL_LPTIM_LPTIM1_EXTI_ENABLE_IT()            (EXTI->IMR1 |= LPTIM_EXTI_LINE_LPTIM1)
597 #define __HAL_LPTIM_LPTIM1_EXTI_DISABLE_IT()           (EXTI->IMR1\
598                                                         &= ~(LPTIM_EXTI_LINE_LPTIM1))
599 
600 #define __HAL_LPTIM_LPTIM2_EXTI_ENABLE_IT()            (EXTI->IMR1 |= LPTIM_EXTI_LINE_LPTIM2)
601 #define __HAL_LPTIM_LPTIM2_EXTI_DISABLE_IT()           (EXTI->IMR1\
602                                                         &= ~(LPTIM_EXTI_LINE_LPTIM2))
603 
604 #define __HAL_LPTIM_LPTIM3_EXTI_ENABLE_IT()            (EXTI->IMR1 |= LPTIM_EXTI_LINE_LPTIM3)
605 #define __HAL_LPTIM_LPTIM3_EXTI_DISABLE_IT()           (EXTI->IMR1\
606                                                         &= ~(LPTIM_EXTI_LINE_LPTIM3))
607 #endif /* CORE_CM0PLUS */
608 
609 /**
610   * @}
611   */
612 
613 /* Exported functions --------------------------------------------------------*/
614 /** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions
615   * @{
616   */
617 
618 /** @addtogroup LPTIM_Exported_Functions_Group1
619   *  @brief    Initialization and Configuration functions.
620   * @{
621   */
622 /* Initialization/de-initialization functions  ********************************/
623 HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
624 HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim);
625 
626 /* MSP functions  *************************************************************/
627 void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim);
628 void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim);
629 /**
630   * @}
631   */
632 
633 /** @addtogroup LPTIM_Exported_Functions_Group2
634   *  @brief   Start-Stop operation functions.
635   * @{
636   */
637 /* Start/Stop operation functions  *********************************************/
638 /* ################################# PWM Mode ################################*/
639 /* Blocking mode: Polling */
640 HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
641 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim);
642 /* Non-Blocking mode: Interrupt */
643 HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
644 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim);
645 
646 /* ############################# One Pulse Mode ##############################*/
647 /* Blocking mode: Polling */
648 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
649 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim);
650 /* Non-Blocking mode: Interrupt */
651 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
652 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim);
653 
654 /* ############################## Set once Mode ##############################*/
655 /* Blocking mode: Polling */
656 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
657 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim);
658 /* Non-Blocking mode: Interrupt */
659 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
660 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim);
661 
662 /* ############################### Encoder Mode ##############################*/
663 /* Blocking mode: Polling */
664 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
665 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim);
666 /* Non-Blocking mode: Interrupt */
667 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
668 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim);
669 
670 /* ############################# Time out  Mode ##############################*/
671 /* Blocking mode: Polling */
672 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
673 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim);
674 /* Non-Blocking mode: Interrupt */
675 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
676 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim);
677 
678 /* ############################## Counter Mode ###############################*/
679 /* Blocking mode: Polling */
680 HAL_StatusTypeDef HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
681 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef *hlptim);
682 /* Non-Blocking mode: Interrupt */
683 HAL_StatusTypeDef HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
684 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef *hlptim);
685 /**
686   * @}
687   */
688 
689 /** @addtogroup LPTIM_Exported_Functions_Group3
690   *  @brief  Read operation functions.
691   * @{
692   */
693 /* Reading operation functions ************************************************/
694 uint32_t HAL_LPTIM_ReadCounter(const LPTIM_HandleTypeDef *hlptim);
695 uint32_t HAL_LPTIM_ReadAutoReload(const LPTIM_HandleTypeDef *hlptim);
696 uint32_t HAL_LPTIM_ReadCompare(const LPTIM_HandleTypeDef *hlptim);
697 /**
698   * @}
699   */
700 
701 /** @addtogroup LPTIM_Exported_Functions_Group4
702   *  @brief  LPTIM IRQ handler and callback functions.
703   * @{
704   */
705 /* LPTIM IRQ functions  *******************************************************/
706 void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim);
707 
708 /* CallBack functions  ********************************************************/
709 void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim);
710 void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim);
711 void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef *hlptim);
712 void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef *hlptim);
713 void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef *hlptim);
714 void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef *hlptim);
715 void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef *hlptim);
716 void HAL_LPTIM_UpdateEventCallback(LPTIM_HandleTypeDef *hlptim);
717 void HAL_LPTIM_RepCounterWriteCallback(LPTIM_HandleTypeDef *hlptim);
718 
719 /* Callbacks Register/UnRegister functions  ***********************************/
720 #if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
721 HAL_StatusTypeDef HAL_LPTIM_RegisterCallback(LPTIM_HandleTypeDef *lphtim, HAL_LPTIM_CallbackIDTypeDef CallbackID,
722                                              pLPTIM_CallbackTypeDef pCallback);
723 HAL_StatusTypeDef HAL_LPTIM_UnRegisterCallback(LPTIM_HandleTypeDef *lphtim, HAL_LPTIM_CallbackIDTypeDef CallbackID);
724 #endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
725 /**
726   * @}
727   */
728 
729 /** @addtogroup LPTIM_Group5
730   *  @brief   Peripheral State functions.
731   * @{
732   */
733 /* Peripheral State functions  ************************************************/
734 HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(LPTIM_HandleTypeDef *hlptim);
735 /**
736   * @}
737   */
738 
739 /**
740   * @}
741   */
742 
743 /* Private types -------------------------------------------------------------*/
744 /** @defgroup LPTIM_Private_Types LPTIM Private Types
745   * @{
746   */
747 
748 /**
749   * @}
750   */
751 
752 /* Private variables ---------------------------------------------------------*/
753 /** @defgroup LPTIM_Private_Variables LPTIM Private Variables
754   * @{
755   */
756 
757 /**
758   * @}
759   */
760 
761 /* Private constants ---------------------------------------------------------*/
762 /** @defgroup LPTIM_Private_Constants LPTIM Private Constants
763   * @{
764   */
765 
766 /**
767   * @}
768   */
769 
770 /* Private macros ------------------------------------------------------------*/
771 /** @defgroup LPTIM_Private_Macros LPTIM Private Macros
772   * @{
773   */
774 
775 #define IS_LPTIM_CLOCK_SOURCE(__SOURCE__)       (((__SOURCE__) == LPTIM_CLOCKSOURCE_ULPTIM) || \
776                                                  ((__SOURCE__) == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC))
777 
778 
779 #define IS_LPTIM_CLOCK_PRESCALER(__PRESCALER__) (((__PRESCALER__) ==  LPTIM_PRESCALER_DIV1  ) || \
780                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV2  ) || \
781                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV4  ) || \
782                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV8  ) || \
783                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV16 ) || \
784                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV32 ) || \
785                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV64 ) || \
786                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV128))
787 
788 #define IS_LPTIM_CLOCK_PRESCALERDIV1(__PRESCALER__) ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV1)
789 
790 #define IS_LPTIM_OUTPUT_POLARITY(__POLARITY__)  (((__POLARITY__) == LPTIM_OUTPUTPOLARITY_LOW ) || \
791                                                  ((__POLARITY__) == LPTIM_OUTPUTPOLARITY_HIGH))
792 
793 #define IS_LPTIM_CLOCK_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION) || \
794                                                     ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_2TRANSITIONS)     || \
795                                                     ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_4TRANSITIONS)     || \
796                                                     ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_8TRANSITIONS))
797 
798 #define IS_LPTIM_CLOCK_POLARITY(__POLARITY__)   (((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING)  || \
799                                                  ((__POLARITY__) == LPTIM_CLOCKPOLARITY_FALLING) || \
800                                                  ((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING_FALLING))
801 
802 #define IS_LPTIM_TRG_SOURCE(__TRIG__)           (((__TRIG__) == LPTIM_TRIGSOURCE_SOFTWARE) || \
803                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_0) || \
804                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_1) || \
805                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_2) || \
806                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_3) || \
807                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_4) || \
808                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_5) || \
809                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_6) || \
810                                                  ((__TRIG__) == LPTIM_TRIGSOURCE_7))
811 
812 #define IS_LPTIM_EXT_TRG_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING         ) || \
813                                                  ((__POLARITY__) == LPTIM_ACTIVEEDGE_FALLING        ) || \
814                                                  ((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING_FALLING ))
815 
816 #define IS_LPTIM_TRIG_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION) || \
817                                                    ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_2TRANSITIONS    ) || \
818                                                    ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_4TRANSITIONS    ) || \
819                                                    ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_8TRANSITIONS    ))
820 
821 #define IS_LPTIM_UPDATE_MODE(__MODE__)          (((__MODE__) == LPTIM_UPDATE_IMMEDIATE) || \
822                                                  ((__MODE__) == LPTIM_UPDATE_ENDOFPERIOD))
823 
824 #define IS_LPTIM_COUNTER_SOURCE(__SOURCE__)     (((__SOURCE__) == LPTIM_COUNTERSOURCE_INTERNAL) || \
825                                                  ((__SOURCE__) == LPTIM_COUNTERSOURCE_EXTERNAL))
826 
827 #define IS_LPTIM_AUTORELOAD(__AUTORELOAD__)     ((0x00000001UL <= (__AUTORELOAD__)) &&\
828                                                  ((__AUTORELOAD__) <= 0x0000FFFFUL))
829 
830 #define IS_LPTIM_COMPARE(__COMPARE__)           ((__COMPARE__) <= 0x0000FFFFUL)
831 
832 #define IS_LPTIM_PERIOD(__PERIOD__)             ((0x00000001UL <= (__PERIOD__)) &&\
833                                                  ((__PERIOD__) <= 0x0000FFFFUL))
834 
835 #define IS_LPTIM_PULSE(__PULSE__)               ((__PULSE__) <= 0x0000FFFFUL)
836 
837 #define IS_LPTIM_REPETITION(__REPETITION__)     ((__REPETITION__) <= 0x000000FFUL)
838 
839 #define IS_LPTIM_INPUT1_SOURCE(__INSTANCE__, __SOURCE__)     \
840   ((((__INSTANCE__) == LPTIM1) &&                          \
841     (((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO) ||           \
842      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1)))           \
843    ||                                                      \
844    (((__INSTANCE__) == LPTIM2) &&                          \
845     (((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO) ||           \
846      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1) ||          \
847      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP2) ||          \
848      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1_COMP2)))     \
849    ||                                                      \
850    (((__INSTANCE__) == LPTIM3) &&                          \
851     (((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO)  ||          \
852      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1) ||          \
853      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP2) ||          \
854      ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1_COMP2))))
855 
856 #define IS_LPTIM_INPUT2_SOURCE(__INSTANCE__, __SOURCE__)  \
857   (((__INSTANCE__) == LPTIM1) &&                       \
858    (((__SOURCE__) == LPTIM_INPUT2SOURCE_GPIO) ||        \
859     ((__SOURCE__) == LPTIM_INPUT2SOURCE_COMP2)))
860 
861 /**
862   * @}
863   */
864 
865 /* Private functions ---------------------------------------------------------*/
866 /** @defgroup LPTIM_Private_Functions LPTIM Private Functions
867   * @{
868   */
869 void LPTIM_Disable(LPTIM_HandleTypeDef *hlptim);
870 /**
871   * @}
872   */
873 
874 /**
875   * @}
876   */
877 
878 #endif /* LPTIM1 || LPTIM2  || LPTIM3 */
879 /**
880   * @}
881   */
882 
883 #ifdef __cplusplus
884 }
885 #endif
886 
887 #endif /* STM32WLxx_HAL_LPTIM_H */
888