]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M7_STM32F7_STM32756G-EVAL/ST_Library/stm32f7xx_hal_lptim.c
Update version number ready for V8.2.1 release.
[freertos] / FreeRTOS / Demo / CORTEX_M7_STM32F7_STM32756G-EVAL / ST_Library / stm32f7xx_hal_lptim.c
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32f7xx_hal_lptim.c\r
4   * @author  MCD Application Team\r
5   * @version V0.3.0\r
6   * @date    06-March-2015\r
7   * @brief   LPTIM HAL module driver.\r
8   *    \r
9   *          This file provides firmware functions to manage the following \r
10   *          functionalities of the Low Power Timer (LPTIM) peripheral:\r
11   *           + Initialization and de-initialization functions.\r
12   *           + Start/Stop operation functions in polling mode.\r
13   *           + Start/Stop operation functions in interrupt mode.\r
14   *           + Reading operation functions.\r
15   *           + Peripheral State functions.\r
16   *         \r
17   @verbatim\r
18   ==============================================================================\r
19                      ##### How to use this driver #####\r
20   ==============================================================================\r
21     [..]\r
22       The LPTIM HAL driver can be used as follows:\r
23 \r
24       (#)Initialize the LPTIM low level resources by implementing the\r
25         HAL_LPTIM_MspInit():\r
26          (##) Enable the LPTIM interface clock using __LPTIMx_CLK_ENABLE().\r
27          (##) In case of using interrupts (e.g. HAL_LPTIM_PWM_Start_IT()):\r
28              (+) Configure the LPTIM interrupt priority using HAL_NVIC_SetPriority().\r
29              (+) Enable the LPTIM IRQ handler using HAL_NVIC_EnableIRQ().\r
30              (+) In LPTIM IRQ handler, call HAL_LPTIM_IRQHandler().\r
31     \r
32       (#)Initialize the LPTIM HAL using HAL_LPTIM_Init(). This function\r
33          configures mainly:\r
34          (##) The instance: LPTIM1.\r
35          (##) Clock: the counter clock.\r
36                  - Source   : it can be either the ULPTIM input (IN1) or one of\r
37                               the internal clock; (APB, LSE, LSI or MSI).\r
38                  - Prescaler: select the clock divider.\r
39          (##)  UltraLowPowerClock : To be used only if the ULPTIM is selected\r
40                as counter clock source.\r
41                  - Polarity:   polarity of the active edge for the counter unit\r
42                                if the ULPTIM input is selected.\r
43                  - SampleTime: clock sampling time to configure the clock glitch\r
44                                filter.              \r
45          (##) Trigger: How the counter start.\r
46                  - Source: trigger can be software or one of the hardware triggers.\r
47                  - ActiveEdge : only for hardware trigger.\r
48                  - SampleTime : trigger sampling time to configure the trigger\r
49                                 glitch filter.\r
50          (##) OutputPolarity : 2 opposite polarities are possibles.\r
51          (##) UpdateMode: specifies whether the update of the autoreload and\r
52               the compare values is done immediately or after the end of current\r
53               period.   \r
54     \r
55       (#)Six modes are available:\r
56       \r
57          (##) PWM Mode: To generate a PWM signal with specified period and pulse,\r
58          call HAL_LPTIM_PWM_Start() or HAL_LPTIM_PWM_Start_IT() for interruption\r
59          mode.\r
60          \r
61          (##) One Pulse Mode: To generate pulse with specified width in response\r
62          to a stimulus, call HAL_LPTIM_OnePulse_Start() or\r
63          HAL_LPTIM_OnePulse_Start_IT() for interruption mode.\r
64          \r
65          (##) Set once Mode: In this mode, the output changes the level (from\r
66          low level to high level if the output polarity is configured high, else\r
67          the opposite) when a compare match occurs. To start this mode, call \r
68          HAL_LPTIM_SetOnce_Start() or HAL_LPTIM_SetOnce_Start_IT() for\r
69          interruption mode.\r
70          \r
71          (##) Encoder Mode: To use the encoder interface call\r
72          HAL_LPTIM_Encoder_Start() or HAL_LPTIM_Encoder_Start_IT() for \r
73          interruption mode.\r
74          \r
75          (##) Time out Mode: an active edge on one selected trigger input rests\r
76          the counter. The first trigger event will start the timer, any\r
77          successive trigger event will reset the counter and the timer will\r
78          restart. To start this mode call HAL_LPTIM_TimeOut_Start_IT() or \r
79          HAL_LPTIM_TimeOut_Start_IT() for interruption mode.\r
80          \r
81          (##) Counter Mode: counter can be used to count external events on\r
82          the LPTIM Input1 or it can be used to count internal clock cycles.\r
83          To start this mode, call HAL_LPTIM_Counter_Start() or \r
84          HAL_LPTIM_Counter_Start_IT() for interruption mode.             \r
85 \r
86     \r
87       (#) User can stop any process by calling the corresponding API:\r
88           HAL_LPTIM_Xxx_Stop() or HAL_LPTIM_Xxx_Stop_IT() if the process is\r
89           already started in interruption mode.\r
90          \r
91        (#)Call HAL_LPTIM_DeInit() to deinitialize the LPTIM peripheral.\r
92 \r
93   @endverbatim\r
94   ******************************************************************************\r
95   * @attention\r
96   *\r
97   * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>\r
98   *\r
99   * Redistribution and use in source and binary forms, with or without modification,\r
100   * are permitted provided that the following conditions are met:\r
101   *   1. Redistributions of source code must retain the above copyright notice,\r
102   *      this list of conditions and the following disclaimer.\r
103   *   2. Redistributions in binary form must reproduce the above copyright notice,\r
104   *      this list of conditions and the following disclaimer in the documentation\r
105   *      and/or other materials provided with the distribution.\r
106   *   3. Neither the name of STMicroelectronics nor the names of its contributors\r
107   *      may be used to endorse or promote products derived from this software\r
108   *      without specific prior written permission.\r
109   *\r
110   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
111   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
112   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
113   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
114   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
115   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
116   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
117   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
118   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
119   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
120   *\r
121   ******************************************************************************  \r
122   */ \r
123 \r
124 /* Includes ------------------------------------------------------------------*/\r
125 #include "stm32f7xx_hal.h"\r
126 \r
127 /** @addtogroup STM32F7xx_HAL_Driver\r
128   * @{\r
129   */\r
130 \r
131 /** @defgroup LPTIM LPTIM\r
132   * @brief LPTIM HAL module driver.\r
133   * @{\r
134   */\r
135 \r
136 #ifdef HAL_LPTIM_MODULE_ENABLED\r
137 /* Private types -------------------------------------------------------------*/\r
138 /** @defgroup LPTIM_Private_Types LPTIM Private Types\r
139   * @{\r
140   */\r
141 \r
142 /**\r
143   * @}\r
144   */\r
145   \r
146 /* Private defines -----------------------------------------------------------*/\r
147 /** @defgroup LPTIM_Private_Defines LPTIM Private Defines\r
148   * @{\r
149   */\r
150 \r
151 /**\r
152   * @}\r
153   */\r
154 \r
155 /* Private variables ---------------------------------------------------------*/\r
156 /** @addtogroup LPTIM_Private_Variables LPTIM Private Variables\r
157   * @{\r
158   */\r
159 \r
160 /**\r
161   * @}\r
162   */\r
163  \r
164 /* Private constants ---------------------------------------------------------*/\r
165 /** @addtogroup LPTIM_Private_Constants LPTIM Private Constants\r
166   * @{\r
167   */\r
168 \r
169 /**\r
170   * @}\r
171   */\r
172   \r
173 /* Private macros ------------------------------------------------------------*/\r
174 /** @addtogroup LPTIM_Private_Macros LPTIM Private Macros\r
175   * @{\r
176   */\r
177 \r
178 /**\r
179   * @}\r
180   */\r
181 \r
182 /* Private function prototypes -----------------------------------------------*/\r
183 /** @addtogroup LPTIM_Private_Functions_Prototypes LPTIM Private Functions Prototypes\r
184   * @{\r
185   */\r
186 \r
187 /**\r
188   * @}\r
189   */\r
190 \r
191 /* Private functions ---------------------------------------------------------*/\r
192 /** @addtogroup LPTIM_Private_Functions LPTIM Private Functions\r
193   * @{\r
194   */\r
195 \r
196 /**\r
197   * @}\r
198   */\r
199   \r
200 /* Exported functions ---------------------------------------------------------*/\r
201 /** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions\r
202   * @{\r
203   */\r
204 \r
205 /** @defgroup LPTIM_Group1 Initialization/de-initialization functions \r
206  *  @brief    Initialization and Configuration functions. \r
207  *\r
208 @verbatim    \r
209   ==============================================================================\r
210               ##### Initialization and de-initialization functions #####\r
211   ==============================================================================\r
212     [..]  This section provides functions allowing to:\r
213       (+) Initialize the LPTIM according to the specified parameters in the\r
214           LPTIM_InitTypeDef and creates the associated handle.\r
215       (+) DeInitialize the LPTIM peripheral.\r
216       (+) Initialize the LPTIM MSP.\r
217       (+) DeInitialize LPTIM MSP. \r
218  \r
219 @endverbatim\r
220   * @{\r
221   */\r
222 \r
223 /**\r
224   * @brief  Initializes the LPTIM according to the specified parameters in the\r
225   *         LPTIM_InitTypeDef and creates the associated handle.\r
226   * @param  hlptim: LPTIM handle\r
227   * @retval HAL status\r
228   */\r
229 HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim)\r
230 {\r
231   uint32_t tmpcfgr = 0;\r
232 \r
233   /* Check the LPTIM handle allocation */\r
234   if(hlptim == NULL)\r
235   {\r
236     return HAL_ERROR;\r
237   }\r
238 \r
239   /* Check the parameters */\r
240   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
241   \r
242   assert_param(IS_LPTIM_CLOCK_SOURCE(hlptim->Init.Clock.Source));\r
243   assert_param(IS_LPTIM_CLOCK_PRESCALER(hlptim->Init.Clock.Prescaler));  \r
244   if ((hlptim->Init.Clock.Source) ==  LPTIM_CLOCKSOURCE_ULPTIM)\r
245   {\r
246     assert_param(IS_LPTIM_CLOCK_POLARITY(hlptim->Init.UltraLowPowerClock.Polarity));\r
247     assert_param(IS_LPTIM_CLOCK_SAMPLE_TIME(hlptim->Init.UltraLowPowerClock.SampleTime));\r
248   }  \r
249   assert_param(IS_LPTIM_TRG_SOURCE(hlptim->Init.Trigger.Source));\r
250   if ((hlptim->Init.Trigger.Source) !=  LPTIM_TRIGSOURCE_SOFTWARE)\r
251   {\r
252     assert_param(IS_LPTIM_TRIG_SAMPLE_TIME(hlptim->Init.Trigger.SampleTime));\r
253     assert_param(IS_LPTIM_EXT_TRG_POLARITY(hlptim->Init.Trigger.ActiveEdge));\r
254   }  \r
255   assert_param(IS_LPTIM_OUTPUT_POLARITY(hlptim->Init.OutputPolarity));  \r
256   assert_param(IS_LPTIM_UPDATE_MODE(hlptim->Init.UpdateMode));\r
257   assert_param(IS_LPTIM_COUNTER_SOURCE(hlptim->Init.CounterSource));\r
258   \r
259   if(hlptim->State == HAL_LPTIM_STATE_RESET)\r
260   {\r
261     /* Init the low level hardware */\r
262     HAL_LPTIM_MspInit(hlptim);\r
263   }\r
264   \r
265   /* Change the LPTIM state */\r
266   hlptim->State = HAL_LPTIM_STATE_BUSY;\r
267   \r
268   /* Get the LPTIMx CFGR value */\r
269   tmpcfgr = hlptim->Instance->CFGR;\r
270   \r
271   if ((hlptim->Init.Clock.Source) ==  LPTIM_CLOCKSOURCE_ULPTIM)\r
272   {\r
273     tmpcfgr &= (uint32_t)(~(LPTIM_CFGR_CKPOL | LPTIM_CFGR_CKFLT));\r
274   }\r
275   if ((hlptim->Init.Trigger.Source) !=  LPTIM_TRIGSOURCE_SOFTWARE)\r
276   {\r
277     tmpcfgr &= (uint32_t)(~ (LPTIM_CFGR_TRGFLT | LPTIM_CFGR_TRIGSEL));\r
278   }\r
279     \r
280   /* Clear CKSEL, PRESC, TRIGEN, TRGFLT, WAVPOL, PRELOAD & COUNTMODE bits */\r
281   tmpcfgr &= (uint32_t)(~(LPTIM_CFGR_CKSEL | LPTIM_CFGR_TRIGEN | LPTIM_CFGR_PRELOAD |\r
282                           LPTIM_CFGR_WAVPOL | LPTIM_CFGR_PRESC | LPTIM_CFGR_COUNTMODE ));\r
283   \r
284   /* Set initialization parameters */\r
285   tmpcfgr |= (hlptim->Init.Clock.Source    |\r
286               hlptim->Init.Clock.Prescaler |\r
287               hlptim->Init.OutputPolarity  |\r
288               hlptim->Init.UpdateMode      |\r
289               hlptim->Init.CounterSource);\r
290   \r
291   if ((hlptim->Init.Clock.Source) ==  LPTIM_CLOCKSOURCE_ULPTIM)\r
292   {\r
293     tmpcfgr |=  (hlptim->Init.UltraLowPowerClock.Polarity |\r
294                 hlptim->Init.UltraLowPowerClock.SampleTime);\r
295   } \r
296   \r
297   if ((hlptim->Init.Trigger.Source) !=  LPTIM_TRIGSOURCE_SOFTWARE)\r
298   {\r
299     /* Enable External trigger and set the trigger source */\r
300     tmpcfgr |= (hlptim->Init.Trigger.Source     |\r
301                 hlptim->Init.Trigger.ActiveEdge |\r
302                 hlptim->Init.Trigger.SampleTime);\r
303   }\r
304   \r
305   /* Write to LPTIMx CFGR */\r
306   hlptim->Instance->CFGR = tmpcfgr;\r
307 \r
308   /* Change the LPTIM state */\r
309   hlptim->State = HAL_LPTIM_STATE_READY;\r
310   \r
311   /* Return function status */\r
312   return HAL_OK;\r
313 }\r
314 \r
315 /**\r
316   * @brief  DeInitializes the LPTIM peripheral. \r
317   * @param  hlptim: LPTIM handle\r
318   * @retval HAL status\r
319   */\r
320 HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim)\r
321 {\r
322   /* Check the LPTIM handle allocation */\r
323   if(hlptim == NULL)\r
324   {\r
325     return HAL_ERROR;\r
326   }\r
327   \r
328   /* Change the LPTIM state */\r
329   hlptim->State = HAL_LPTIM_STATE_BUSY;\r
330   \r
331   /* Disable the LPTIM Peripheral Clock */\r
332   __HAL_LPTIM_DISABLE(hlptim);\r
333   \r
334   /* DeInit the low level hardware: CLOCK, NVIC.*/\r
335   HAL_LPTIM_MspDeInit(hlptim);\r
336   \r
337   /* Change the LPTIM state */\r
338   hlptim->State = HAL_LPTIM_STATE_RESET;\r
339   \r
340   /* Release Lock */\r
341   __HAL_UNLOCK(hlptim);\r
342   \r
343   /* Return function status */\r
344   return HAL_OK;\r
345 }\r
346 \r
347 /**\r
348   * @brief  Initializes the LPTIM MSP.\r
349   * @param  hlptim: LPTIM handle\r
350   * @retval None\r
351   */\r
352 __weak void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim)\r
353 {\r
354   /* NOTE : This function Should not be modified, when the callback is needed,\r
355             the HAL_LPTIM_MspInit could be implemented in the user file\r
356    */\r
357 }\r
358 \r
359 /**\r
360   * @brief  DeInitializes LPTIM MSP.\r
361   * @param  hlptim: LPTIM handle\r
362   * @retval None\r
363   */\r
364 __weak void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim)\r
365 {\r
366   /* NOTE : This function Should not be modified, when the callback is needed,\r
367             the HAL_LPTIM_MspDeInit could be implemented in the user file\r
368    */\r
369 }\r
370 \r
371 /**\r
372   * @}\r
373   */\r
374 \r
375 /** @defgroup LPTIM_Group2 LPTIM Start-Stop operation functions \r
376  *  @brief   Start-Stop operation functions. \r
377  *\r
378 @verbatim   \r
379   ==============================================================================\r
380                 ##### LPTIM Start Stop operation functions #####\r
381   ==============================================================================  \r
382     [..]  This section provides functions allowing to:\r
383       (+) Start the PWM mode.\r
384       (+) Stop the PWM mode.\r
385       (+) Start the One pulse mode.\r
386       (+) Stop the One pulse mode.\r
387       (+) Start the Set once mode.\r
388       (+) Stop the Set once mode.\r
389       (+) Start the Encoder mode.\r
390       (+) Stop the Encoder mode.\r
391       (+) Start the Timeout mode.\r
392       (+) Stop the Timeout mode.      \r
393       (+) Start the Counter mode.\r
394       (+) Stop the Counter mode.\r
395       \r
396 \r
397 @endverbatim\r
398   * @{\r
399   */\r
400     \r
401 /**\r
402   * @brief  Starts the LPTIM PWM generation.\r
403   * @param  hlptim : LPTIM handle\r
404   * @param  Period : Specifies the Autoreload value.\r
405   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
406   * @param  Pulse : Specifies the compare value.\r
407   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
408   * @retval HAL status\r
409   */\r
410 HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)\r
411 {\r
412   /* Check the parameters */\r
413   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
414   assert_param(IS_LPTIM_PERIOD(Period));\r
415   assert_param(IS_LPTIM_PULSE(Pulse));\r
416                \r
417   /* Set the LPTIM state */\r
418   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
419  \r
420   /* Reset WAVE bit to set PWM mode */\r
421   hlptim->Instance->CFGR &= ~LPTIM_CFGR_WAVE;\r
422   \r
423   /* Enable the Peripheral */\r
424   __HAL_LPTIM_ENABLE(hlptim);\r
425   \r
426   /* Load the period value in the autoreload register */\r
427   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
428   \r
429   /* Load the pulse value in the compare register */\r
430   __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);\r
431   \r
432   /* Start timer in continuous mode */\r
433   __HAL_LPTIM_START_CONTINUOUS(hlptim);\r
434     \r
435   /* Change the TIM state*/\r
436   hlptim->State= HAL_LPTIM_STATE_READY;\r
437   \r
438   /* Return function status */\r
439   return HAL_OK;\r
440 }\r
441 \r
442 /**\r
443   * @brief  Stops the LPTIM PWM generation.\r
444   * @param  hlptim : LPTIM handle\r
445   * @retval HAL status\r
446   */\r
447 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim)\r
448 {\r
449   /* Check the parameters */\r
450   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
451                \r
452   /* Set the LPTIM state */\r
453   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
454   \r
455   /* Disable the Peripheral */\r
456   __HAL_LPTIM_DISABLE(hlptim);\r
457 \r
458   /* Change the TIM state*/\r
459   hlptim->State= HAL_LPTIM_STATE_READY;\r
460   \r
461   /* Return function status */\r
462   return HAL_OK;\r
463 }\r
464 \r
465 /**\r
466   * @brief  Starts the LPTIM PWM generation in interrupt mode.\r
467   * @param  hlptim : LPTIM handle\r
468   * @param  Period : Specifies the Autoreload value.\r
469   *         This parameter must be a value between 0x0000 and 0xFFFF\r
470   * @param  Pulse : Specifies the compare value.\r
471   *         This parameter must be a value between 0x0000 and 0xFFFF\r
472   * @retval HAL status\r
473   */\r
474 HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)\r
475 {\r
476   /* Check the parameters */\r
477   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
478   assert_param(IS_LPTIM_PERIOD(Period));\r
479   assert_param(IS_LPTIM_PULSE(Pulse));\r
480                \r
481   /* Set the LPTIM state */\r
482   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
483  \r
484   /* Reset WAVE bit to set PWM mode */\r
485   hlptim->Instance->CFGR &= ~LPTIM_CFGR_WAVE;\r
486   \r
487   /* Enable Autoreload write complete interrupt */\r
488   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARROK);\r
489   \r
490   /* Enable Compare write complete interrupt */\r
491   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPOK);\r
492   \r
493   /* Enable Autoreload match interrupt */\r
494   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARRM);\r
495   \r
496   /* Enable Compare match interrupt */\r
497   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPM);\r
498   \r
499   /* If external trigger source is used, then enable external trigger interrupt */\r
500   if ((hlptim->Init.Trigger.Source) !=  LPTIM_TRIGSOURCE_SOFTWARE)\r
501   {\r
502     /* Enable external trigger interrupt */\r
503     __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_EXTTRIG);\r
504   }  \r
505   \r
506   /* Enable the Peripheral */\r
507   __HAL_LPTIM_ENABLE(hlptim);\r
508   \r
509   /* Load the period value in the autoreload register */\r
510   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
511   \r
512   /* Load the pulse value in the compare register */\r
513   __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);\r
514   \r
515   /* Start timer in continuous mode */\r
516   __HAL_LPTIM_START_CONTINUOUS(hlptim);\r
517     \r
518   /* Change the TIM state*/\r
519   hlptim->State= HAL_LPTIM_STATE_READY;\r
520   \r
521   /* Return function status */\r
522   return HAL_OK;\r
523 }\r
524 \r
525 /**\r
526   * @brief  Stops the LPTIM PWM generation in interrupt mode.\r
527   * @param  hlptim : LPTIM handle\r
528   * @retval HAL status\r
529   */\r
530 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim)\r
531 {\r
532   /* Check the parameters */\r
533   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
534                \r
535   /* Set the LPTIM state */\r
536   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
537   \r
538   /* Disable the Peripheral */\r
539   __HAL_LPTIM_DISABLE(hlptim);\r
540   \r
541     /* Disable Autoreload write complete interrupt */\r
542   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARROK);\r
543   \r
544   /* Disable Compare write complete interrupt */\r
545   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPOK);\r
546   \r
547   /* Disable Autoreload match interrupt */\r
548   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARRM);\r
549   \r
550   /* Disable Compare match interrupt */\r
551   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPM);\r
552   \r
553   /* If external trigger source is used, then disable external trigger interrupt */\r
554   if ((hlptim->Init.Trigger.Source) !=  LPTIM_TRIGSOURCE_SOFTWARE)\r
555   {\r
556     /* Disable external trigger interrupt */\r
557     __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_EXTTRIG);\r
558   }  \r
559 \r
560   /* Change the TIM state*/\r
561   hlptim->State= HAL_LPTIM_STATE_READY;\r
562   \r
563   /* Return function status */\r
564   return HAL_OK;\r
565 }\r
566 \r
567 /**\r
568   * @brief  Starts the LPTIM One pulse generation.\r
569   * @param  hlptim : LPTIM handle\r
570   * @param  Period : Specifies the Autoreload value.\r
571   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
572   * @param  Pulse : Specifies the compare value.\r
573   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
574   * @retval HAL status\r
575   */\r
576 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)\r
577 {\r
578   /* Check the parameters */\r
579   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
580   assert_param(IS_LPTIM_PERIOD(Period));\r
581   assert_param(IS_LPTIM_PULSE(Pulse));\r
582                \r
583   /* Set the LPTIM state */\r
584   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
585   \r
586   /* Reset WAVE bit to set one pulse mode */\r
587   hlptim->Instance->CFGR &= ~LPTIM_CFGR_WAVE;\r
588   \r
589   /* Enable the Peripheral */\r
590   __HAL_LPTIM_ENABLE(hlptim);\r
591   \r
592   /* Load the period value in the autoreload register */\r
593   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
594   \r
595   /* Load the pulse value in the compare register */\r
596   __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);\r
597   \r
598   /* Start timer in continuous mode */\r
599   __HAL_LPTIM_START_SINGLE(hlptim);\r
600     \r
601   /* Change the TIM state*/\r
602   hlptim->State= HAL_LPTIM_STATE_READY;\r
603   \r
604   /* Return function status */\r
605   return HAL_OK;\r
606 }\r
607 \r
608 /**\r
609   * @brief  Stops the LPTIM One pulse generation.\r
610   * @param  hlptim : LPTIM handle\r
611   * @retval HAL status\r
612   */\r
613 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim)\r
614 {\r
615   /* Check the parameters */\r
616   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
617                \r
618   /* Set the LPTIM state */\r
619   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
620   \r
621   /* Disable the Peripheral */\r
622   __HAL_LPTIM_DISABLE(hlptim);\r
623 \r
624   /* Change the TIM state*/\r
625   hlptim->State= HAL_LPTIM_STATE_READY;\r
626   \r
627   /* Return function status */\r
628   return HAL_OK;\r
629 }\r
630 \r
631 /**\r
632   * @brief  Starts the LPTIM One pulse generation in interrupt mode.\r
633   * @param  hlptim : LPTIM handle\r
634   * @param  Period : Specifies the Autoreload value.\r
635   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
636   * @param  Pulse : Specifies the compare value.\r
637   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
638   * @retval HAL status\r
639   */\r
640 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)\r
641 {\r
642   /* Check the parameters */\r
643   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
644   assert_param(IS_LPTIM_PERIOD(Period));\r
645   assert_param(IS_LPTIM_PULSE(Pulse));\r
646                \r
647   /* Set the LPTIM state */\r
648   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
649   \r
650   /* Reset WAVE bit to set one pulse mode */\r
651   hlptim->Instance->CFGR &= ~LPTIM_CFGR_WAVE;\r
652   \r
653   /* Enable Autoreload write complete interrupt */\r
654   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARROK);\r
655   \r
656   /* Enable Compare write complete interrupt */\r
657   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPOK);\r
658   \r
659   /* Enable Autoreload match interrupt */\r
660   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARRM);\r
661   \r
662   /* Enable Compare match interrupt */\r
663   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPM);\r
664   \r
665   /* If external trigger source is used, then enable external trigger interrupt */\r
666   if ((hlptim->Init.Trigger.Source) !=  LPTIM_TRIGSOURCE_SOFTWARE)\r
667   {\r
668     /* Enable external trigger interrupt */\r
669     __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_EXTTRIG);\r
670   }\r
671   \r
672   /* Enable the Peripheral */\r
673   __HAL_LPTIM_ENABLE(hlptim);\r
674   \r
675   /* Load the period value in the autoreload register */\r
676   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
677   \r
678   /* Load the pulse value in the compare register */\r
679   __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);\r
680   \r
681   /* Start timer in continuous mode */\r
682   __HAL_LPTIM_START_SINGLE(hlptim);\r
683     \r
684   /* Change the TIM state*/\r
685   hlptim->State= HAL_LPTIM_STATE_READY;\r
686   \r
687   /* Return function status */\r
688   return HAL_OK;\r
689 }\r
690 \r
691 /**\r
692   * @brief  Stops the LPTIM One pulse generation in interrupt mode.\r
693   * @param  hlptim : LPTIM handle\r
694   * @retval HAL status\r
695   */\r
696 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim)\r
697 {\r
698   /* Check the parameters */\r
699   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
700                \r
701   /* Set the LPTIM state */\r
702   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
703   \r
704   /* Disable the Peripheral */\r
705   __HAL_LPTIM_DISABLE(hlptim);\r
706   \r
707   /* Disable Autoreload write complete interrupt */\r
708   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARROK);\r
709   \r
710   /* Disable Compare write complete interrupt */\r
711   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPOK);\r
712   \r
713   /* Disable Autoreload match interrupt */\r
714   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARRM);\r
715   \r
716   /* Disable Compare match interrupt */\r
717   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPM);\r
718   \r
719   /* If external trigger source is used, then disable external trigger interrupt */\r
720   if ((hlptim->Init.Trigger.Source) !=  LPTIM_TRIGSOURCE_SOFTWARE)\r
721   {\r
722     /* Disable external trigger interrupt */\r
723     __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_EXTTRIG);\r
724   }\r
725   \r
726   /* Change the TIM state*/\r
727   hlptim->State= HAL_LPTIM_STATE_READY;\r
728   \r
729   /* Return function status */\r
730   return HAL_OK;\r
731 }\r
732 \r
733 /**\r
734   * @brief  Starts the LPTIM in Set once mode.\r
735   * @param  hlptim : LPTIM handle\r
736   * @param  Period : Specifies the Autoreload value.\r
737   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
738   * @param  Pulse : Specifies the compare value.\r
739   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
740   * @retval HAL status\r
741   */\r
742 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)\r
743 {\r
744   /* Check the parameters */\r
745   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
746   assert_param(IS_LPTIM_PERIOD(Period));\r
747   assert_param(IS_LPTIM_PULSE(Pulse));\r
748                \r
749   /* Set the LPTIM state */\r
750   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
751   \r
752   /* Set WAVE bit to enable the set once mode */\r
753   hlptim->Instance->CFGR |= LPTIM_CFGR_WAVE;\r
754   \r
755   /* Enable the Peripheral */\r
756   __HAL_LPTIM_ENABLE(hlptim);\r
757   \r
758   /* Load the period value in the autoreload register */\r
759   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
760   \r
761   /* Load the pulse value in the compare register */\r
762   __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);\r
763   \r
764   /* Start timer in continuous mode */\r
765   __HAL_LPTIM_START_SINGLE(hlptim);\r
766     \r
767   /* Change the TIM state*/\r
768   hlptim->State= HAL_LPTIM_STATE_READY;\r
769   \r
770   /* Return function status */\r
771   return HAL_OK;\r
772 }\r
773 \r
774 /**\r
775   * @brief  Stops the LPTIM Set once mode.\r
776   * @param  hlptim : LPTIM handle\r
777   * @retval HAL status\r
778   */\r
779 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim)\r
780 {\r
781   /* Check the parameters */\r
782   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
783                \r
784   /* Set the LPTIM state */\r
785   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
786   \r
787   /* Disable the Peripheral */\r
788   __HAL_LPTIM_DISABLE(hlptim);\r
789 \r
790   /* Change the TIM state*/\r
791   hlptim->State= HAL_LPTIM_STATE_READY;\r
792   \r
793   /* Return function status */\r
794   return HAL_OK;\r
795 }\r
796 \r
797 /**\r
798   * @brief  Starts the LPTIM Set once mode in interrupt mode.\r
799   * @param  hlptim : LPTIM handle\r
800   * @param  Period : Specifies the Autoreload value.\r
801   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
802   * @param  Pulse : Specifies the compare value.\r
803   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
804   * @retval HAL status\r
805   */\r
806 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)\r
807 {\r
808   /* Check the parameters */\r
809   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
810   assert_param(IS_LPTIM_PERIOD(Period));\r
811   assert_param(IS_LPTIM_PULSE(Pulse));\r
812                \r
813   /* Set the LPTIM state */\r
814   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
815   \r
816   /* Set WAVE bit to enable the set once mode */\r
817   hlptim->Instance->CFGR |= LPTIM_CFGR_WAVE;\r
818   \r
819   /* Enable Autoreload write complete interrupt */\r
820   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARROK);\r
821   \r
822   /* Enable Compare write complete interrupt */\r
823   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPOK);\r
824   \r
825   /* Enable Autoreload match interrupt */\r
826   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARRM);\r
827   \r
828   /* Enable Compare match interrupt */\r
829   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPM);\r
830   \r
831   /* If external trigger source is used, then enable external trigger interrupt */\r
832   if ((hlptim->Init.Trigger.Source) !=  LPTIM_TRIGSOURCE_SOFTWARE)\r
833   {\r
834     /* Enable external trigger interrupt */\r
835     __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_EXTTRIG);\r
836   }  \r
837   \r
838   /* Enable the Peripheral */\r
839   __HAL_LPTIM_ENABLE(hlptim);\r
840   \r
841   /* Load the period value in the autoreload register */\r
842   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
843   \r
844   /* Load the pulse value in the compare register */\r
845   __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);\r
846   \r
847   /* Start timer in continuous mode */\r
848   __HAL_LPTIM_START_SINGLE(hlptim);\r
849     \r
850   /* Change the TIM state*/\r
851   hlptim->State= HAL_LPTIM_STATE_READY;\r
852   \r
853   /* Return function status */\r
854   return HAL_OK;\r
855 }\r
856 \r
857 /**\r
858   * @brief  Stops the LPTIM Set once mode in interrupt mode.\r
859   * @param  hlptim : LPTIM handle\r
860   * @retval HAL status\r
861   */\r
862 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim)\r
863 {\r
864   /* Check the parameters */\r
865   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
866                \r
867   /* Set the LPTIM state */\r
868   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
869   \r
870   /* Disable the Peripheral */\r
871   __HAL_LPTIM_DISABLE(hlptim);\r
872 \r
873   /* Disable Autoreload write complete interrupt */\r
874   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARROK);\r
875   \r
876   /* Disable Compare write complete interrupt */\r
877   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPOK);\r
878   \r
879   /* Disable Autoreload match interrupt */\r
880   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARRM);\r
881   \r
882   /* Disable Compare match interrupt */\r
883   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPM);\r
884   \r
885   /* If external trigger source is used, then disable external trigger interrupt */\r
886   if ((hlptim->Init.Trigger.Source) !=  LPTIM_TRIGSOURCE_SOFTWARE)\r
887   {\r
888     /* Disable external trigger interrupt */\r
889     __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_EXTTRIG);\r
890   } \r
891   \r
892   /* Change the TIM state*/\r
893   hlptim->State= HAL_LPTIM_STATE_READY;\r
894   \r
895   /* Return function status */\r
896   return HAL_OK;\r
897 }\r
898 \r
899 /**\r
900   * @brief  Starts the Encoder interface.\r
901   * @param  hlptim : LPTIM handle\r
902   * @param  Period : Specifies the Autoreload value.\r
903   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
904   * @retval HAL status\r
905   */\r
906 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period)\r
907 {\r
908   uint32_t tmpcfgr = 0;\r
909 \r
910   /* Check the parameters */\r
911   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
912   assert_param(IS_LPTIM_PERIOD(Period));\r
913   assert_param(hlptim->Init.Clock.Source == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC);\r
914   assert_param(hlptim->Init.Clock.Prescaler == LPTIM_PRESCALER_DIV1);\r
915   assert_param(IS_LPTIM_CLOCK_POLARITY(hlptim->Init.UltraLowPowerClock.Polarity));\r
916 \r
917   /* Set the LPTIM state */\r
918   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
919 \r
920   /* Get the LPTIMx CFGR value */\r
921   tmpcfgr = hlptim->Instance->CFGR;\r
922 \r
923   /* Clear CKPOL bits */\r
924   tmpcfgr &= (uint32_t)(~LPTIM_CFGR_CKPOL);\r
925 \r
926   /* Set Input polarity */\r
927   tmpcfgr |=  hlptim->Init.UltraLowPowerClock.Polarity;\r
928 \r
929   /* Write to LPTIMx CFGR */\r
930   hlptim->Instance->CFGR = tmpcfgr;\r
931 \r
932   /* Set ENC bit to enable the encoder interface */\r
933   hlptim->Instance->CFGR |= LPTIM_CFGR_ENC;\r
934 \r
935   /* Enable the Peripheral */\r
936   __HAL_LPTIM_ENABLE(hlptim);\r
937 \r
938   /* Load the period value in the autoreload register */\r
939   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
940 \r
941   /* Start timer in continuous mode */\r
942   __HAL_LPTIM_START_CONTINUOUS(hlptim);\r
943 \r
944   /* Change the TIM state*/\r
945   hlptim->State= HAL_LPTIM_STATE_READY;\r
946 \r
947   /* Return function status */\r
948   return HAL_OK;\r
949 }\r
950 \r
951 /**\r
952   * @brief  Stops the Encoder interface.\r
953   * @param  hlptim : LPTIM handle\r
954   * @retval HAL status\r
955   */\r
956 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim)\r
957 {\r
958   /* Check the parameters */\r
959   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
960                \r
961   /* Set the LPTIM state */\r
962   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
963   \r
964   /* Disable the Peripheral */\r
965   __HAL_LPTIM_DISABLE(hlptim);\r
966   \r
967   /* Reset ENC bit to disable the encoder interface */\r
968   hlptim->Instance->CFGR &= ~LPTIM_CFGR_ENC;\r
969   \r
970   /* Change the TIM state*/\r
971   hlptim->State= HAL_LPTIM_STATE_READY;\r
972   \r
973   /* Return function status */\r
974   return HAL_OK;\r
975 }\r
976 \r
977 /**\r
978   * @brief  Starts the Encoder interface in interrupt mode.\r
979   * @param  hlptim : LPTIM handle\r
980   * @param  Period : Specifies the Autoreload value.\r
981   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
982   * @retval HAL status\r
983   */\r
984 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period)\r
985 {\r
986   uint32_t tmpcfgr = 0;\r
987 \r
988   /* Check the parameters */\r
989   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
990   assert_param(IS_LPTIM_PERIOD(Period));\r
991   assert_param(hlptim->Init.Clock.Source == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC);\r
992   assert_param(hlptim->Init.Clock.Prescaler == LPTIM_PRESCALER_DIV1);\r
993   assert_param(IS_LPTIM_CLOCK_POLARITY(hlptim->Init.UltraLowPowerClock.Polarity));\r
994 \r
995   /* Set the LPTIM state */\r
996   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
997 \r
998   /* Configure edge sensitivity for encoder mode */\r
999   /* Get the LPTIMx CFGR value */\r
1000   tmpcfgr = hlptim->Instance->CFGR;\r
1001 \r
1002   /* Clear CKPOL bits */\r
1003   tmpcfgr &= (uint32_t)(~LPTIM_CFGR_CKPOL);\r
1004 \r
1005   /* Set Input polarity */\r
1006   tmpcfgr |=  hlptim->Init.UltraLowPowerClock.Polarity;\r
1007 \r
1008   /* Write to LPTIMx CFGR */\r
1009   hlptim->Instance->CFGR = tmpcfgr;\r
1010 \r
1011   /* Set ENC bit to enable the encoder interface */\r
1012   hlptim->Instance->CFGR |= LPTIM_CFGR_ENC;\r
1013 \r
1014   /* Enable "switch to down direction" interrupt */\r
1015   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_DOWN);\r
1016 \r
1017   /* Enable "switch to up direction" interrupt */\r
1018   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_UP);  \r
1019 \r
1020   /* Enable the Peripheral */\r
1021   __HAL_LPTIM_ENABLE(hlptim);\r
1022 \r
1023   /* Load the period value in the autoreload register */\r
1024   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
1025 \r
1026   /* Start timer in continuous mode */\r
1027   __HAL_LPTIM_START_CONTINUOUS(hlptim);\r
1028 \r
1029   /* Change the TIM state*/\r
1030   hlptim->State= HAL_LPTIM_STATE_READY;\r
1031 \r
1032   /* Return function status */\r
1033   return HAL_OK;\r
1034 }\r
1035 \r
1036 /**\r
1037   * @brief  Stops the Encoder interface in interrupt mode.\r
1038   * @param  hlptim : LPTIM handle\r
1039   * @retval HAL status\r
1040   */\r
1041 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim)\r
1042 {\r
1043   /* Check the parameters */\r
1044   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1045                \r
1046   /* Set the LPTIM state */\r
1047   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1048   \r
1049   /* Disable the Peripheral */\r
1050   __HAL_LPTIM_DISABLE(hlptim);\r
1051   \r
1052   /* Reset ENC bit to disable the encoder interface */\r
1053   hlptim->Instance->CFGR &= ~LPTIM_CFGR_ENC;\r
1054   \r
1055   /* Disable "switch to down direction" interrupt */\r
1056   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_DOWN);\r
1057   \r
1058   /* Disable "switch to up direction" interrupt */\r
1059   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_UP); \r
1060   \r
1061   /* Change the TIM state*/\r
1062   hlptim->State= HAL_LPTIM_STATE_READY;\r
1063   \r
1064   /* Return function status */\r
1065   return HAL_OK;\r
1066 }\r
1067 \r
1068 /**\r
1069   * @brief  Starts the Timeout function. The first trigger event will start the\r
1070   *         timer, any successive trigger event will reset the counter and\r
1071   *         the timer restarts.\r
1072   * @param  hlptim : LPTIM handle\r
1073   * @param  Period : Specifies the Autoreload value.\r
1074   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
1075   * @param  Timeout : Specifies the TimeOut value to rest the counter.\r
1076   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
1077   * @retval HAL status\r
1078   */\r
1079 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout)\r
1080 {\r
1081   /* Check the parameters */\r
1082   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1083   assert_param(IS_LPTIM_PERIOD(Period));\r
1084   assert_param(IS_LPTIM_PULSE(Timeout));\r
1085                \r
1086   /* Set the LPTIM state */\r
1087   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1088  \r
1089   /* Set TIMOUT bit to enable the timeout function */\r
1090   hlptim->Instance->CFGR |= LPTIM_CFGR_TIMOUT;\r
1091   \r
1092   /* Enable the Peripheral */\r
1093   __HAL_LPTIM_ENABLE(hlptim);\r
1094   \r
1095   /* Load the period value in the autoreload register */\r
1096   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
1097   \r
1098   /* Load the Timeout value in the compare register */\r
1099   __HAL_LPTIM_COMPARE_SET(hlptim, Timeout);\r
1100   \r
1101   /* Start timer in continuous mode */\r
1102   __HAL_LPTIM_START_CONTINUOUS(hlptim);\r
1103     \r
1104   /* Change the TIM state*/\r
1105   hlptim->State= HAL_LPTIM_STATE_READY;\r
1106   \r
1107   /* Return function status */\r
1108   return HAL_OK;\r
1109 }\r
1110 \r
1111 /**\r
1112   * @brief  Stops the Timeout function.\r
1113   * @param  hlptim : LPTIM handle\r
1114   * @retval HAL status\r
1115   */\r
1116 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim)\r
1117 {\r
1118   /* Check the parameters */\r
1119   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1120   \r
1121   /* Set the LPTIM state */\r
1122   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1123   \r
1124   /* Disable the Peripheral */\r
1125   __HAL_LPTIM_DISABLE(hlptim);\r
1126   \r
1127   /* Reset TIMOUT bit to enable the timeout function */\r
1128   hlptim->Instance->CFGR &= ~LPTIM_CFGR_TIMOUT;\r
1129   \r
1130   /* Change the TIM state*/\r
1131   hlptim->State= HAL_LPTIM_STATE_READY;\r
1132   \r
1133   /* Return function status */\r
1134   return HAL_OK;\r
1135 }\r
1136 \r
1137 /**\r
1138   * @brief  Starts the Timeout function in interrupt mode. The first trigger \r
1139   *         event will start the timer, any successive trigger event will reset\r
1140   *         the counter and the timer restarts.\r
1141   * @param  hlptim : LPTIM handle\r
1142   * @param  Period : Specifies the Autoreload value.\r
1143   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
1144   * @param  Timeout : Specifies the TimeOut value to rest the counter.\r
1145   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
1146   * @retval HAL status\r
1147   */\r
1148 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout)\r
1149 {\r
1150   /* Check the parameters */\r
1151   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1152   assert_param(IS_LPTIM_PERIOD(Period));\r
1153   assert_param(IS_LPTIM_PULSE(Timeout));\r
1154                \r
1155   /* Set the LPTIM state */\r
1156   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1157  \r
1158   /* Set TIMOUT bit to enable the timeout function */\r
1159   hlptim->Instance->CFGR |= LPTIM_CFGR_TIMOUT;\r
1160   \r
1161   /* Enable Compare match interrupt */\r
1162   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPM);\r
1163   \r
1164   /* Enable the Peripheral */\r
1165   __HAL_LPTIM_ENABLE(hlptim);\r
1166   \r
1167   /* Load the period value in the autoreload register */\r
1168   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
1169   \r
1170   /* Load the Timeout value in the compare register */\r
1171   __HAL_LPTIM_COMPARE_SET(hlptim, Timeout);\r
1172   \r
1173   /* Start timer in continuous mode */\r
1174   __HAL_LPTIM_START_CONTINUOUS(hlptim);\r
1175     \r
1176   /* Change the TIM state*/\r
1177   hlptim->State= HAL_LPTIM_STATE_READY;\r
1178   \r
1179   /* Return function status */\r
1180   return HAL_OK;\r
1181 }\r
1182 \r
1183 /**\r
1184   * @brief  Stops the Timeout function in interrupt mode.\r
1185   * @param  hlptim : LPTIM handle\r
1186   * @retval HAL status\r
1187   */\r
1188 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim)\r
1189 {\r
1190   /* Check the parameters */\r
1191   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1192   \r
1193   /* Set the LPTIM state */\r
1194   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1195   \r
1196   /* Disable the Peripheral */\r
1197   __HAL_LPTIM_DISABLE(hlptim);\r
1198   \r
1199   /* Reset TIMOUT bit to enable the timeout function */\r
1200   hlptim->Instance->CFGR &= ~LPTIM_CFGR_TIMOUT;\r
1201   \r
1202   /* Disable Compare match interrupt */\r
1203   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPM);\r
1204   \r
1205   /* Change the TIM state*/\r
1206   hlptim->State= HAL_LPTIM_STATE_READY;\r
1207   \r
1208   /* Return function status */\r
1209   return HAL_OK;\r
1210 }\r
1211 \r
1212 /**\r
1213   * @brief  Starts the Counter mode.\r
1214   * @param  hlptim : LPTIM handle\r
1215   * @param  Period : Specifies the Autoreload value.\r
1216   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
1217   * @retval HAL status\r
1218   */\r
1219 HAL_StatusTypeDef HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period)\r
1220 {\r
1221   /* Check the parameters */\r
1222   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1223   assert_param(IS_LPTIM_PERIOD(Period));\r
1224                \r
1225   /* Set the LPTIM state */\r
1226   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1227   \r
1228   /* If clock source is not ULPTIM clock and counter source is external, then it must not be prescaled */\r
1229   if((hlptim->Init.Clock.Source != LPTIM_CLOCKSOURCE_ULPTIM) && (hlptim->Init.CounterSource == LPTIM_COUNTERSOURCE_EXTERNAL))\r
1230   {\r
1231     /* Check if clock is prescaled */\r
1232     assert_param(IS_LPTIM_CLOCK_PRESCALERDIV1(hlptim->Init.Clock.Prescaler));\r
1233     /* Set clock prescaler to 0 */\r
1234     hlptim->Instance->CFGR &= ~LPTIM_CFGR_PRESC;\r
1235   }\r
1236 \r
1237   /* Enable the Peripheral */\r
1238   __HAL_LPTIM_ENABLE(hlptim);\r
1239   \r
1240   /* Load the period value in the autoreload register */\r
1241   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
1242   \r
1243   /* Start timer in continuous mode */\r
1244   __HAL_LPTIM_START_CONTINUOUS(hlptim);\r
1245     \r
1246   /* Change the TIM state*/\r
1247   hlptim->State= HAL_LPTIM_STATE_READY;\r
1248   \r
1249   /* Return function status */\r
1250   return HAL_OK;\r
1251 }\r
1252 \r
1253 /**\r
1254   * @brief  Stops the Counter mode.\r
1255   * @param  hlptim : LPTIM handle\r
1256   * @retval HAL status\r
1257   */\r
1258 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef *hlptim)\r
1259 {\r
1260   /* Check the parameters */\r
1261   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1262   \r
1263   /* Set the LPTIM state */\r
1264   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1265   \r
1266   /* Disable the Peripheral */\r
1267   __HAL_LPTIM_DISABLE(hlptim);\r
1268   \r
1269   /* Change the TIM state*/\r
1270   hlptim->State= HAL_LPTIM_STATE_READY;\r
1271   \r
1272   /* Return function status */\r
1273   return HAL_OK;\r
1274 }\r
1275 \r
1276 /**\r
1277   * @brief  Starts the Counter mode in interrupt mode.\r
1278   * @param  hlptim : LPTIM handle\r
1279   * @param  Period : Specifies the Autoreload value.\r
1280   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
1281   * @retval HAL status\r
1282   */\r
1283 HAL_StatusTypeDef HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period)\r
1284 {\r
1285   /* Check the parameters */\r
1286   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1287   assert_param(IS_LPTIM_PERIOD(Period));\r
1288                \r
1289   /* Set the LPTIM state */\r
1290   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1291   \r
1292   /* If clock source is not ULPTIM clock and counter source is external, then it must not be prescaled */\r
1293   if((hlptim->Init.Clock.Source != LPTIM_CLOCKSOURCE_ULPTIM) && (hlptim->Init.CounterSource == LPTIM_COUNTERSOURCE_EXTERNAL))\r
1294   {\r
1295     /* Check if clock is prescaled */\r
1296     assert_param(IS_LPTIM_CLOCK_PRESCALERDIV1(hlptim->Init.Clock.Prescaler));\r
1297     /* Set clock prescaler to 0 */\r
1298     hlptim->Instance->CFGR &= ~LPTIM_CFGR_PRESC;\r
1299   }\r
1300   \r
1301   /* Enable Autoreload write complete interrupt */\r
1302   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARROK);\r
1303   \r
1304   /* Enable Autoreload match interrupt */\r
1305   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARRM);\r
1306   \r
1307   /* Enable the Peripheral */\r
1308   __HAL_LPTIM_ENABLE(hlptim);\r
1309   \r
1310   /* Load the period value in the autoreload register */\r
1311   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
1312   \r
1313   /* Start timer in continuous mode */\r
1314   __HAL_LPTIM_START_CONTINUOUS(hlptim);\r
1315     \r
1316   /* Change the TIM state*/\r
1317   hlptim->State= HAL_LPTIM_STATE_READY;\r
1318   \r
1319   /* Return function status */\r
1320   return HAL_OK;\r
1321 }\r
1322 \r
1323 /**\r
1324   * @brief  Stops the Counter mode in interrupt mode.\r
1325   * @param  hlptim : LPTIM handle\r
1326   * @retval HAL status\r
1327   */\r
1328 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef *hlptim)\r
1329 {\r
1330   /* Check the parameters */\r
1331   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1332   \r
1333   /* Set the LPTIM state */\r
1334   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1335   \r
1336   /* Disable the Peripheral */\r
1337   __HAL_LPTIM_DISABLE(hlptim);\r
1338   \r
1339   /* Disable Autoreload write complete interrupt */\r
1340   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARROK);\r
1341   \r
1342   /* Disable Autoreload match interrupt */\r
1343   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARRM);\r
1344   \r
1345   /* Change the TIM state*/\r
1346   hlptim->State= HAL_LPTIM_STATE_READY;\r
1347   \r
1348   /* Return function status */\r
1349   return HAL_OK;\r
1350 }\r
1351 \r
1352 /**\r
1353   * @}\r
1354   */\r
1355 \r
1356 /** @defgroup LPTIM_Group3 LPTIM Read operation functions \r
1357  *  @brief  Read operation functions.\r
1358  *\r
1359 @verbatim   \r
1360   ==============================================================================\r
1361                   ##### LPTIM Read operation functions #####\r
1362   ==============================================================================  \r
1363 [..]  This section provides LPTIM Reading functions.\r
1364       (+) Read the counter value.\r
1365       (+) Read the period (Auto-reload) value.\r
1366       (+) Read the pulse (Compare)value.\r
1367 @endverbatim\r
1368   * @{\r
1369   */\r
1370 \r
1371 /**\r
1372   * @brief  This function returns the current counter value.\r
1373   * @param  hlptim: LPTIM handle\r
1374   * @retval Counter value.\r
1375   */\r
1376 uint32_t HAL_LPTIM_ReadCounter(LPTIM_HandleTypeDef *hlptim)\r
1377 {\r
1378     /* Check the parameters */\r
1379   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1380   \r
1381   return (hlptim->Instance->CNT);\r
1382 }\r
1383 \r
1384 /**\r
1385   * @brief  This function return the current Autoreload (Period) value.\r
1386   * @param  hlptim: LPTIM handle\r
1387   * @retval Autoreload value.\r
1388   */\r
1389 uint32_t HAL_LPTIM_ReadAutoReload(LPTIM_HandleTypeDef *hlptim)\r
1390 {\r
1391     /* Check the parameters */\r
1392   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1393   \r
1394   return (hlptim->Instance->ARR);\r
1395 }\r
1396 \r
1397 /**\r
1398   * @brief  This function return the current Compare (Pulse) value.\r
1399   * @param  hlptim: LPTIM handle\r
1400   * @retval Compare value.\r
1401   */\r
1402 uint32_t HAL_LPTIM_ReadCompare(LPTIM_HandleTypeDef *hlptim)\r
1403 {\r
1404     /* Check the parameters */\r
1405   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1406   \r
1407   return (hlptim->Instance->CMP);\r
1408 }\r
1409 \r
1410 /**\r
1411   * @}\r
1412   */\r
1413 \r
1414 \r
1415 \r
1416 /** @defgroup LPTIM_Group4 LPTIM IRQ handler \r
1417  *  @brief  LPTIM  IRQ handler.\r
1418  *\r
1419 @verbatim   \r
1420   ==============================================================================\r
1421                       ##### LPTIM IRQ handler  #####\r
1422   ==============================================================================  \r
1423 [..]  This section provides LPTIM IRQ handler function.\r
1424 \r
1425 @endverbatim\r
1426   * @{\r
1427   */\r
1428 \r
1429 /**\r
1430   * @brief  This function handles LPTIM interrupt request.\r
1431   * @param  hlptim: LPTIM handle\r
1432   * @retval None\r
1433   */\r
1434 void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim)\r
1435 {\r
1436   /* Compare match interrupt */\r
1437   if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_CMPM) != RESET)\r
1438         {\r
1439     if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_CMPM) !=RESET)\r
1440                 {\r
1441       /* Clear Compare match flag */\r
1442       __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_CMPM);\r
1443       /* Compare match Callback */\r
1444       HAL_LPTIM_CompareMatchCallback(hlptim);      \r
1445     }\r
1446   }\r
1447   \r
1448   /* Autoreload match interrupt */\r
1449   if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_ARRM) != RESET)\r
1450         {\r
1451     if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_ARRM) !=RESET)\r
1452                 {\r
1453       /* Clear Autoreload match flag */\r
1454       __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_ARRM);\r
1455       /* Autoreload match Callback */\r
1456       HAL_LPTIM_AutoReloadMatchCallback(hlptim);      \r
1457     }\r
1458   }\r
1459   \r
1460   /* Trigger detected interrupt */\r
1461   if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_EXTTRIG) != RESET)\r
1462         {\r
1463     if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_EXTTRIG) !=RESET)\r
1464                 {\r
1465       /* Clear Trigger detected flag */\r
1466       __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_EXTTRIG);\r
1467       /* Trigger detected callback */\r
1468       HAL_LPTIM_TriggerCallback(hlptim);      \r
1469     }\r
1470   }\r
1471   \r
1472   /* Compare write interrupt */\r
1473   if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_CMPOK) != RESET)\r
1474         {\r
1475     if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_FLAG_CMPM) !=RESET)\r
1476                 {\r
1477       /* Clear Compare write flag */\r
1478       __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_CMPOK);\r
1479       /* Compare write Callback */\r
1480       HAL_LPTIM_CompareWriteCallback(hlptim);      \r
1481     }\r
1482   }\r
1483   \r
1484   /* Autoreload write interrupt */\r
1485   if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_ARROK) != RESET)\r
1486         {\r
1487     if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_ARROK) !=RESET)\r
1488                 {\r
1489       /* Clear Autoreload write flag */\r
1490       __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_ARROK);\r
1491       /* Autoreload write Callback */\r
1492       HAL_LPTIM_AutoReloadWriteCallback(hlptim);      \r
1493     }\r
1494   }\r
1495   \r
1496   /* Direction counter changed from Down to Up interrupt */\r
1497   if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_UP) != RESET)\r
1498         {\r
1499     if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_UP) !=RESET)\r
1500                 {\r
1501       /* Clear Direction counter changed from Down to Up flag */\r
1502       __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_UP);\r
1503       /* Direction counter changed from Down to Up Callback */\r
1504       HAL_LPTIM_DirectionUpCallback(hlptim);      \r
1505     }\r
1506   }\r
1507   \r
1508   /* Direction counter changed from Up to Down interrupt */\r
1509   if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_DOWN) != RESET)\r
1510         {\r
1511     if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_DOWN) !=RESET)\r
1512                 {\r
1513       /* Clear Direction counter changed from Up to Down flag */\r
1514       __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_DOWN);\r
1515       /* Direction counter changed from Up to Down Callback */\r
1516       HAL_LPTIM_DirectionDownCallback(hlptim);      \r
1517     }\r
1518   }\r
1519 }\r
1520 \r
1521 /**\r
1522   * @brief  Compare match callback in non blocking mode \r
1523   * @param  hlptim : LPTIM handle\r
1524   * @retval None\r
1525   */\r
1526 __weak void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim)\r
1527 {\r
1528   /* NOTE : This function Should not be modified, when the callback is needed,\r
1529             the HAL_LPTIM_CompareMatchCallback could be implemented in the user file\r
1530    */  \r
1531 }\r
1532 \r
1533 /**\r
1534   * @brief  Autoreload match callback in non blocking mode \r
1535   * @param  hlptim : LPTIM handle\r
1536   * @retval None\r
1537   */\r
1538 __weak void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim)\r
1539 {\r
1540   /* NOTE : This function Should not be modified, when the callback is needed,\r
1541             the HAL_LPTIM_AutoReloadMatchCallback could be implemented in the user file\r
1542    */  \r
1543 }\r
1544 \r
1545 /**\r
1546   * @brief  Trigger detected callback in non blocking mode \r
1547   * @param  hlptim : LPTIM handle\r
1548   * @retval None\r
1549   */\r
1550 __weak void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef *hlptim)\r
1551 {\r
1552   /* NOTE : This function Should not be modified, when the callback is needed,\r
1553             the HAL_LPTIM_TriggerCallback could be implemented in the user file\r
1554    */  \r
1555 }\r
1556 \r
1557 /**\r
1558   * @brief  Compare write callback in non blocking mode \r
1559   * @param  hlptim : LPTIM handle\r
1560   * @retval None\r
1561   */\r
1562 __weak void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef *hlptim)\r
1563 {\r
1564   /* NOTE : This function Should not be modified, when the callback is needed,\r
1565             the HAL_LPTIM_CompareWriteCallback could be implemented in the user file\r
1566    */  \r
1567 }\r
1568 \r
1569 /**\r
1570   * @brief  Autoreload write callback in non blocking mode \r
1571   * @param  hlptim : LPTIM handle\r
1572   * @retval None\r
1573   */\r
1574 __weak void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef *hlptim)\r
1575 {\r
1576   /* NOTE : This function Should not be modified, when the callback is needed,\r
1577             the HAL_LPTIM_AutoReloadWriteCallback could be implemented in the user file\r
1578    */  \r
1579 }\r
1580 \r
1581 /**\r
1582   * @brief  Direction counter changed from Down to Up callback in non blocking mode \r
1583   * @param  hlptim : LPTIM handle\r
1584   * @retval None\r
1585   */\r
1586 __weak void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef *hlptim)\r
1587 {\r
1588   /* NOTE : This function Should not be modified, when the callback is needed,\r
1589             the HAL_LPTIM_DirectionUpCallback could be implemented in the user file\r
1590    */  \r
1591 }\r
1592 \r
1593 /**\r
1594   * @brief  Direction counter changed from Up to Down callback in non blocking mode \r
1595   * @param  hlptim : LPTIM handle\r
1596   * @retval None\r
1597   */\r
1598 __weak void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef *hlptim)\r
1599 {\r
1600   /* NOTE : This function Should not be modified, when the callback is needed,\r
1601             the HAL_LPTIM_DirectionDownCallback could be implemented in the user file\r
1602    */  \r
1603 }\r
1604 \r
1605 /**\r
1606   * @}\r
1607   */\r
1608 \r
1609 /** @defgroup LPTIM_Group5 Peripheral State functions \r
1610  *  @brief   Peripheral State functions. \r
1611  *\r
1612 @verbatim   \r
1613   ==============================================================================\r
1614                       ##### Peripheral State functions #####\r
1615   ==============================================================================  \r
1616     [..]\r
1617     This subsection permits to get in run-time the status of the peripheral.\r
1618 \r
1619 @endverbatim\r
1620   * @{\r
1621   */\r
1622 \r
1623 /**\r
1624   * @brief  Returns the LPTIM state.\r
1625   * @param  hlptim: LPTIM handle\r
1626   * @retval HAL state\r
1627   */\r
1628 HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(LPTIM_HandleTypeDef *hlptim)\r
1629 {\r
1630   return hlptim->State;\r
1631 }\r
1632 \r
1633 /**\r
1634   * @}\r
1635   */\r
1636 \r
1637 \r
1638 /**\r
1639   * @}\r
1640   */\r
1641 \r
1642 #endif /* HAL_LPTIM_MODULE_ENABLED */\r
1643 /**\r
1644   * @}\r
1645   */\r
1646 \r
1647 /**\r
1648   * @}\r
1649   */\r
1650 \r
1651 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r