]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M7_STM32F7_STM32756G-EVAL_IAR_Keil/ST_Library/stm32f7xx_hal_lptim.c
commit 9f316c246baafa15c542a5aea81a94f26e3d6507
[freertos] / FreeRTOS / Demo / CORTEX_M7_STM32F7_STM32756G-EVAL_IAR_Keil / 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 V1.0.0\r
6   * @date    12-May-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     /* Allocate lock resource and initialize it */\r
262     hlptim->Lock = HAL_UNLOCKED;\r
263     /* Init the low level hardware */\r
264     HAL_LPTIM_MspInit(hlptim);\r
265   }\r
266   \r
267   /* Change the LPTIM state */\r
268   hlptim->State = HAL_LPTIM_STATE_BUSY;\r
269   \r
270   /* Get the LPTIMx CFGR value */\r
271   tmpcfgr = hlptim->Instance->CFGR;\r
272   \r
273   if ((hlptim->Init.Clock.Source) ==  LPTIM_CLOCKSOURCE_ULPTIM)\r
274   {\r
275     tmpcfgr &= (uint32_t)(~(LPTIM_CFGR_CKPOL | LPTIM_CFGR_CKFLT));\r
276   }\r
277   if ((hlptim->Init.Trigger.Source) !=  LPTIM_TRIGSOURCE_SOFTWARE)\r
278   {\r
279     tmpcfgr &= (uint32_t)(~ (LPTIM_CFGR_TRGFLT | LPTIM_CFGR_TRIGSEL));\r
280   }\r
281     \r
282   /* Clear CKSEL, PRESC, TRIGEN, TRGFLT, WAVPOL, PRELOAD & COUNTMODE bits */\r
283   tmpcfgr &= (uint32_t)(~(LPTIM_CFGR_CKSEL | LPTIM_CFGR_TRIGEN | LPTIM_CFGR_PRELOAD |\r
284                           LPTIM_CFGR_WAVPOL | LPTIM_CFGR_PRESC | LPTIM_CFGR_COUNTMODE ));\r
285   \r
286   /* Set initialization parameters */\r
287   tmpcfgr |= (hlptim->Init.Clock.Source    |\r
288               hlptim->Init.Clock.Prescaler |\r
289               hlptim->Init.OutputPolarity  |\r
290               hlptim->Init.UpdateMode      |\r
291               hlptim->Init.CounterSource);\r
292   \r
293   if ((hlptim->Init.Clock.Source) ==  LPTIM_CLOCKSOURCE_ULPTIM)\r
294   {\r
295     tmpcfgr |=  (hlptim->Init.UltraLowPowerClock.Polarity |\r
296                 hlptim->Init.UltraLowPowerClock.SampleTime);\r
297   } \r
298   \r
299   if ((hlptim->Init.Trigger.Source) !=  LPTIM_TRIGSOURCE_SOFTWARE)\r
300   {\r
301     /* Enable External trigger and set the trigger source */\r
302     tmpcfgr |= (hlptim->Init.Trigger.Source     |\r
303                 hlptim->Init.Trigger.ActiveEdge |\r
304                 hlptim->Init.Trigger.SampleTime);\r
305   }\r
306   \r
307   /* Write to LPTIMx CFGR */\r
308   hlptim->Instance->CFGR = tmpcfgr;\r
309 \r
310   /* Change the LPTIM state */\r
311   hlptim->State = HAL_LPTIM_STATE_READY;\r
312   \r
313   /* Return function status */\r
314   return HAL_OK;\r
315 }\r
316 \r
317 /**\r
318   * @brief  DeInitializes the LPTIM peripheral. \r
319   * @param  hlptim: LPTIM handle\r
320   * @retval HAL status\r
321   */\r
322 HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim)\r
323 {\r
324   /* Check the LPTIM handle allocation */\r
325   if(hlptim == NULL)\r
326   {\r
327     return HAL_ERROR;\r
328   }\r
329   \r
330   /* Change the LPTIM state */\r
331   hlptim->State = HAL_LPTIM_STATE_BUSY;\r
332   \r
333   /* Disable the LPTIM Peripheral Clock */\r
334   __HAL_LPTIM_DISABLE(hlptim);\r
335   \r
336   /* DeInit the low level hardware: CLOCK, NVIC.*/\r
337   HAL_LPTIM_MspDeInit(hlptim);\r
338   \r
339   /* Change the LPTIM state */\r
340   hlptim->State = HAL_LPTIM_STATE_RESET;\r
341   \r
342   /* Release Lock */\r
343   __HAL_UNLOCK(hlptim);\r
344   \r
345   /* Return function status */\r
346   return HAL_OK;\r
347 }\r
348 \r
349 /**\r
350   * @brief  Initializes the LPTIM MSP.\r
351   * @param  hlptim: LPTIM handle\r
352   * @retval None\r
353   */\r
354 __weak void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim)\r
355 {\r
356   /* NOTE : This function Should not be modified, when the callback is needed,\r
357             the HAL_LPTIM_MspInit could be implemented in the user file\r
358    */\r
359 }\r
360 \r
361 /**\r
362   * @brief  DeInitializes LPTIM MSP.\r
363   * @param  hlptim: LPTIM handle\r
364   * @retval None\r
365   */\r
366 __weak void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim)\r
367 {\r
368   /* NOTE : This function Should not be modified, when the callback is needed,\r
369             the HAL_LPTIM_MspDeInit could be implemented in the user file\r
370    */\r
371 }\r
372 \r
373 /**\r
374   * @}\r
375   */\r
376 \r
377 /** @defgroup LPTIM_Group2 LPTIM Start-Stop operation functions \r
378  *  @brief   Start-Stop operation functions. \r
379  *\r
380 @verbatim   \r
381   ==============================================================================\r
382                 ##### LPTIM Start Stop operation functions #####\r
383   ==============================================================================  \r
384     [..]  This section provides functions allowing to:\r
385       (+) Start the PWM mode.\r
386       (+) Stop the PWM mode.\r
387       (+) Start the One pulse mode.\r
388       (+) Stop the One pulse mode.\r
389       (+) Start the Set once mode.\r
390       (+) Stop the Set once mode.\r
391       (+) Start the Encoder mode.\r
392       (+) Stop the Encoder mode.\r
393       (+) Start the Timeout mode.\r
394       (+) Stop the Timeout mode.      \r
395       (+) Start the Counter mode.\r
396       (+) Stop the Counter mode.\r
397       \r
398 \r
399 @endverbatim\r
400   * @{\r
401   */\r
402     \r
403 /**\r
404   * @brief  Starts the LPTIM PWM generation.\r
405   * @param  hlptim : LPTIM handle\r
406   * @param  Period : Specifies the Autoreload value.\r
407   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
408   * @param  Pulse : Specifies the compare value.\r
409   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
410   * @retval HAL status\r
411   */\r
412 HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)\r
413 {\r
414   /* Check the parameters */\r
415   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
416   assert_param(IS_LPTIM_PERIOD(Period));\r
417   assert_param(IS_LPTIM_PULSE(Pulse));\r
418                \r
419   /* Set the LPTIM state */\r
420   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
421  \r
422   /* Reset WAVE bit to set PWM mode */\r
423   hlptim->Instance->CFGR &= ~LPTIM_CFGR_WAVE;\r
424   \r
425   /* Enable the Peripheral */\r
426   __HAL_LPTIM_ENABLE(hlptim);\r
427   \r
428   /* Load the period value in the autoreload register */\r
429   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
430   \r
431   /* Load the pulse value in the compare register */\r
432   __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);\r
433   \r
434   /* Start timer in continuous mode */\r
435   __HAL_LPTIM_START_CONTINUOUS(hlptim);\r
436     \r
437   /* Change the TIM state*/\r
438   hlptim->State= HAL_LPTIM_STATE_READY;\r
439   \r
440   /* Return function status */\r
441   return HAL_OK;\r
442 }\r
443 \r
444 /**\r
445   * @brief  Stops the LPTIM PWM generation.\r
446   * @param  hlptim : LPTIM handle\r
447   * @retval HAL status\r
448   */\r
449 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim)\r
450 {\r
451   /* Check the parameters */\r
452   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
453                \r
454   /* Set the LPTIM state */\r
455   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
456   \r
457   /* Disable the Peripheral */\r
458   __HAL_LPTIM_DISABLE(hlptim);\r
459 \r
460   /* Change the TIM state*/\r
461   hlptim->State= HAL_LPTIM_STATE_READY;\r
462   \r
463   /* Return function status */\r
464   return HAL_OK;\r
465 }\r
466 \r
467 /**\r
468   * @brief  Starts the LPTIM PWM generation in interrupt mode.\r
469   * @param  hlptim : LPTIM handle\r
470   * @param  Period : Specifies the Autoreload value.\r
471   *         This parameter must be a value between 0x0000 and 0xFFFF\r
472   * @param  Pulse : Specifies the compare value.\r
473   *         This parameter must be a value between 0x0000 and 0xFFFF\r
474   * @retval HAL status\r
475   */\r
476 HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)\r
477 {\r
478   /* Check the parameters */\r
479   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
480   assert_param(IS_LPTIM_PERIOD(Period));\r
481   assert_param(IS_LPTIM_PULSE(Pulse));\r
482                \r
483   /* Set the LPTIM state */\r
484   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
485  \r
486   /* Reset WAVE bit to set PWM mode */\r
487   hlptim->Instance->CFGR &= ~LPTIM_CFGR_WAVE;\r
488   \r
489   /* Enable Autoreload write complete interrupt */\r
490   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARROK);\r
491   \r
492   /* Enable Compare write complete interrupt */\r
493   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPOK);\r
494   \r
495   /* Enable Autoreload match interrupt */\r
496   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARRM);\r
497   \r
498   /* Enable Compare match interrupt */\r
499   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPM);\r
500   \r
501   /* If external trigger source is used, then enable external trigger interrupt */\r
502   if ((hlptim->Init.Trigger.Source) !=  LPTIM_TRIGSOURCE_SOFTWARE)\r
503   {\r
504     /* Enable external trigger interrupt */\r
505     __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_EXTTRIG);\r
506   }  \r
507   \r
508   /* Enable the Peripheral */\r
509   __HAL_LPTIM_ENABLE(hlptim);\r
510   \r
511   /* Load the period value in the autoreload register */\r
512   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
513   \r
514   /* Load the pulse value in the compare register */\r
515   __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);\r
516   \r
517   /* Start timer in continuous mode */\r
518   __HAL_LPTIM_START_CONTINUOUS(hlptim);\r
519     \r
520   /* Change the TIM state*/\r
521   hlptim->State= HAL_LPTIM_STATE_READY;\r
522   \r
523   /* Return function status */\r
524   return HAL_OK;\r
525 }\r
526 \r
527 /**\r
528   * @brief  Stops the LPTIM PWM generation in interrupt mode.\r
529   * @param  hlptim : LPTIM handle\r
530   * @retval HAL status\r
531   */\r
532 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim)\r
533 {\r
534   /* Check the parameters */\r
535   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
536                \r
537   /* Set the LPTIM state */\r
538   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
539   \r
540   /* Disable the Peripheral */\r
541   __HAL_LPTIM_DISABLE(hlptim);\r
542   \r
543     /* Disable Autoreload write complete interrupt */\r
544   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARROK);\r
545   \r
546   /* Disable Compare write complete interrupt */\r
547   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPOK);\r
548   \r
549   /* Disable Autoreload match interrupt */\r
550   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARRM);\r
551   \r
552   /* Disable Compare match interrupt */\r
553   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPM);\r
554   \r
555   /* If external trigger source is used, then disable external trigger interrupt */\r
556   if ((hlptim->Init.Trigger.Source) !=  LPTIM_TRIGSOURCE_SOFTWARE)\r
557   {\r
558     /* Disable external trigger interrupt */\r
559     __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_EXTTRIG);\r
560   }  \r
561 \r
562   /* Change the TIM state*/\r
563   hlptim->State= HAL_LPTIM_STATE_READY;\r
564   \r
565   /* Return function status */\r
566   return HAL_OK;\r
567 }\r
568 \r
569 /**\r
570   * @brief  Starts the LPTIM One pulse generation.\r
571   * @param  hlptim : LPTIM handle\r
572   * @param  Period : Specifies the Autoreload value.\r
573   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
574   * @param  Pulse : Specifies the compare value.\r
575   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
576   * @retval HAL status\r
577   */\r
578 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)\r
579 {\r
580   /* Check the parameters */\r
581   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
582   assert_param(IS_LPTIM_PERIOD(Period));\r
583   assert_param(IS_LPTIM_PULSE(Pulse));\r
584                \r
585   /* Set the LPTIM state */\r
586   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
587   \r
588   /* Reset WAVE bit to set one pulse mode */\r
589   hlptim->Instance->CFGR &= ~LPTIM_CFGR_WAVE;\r
590   \r
591   /* Enable the Peripheral */\r
592   __HAL_LPTIM_ENABLE(hlptim);\r
593   \r
594   /* Load the period value in the autoreload register */\r
595   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
596   \r
597   /* Load the pulse value in the compare register */\r
598   __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);\r
599   \r
600   /* Start timer in continuous mode */\r
601   __HAL_LPTIM_START_SINGLE(hlptim);\r
602     \r
603   /* Change the TIM state*/\r
604   hlptim->State= HAL_LPTIM_STATE_READY;\r
605   \r
606   /* Return function status */\r
607   return HAL_OK;\r
608 }\r
609 \r
610 /**\r
611   * @brief  Stops the LPTIM One pulse generation.\r
612   * @param  hlptim : LPTIM handle\r
613   * @retval HAL status\r
614   */\r
615 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim)\r
616 {\r
617   /* Check the parameters */\r
618   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
619                \r
620   /* Set the LPTIM state */\r
621   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
622   \r
623   /* Disable the Peripheral */\r
624   __HAL_LPTIM_DISABLE(hlptim);\r
625 \r
626   /* Change the TIM state*/\r
627   hlptim->State= HAL_LPTIM_STATE_READY;\r
628   \r
629   /* Return function status */\r
630   return HAL_OK;\r
631 }\r
632 \r
633 /**\r
634   * @brief  Starts the LPTIM One pulse generation in interrupt mode.\r
635   * @param  hlptim : LPTIM handle\r
636   * @param  Period : Specifies the Autoreload value.\r
637   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
638   * @param  Pulse : Specifies the compare value.\r
639   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
640   * @retval HAL status\r
641   */\r
642 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)\r
643 {\r
644   /* Check the parameters */\r
645   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
646   assert_param(IS_LPTIM_PERIOD(Period));\r
647   assert_param(IS_LPTIM_PULSE(Pulse));\r
648                \r
649   /* Set the LPTIM state */\r
650   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
651   \r
652   /* Reset WAVE bit to set one pulse mode */\r
653   hlptim->Instance->CFGR &= ~LPTIM_CFGR_WAVE;\r
654   \r
655   /* Enable Autoreload write complete interrupt */\r
656   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARROK);\r
657   \r
658   /* Enable Compare write complete interrupt */\r
659   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPOK);\r
660   \r
661   /* Enable Autoreload match interrupt */\r
662   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARRM);\r
663   \r
664   /* Enable Compare match interrupt */\r
665   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPM);\r
666   \r
667   /* If external trigger source is used, then enable external trigger interrupt */\r
668   if ((hlptim->Init.Trigger.Source) !=  LPTIM_TRIGSOURCE_SOFTWARE)\r
669   {\r
670     /* Enable external trigger interrupt */\r
671     __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_EXTTRIG);\r
672   }\r
673   \r
674   /* Enable the Peripheral */\r
675   __HAL_LPTIM_ENABLE(hlptim);\r
676   \r
677   /* Load the period value in the autoreload register */\r
678   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
679   \r
680   /* Load the pulse value in the compare register */\r
681   __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);\r
682   \r
683   /* Start timer in continuous mode */\r
684   __HAL_LPTIM_START_SINGLE(hlptim);\r
685     \r
686   /* Change the TIM state*/\r
687   hlptim->State= HAL_LPTIM_STATE_READY;\r
688   \r
689   /* Return function status */\r
690   return HAL_OK;\r
691 }\r
692 \r
693 /**\r
694   * @brief  Stops the LPTIM One pulse generation in interrupt mode.\r
695   * @param  hlptim : LPTIM handle\r
696   * @retval HAL status\r
697   */\r
698 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim)\r
699 {\r
700   /* Check the parameters */\r
701   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
702                \r
703   /* Set the LPTIM state */\r
704   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
705   \r
706   /* Disable the Peripheral */\r
707   __HAL_LPTIM_DISABLE(hlptim);\r
708   \r
709   /* Disable Autoreload write complete interrupt */\r
710   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARROK);\r
711   \r
712   /* Disable Compare write complete interrupt */\r
713   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPOK);\r
714   \r
715   /* Disable Autoreload match interrupt */\r
716   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARRM);\r
717   \r
718   /* Disable Compare match interrupt */\r
719   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPM);\r
720   \r
721   /* If external trigger source is used, then disable external trigger interrupt */\r
722   if ((hlptim->Init.Trigger.Source) !=  LPTIM_TRIGSOURCE_SOFTWARE)\r
723   {\r
724     /* Disable external trigger interrupt */\r
725     __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_EXTTRIG);\r
726   }\r
727   \r
728   /* Change the TIM state*/\r
729   hlptim->State= HAL_LPTIM_STATE_READY;\r
730   \r
731   /* Return function status */\r
732   return HAL_OK;\r
733 }\r
734 \r
735 /**\r
736   * @brief  Starts the LPTIM in Set once mode.\r
737   * @param  hlptim : LPTIM handle\r
738   * @param  Period : Specifies the Autoreload value.\r
739   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
740   * @param  Pulse : Specifies the compare value.\r
741   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
742   * @retval HAL status\r
743   */\r
744 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)\r
745 {\r
746   /* Check the parameters */\r
747   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
748   assert_param(IS_LPTIM_PERIOD(Period));\r
749   assert_param(IS_LPTIM_PULSE(Pulse));\r
750                \r
751   /* Set the LPTIM state */\r
752   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
753   \r
754   /* Set WAVE bit to enable the set once mode */\r
755   hlptim->Instance->CFGR |= LPTIM_CFGR_WAVE;\r
756   \r
757   /* Enable the Peripheral */\r
758   __HAL_LPTIM_ENABLE(hlptim);\r
759   \r
760   /* Load the period value in the autoreload register */\r
761   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
762   \r
763   /* Load the pulse value in the compare register */\r
764   __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);\r
765   \r
766   /* Start timer in continuous mode */\r
767   __HAL_LPTIM_START_SINGLE(hlptim);\r
768     \r
769   /* Change the TIM state*/\r
770   hlptim->State= HAL_LPTIM_STATE_READY;\r
771   \r
772   /* Return function status */\r
773   return HAL_OK;\r
774 }\r
775 \r
776 /**\r
777   * @brief  Stops the LPTIM Set once mode.\r
778   * @param  hlptim : LPTIM handle\r
779   * @retval HAL status\r
780   */\r
781 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim)\r
782 {\r
783   /* Check the parameters */\r
784   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
785                \r
786   /* Set the LPTIM state */\r
787   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
788   \r
789   /* Disable the Peripheral */\r
790   __HAL_LPTIM_DISABLE(hlptim);\r
791 \r
792   /* Change the TIM state*/\r
793   hlptim->State= HAL_LPTIM_STATE_READY;\r
794   \r
795   /* Return function status */\r
796   return HAL_OK;\r
797 }\r
798 \r
799 /**\r
800   * @brief  Starts the LPTIM Set once mode in interrupt mode.\r
801   * @param  hlptim : LPTIM handle\r
802   * @param  Period : Specifies the Autoreload value.\r
803   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
804   * @param  Pulse : Specifies the compare value.\r
805   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
806   * @retval HAL status\r
807   */\r
808 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)\r
809 {\r
810   /* Check the parameters */\r
811   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
812   assert_param(IS_LPTIM_PERIOD(Period));\r
813   assert_param(IS_LPTIM_PULSE(Pulse));\r
814                \r
815   /* Set the LPTIM state */\r
816   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
817   \r
818   /* Set WAVE bit to enable the set once mode */\r
819   hlptim->Instance->CFGR |= LPTIM_CFGR_WAVE;\r
820   \r
821   /* Enable Autoreload write complete interrupt */\r
822   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARROK);\r
823   \r
824   /* Enable Compare write complete interrupt */\r
825   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPOK);\r
826   \r
827   /* Enable Autoreload match interrupt */\r
828   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARRM);\r
829   \r
830   /* Enable Compare match interrupt */\r
831   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPM);\r
832   \r
833   /* If external trigger source is used, then enable external trigger interrupt */\r
834   if ((hlptim->Init.Trigger.Source) !=  LPTIM_TRIGSOURCE_SOFTWARE)\r
835   {\r
836     /* Enable external trigger interrupt */\r
837     __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_EXTTRIG);\r
838   }  \r
839   \r
840   /* Enable the Peripheral */\r
841   __HAL_LPTIM_ENABLE(hlptim);\r
842   \r
843   /* Load the period value in the autoreload register */\r
844   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
845   \r
846   /* Load the pulse value in the compare register */\r
847   __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);\r
848   \r
849   /* Start timer in continuous mode */\r
850   __HAL_LPTIM_START_SINGLE(hlptim);\r
851     \r
852   /* Change the TIM state*/\r
853   hlptim->State= HAL_LPTIM_STATE_READY;\r
854   \r
855   /* Return function status */\r
856   return HAL_OK;\r
857 }\r
858 \r
859 /**\r
860   * @brief  Stops the LPTIM Set once mode in interrupt mode.\r
861   * @param  hlptim : LPTIM handle\r
862   * @retval HAL status\r
863   */\r
864 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim)\r
865 {\r
866   /* Check the parameters */\r
867   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
868                \r
869   /* Set the LPTIM state */\r
870   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
871   \r
872   /* Disable the Peripheral */\r
873   __HAL_LPTIM_DISABLE(hlptim);\r
874 \r
875   /* Disable Autoreload write complete interrupt */\r
876   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARROK);\r
877   \r
878   /* Disable Compare write complete interrupt */\r
879   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPOK);\r
880   \r
881   /* Disable Autoreload match interrupt */\r
882   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARRM);\r
883   \r
884   /* Disable Compare match interrupt */\r
885   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPM);\r
886   \r
887   /* If external trigger source is used, then disable external trigger interrupt */\r
888   if ((hlptim->Init.Trigger.Source) !=  LPTIM_TRIGSOURCE_SOFTWARE)\r
889   {\r
890     /* Disable external trigger interrupt */\r
891     __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_EXTTRIG);\r
892   } \r
893   \r
894   /* Change the TIM state*/\r
895   hlptim->State= HAL_LPTIM_STATE_READY;\r
896   \r
897   /* Return function status */\r
898   return HAL_OK;\r
899 }\r
900 \r
901 /**\r
902   * @brief  Starts the Encoder interface.\r
903   * @param  hlptim : LPTIM handle\r
904   * @param  Period : Specifies the Autoreload value.\r
905   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
906   * @retval HAL status\r
907   */\r
908 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period)\r
909 {\r
910   uint32_t tmpcfgr = 0;\r
911 \r
912   /* Check the parameters */\r
913   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
914   assert_param(IS_LPTIM_PERIOD(Period));\r
915   assert_param(hlptim->Init.Clock.Source == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC);\r
916   assert_param(hlptim->Init.Clock.Prescaler == LPTIM_PRESCALER_DIV1);\r
917   assert_param(IS_LPTIM_CLOCK_POLARITY(hlptim->Init.UltraLowPowerClock.Polarity));\r
918 \r
919   /* Set the LPTIM state */\r
920   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
921 \r
922   /* Get the LPTIMx CFGR value */\r
923   tmpcfgr = hlptim->Instance->CFGR;\r
924 \r
925   /* Clear CKPOL bits */\r
926   tmpcfgr &= (uint32_t)(~LPTIM_CFGR_CKPOL);\r
927 \r
928   /* Set Input polarity */\r
929   tmpcfgr |=  hlptim->Init.UltraLowPowerClock.Polarity;\r
930 \r
931   /* Write to LPTIMx CFGR */\r
932   hlptim->Instance->CFGR = tmpcfgr;\r
933 \r
934   /* Set ENC bit to enable the encoder interface */\r
935   hlptim->Instance->CFGR |= LPTIM_CFGR_ENC;\r
936 \r
937   /* Enable the Peripheral */\r
938   __HAL_LPTIM_ENABLE(hlptim);\r
939 \r
940   /* Load the period value in the autoreload register */\r
941   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
942 \r
943   /* Start timer in continuous mode */\r
944   __HAL_LPTIM_START_CONTINUOUS(hlptim);\r
945 \r
946   /* Change the TIM state*/\r
947   hlptim->State= HAL_LPTIM_STATE_READY;\r
948 \r
949   /* Return function status */\r
950   return HAL_OK;\r
951 }\r
952 \r
953 /**\r
954   * @brief  Stops the Encoder interface.\r
955   * @param  hlptim : LPTIM handle\r
956   * @retval HAL status\r
957   */\r
958 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim)\r
959 {\r
960   /* Check the parameters */\r
961   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
962                \r
963   /* Set the LPTIM state */\r
964   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
965   \r
966   /* Disable the Peripheral */\r
967   __HAL_LPTIM_DISABLE(hlptim);\r
968   \r
969   /* Reset ENC bit to disable the encoder interface */\r
970   hlptim->Instance->CFGR &= ~LPTIM_CFGR_ENC;\r
971   \r
972   /* Change the TIM state*/\r
973   hlptim->State= HAL_LPTIM_STATE_READY;\r
974   \r
975   /* Return function status */\r
976   return HAL_OK;\r
977 }\r
978 \r
979 /**\r
980   * @brief  Starts the Encoder interface in interrupt mode.\r
981   * @param  hlptim : LPTIM handle\r
982   * @param  Period : Specifies the Autoreload value.\r
983   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
984   * @retval HAL status\r
985   */\r
986 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period)\r
987 {\r
988   uint32_t tmpcfgr = 0;\r
989 \r
990   /* Check the parameters */\r
991   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
992   assert_param(IS_LPTIM_PERIOD(Period));\r
993   assert_param(hlptim->Init.Clock.Source == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC);\r
994   assert_param(hlptim->Init.Clock.Prescaler == LPTIM_PRESCALER_DIV1);\r
995   assert_param(IS_LPTIM_CLOCK_POLARITY(hlptim->Init.UltraLowPowerClock.Polarity));\r
996 \r
997   /* Set the LPTIM state */\r
998   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
999 \r
1000   /* Configure edge sensitivity for encoder mode */\r
1001   /* Get the LPTIMx CFGR value */\r
1002   tmpcfgr = hlptim->Instance->CFGR;\r
1003 \r
1004   /* Clear CKPOL bits */\r
1005   tmpcfgr &= (uint32_t)(~LPTIM_CFGR_CKPOL);\r
1006 \r
1007   /* Set Input polarity */\r
1008   tmpcfgr |=  hlptim->Init.UltraLowPowerClock.Polarity;\r
1009 \r
1010   /* Write to LPTIMx CFGR */\r
1011   hlptim->Instance->CFGR = tmpcfgr;\r
1012 \r
1013   /* Set ENC bit to enable the encoder interface */\r
1014   hlptim->Instance->CFGR |= LPTIM_CFGR_ENC;\r
1015 \r
1016   /* Enable "switch to down direction" interrupt */\r
1017   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_DOWN);\r
1018 \r
1019   /* Enable "switch to up direction" interrupt */\r
1020   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_UP);  \r
1021 \r
1022   /* Enable the Peripheral */\r
1023   __HAL_LPTIM_ENABLE(hlptim);\r
1024 \r
1025   /* Load the period value in the autoreload register */\r
1026   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
1027 \r
1028   /* Start timer in continuous mode */\r
1029   __HAL_LPTIM_START_CONTINUOUS(hlptim);\r
1030 \r
1031   /* Change the TIM state*/\r
1032   hlptim->State= HAL_LPTIM_STATE_READY;\r
1033 \r
1034   /* Return function status */\r
1035   return HAL_OK;\r
1036 }\r
1037 \r
1038 /**\r
1039   * @brief  Stops the Encoder interface in interrupt mode.\r
1040   * @param  hlptim : LPTIM handle\r
1041   * @retval HAL status\r
1042   */\r
1043 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim)\r
1044 {\r
1045   /* Check the parameters */\r
1046   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1047                \r
1048   /* Set the LPTIM state */\r
1049   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1050   \r
1051   /* Disable the Peripheral */\r
1052   __HAL_LPTIM_DISABLE(hlptim);\r
1053   \r
1054   /* Reset ENC bit to disable the encoder interface */\r
1055   hlptim->Instance->CFGR &= ~LPTIM_CFGR_ENC;\r
1056   \r
1057   /* Disable "switch to down direction" interrupt */\r
1058   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_DOWN);\r
1059   \r
1060   /* Disable "switch to up direction" interrupt */\r
1061   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_UP); \r
1062   \r
1063   /* Change the TIM state*/\r
1064   hlptim->State= HAL_LPTIM_STATE_READY;\r
1065   \r
1066   /* Return function status */\r
1067   return HAL_OK;\r
1068 }\r
1069 \r
1070 /**\r
1071   * @brief  Starts the Timeout function. The first trigger event will start the\r
1072   *         timer, any successive trigger event will reset the counter and\r
1073   *         the timer restarts.\r
1074   * @param  hlptim : LPTIM handle\r
1075   * @param  Period : Specifies the Autoreload value.\r
1076   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
1077   * @param  Timeout : Specifies the TimeOut value to rest the counter.\r
1078   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
1079   * @retval HAL status\r
1080   */\r
1081 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout)\r
1082 {\r
1083   /* Check the parameters */\r
1084   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1085   assert_param(IS_LPTIM_PERIOD(Period));\r
1086   assert_param(IS_LPTIM_PULSE(Timeout));\r
1087                \r
1088   /* Set the LPTIM state */\r
1089   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1090  \r
1091   /* Set TIMOUT bit to enable the timeout function */\r
1092   hlptim->Instance->CFGR |= LPTIM_CFGR_TIMOUT;\r
1093   \r
1094   /* Enable the Peripheral */\r
1095   __HAL_LPTIM_ENABLE(hlptim);\r
1096   \r
1097   /* Load the period value in the autoreload register */\r
1098   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
1099   \r
1100   /* Load the Timeout value in the compare register */\r
1101   __HAL_LPTIM_COMPARE_SET(hlptim, Timeout);\r
1102   \r
1103   /* Start timer in continuous mode */\r
1104   __HAL_LPTIM_START_CONTINUOUS(hlptim);\r
1105     \r
1106   /* Change the TIM state*/\r
1107   hlptim->State= HAL_LPTIM_STATE_READY;\r
1108   \r
1109   /* Return function status */\r
1110   return HAL_OK;\r
1111 }\r
1112 \r
1113 /**\r
1114   * @brief  Stops the Timeout function.\r
1115   * @param  hlptim : LPTIM handle\r
1116   * @retval HAL status\r
1117   */\r
1118 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim)\r
1119 {\r
1120   /* Check the parameters */\r
1121   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1122   \r
1123   /* Set the LPTIM state */\r
1124   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1125   \r
1126   /* Disable the Peripheral */\r
1127   __HAL_LPTIM_DISABLE(hlptim);\r
1128   \r
1129   /* Reset TIMOUT bit to enable the timeout function */\r
1130   hlptim->Instance->CFGR &= ~LPTIM_CFGR_TIMOUT;\r
1131   \r
1132   /* Change the TIM state*/\r
1133   hlptim->State= HAL_LPTIM_STATE_READY;\r
1134   \r
1135   /* Return function status */\r
1136   return HAL_OK;\r
1137 }\r
1138 \r
1139 /**\r
1140   * @brief  Starts the Timeout function in interrupt mode. The first trigger \r
1141   *         event will start the timer, any successive trigger event will reset\r
1142   *         the counter and the timer restarts.\r
1143   * @param  hlptim : LPTIM handle\r
1144   * @param  Period : Specifies the Autoreload value.\r
1145   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
1146   * @param  Timeout : Specifies the TimeOut value to rest the counter.\r
1147   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
1148   * @retval HAL status\r
1149   */\r
1150 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout)\r
1151 {\r
1152   /* Check the parameters */\r
1153   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1154   assert_param(IS_LPTIM_PERIOD(Period));\r
1155   assert_param(IS_LPTIM_PULSE(Timeout));\r
1156                \r
1157   /* Set the LPTIM state */\r
1158   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1159  \r
1160   /* Set TIMOUT bit to enable the timeout function */\r
1161   hlptim->Instance->CFGR |= LPTIM_CFGR_TIMOUT;\r
1162   \r
1163   /* Enable Compare match interrupt */\r
1164   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPM);\r
1165   \r
1166   /* Enable the Peripheral */\r
1167   __HAL_LPTIM_ENABLE(hlptim);\r
1168   \r
1169   /* Load the period value in the autoreload register */\r
1170   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
1171   \r
1172   /* Load the Timeout value in the compare register */\r
1173   __HAL_LPTIM_COMPARE_SET(hlptim, Timeout);\r
1174   \r
1175   /* Start timer in continuous mode */\r
1176   __HAL_LPTIM_START_CONTINUOUS(hlptim);\r
1177     \r
1178   /* Change the TIM state*/\r
1179   hlptim->State= HAL_LPTIM_STATE_READY;\r
1180   \r
1181   /* Return function status */\r
1182   return HAL_OK;\r
1183 }\r
1184 \r
1185 /**\r
1186   * @brief  Stops the Timeout function in interrupt mode.\r
1187   * @param  hlptim : LPTIM handle\r
1188   * @retval HAL status\r
1189   */\r
1190 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim)\r
1191 {\r
1192   /* Check the parameters */\r
1193   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1194   \r
1195   /* Set the LPTIM state */\r
1196   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1197   \r
1198   /* Disable the Peripheral */\r
1199   __HAL_LPTIM_DISABLE(hlptim);\r
1200   \r
1201   /* Reset TIMOUT bit to enable the timeout function */\r
1202   hlptim->Instance->CFGR &= ~LPTIM_CFGR_TIMOUT;\r
1203   \r
1204   /* Disable Compare match interrupt */\r
1205   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPM);\r
1206   \r
1207   /* Change the TIM state*/\r
1208   hlptim->State= HAL_LPTIM_STATE_READY;\r
1209   \r
1210   /* Return function status */\r
1211   return HAL_OK;\r
1212 }\r
1213 \r
1214 /**\r
1215   * @brief  Starts the Counter mode.\r
1216   * @param  hlptim : LPTIM handle\r
1217   * @param  Period : Specifies the Autoreload value.\r
1218   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
1219   * @retval HAL status\r
1220   */\r
1221 HAL_StatusTypeDef HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period)\r
1222 {\r
1223   /* Check the parameters */\r
1224   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1225   assert_param(IS_LPTIM_PERIOD(Period));\r
1226                \r
1227   /* Set the LPTIM state */\r
1228   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1229   \r
1230   /* If clock source is not ULPTIM clock and counter source is external, then it must not be prescaled */\r
1231   if((hlptim->Init.Clock.Source != LPTIM_CLOCKSOURCE_ULPTIM) && (hlptim->Init.CounterSource == LPTIM_COUNTERSOURCE_EXTERNAL))\r
1232   {\r
1233     /* Check if clock is prescaled */\r
1234     assert_param(IS_LPTIM_CLOCK_PRESCALERDIV1(hlptim->Init.Clock.Prescaler));\r
1235     /* Set clock prescaler to 0 */\r
1236     hlptim->Instance->CFGR &= ~LPTIM_CFGR_PRESC;\r
1237   }\r
1238 \r
1239   /* Enable the Peripheral */\r
1240   __HAL_LPTIM_ENABLE(hlptim);\r
1241   \r
1242   /* Load the period value in the autoreload register */\r
1243   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
1244   \r
1245   /* Start timer in continuous mode */\r
1246   __HAL_LPTIM_START_CONTINUOUS(hlptim);\r
1247     \r
1248   /* Change the TIM state*/\r
1249   hlptim->State= HAL_LPTIM_STATE_READY;\r
1250   \r
1251   /* Return function status */\r
1252   return HAL_OK;\r
1253 }\r
1254 \r
1255 /**\r
1256   * @brief  Stops the Counter mode.\r
1257   * @param  hlptim : LPTIM handle\r
1258   * @retval HAL status\r
1259   */\r
1260 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef *hlptim)\r
1261 {\r
1262   /* Check the parameters */\r
1263   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1264   \r
1265   /* Set the LPTIM state */\r
1266   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1267   \r
1268   /* Disable the Peripheral */\r
1269   __HAL_LPTIM_DISABLE(hlptim);\r
1270   \r
1271   /* Change the TIM state*/\r
1272   hlptim->State= HAL_LPTIM_STATE_READY;\r
1273   \r
1274   /* Return function status */\r
1275   return HAL_OK;\r
1276 }\r
1277 \r
1278 /**\r
1279   * @brief  Starts the Counter mode in interrupt mode.\r
1280   * @param  hlptim : LPTIM handle\r
1281   * @param  Period : Specifies the Autoreload value.\r
1282   *         This parameter must be a value between 0x0000 and 0xFFFF.\r
1283   * @retval HAL status\r
1284   */\r
1285 HAL_StatusTypeDef HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period)\r
1286 {\r
1287   /* Check the parameters */\r
1288   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1289   assert_param(IS_LPTIM_PERIOD(Period));\r
1290                \r
1291   /* Set the LPTIM state */\r
1292   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1293   \r
1294   /* If clock source is not ULPTIM clock and counter source is external, then it must not be prescaled */\r
1295   if((hlptim->Init.Clock.Source != LPTIM_CLOCKSOURCE_ULPTIM) && (hlptim->Init.CounterSource == LPTIM_COUNTERSOURCE_EXTERNAL))\r
1296   {\r
1297     /* Check if clock is prescaled */\r
1298     assert_param(IS_LPTIM_CLOCK_PRESCALERDIV1(hlptim->Init.Clock.Prescaler));\r
1299     /* Set clock prescaler to 0 */\r
1300     hlptim->Instance->CFGR &= ~LPTIM_CFGR_PRESC;\r
1301   }\r
1302   \r
1303   /* Enable Autoreload write complete interrupt */\r
1304   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARROK);\r
1305   \r
1306   /* Enable Autoreload match interrupt */\r
1307   __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARRM);\r
1308   \r
1309   /* Enable the Peripheral */\r
1310   __HAL_LPTIM_ENABLE(hlptim);\r
1311   \r
1312   /* Load the period value in the autoreload register */\r
1313   __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);\r
1314   \r
1315   /* Start timer in continuous mode */\r
1316   __HAL_LPTIM_START_CONTINUOUS(hlptim);\r
1317     \r
1318   /* Change the TIM state*/\r
1319   hlptim->State= HAL_LPTIM_STATE_READY;\r
1320   \r
1321   /* Return function status */\r
1322   return HAL_OK;\r
1323 }\r
1324 \r
1325 /**\r
1326   * @brief  Stops the Counter mode in interrupt mode.\r
1327   * @param  hlptim : LPTIM handle\r
1328   * @retval HAL status\r
1329   */\r
1330 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef *hlptim)\r
1331 {\r
1332   /* Check the parameters */\r
1333   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1334   \r
1335   /* Set the LPTIM state */\r
1336   hlptim->State= HAL_LPTIM_STATE_BUSY;\r
1337   \r
1338   /* Disable the Peripheral */\r
1339   __HAL_LPTIM_DISABLE(hlptim);\r
1340   \r
1341   /* Disable Autoreload write complete interrupt */\r
1342   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARROK);\r
1343   \r
1344   /* Disable Autoreload match interrupt */\r
1345   __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARRM);\r
1346   \r
1347   /* Change the TIM state*/\r
1348   hlptim->State= HAL_LPTIM_STATE_READY;\r
1349   \r
1350   /* Return function status */\r
1351   return HAL_OK;\r
1352 }\r
1353 \r
1354 /**\r
1355   * @}\r
1356   */\r
1357 \r
1358 /** @defgroup LPTIM_Group3 LPTIM Read operation functions \r
1359  *  @brief  Read operation functions.\r
1360  *\r
1361 @verbatim   \r
1362   ==============================================================================\r
1363                   ##### LPTIM Read operation functions #####\r
1364   ==============================================================================  \r
1365 [..]  This section provides LPTIM Reading functions.\r
1366       (+) Read the counter value.\r
1367       (+) Read the period (Auto-reload) value.\r
1368       (+) Read the pulse (Compare)value.\r
1369 @endverbatim\r
1370   * @{\r
1371   */\r
1372 \r
1373 /**\r
1374   * @brief  This function returns the current counter value.\r
1375   * @param  hlptim: LPTIM handle\r
1376   * @retval Counter value.\r
1377   */\r
1378 uint32_t HAL_LPTIM_ReadCounter(LPTIM_HandleTypeDef *hlptim)\r
1379 {\r
1380     /* Check the parameters */\r
1381   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1382   \r
1383   return (hlptim->Instance->CNT);\r
1384 }\r
1385 \r
1386 /**\r
1387   * @brief  This function return the current Autoreload (Period) value.\r
1388   * @param  hlptim: LPTIM handle\r
1389   * @retval Autoreload value.\r
1390   */\r
1391 uint32_t HAL_LPTIM_ReadAutoReload(LPTIM_HandleTypeDef *hlptim)\r
1392 {\r
1393     /* Check the parameters */\r
1394   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1395   \r
1396   return (hlptim->Instance->ARR);\r
1397 }\r
1398 \r
1399 /**\r
1400   * @brief  This function return the current Compare (Pulse) value.\r
1401   * @param  hlptim: LPTIM handle\r
1402   * @retval Compare value.\r
1403   */\r
1404 uint32_t HAL_LPTIM_ReadCompare(LPTIM_HandleTypeDef *hlptim)\r
1405 {\r
1406     /* Check the parameters */\r
1407   assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));\r
1408   \r
1409   return (hlptim->Instance->CMP);\r
1410 }\r
1411 \r
1412 /**\r
1413   * @}\r
1414   */\r
1415 \r
1416 \r
1417 \r
1418 /** @defgroup LPTIM_Group4 LPTIM IRQ handler \r
1419  *  @brief  LPTIM  IRQ handler.\r
1420  *\r
1421 @verbatim   \r
1422   ==============================================================================\r
1423                       ##### LPTIM IRQ handler  #####\r
1424   ==============================================================================  \r
1425 [..]  This section provides LPTIM IRQ handler function.\r
1426 \r
1427 @endverbatim\r
1428   * @{\r
1429   */\r
1430 \r
1431 /**\r
1432   * @brief  This function handles LPTIM interrupt request.\r
1433   * @param  hlptim: LPTIM handle\r
1434   * @retval None\r
1435   */\r
1436 void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim)\r
1437 {\r
1438   /* Compare match interrupt */\r
1439   if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_CMPM) != RESET)\r
1440         {\r
1441     if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_CMPM) !=RESET)\r
1442                 {\r
1443       /* Clear Compare match flag */\r
1444       __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_CMPM);\r
1445       /* Compare match Callback */\r
1446       HAL_LPTIM_CompareMatchCallback(hlptim);      \r
1447     }\r
1448   }\r
1449   \r
1450   /* Autoreload match interrupt */\r
1451   if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_ARRM) != RESET)\r
1452         {\r
1453     if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_ARRM) !=RESET)\r
1454                 {\r
1455       /* Clear Autoreload match flag */\r
1456       __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_ARRM);\r
1457       /* Autoreload match Callback */\r
1458       HAL_LPTIM_AutoReloadMatchCallback(hlptim);      \r
1459     }\r
1460   }\r
1461   \r
1462   /* Trigger detected interrupt */\r
1463   if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_EXTTRIG) != RESET)\r
1464         {\r
1465     if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_EXTTRIG) !=RESET)\r
1466                 {\r
1467       /* Clear Trigger detected flag */\r
1468       __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_EXTTRIG);\r
1469       /* Trigger detected callback */\r
1470       HAL_LPTIM_TriggerCallback(hlptim);      \r
1471     }\r
1472   }\r
1473   \r
1474   /* Compare write interrupt */\r
1475   if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_CMPOK) != RESET)\r
1476         {\r
1477     if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_FLAG_CMPM) !=RESET)\r
1478                 {\r
1479       /* Clear Compare write flag */\r
1480       __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_CMPOK);\r
1481       /* Compare write Callback */\r
1482       HAL_LPTIM_CompareWriteCallback(hlptim);      \r
1483     }\r
1484   }\r
1485   \r
1486   /* Autoreload write interrupt */\r
1487   if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_ARROK) != RESET)\r
1488         {\r
1489     if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_ARROK) !=RESET)\r
1490                 {\r
1491       /* Clear Autoreload write flag */\r
1492       __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_ARROK);\r
1493       /* Autoreload write Callback */\r
1494       HAL_LPTIM_AutoReloadWriteCallback(hlptim);      \r
1495     }\r
1496   }\r
1497   \r
1498   /* Direction counter changed from Down to Up interrupt */\r
1499   if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_UP) != RESET)\r
1500         {\r
1501     if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_UP) !=RESET)\r
1502                 {\r
1503       /* Clear Direction counter changed from Down to Up flag */\r
1504       __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_UP);\r
1505       /* Direction counter changed from Down to Up Callback */\r
1506       HAL_LPTIM_DirectionUpCallback(hlptim);      \r
1507     }\r
1508   }\r
1509   \r
1510   /* Direction counter changed from Up to Down interrupt */\r
1511   if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_DOWN) != RESET)\r
1512         {\r
1513     if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_DOWN) !=RESET)\r
1514                 {\r
1515       /* Clear Direction counter changed from Up to Down flag */\r
1516       __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_DOWN);\r
1517       /* Direction counter changed from Up to Down Callback */\r
1518       HAL_LPTIM_DirectionDownCallback(hlptim);      \r
1519     }\r
1520   }\r
1521 }\r
1522 \r
1523 /**\r
1524   * @brief  Compare match callback in non blocking mode \r
1525   * @param  hlptim : LPTIM handle\r
1526   * @retval None\r
1527   */\r
1528 __weak void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim)\r
1529 {\r
1530   /* NOTE : This function Should not be modified, when the callback is needed,\r
1531             the HAL_LPTIM_CompareMatchCallback could be implemented in the user file\r
1532    */  \r
1533 }\r
1534 \r
1535 /**\r
1536   * @brief  Autoreload match callback in non blocking mode \r
1537   * @param  hlptim : LPTIM handle\r
1538   * @retval None\r
1539   */\r
1540 __weak void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim)\r
1541 {\r
1542   /* NOTE : This function Should not be modified, when the callback is needed,\r
1543             the HAL_LPTIM_AutoReloadMatchCallback could be implemented in the user file\r
1544    */  \r
1545 }\r
1546 \r
1547 /**\r
1548   * @brief  Trigger detected callback in non blocking mode \r
1549   * @param  hlptim : LPTIM handle\r
1550   * @retval None\r
1551   */\r
1552 __weak void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef *hlptim)\r
1553 {\r
1554   /* NOTE : This function Should not be modified, when the callback is needed,\r
1555             the HAL_LPTIM_TriggerCallback could be implemented in the user file\r
1556    */  \r
1557 }\r
1558 \r
1559 /**\r
1560   * @brief  Compare write callback in non blocking mode \r
1561   * @param  hlptim : LPTIM handle\r
1562   * @retval None\r
1563   */\r
1564 __weak void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef *hlptim)\r
1565 {\r
1566   /* NOTE : This function Should not be modified, when the callback is needed,\r
1567             the HAL_LPTIM_CompareWriteCallback could be implemented in the user file\r
1568    */  \r
1569 }\r
1570 \r
1571 /**\r
1572   * @brief  Autoreload write callback in non blocking mode \r
1573   * @param  hlptim : LPTIM handle\r
1574   * @retval None\r
1575   */\r
1576 __weak void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef *hlptim)\r
1577 {\r
1578   /* NOTE : This function Should not be modified, when the callback is needed,\r
1579             the HAL_LPTIM_AutoReloadWriteCallback could be implemented in the user file\r
1580    */  \r
1581 }\r
1582 \r
1583 /**\r
1584   * @brief  Direction counter changed from Down to Up callback in non blocking mode \r
1585   * @param  hlptim : LPTIM handle\r
1586   * @retval None\r
1587   */\r
1588 __weak void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef *hlptim)\r
1589 {\r
1590   /* NOTE : This function Should not be modified, when the callback is needed,\r
1591             the HAL_LPTIM_DirectionUpCallback could be implemented in the user file\r
1592    */  \r
1593 }\r
1594 \r
1595 /**\r
1596   * @brief  Direction counter changed from Up to Down callback in non blocking mode \r
1597   * @param  hlptim : LPTIM handle\r
1598   * @retval None\r
1599   */\r
1600 __weak void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef *hlptim)\r
1601 {\r
1602   /* NOTE : This function Should not be modified, when the callback is needed,\r
1603             the HAL_LPTIM_DirectionDownCallback could be implemented in the user file\r
1604    */  \r
1605 }\r
1606 \r
1607 /**\r
1608   * @}\r
1609   */\r
1610 \r
1611 /** @defgroup LPTIM_Group5 Peripheral State functions \r
1612  *  @brief   Peripheral State functions. \r
1613  *\r
1614 @verbatim   \r
1615   ==============================================================================\r
1616                       ##### Peripheral State functions #####\r
1617   ==============================================================================  \r
1618     [..]\r
1619     This subsection permits to get in run-time the status of the peripheral.\r
1620 \r
1621 @endverbatim\r
1622   * @{\r
1623   */\r
1624 \r
1625 /**\r
1626   * @brief  Returns the LPTIM state.\r
1627   * @param  hlptim: LPTIM handle\r
1628   * @retval HAL state\r
1629   */\r
1630 HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(LPTIM_HandleTypeDef *hlptim)\r
1631 {\r
1632   return hlptim->State;\r
1633 }\r
1634 \r
1635 /**\r
1636   * @}\r
1637   */\r
1638 \r
1639 \r
1640 /**\r
1641   * @}\r
1642   */\r
1643 \r
1644 #endif /* HAL_LPTIM_MODULE_ENABLED */\r
1645 /**\r
1646   * @}\r
1647   */\r
1648 \r
1649 /**\r
1650   * @}\r
1651   */\r
1652 \r
1653 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r