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