]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32L0/stm32l0xx_hal_lptim.h
Merge commit '5a0132f1c1c9a14fd2941f0a5e29bbf5e31da20c' into master-core-pull
[max/tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32L0 / stm32l0xx_hal_lptim.h
1 /**
2   ******************************************************************************
3   * @file    stm32l0xx_hal_lptim.h
4   * @author  MCD Application Team
5   * @version V1.2.0
6   * @date    06-February-2015
7   * @brief   Header file of LPTIM HAL module.
8   ******************************************************************************
9   * @attention
10   *
11   * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
12   *
13   * Redistribution and use in source and binary forms, with or without modification,
14   * are permitted provided that the following conditions are met:
15   *   1. Redistributions of source code must retain the above copyright notice,
16   *      this list of conditions and the following disclaimer.
17   *   2. Redistributions in binary form must reproduce the above copyright notice,
18   *      this list of conditions and the following disclaimer in the documentation
19   *      and/or other materials provided with the distribution.
20   *   3. Neither the name of STMicroelectronics nor the names of its contributors
21   *      may be used to endorse or promote products derived from this software
22   *      without specific prior written permission.
23   *
24   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34   *
35   ******************************************************************************
36   */ 
37
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32L0xx_HAL_LPTIM_H
40 #define __STM32L0xx_HAL_LPTIM_H
41
42 #ifdef __cplusplus
43  extern "C" {
44 #endif
45
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32l0xx_hal_def.h"
48
49 /** @addtogroup STM32L0xx_HAL_Driver
50   * @{
51   */
52
53 /** @defgroup LPTIM LPTIM (Low power timer)
54   * @{
55   */ 
56
57 /* Exported types ------------------------------------------------------------*/ 
58  /** @defgroup TIM_Exported_Types TIM Exported Types
59   * @{
60   */
61
62 /** @defgroup LPTIM_Clock_Configuration LPTIM Clock configuration structure
63   * @{
64   */
65 /** 
66   * @brief  LPTIM Clock configuration definition  
67   */
68 typedef struct
69 {
70   uint32_t Source;         /*!< Selects the clock source.
71                            This parameter can be a value of @ref LPTIM_Clock_Source   */
72
73   uint32_t Prescaler;      /*!< Specifies the counter clock Prescaler.
74                            This parameter can be a value of @ref LPTIM_Clock_Prescaler */
75   
76 }LPTIM_ClockConfigTypeDef;
77 /**
78   * @}
79   */
80
81 /** @defgroup LPTIM_ULPClock_Configuration LPTIM ULP Clock configuration structure
82   * @{
83   */
84 /** 
85   * @brief  LPTIM ULP Clock configuration definition
86   */
87 typedef struct
88 {
89   uint32_t Polarity;      /*!< Selects the polarity of the active edge for the counter unit
90                            if the ULPTIM input is selected.
91                            Note: This parameter is used only when Ultra low power clock source is used.
92                            Note: If the polarity is configured on 'both edges', an auxiliary clock
93                            (one of the Low power oscillator) must be active.
94                            This parameter can be a value of @ref LPTIM_Clock_Polarity */ 
95   
96   uint32_t SampleTime;     /*!< Selects the clock sampling time to configure the clock glitch filter.
97                            Note: This parameter is used only when Ultra low power clock source is used.
98                            This parameter can be a value of @ref LPTIM_Clock_Sample_Time */  
99   
100 }LPTIM_ULPClockConfigTypeDef;
101 /**
102   * @}
103   */
104
105 /** @defgroup LPTIM_Trigger_Configuration LPTIM Trigger configuration structure
106   * @{
107   */
108 /** 
109   * @brief  LPTIM Trigger configuration structure
110   */
111 typedef struct
112 {
113   uint32_t Source;        /*!< Selects the Trigger source.
114                           This parameter can be a value of @ref LPTIM_Trigger_Source */
115   
116   uint32_t ActiveEdge;    /*!< Selects the Trigger active edge.
117                           Note: This parameter is used only when an external trigger is used.
118                           This parameter can be a value of @ref LPTIM_External_Trigger_Polarity */
119   
120   uint32_t SampleTime;    /*!< Selects the trigger sampling time to configure the clock glitch filter.
121                           Note: This parameter is used only when an external trigger is used.
122                           This parameter can be a value of @ref LPTIM_Trigger_Sample_Time  */  
123 }LPTIM_TriggerConfigTypeDef;
124 /**
125   * @}
126   */
127
128 /** @defgroup LPTIM_Init_Configuration LPTIM Initialization configuration structure
129   * @{
130   */
131 /** 
132   * @brief  LPTIM Initialization Structure definition  
133   */
134 typedef struct
135 {                                                    
136   LPTIM_ClockConfigTypeDef     Clock;               /*!< Specifies the clock parameters */
137                                                     
138   LPTIM_ULPClockConfigTypeDef  UltraLowPowerClock;  /*!< Specifies the Ultra Low Power clock parameters */
139                                                     
140   LPTIM_TriggerConfigTypeDef   Trigger;             /*!< Specifies the Trigger parameters */
141                                                     
142   uint32_t                     OutputPolarity;      /*!< Specifies the Output polarity.
143                                                     This parameter can be a value of @ref LPTIM_Output_Polarity */
144                                                     
145   uint32_t                     UpdateMode;          /*!< Specifies whether the update of the autorelaod and the compare
146                                                     values is done immediately or after the end of current period.
147                                                     This parameter can be a value of @ref LPTIM_Updating_Mode */
148
149   uint32_t                     CounterSource;       /*!< Specifies whether the counter is incremented each internal event
150                                                     or each external event.
151                                                     This parameter can be a value of @ref LPTIM_Counter_Source */  
152   
153 }LPTIM_InitTypeDef;
154 /**
155   * @}
156   */
157 /** @defgroup LPTIM_State_structure  LPTIM state definition
158   * @{
159   */
160 /** 
161   * @brief  HAL LPTIM State structure definition  
162   */ 
163 typedef enum __HAL_LPTIM_StateTypeDef
164 {
165   HAL_LPTIM_STATE_RESET            = 0x00,    /*!< Peripheral not yet initialized or disabled  */
166   HAL_LPTIM_STATE_READY            = 0x01,    /*!< Peripheral Initialized and ready for use    */
167   HAL_LPTIM_STATE_BUSY             = 0x02,    /*!< An internal process is ongoing              */    
168   HAL_LPTIM_STATE_TIMEOUT          = 0x03,    /*!< Timeout state                               */  
169   HAL_LPTIM_STATE_ERROR            = 0x04     /*!< Internal Process is ongoing                */                                                                             
170 }HAL_LPTIM_StateTypeDef;
171 /**
172   * @}
173   */
174
175 /** @defgroup LPTIM_Handle  LPTIM handler
176   * @{
177   */
178 /** 
179   * @brief  LPTIM handle Structure definition  
180   */ 
181 typedef struct
182 {
183       LPTIM_TypeDef              *Instance;         /*!< Register base address     */
184       
185       LPTIM_InitTypeDef           Init;             /*!< LPTIM required parameters */
186   
187       HAL_StatusTypeDef           Status;           /*!< LPTIM peripheral status   */  
188   
189       HAL_LockTypeDef             Lock;             /*!< LPTIM locking object      */
190   
191    __IO  HAL_LPTIM_StateTypeDef   State;            /*!< LPTIM peripheral state    */
192   
193 }LPTIM_HandleTypeDef;
194
195 /**
196   * @}
197   */
198 /**
199   * @}
200   */
201
202 /* Exported constants --------------------------------------------------------*/
203
204 /** @defgroup LPTIM_Exported_Constants LPTIM Exported constants
205   * @{
206   */
207
208 /* Check autoreload value */
209 #define IS_LPTIM_AUTORELOAD(__AUTORELOAD__)     ((__AUTORELOAD__) <= 0x0000FFFF)
210
211 /* Check compare value */
212 #define IS_LPTIM_COMPARE(__COMPARE__)          ((__COMPARE__) <= 0x0000FFFF)
213
214 /** @defgroup LPTIM_Clock_Source Clock source
215   * @{
216   */
217 #define LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC        ((uint32_t)0x00)
218 #define LPTIM_CLOCKSOURCE_ULPTIM                LPTIM_CFGR_CKSEL
219 /**                                             
220   * @}
221   */
222 #define IS_LPTIM_CLOCK_SOURCE(__SOURCE__)       (((__SOURCE__) == LPTIM_CLOCKSOURCE_ULPTIM) || \
223                                                  ((__SOURCE__) == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC))
224
225
226 /** @defgroup LPTIM_Clock_Prescaler Prescaler
227   * @{
228   */
229 #define LPTIM_PRESCALER_DIV1                    ((uint32_t)0x000000)
230 #define LPTIM_PRESCALER_DIV2                    LPTIM_CFGR_PRESC_0
231 #define LPTIM_PRESCALER_DIV4                    LPTIM_CFGR_PRESC_1
232 #define LPTIM_PRESCALER_DIV8                    ((uint32_t)(LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_1))
233 #define LPTIM_PRESCALER_DIV16                   LPTIM_CFGR_PRESC_2
234 #define LPTIM_PRESCALER_DIV32                   ((uint32_t)(LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_2))
235 #define LPTIM_PRESCALER_DIV64                   ((uint32_t)(LPTIM_CFGR_PRESC_1 | LPTIM_CFGR_PRESC_2))
236 #define LPTIM_PRESCALER_DIV128                  ((uint32_t)LPTIM_CFGR_PRESC)
237 /**
238   * @}
239   */
240
241 #define IS_LPTIM_CLOCK_PRESCALER(__PRESCALER__) (((__PRESCALER__) ==  LPTIM_PRESCALER_DIV1  ) || \
242                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV2  ) || \
243                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV4  ) || \
244                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV8  ) || \
245                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV16 ) || \
246                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV32 ) || \
247                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV64 ) || \
248                                                  ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV128))
249
250 #define IS_LPTIM_CLOCK_PRESCALERDIV1(__PRESCALER__) ((__PRESCALER__) ==  LPTIM_PRESCALER_DIV1)
251
252
253 /** @defgroup LPTIM_Output_Polarity Output polarity
254   * @{
255   */
256 #define LPTIM_OUTPUTPOLARITY_HIGH               ((uint32_t)0x00000000)
257 #define LPTIM_OUTPUTPOLARITY_LOW                (LPTIM_CFGR_WAVPOL)
258 /**
259   * @}
260   */
261 #define IS_LPTIM_OUTPUT_POLARITY(__POLARITY__)  (((__POLARITY__) == LPTIM_OUTPUTPOLARITY_LOW ) || \
262                                                  ((__POLARITY__) == LPTIM_OUTPUTPOLARITY_HIGH))
263
264 /** @defgroup LPTIM_Clock_Sample_Time Clock sample time
265   * @{
266   */
267 #define LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION ((uint32_t)0x00000000)
268 #define LPTIM_CLOCKSAMPLETIME_2TRANSITIONS     LPTIM_CFGR_CKFLT_0
269 #define LPTIM_CLOCKSAMPLETIME_4TRANSITIONS     LPTIM_CFGR_CKFLT_1
270 #define LPTIM_CLOCKSAMPLETIME_8TRANSITIONS     LPTIM_CFGR_CKFLT
271 /**
272   * @}
273   */
274 #define IS_LPTIM_CLOCK_SAMPLE_TIME(__SAMPLETIME__)  (((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION) || \
275                                                      ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_2TRANSITIONS)     || \
276                                                      ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_4TRANSITIONS)     || \
277                                                      ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_8TRANSITIONS))
278
279 /** @defgroup LPTIM_Clock_Polarity Clock polarity
280   * @{
281   */
282 #define LPTIM_CLOCKPOLARITY_RISING                   ((uint32_t)0x00000000)
283 #define LPTIM_CLOCKPOLARITY_FALLING                  LPTIM_CFGR_CKPOL_0
284 #define LPTIM_CLOCKPOLARITY_RISING_FALLING           LPTIM_CFGR_CKPOL_1
285 /**
286   * @}
287   */
288
289 #define IS_LPTIM_CLOCK_POLARITY(__POLARITY__)   (((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING)  || \
290                                                  ((__POLARITY__) == LPTIM_CLOCKPOLARITY_FALLING) || \
291                                                  ((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING_FALLING))
292
293 /** @defgroup LPTIM_External_Trigger_Polarity Trigger polarity
294   * @{
295   */
296 #define LPTIM_ACTIVEEDGE_RISING                LPTIM_CFGR_TRIGEN_0
297 #define LPTIM_ACTIVEEDGE_FALLING               LPTIM_CFGR_TRIGEN_1
298 #define LPTIM_ACTIVEEDGE_RISING_FALLING        LPTIM_CFGR_TRIGEN
299 /**
300   * @}
301   */
302 #define IS_LPTIM_EXT_TRG_POLARITY(__POLAR__)   (((__POLAR__) == LPTIM_ACTIVEEDGE_RISING         ) || \
303                                                 ((__POLAR__) == LPTIM_ACTIVEEDGE_FALLING        ) || \
304                                                 ((__POLAR__) == LPTIM_ACTIVEEDGE_RISING_FALLING ))
305
306 /** @defgroup LPTIM_Trigger_Sample_Time Trigger sample time
307   * @{
308   */
309 #define LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION  ((uint32_t)0x00000000)
310 #define LPTIM_TRIGSAMPLETIME_2TRANSITIONS       LPTIM_CFGR_TRGFLT_0
311 #define LPTIM_TRIGSAMPLETIME_4TRANSITIONS       LPTIM_CFGR_TRGFLT_1
312 #define LPTIM_TRIGSAMPLETIME_8TRANSITIONS       LPTIM_CFGR_TRGFLT
313 /**
314   * @}
315   */
316 #define IS_LPTIM_TRIG_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION  ) || \
317                                                    ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_2TRANSITIONS    ) || \
318                                                    ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_4TRANSITIONS    ) || \
319                                                    ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_8TRANSITIONS    ))
320
321
322 /** @defgroup LPTIM_Updating_Mode Updating mode
323   * @{
324   */
325
326 #define LPTIM_UPDATE_IMMEDIATE                  ((uint32_t)0x00000000)
327 #define LPTIM_UPDATE_ENDOFPERIOD                LPTIM_CFGR_PRELOAD
328 /**
329   * @}
330   */
331 #define IS_LPTIM_UPDATE_MODE(__MODE__)          (((__MODE__) == LPTIM_UPDATE_IMMEDIATE) || \
332                                                  ((__MODE__) == LPTIM_UPDATE_ENDOFPERIOD))
333
334
335
336 /** @defgroup LPTIM_Counter_Source Counter source
337   * @{
338   */
339 #define LPTIM_COUNTERSOURCE_INTERNAL            ((uint32_t)0x00000000)
340 #define LPTIM_COUNTERSOURCE_EXTERNAL            LPTIM_CFGR_COUNTMODE
341 /**
342   * @}
343   */
344 #define IS_LPTIM_COUNTER_SOURCE(__SOURCE__)     (((__SOURCE__) == LPTIM_COUNTERSOURCE_INTERNAL) || \
345                                                  ((__SOURCE__) == LPTIM_COUNTERSOURCE_EXTERNAL))
346
347
348
349 /* Check for period value */
350 #define IS_LPTIM_PERIOD(__PERIOD__)               ((__PERIOD__) <= 0x0000FFFF)
351
352 /* Check for pulse value */
353 #define IS_LPTIM_PULSE(__PULSE__)                 ((__PULSE__) <= 0x0000FFFF)
354
355 /** @defgroup LPTIM_Flag_Definition Flag definition
356   * @{
357   */
358 #define LPTIM_FLAG_DOWN                          LPTIM_ISR_DOWN
359 #define LPTIM_FLAG_UP                            LPTIM_ISR_UP
360 #define LPTIM_FLAG_ARROK                         LPTIM_ISR_ARROK
361 #define LPTIM_FLAG_CMPOK                         LPTIM_ISR_CMPOK
362 #define LPTIM_FLAG_EXTTRIG                       LPTIM_ISR_EXTTRIG
363 #define LPTIM_FLAG_ARRM                          LPTIM_ISR_ARRM
364 #define LPTIM_FLAG_CMPM                          LPTIM_ISR_CMPM
365 /**
366   * @}
367   */
368
369 /** @defgroup LPTIM_Interrupts_Definition Interrupts definition
370   * @{
371   */
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 macro ------------------------------------------------------------*/
388
389 /** @defgroup LPTIM_Exported_Macros LPTIM Exported Macros
390   * @{
391   */
392
393 /** @brief Reset LPTIM handle state
394   * @param  __HANDLE__: LPTIM handle
395   * @retval None
396   */
397 #define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LPTIM_STATE_RESET)
398
399 /**
400   * @brief  Enable/Disable the LPTIM peripheral.
401   * @param  __HANDLE__: LPTIM handle
402   * @retval None
403   */
404 #define __HAL_LPTIM_ENABLE(__HANDLE__)   ((__HANDLE__)->Instance->CR |=  (LPTIM_CR_ENABLE))
405 #define __HAL_LPTIM_DISABLE(__HANDLE__)  ((__HANDLE__)->Instance->CR &=  ~(LPTIM_CR_ENABLE))
406
407 /**
408   * @brief  Starts the LPTIM peripheral in Continuous or in single mode.
409   * @param  __HANDLE__: DMA handle
410   * @retval None
411   */
412 #define __HAL_LPTIM_START_CONTINUOUS(__HANDLE__)  ((__HANDLE__)->Instance->CR |=  LPTIM_CR_CNTSTRT)
413 #define __HAL_LPTIM_START_SINGLE(__HANDLE__)      ((__HANDLE__)->Instance->CR |=  LPTIM_CR_SNGSTRT)
414  
415     
416 /**
417   * @brief  Writes the passed parameter in the Autoreload register.
418   * @param  __HANDLE__: LPTIM handle
419   * @param  __VALUE__ : Autoreload value
420   * @retval None
421   */
422 #define __HAL_LPTIM_AUTORELOAD_SET(__HANDLE__ , __VALUE__)  ((__HANDLE__)->Instance->ARR =  (__VALUE__))
423
424 /**
425   * @brief  Writes the passed parameter in the Compare register.
426   * @param  __HANDLE__: LPTIM handle
427   * @param  __VALUE__ : Compare value
428   * @retval None
429   */
430 #define __HAL_LPTIM_COMPARE_SET(__HANDLE__ , __VALUE__)     ((__HANDLE__)->Instance->CMP =  (__VALUE__))
431
432 /**
433   * @brief  Checks whether the specified LPTIM flag is set or not.
434   * @param  __HANDLE__: LPTIM handle
435   * @param  __FLAG__  : LPTIM flag to check
436   *            This parameter can be a value of:
437   *            @arg LPTIM_FLAG_DOWN    : Counter direction change up Flag.
438   *            @arg LPTIM_FLAG_UP      : Counter direction change down to up Flag.
439   *            @arg LPTIM_FLAG_ARROK   : Autoreload register update OK Flag.
440   *            @arg LPTIM_FLAG_CMPOK   : Compare register update OK Flag.
441   *            @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
442   *            @arg LPTIM_FLAG_ARRM    : Autoreload match Flag.
443   *            @arg LPTIM_FLAG_CMPM    : Compare match Flag.
444   * @retval The state of the specified flag (SET or RESET).
445   */
446 #define __HAL_LPTIM_GET_FLAG(__HANDLE__, __FLAG__)          (((__HANDLE__)->Instance->ISR &(__FLAG__)) == (__FLAG__))
447
448 /**
449   * @brief  Clears the specified LPTIM flag.
450   * @param  __HANDLE__: LPTIM handle.
451   * @param  __FLAG__  : LPTIM flag to clear.
452   *            This parameter can be a value of:
453   *            @arg LPTIM_FLAG_DOWN    : Counter direction change up Flag.
454   *            @arg LPTIM_FLAG_UP      : Counter direction change down to up Flag.
455   *            @arg LPTIM_FLAG_ARROK   : Autoreload register update OK Flag.
456   *            @arg LPTIM_FLAG_CMPOK   : Compare register update OK Flag.
457   *            @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
458   *            @arg LPTIM_FLAG_ARRM    : Autoreload match Flag.
459   *            @arg LPTIM_FLAG_CMPM    : Compare match Flag.
460   * @retval None.
461   */
462 #define __HAL_LPTIM_CLEAR_FLAG(__HANDLE__, __FLAG__)         ((__HANDLE__)->Instance->ICR  = (__FLAG__))
463
464 /**
465   * @brief  Enable the specified LPTIM interrupt.
466   * @param  __HANDLE__    : LPTIM handle.
467   * @param  __INTERRUPT__ : LPTIM interrupt to set.
468   *            This parameter can be a value of:
469   *            @arg LPTIM_IT_DOWN    : Counter direction change up Interrupt.
470   *            @arg LPTIM_IT_UP      : Counter direction change down to up Interrupt.
471   *            @arg LPTIM_IT_ARROK   : Autoreload register update OK Interrupt.
472   *            @arg LPTIM_IT_CMPOK   : Compare register update OK Interrupt.
473   *            @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
474   *            @arg LPTIM_IT_ARRM    : Autoreload match Interrupt.
475   *            @arg LPTIM_IT_CMPM    : Compare match Interrupt.
476   * @retval None.
477   */
478 #define __HAL_LPTIM_ENABLE_IT(__HANDLE__, __INTERRUPT__)         ((__HANDLE__)->Instance->IER  |= (__INTERRUPT__))
479
480  /**
481   * @brief  Disable the specified LPTIM interrupt.
482   * @param  __HANDLE__    : LPTIM handle.
483   * @param  __INTERRUPT__ : LPTIM interrupt to set.
484   *            This parameter can be a value of:
485   *            @arg LPTIM_IT_DOWN    : Counter direction change up Interrupt.
486   *            @arg LPTIM_IT_UP      : Counter direction change down to up Interrupt.
487   *            @arg LPTIM_IT_ARROK   : Autoreload register update OK Interrupt.
488   *            @arg LPTIM_IT_CMPOK   : Compare register update OK Interrupt.
489   *            @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
490   *            @arg LPTIM_IT_ARRM    : Autoreload match Interrupt.
491   *            @arg LPTIM_IT_CMPM    : Compare match Interrupt.
492   * @retval None.
493   */
494 #define __HAL_LPTIM_DISABLE_IT(__HANDLE__, __INTERRUPT__)         ((__HANDLE__)->Instance->IER  &= (~(__INTERRUPT__)))
495
496   /**
497   * @brief  Checks whether the specified LPTIM interrupt is set or not.
498   * @param  __HANDLE__    : LPTIM handle.
499   * @param  __INTERRUPT__ : LPTIM interrupt to check.
500   *            This parameter can be a value of:
501   *            @arg LPTIM_IT_DOWN    : Counter direction change up Interrupt.
502   *            @arg LPTIM_IT_UP      : Counter direction change down to up Interrupt.
503   *            @arg LPTIM_IT_ARROK   : Autoreload register update OK Interrupt.
504   *            @arg LPTIM_IT_CMPOK   : Compare register update OK Interrupt.
505   *            @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
506   *            @arg LPTIM_IT_ARRM    : Autoreload match Interrupt.
507   *            @arg LPTIM_IT_CMPM    : Compare match Interrupt.
508   * @retval Interrupt status.
509   */
510     
511 #define __HAL_LPTIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
512
513 /**
514   * @}
515   */
516
517
518 /* Include LPTIM HAL Extension module */
519 #include "stm32l0xx_hal_lptim_ex.h"
520
521 /* Exported functions --------------------------------------------------------*/
522
523 /** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions
524   * @{
525   */
526 /* Initialization/de-initialization functions  ********************************/
527
528 /** @defgroup LPTIM_Exported_Functions_Group1 Initialization/de-initialization functions
529   * @{
530   */
531 HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
532 HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim);
533
534
535 /* MSP functions  *************************************************************/
536
537 void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim);
538 void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim);
539
540 /**
541   * @}
542   */
543
544 /* Start/Stop operation functions  *********************************************/
545
546 /** @defgroup LPTIM_Exported_Functions_Group2 LPTIM Start-Stop operation functions
547   * @{
548   */
549
550 /* ################################# PWM Mode ################################*/
551 /* Blocking mode: Polling */
552 HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
553 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim);
554 /* Non-Blocking mode: Interrupt */
555 HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
556 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim);
557
558 /* ############################# One Pulse Mode ##############################*/
559 /* Blocking mode: Polling */
560 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
561 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim);
562 /* Non-Blocking mode: Interrupt */
563 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
564 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim);
565
566 /* ############################## Set once Mode ##############################*/
567 /* Blocking mode: Polling */
568 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
569 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim);
570 /* Non-Blocking mode: Interrupt */
571 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
572 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim);
573
574 /* ############################### Encoder Mode ##############################*/
575 /* Blocking mode: Polling */
576 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
577 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim);
578 /* Non-Blocking mode: Interrupt */
579 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
580 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim);
581
582 /* ############################# Time out  Mode ##############################*/
583 /* Blocking mode: Polling */
584 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
585 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim);
586 /* Non-Blocking mode: Interrupt */
587 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
588 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim);
589
590 /* ############################## Counter Mode ###############################*/
591 /* Blocking mode: Polling */
592 HAL_StatusTypeDef HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
593 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef *hlptim);
594 /* Non-Blocking mode: Interrupt */
595 HAL_StatusTypeDef HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
596 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef *hlptim);
597
598 /**
599   * @}
600   */
601
602 /* Reading operation functions ************************************************/
603
604 /** @defgroup LPTIM_Exported_Functions_Group3 LPTIM Read operation functions
605   * @{
606   */
607 uint32_t HAL_LPTIM_ReadCounter(LPTIM_HandleTypeDef *hlptim);
608 uint32_t HAL_LPTIM_ReadAutoReload(LPTIM_HandleTypeDef *hlptim);
609 uint32_t HAL_LPTIM_ReadCompare(LPTIM_HandleTypeDef *hlptim);
610 /**
611   * @}
612   */
613
614 /* LPTIM IRQ functions  *******************************************************/
615 /** @defgroup LPTIM_Exported_Functions_Group4 LPTIM IRQ handler
616   * @{
617   */
618 void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim);
619
620 /* CallBack functions  ********************************************************/
621 void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim);
622 void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim);
623 void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef *hlptim);
624 void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef *hlptim);
625 void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef *hlptim);
626 void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef *hlptim);
627 void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef *hlptim);
628 /**
629   * @}
630   */
631 /* Peripheral State functions  ************************************************/
632 /** @defgroup LPTIM_Exported_Functions_Group5 Peripheral State functions
633   * @{
634   */
635
636 HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(LPTIM_HandleTypeDef *hlptim);
637
638 /**
639   * @}
640   */ 
641
642 /**
643   * @}
644   */ 
645
646 /**
647   * @}
648   */
649
650 /**
651   * @}
652   */
653
654 #ifdef __cplusplus
655 }
656 #endif
657
658 #endif /* __STM32L0xx_HAL_LPTIM_H */
659
660 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
661