source: S-port/trunk/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_lptim.h

Last change on this file was 1, checked in by AlexLir, 3 years ago
File size: 36.7 KB
Line 
1/**
2 ******************************************************************************
3 * @file stm32f4xx_hal_lptim.h
4 * @author MCD Application Team
5 * @brief Header file of LPTIM HAL module.
6 ******************************************************************************
7 * @attention
8 *
9 * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10 * All rights reserved.</center></h2>
11 *
12 * This software component is licensed by ST under BSD 3-Clause license,
13 * the "License"; You may not use this file except in compliance with the
14 * License. You may obtain a copy of the License at:
15 * opensource.org/licenses/BSD-3-Clause
16 *
17 ******************************************************************************
18 */
19
20/* Define to prevent recursive inclusion -------------------------------------*/
21#ifndef STM32F4xx_HAL_LPTIM_H
22#define STM32F4xx_HAL_LPTIM_H
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/* Includes ------------------------------------------------------------------*/
29#include "stm32f4xx_hal_def.h"
30
31/** @addtogroup STM32F4xx_HAL_Driver
32 * @{
33 */
34
35#if defined (LPTIM1)
36
37/** @addtogroup LPTIM
38 * @{
39 */
40
41/* Exported types ------------------------------------------------------------*/
42/** @defgroup LPTIM_Exported_Types LPTIM Exported Types
43 * @{
44 */
45#define LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT EXTI_IMR_MR23 /*!< External interrupt line 23 Connected to the LPTIM EXTI Line */
46
47/**
48 * @brief LPTIM Clock configuration definition
49 */
50typedef struct
51{
52 uint32_t Source; /*!< Selects the clock source.
53 This parameter can be a value of @ref LPTIM_Clock_Source */
54
55 uint32_t Prescaler; /*!< Specifies the counter clock Prescaler.
56 This parameter can be a value of @ref LPTIM_Clock_Prescaler */
57
58} LPTIM_ClockConfigTypeDef;
59
60/**
61 * @brief LPTIM Clock configuration definition
62 */
63typedef struct
64{
65 uint32_t Polarity; /*!< Selects the polarity of the active edge for the counter unit
66 if the ULPTIM input is selected.
67 Note: This parameter is used only when Ultra low power clock source is used.
68 Note: If the polarity is configured on 'both edges', an auxiliary clock
69 (one of the Low power oscillator) must be active.
70 This parameter can be a value of @ref LPTIM_Clock_Polarity */
71
72 uint32_t SampleTime; /*!< Selects the clock sampling time to configure the clock glitch filter.
73 Note: This parameter is used only when Ultra low power clock source is used.
74 This parameter can be a value of @ref LPTIM_Clock_Sample_Time */
75
76} LPTIM_ULPClockConfigTypeDef;
77
78/**
79 * @brief LPTIM Trigger configuration definition
80 */
81typedef struct
82{
83 uint32_t Source; /*!< Selects the Trigger source.
84 This parameter can be a value of @ref LPTIM_Trigger_Source */
85
86 uint32_t ActiveEdge; /*!< Selects the Trigger active edge.
87 Note: This parameter is used only when an external trigger is used.
88 This parameter can be a value of @ref LPTIM_External_Trigger_Polarity */
89
90 uint32_t SampleTime; /*!< Selects the trigger sampling time to configure the clock glitch filter.
91 Note: This parameter is used only when an external trigger is used.
92 This parameter can be a value of @ref LPTIM_Trigger_Sample_Time */
93} LPTIM_TriggerConfigTypeDef;
94
95/**
96 * @brief LPTIM Initialization Structure definition
97 */
98typedef struct
99{
100 LPTIM_ClockConfigTypeDef Clock; /*!< Specifies the clock parameters */
101
102 LPTIM_ULPClockConfigTypeDef UltraLowPowerClock; /*!< Specifies the Ultra Low Power clock parameters */
103
104 LPTIM_TriggerConfigTypeDef Trigger; /*!< Specifies the Trigger parameters */
105
106 uint32_t OutputPolarity; /*!< Specifies the Output polarity.
107 This parameter can be a value of @ref LPTIM_Output_Polarity */
108
109 uint32_t UpdateMode; /*!< Specifies whether the update of the autoreload and the compare
110 values is done immediately or after the end of current period.
111 This parameter can be a value of @ref LPTIM_Updating_Mode */
112
113 uint32_t CounterSource; /*!< Specifies whether the counter is incremented each internal event
114 or each external event.
115 This parameter can be a value of @ref LPTIM_Counter_Source */
116} LPTIM_InitTypeDef;
117
118/**
119 * @brief HAL LPTIM State structure definition
120 */
121typedef enum
122{
123 HAL_LPTIM_STATE_RESET = 0x00U, /*!< Peripheral not yet initialized or disabled */
124 HAL_LPTIM_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
125 HAL_LPTIM_STATE_BUSY = 0x02U, /*!< An internal process is ongoing */
126 HAL_LPTIM_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
127 HAL_LPTIM_STATE_ERROR = 0x04U /*!< Internal Process is ongoing */
128} HAL_LPTIM_StateTypeDef;
129
130/**
131 * @brief LPTIM handle Structure definition
132 */
133#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
134typedef struct __LPTIM_HandleTypeDef
135#else
136typedef struct
137#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
138{
139 LPTIM_TypeDef *Instance; /*!< Register base address */
140
141 LPTIM_InitTypeDef Init; /*!< LPTIM required parameters */
142
143 HAL_StatusTypeDef Status; /*!< LPTIM peripheral status */
144
145 HAL_LockTypeDef Lock; /*!< LPTIM locking object */
146
147 __IO HAL_LPTIM_StateTypeDef State; /*!< LPTIM peripheral state */
148
149#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
150 void (* MspInitCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Base Msp Init Callback */
151 void (* MspDeInitCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Base Msp DeInit Callback */
152 void (* CompareMatchCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Compare match Callback */
153 void (* AutoReloadMatchCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Auto-reload match Callback */
154 void (* TriggerCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< External trigger event detection Callback */
155 void (* CompareWriteCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Compare register write complete Callback */
156 void (* AutoReloadWriteCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Auto-reload register write complete Callback */
157 void (* DirectionUpCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Up-counting direction change Callback */
158 void (* DirectionDownCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Down-counting direction change Callback */
159#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
160} LPTIM_HandleTypeDef;
161
162#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
163/**
164 * @brief HAL LPTIM Callback ID enumeration definition
165 */
166typedef enum
167{
168 HAL_LPTIM_MSPINIT_CB_ID = 0x00U, /*!< LPTIM Base Msp Init Callback ID */
169 HAL_LPTIM_MSPDEINIT_CB_ID = 0x01U, /*!< LPTIM Base Msp DeInit Callback ID */
170 HAL_LPTIM_COMPARE_MATCH_CB_ID = 0x02U, /*!< Compare match Callback ID */
171 HAL_LPTIM_AUTORELOAD_MATCH_CB_ID = 0x03U, /*!< Auto-reload match Callback ID */
172 HAL_LPTIM_TRIGGER_CB_ID = 0x04U, /*!< External trigger event detection Callback ID */
173 HAL_LPTIM_COMPARE_WRITE_CB_ID = 0x05U, /*!< Compare register write complete Callback ID */
174 HAL_LPTIM_AUTORELOAD_WRITE_CB_ID = 0x06U, /*!< Auto-reload register write complete Callback ID */
175 HAL_LPTIM_DIRECTION_UP_CB_ID = 0x07U, /*!< Up-counting direction change Callback ID */
176 HAL_LPTIM_DIRECTION_DOWN_CB_ID = 0x08U, /*!< Down-counting direction change Callback ID */
177} HAL_LPTIM_CallbackIDTypeDef;
178
179/**
180 * @brief HAL TIM Callback pointer definition
181 */
182typedef void (*pLPTIM_CallbackTypeDef)(LPTIM_HandleTypeDef *hlptim); /*!< pointer to the LPTIM callback function */
183
184#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
185/**
186 * @}
187 */
188
189/* Exported constants --------------------------------------------------------*/
190/** @defgroup LPTIM_Exported_Constants LPTIM Exported Constants
191 * @{
192 */
193
194/** @defgroup LPTIM_Clock_Source LPTIM Clock Source
195 * @{
196 */
197#define LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC 0x00000000U
198#define LPTIM_CLOCKSOURCE_ULPTIM LPTIM_CFGR_CKSEL
199/**
200 * @}
201 */
202
203/** @defgroup LPTIM_Clock_Prescaler LPTIM Clock Prescaler
204 * @{
205 */
206#define LPTIM_PRESCALER_DIV1 0x00000000U
207#define LPTIM_PRESCALER_DIV2 LPTIM_CFGR_PRESC_0
208#define LPTIM_PRESCALER_DIV4 LPTIM_CFGR_PRESC_1
209#define LPTIM_PRESCALER_DIV8 (LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_1)
210#define LPTIM_PRESCALER_DIV16 LPTIM_CFGR_PRESC_2
211#define LPTIM_PRESCALER_DIV32 (LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_2)
212#define LPTIM_PRESCALER_DIV64 (LPTIM_CFGR_PRESC_1 | LPTIM_CFGR_PRESC_2)
213#define LPTIM_PRESCALER_DIV128 LPTIM_CFGR_PRESC
214/**
215 * @}
216 */
217
218/** @defgroup LPTIM_Output_Polarity LPTIM Output Polarity
219 * @{
220 */
221
222#define LPTIM_OUTPUTPOLARITY_HIGH 0x00000000U
223#define LPTIM_OUTPUTPOLARITY_LOW LPTIM_CFGR_WAVPOL
224/**
225 * @}
226 */
227
228/** @defgroup LPTIM_Clock_Sample_Time LPTIM Clock Sample Time
229 * @{
230 */
231#define LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION 0x00000000U
232#define LPTIM_CLOCKSAMPLETIME_2TRANSITIONS LPTIM_CFGR_CKFLT_0
233#define LPTIM_CLOCKSAMPLETIME_4TRANSITIONS LPTIM_CFGR_CKFLT_1
234#define LPTIM_CLOCKSAMPLETIME_8TRANSITIONS LPTIM_CFGR_CKFLT
235/**
236 * @}
237 */
238
239/** @defgroup LPTIM_Clock_Polarity LPTIM Clock Polarity
240 * @{
241 */
242#define LPTIM_CLOCKPOLARITY_RISING 0x00000000U
243#define LPTIM_CLOCKPOLARITY_FALLING LPTIM_CFGR_CKPOL_0
244#define LPTIM_CLOCKPOLARITY_RISING_FALLING LPTIM_CFGR_CKPOL_1
245/**
246 * @}
247 */
248
249/** @defgroup LPTIM_Trigger_Source LPTIM Trigger Source
250 * @{
251 */
252#define LPTIM_TRIGSOURCE_SOFTWARE 0x0000FFFFU
253#define LPTIM_TRIGSOURCE_0 0x00000000U
254#define LPTIM_TRIGSOURCE_1 LPTIM_CFGR_TRIGSEL_0
255#define LPTIM_TRIGSOURCE_2 LPTIM_CFGR_TRIGSEL_1
256#define LPTIM_TRIGSOURCE_3 (LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_1)
257#define LPTIM_TRIGSOURCE_4 LPTIM_CFGR_TRIGSEL_2
258#define LPTIM_TRIGSOURCE_5 (LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_2)
259/**
260 * @}
261 */
262
263/** @defgroup LPTIM_External_Trigger_Polarity LPTIM External Trigger Polarity
264 * @{
265 */
266#define LPTIM_ACTIVEEDGE_RISING LPTIM_CFGR_TRIGEN_0
267#define LPTIM_ACTIVEEDGE_FALLING LPTIM_CFGR_TRIGEN_1
268#define LPTIM_ACTIVEEDGE_RISING_FALLING LPTIM_CFGR_TRIGEN
269/**
270 * @}
271 */
272
273/** @defgroup LPTIM_Trigger_Sample_Time LPTIM Trigger Sample Time
274 * @{
275 */
276#define LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION 0x00000000U
277#define LPTIM_TRIGSAMPLETIME_2TRANSITIONS LPTIM_CFGR_TRGFLT_0
278#define LPTIM_TRIGSAMPLETIME_4TRANSITIONS LPTIM_CFGR_TRGFLT_1
279#define LPTIM_TRIGSAMPLETIME_8TRANSITIONS LPTIM_CFGR_TRGFLT
280/**
281 * @}
282 */
283
284/** @defgroup LPTIM_Updating_Mode LPTIM Updating Mode
285 * @{
286 */
287
288#define LPTIM_UPDATE_IMMEDIATE 0x00000000U
289#define LPTIM_UPDATE_ENDOFPERIOD LPTIM_CFGR_PRELOAD
290/**
291 * @}
292 */
293
294/** @defgroup LPTIM_Counter_Source LPTIM Counter Source
295 * @{
296 */
297
298#define LPTIM_COUNTERSOURCE_INTERNAL 0x00000000U
299#define LPTIM_COUNTERSOURCE_EXTERNAL LPTIM_CFGR_COUNTMODE
300/**
301 * @}
302 */
303
304/** @defgroup LPTIM_Flag_Definition LPTIM Flags Definition
305 * @{
306 */
307
308#define LPTIM_FLAG_DOWN LPTIM_ISR_DOWN
309#define LPTIM_FLAG_UP LPTIM_ISR_UP
310#define LPTIM_FLAG_ARROK LPTIM_ISR_ARROK
311#define LPTIM_FLAG_CMPOK LPTIM_ISR_CMPOK
312#define LPTIM_FLAG_EXTTRIG LPTIM_ISR_EXTTRIG
313#define LPTIM_FLAG_ARRM LPTIM_ISR_ARRM
314#define LPTIM_FLAG_CMPM LPTIM_ISR_CMPM
315/**
316 * @}
317 */
318
319/** @defgroup LPTIM_Interrupts_Definition LPTIM Interrupts Definition
320 * @{
321 */
322#define LPTIM_IT_DOWN LPTIM_IER_DOWNIE
323#define LPTIM_IT_UP LPTIM_IER_UPIE
324#define LPTIM_IT_ARROK LPTIM_IER_ARROKIE
325#define LPTIM_IT_CMPOK LPTIM_IER_CMPOKIE
326#define LPTIM_IT_EXTTRIG LPTIM_IER_EXTTRIGIE
327#define LPTIM_IT_ARRM LPTIM_IER_ARRMIE
328#define LPTIM_IT_CMPM LPTIM_IER_CMPMIE
329/**
330 * @}
331 */
332
333/** @defgroup LPTIM_Option Register Definition
334 * @{
335 */
336#define LPTIM_OP_PAD_AF 0x00000000U
337#define LPTIM_OP_PAD_PA4 LPTIM_OR_LPT_IN1_RMP_0
338#define LPTIM_OP_PAD_PB9 LPTIM_OR_LPT_IN1_RMP_1
339#define LPTIM_OP_TIM_DAC LPTIM_OR_LPT_IN1_RMP
340/**
341 * @}
342 */
343
344/**
345 * @}
346 */
347
348/* Exported macros -----------------------------------------------------------*/
349/** @defgroup LPTIM_Exported_Macros LPTIM Exported Macros
350 * @{
351 */
352
353/** @brief Reset LPTIM handle state.
354 * @param __HANDLE__ LPTIM handle
355 * @retval None
356 */
357#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
358#define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) do { \
359 (__HANDLE__)->State = HAL_LPTIM_STATE_RESET; \
360 (__HANDLE__)->MspInitCallback = NULL; \
361 (__HANDLE__)->MspDeInitCallback = NULL; \
362 } while(0)
363#else
364#define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LPTIM_STATE_RESET)
365#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
366
367/**
368 * @brief Enable the LPTIM peripheral.
369 * @param __HANDLE__ LPTIM handle
370 * @retval None
371 */
372#define __HAL_LPTIM_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (LPTIM_CR_ENABLE))
373
374/**
375 * @brief Disable the LPTIM peripheral.
376 * @param __HANDLE__ LPTIM handle
377 * @note The following sequence is required to solve LPTIM disable HW limitation.
378 * Please check Errata Sheet ES0335 for more details under "MCU may remain
379 * stuck in LPTIM interrupt when entering Stop mode" section.
380 * @note Please call @ref HAL_LPTIM_GetState() after a call to __HAL_LPTIM_DISABLE to
381 * check for TIMEOUT.
382 * @retval None
383 */
384#define __HAL_LPTIM_DISABLE(__HANDLE__) LPTIM_Disable(__HANDLE__)
385
386/**
387 * @brief Start the LPTIM peripheral in Continuous mode.
388 * @param __HANDLE__ LPTIM handle
389 * @retval None
390 */
391#define __HAL_LPTIM_START_CONTINUOUS(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_CNTSTRT)
392/**
393 * @brief Start the LPTIM peripheral in single mode.
394 * @param __HANDLE__ LPTIM handle
395 * @retval None
396 */
397#define __HAL_LPTIM_START_SINGLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_SNGSTRT)
398
399/**
400 * @brief Write the passed parameter in the Autoreload register.
401 * @param __HANDLE__ LPTIM handle
402 * @param __VALUE__ Autoreload value
403 * @retval None
404 * @note The ARR register can only be modified when the LPTIM instance is enabled.
405 */
406#define __HAL_LPTIM_AUTORELOAD_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->ARR = (__VALUE__))
407
408/**
409 * @brief Write the passed parameter in the Compare register.
410 * @param __HANDLE__ LPTIM handle
411 * @param __VALUE__ Compare value
412 * @retval None
413 * @note The CMP register can only be modified when the LPTIM instance is enabled.
414 */
415#define __HAL_LPTIM_COMPARE_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->CMP = (__VALUE__))
416
417/**
418 * @brief Check whether the specified LPTIM flag is set or not.
419 * @param __HANDLE__ LPTIM handle
420 * @param __FLAG__ LPTIM flag to check
421 * This parameter can be a value of:
422 * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag.
423 * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag.
424 * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag.
425 * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag.
426 * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
427 * @arg LPTIM_FLAG_ARRM : Autoreload match Flag.
428 * @arg LPTIM_FLAG_CMPM : Compare match Flag.
429 * @retval The state of the specified flag (SET or RESET).
430 */
431#define __HAL_LPTIM_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR &(__FLAG__)) == (__FLAG__))
432
433/**
434 * @brief Clear the specified LPTIM flag.
435 * @param __HANDLE__ LPTIM handle.
436 * @param __FLAG__ LPTIM flag to clear.
437 * This parameter can be a value of:
438 * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag.
439 * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag.
440 * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag.
441 * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag.
442 * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
443 * @arg LPTIM_FLAG_ARRM : Autoreload match Flag.
444 * @arg LPTIM_FLAG_CMPM : Compare match Flag.
445 * @retval None.
446 */
447#define __HAL_LPTIM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
448
449/**
450 * @brief Enable the specified LPTIM interrupt.
451 * @param __HANDLE__ LPTIM handle.
452 * @param __INTERRUPT__ LPTIM interrupt to set.
453 * This parameter can be a value of:
454 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
455 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
456 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
457 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
458 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
459 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
460 * @arg LPTIM_IT_CMPM : Compare match Interrupt.
461 * @retval None.
462 * @note The LPTIM interrupts can only be enabled when the LPTIM instance is disabled.
463 */
464#define __HAL_LPTIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
465
466/**
467 * @brief Disable the specified LPTIM interrupt.
468 * @param __HANDLE__ LPTIM handle.
469 * @param __INTERRUPT__ LPTIM interrupt to set.
470 * This parameter can be a value of:
471 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
472 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
473 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
474 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
475 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
476 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
477 * @arg LPTIM_IT_CMPM : Compare match Interrupt.
478 * @retval None.
479 * @note The LPTIM interrupts can only be disabled when the LPTIM instance is disabled.
480 */
481#define __HAL_LPTIM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= (~(__INTERRUPT__)))
482
483/**
484 * @brief Check whether the specified LPTIM interrupt source is enabled or not.
485 * @param __HANDLE__ LPTIM handle.
486 * @param __INTERRUPT__ LPTIM interrupt to check.
487 * This parameter can be a value of:
488 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
489 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
490 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
491 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
492 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
493 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
494 * @arg LPTIM_IT_CMPM : Compare match Interrupt.
495 * @retval Interrupt status.
496 */
497
498#define __HAL_LPTIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER\
499 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
500
501/** @brief LPTIM Option Register
502 * @param __HANDLE__ LPTIM handle
503 * @param __VALUE__ This parameter can be a value of :
504 * @arg LPTIM_OP_PAD_AF
505 * @arg LPTIM_OP_PAD_PA4
506 * @arg LPTIM_OP_PAD_PB9
507 * @arg LPTIM_OP_TIM_DAC
508 * @retval None
509 */
510#define __HAL_LPTIM_OPTR_CONFIG(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->OR = (__VALUE__))
511
512
513/**
514 * @brief Enable interrupt on the LPTIM Wake-up Timer associated Exti line.
515 * @retval None
516 */
517#define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR\
518 |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
519
520/**
521 * @brief Disable interrupt on the LPTIM Wake-up Timer associated Exti line.
522 * @retval None
523 */
524#define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR\
525 &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
526
527/**
528 * @brief Enable event on the LPTIM Wake-up Timer associated Exti line.
529 * @retval None.
530 */
531#define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR\
532 |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
533
534/**
535 * @brief Disable event on the LPTIM Wake-up Timer associated Exti line.
536 * @retval None.
537 */
538#define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR\
539 &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
540#if defined(EXTI_IMR_MR23)
541
542/**
543 * @brief Enable falling edge trigger on the LPTIM Wake-up Timer associated Exti line.
544 * @retval None.
545 */
546#define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR\
547 |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
548
549/**
550 * @brief Disable falling edge trigger on the LPTIM Wake-up Timer associated Exti line.
551 * @retval None.
552 */
553#define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR\
554 &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
555
556/**
557 * @brief Enable rising edge trigger on the LPTIM Wake-up Timer associated Exti line.
558 * @retval None.
559 */
560#define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR\
561 |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
562
563/**
564 * @brief Disable rising edge trigger on the LPTIM Wake-up Timer associated Exti line.
565 * @retval None.
566 */
567#define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR\
568 &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
569
570/**
571 * @brief Enable rising & falling edge trigger on the LPTIM Wake-up Timer associated Exti line.
572 * @retval None.
573 */
574#define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_RISING_FALLING_EDGE() do{__HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE();\
575 __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE();\
576 }while(0)
577
578/**
579 * @brief Disable rising & falling edge trigger on the LPTIM Wake-up Timer associated Exti line.
580 * @retval None.
581 */
582#define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_RISING_FALLING_EDGE() do{__HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE();\
583 __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE();\
584 }while(0)
585
586/**
587 * @brief Check whether the LPTIM Wake-up Timer associated Exti line interrupt flag is set or not.
588 * @retval Line Status.
589 */
590#define __HAL_LPTIM_WAKEUPTIMER_EXTI_GET_FLAG() (EXTI->PR\
591 & LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
592
593/**
594 * @brief Clear the LPTIM Wake-up Timer associated Exti line flag.
595 * @retval None.
596 */
597#define __HAL_LPTIM_WAKEUPTIMER_EXTI_CLEAR_FLAG() (EXTI->PR\
598 = LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
599
600/**
601 * @brief Generate a Software interrupt on the LPTIM Wake-up Timer associated Exti line.
602 * @retval None.
603 */
604#define __HAL_LPTIM_WAKEUPTIMER_EXTI_GENERATE_SWIT() (EXTI->SWIER\
605 |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
606#endif /* EXTI_IMR_MR23 */
607
608/**
609 * @}
610 */
611
612/* Exported functions --------------------------------------------------------*/
613/** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions
614 * @{
615 */
616
617/** @addtogroup LPTIM_Exported_Functions_Group1
618 * @brief Initialization and Configuration functions.
619 * @{
620 */
621/* Initialization/de-initialization functions ********************************/
622HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
623HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim);
624
625/* MSP functions *************************************************************/
626void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim);
627void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim);
628/**
629 * @}
630 */
631
632/** @addtogroup LPTIM_Exported_Functions_Group2
633 * @brief Start-Stop operation functions.
634 * @{
635 */
636/* Start/Stop operation functions *********************************************/
637/* ################################# PWM Mode ################################*/
638/* Blocking mode: Polling */
639HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
640HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim);
641/* Non-Blocking mode: Interrupt */
642HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
643HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim);
644
645/* ############################# One Pulse Mode ##############################*/
646/* Blocking mode: Polling */
647HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
648HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim);
649/* Non-Blocking mode: Interrupt */
650HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
651HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim);
652
653/* ############################## Set once Mode ##############################*/
654/* Blocking mode: Polling */
655HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
656HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim);
657/* Non-Blocking mode: Interrupt */
658HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
659HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim);
660
661/* ############################### Encoder Mode ##############################*/
662/* Blocking mode: Polling */
663HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
664HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim);
665/* Non-Blocking mode: Interrupt */
666HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
667HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim);
668
669/* ############################# Time out Mode ##############################*/
670/* Blocking mode: Polling */
671HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
672HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim);
673/* Non-Blocking mode: Interrupt */
674HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
675HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim);
676
677/* ############################## Counter Mode ###############################*/
678/* Blocking mode: Polling */
679HAL_StatusTypeDef HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
680HAL_StatusTypeDef HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef *hlptim);
681/* Non-Blocking mode: Interrupt */
682HAL_StatusTypeDef HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
683HAL_StatusTypeDef HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef *hlptim);
684/**
685 * @}
686 */
687
688/** @addtogroup LPTIM_Exported_Functions_Group3
689 * @brief Read operation functions.
690 * @{
691 */
692/* Reading operation functions ************************************************/
693uint32_t HAL_LPTIM_ReadCounter(LPTIM_HandleTypeDef *hlptim);
694uint32_t HAL_LPTIM_ReadAutoReload(LPTIM_HandleTypeDef *hlptim);
695uint32_t HAL_LPTIM_ReadCompare(LPTIM_HandleTypeDef *hlptim);
696/**
697 * @}
698 */
699
700/** @addtogroup LPTIM_Exported_Functions_Group4
701 * @brief LPTIM IRQ handler and callback functions.
702 * @{
703 */
704/* LPTIM IRQ functions *******************************************************/
705void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim);
706
707/* CallBack functions ********************************************************/
708void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim);
709void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim);
710void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef *hlptim);
711void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef *hlptim);
712void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef *hlptim);
713void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef *hlptim);
714void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef *hlptim);
715
716/* Callbacks Register/UnRegister functions ***********************************/
717#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
718HAL_StatusTypeDef HAL_LPTIM_RegisterCallback(LPTIM_HandleTypeDef *lphtim, HAL_LPTIM_CallbackIDTypeDef CallbackID,
719 pLPTIM_CallbackTypeDef pCallback);
720HAL_StatusTypeDef HAL_LPTIM_UnRegisterCallback(LPTIM_HandleTypeDef *lphtim, HAL_LPTIM_CallbackIDTypeDef CallbackID);
721#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
722/**
723 * @}
724 */
725
726/** @addtogroup LPTIM_Group5
727 * @brief Peripheral State functions.
728 * @{
729 */
730/* Peripheral State functions ************************************************/
731HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(LPTIM_HandleTypeDef *hlptim);
732/**
733 * @}
734 */
735
736/**
737 * @}
738 */
739
740/* Private types -------------------------------------------------------------*/
741/** @defgroup LPTIM_Private_Types LPTIM Private Types
742 * @{
743 */
744
745/**
746 * @}
747 */
748
749/* Private variables ---------------------------------------------------------*/
750/** @defgroup LPTIM_Private_Variables LPTIM Private Variables
751 * @{
752 */
753
754/**
755 * @}
756 */
757
758/* Private constants ---------------------------------------------------------*/
759/** @defgroup LPTIM_Private_Constants LPTIM Private Constants
760 * @{
761 */
762
763/**
764 * @}
765 */
766
767/* Private macros ------------------------------------------------------------*/
768/** @defgroup LPTIM_Private_Macros LPTIM Private Macros
769 * @{
770 */
771
772#define IS_LPTIM_CLOCK_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_CLOCKSOURCE_ULPTIM) || \
773 ((__SOURCE__) == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC))
774
775
776#define IS_LPTIM_CLOCK_PRESCALER(__PRESCALER__) (((__PRESCALER__) == LPTIM_PRESCALER_DIV1 ) || \
777 ((__PRESCALER__) == LPTIM_PRESCALER_DIV2 ) || \
778 ((__PRESCALER__) == LPTIM_PRESCALER_DIV4 ) || \
779 ((__PRESCALER__) == LPTIM_PRESCALER_DIV8 ) || \
780 ((__PRESCALER__) == LPTIM_PRESCALER_DIV16 ) || \
781 ((__PRESCALER__) == LPTIM_PRESCALER_DIV32 ) || \
782 ((__PRESCALER__) == LPTIM_PRESCALER_DIV64 ) || \
783 ((__PRESCALER__) == LPTIM_PRESCALER_DIV128))
784
785#define IS_LPTIM_CLOCK_PRESCALERDIV1(__PRESCALER__) ((__PRESCALER__) == LPTIM_PRESCALER_DIV1)
786
787#define IS_LPTIM_OUTPUT_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_OUTPUTPOLARITY_LOW ) || \
788 ((__POLARITY__) == LPTIM_OUTPUTPOLARITY_HIGH))
789
790#define IS_LPTIM_CLOCK_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION) || \
791 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_2TRANSITIONS) || \
792 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_4TRANSITIONS) || \
793 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_8TRANSITIONS))
794
795#define IS_LPTIM_CLOCK_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING) || \
796 ((__POLARITY__) == LPTIM_CLOCKPOLARITY_FALLING) || \
797 ((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING_FALLING))
798
799#define IS_LPTIM_TRG_SOURCE(__TRIG__) (((__TRIG__) == LPTIM_TRIGSOURCE_SOFTWARE) || \
800 ((__TRIG__) == LPTIM_TRIGSOURCE_0) || \
801 ((__TRIG__) == LPTIM_TRIGSOURCE_1) || \
802 ((__TRIG__) == LPTIM_TRIGSOURCE_2) || \
803 ((__TRIG__) == LPTIM_TRIGSOURCE_3) || \
804 ((__TRIG__) == LPTIM_TRIGSOURCE_4) || \
805 ((__TRIG__) == LPTIM_TRIGSOURCE_5))
806
807#define IS_LPTIM_EXT_TRG_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING ) || \
808 ((__POLARITY__) == LPTIM_ACTIVEEDGE_FALLING ) || \
809 ((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING_FALLING ))
810
811#define IS_LPTIM_TRIG_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION) || \
812 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_2TRANSITIONS ) || \
813 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_4TRANSITIONS ) || \
814 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_8TRANSITIONS ))
815
816#define IS_LPTIM_UPDATE_MODE(__MODE__) (((__MODE__) == LPTIM_UPDATE_IMMEDIATE) || \
817 ((__MODE__) == LPTIM_UPDATE_ENDOFPERIOD))
818
819#define IS_LPTIM_COUNTER_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_COUNTERSOURCE_INTERNAL) || \
820 ((__SOURCE__) == LPTIM_COUNTERSOURCE_EXTERNAL))
821
822#define IS_LPTIM_AUTORELOAD(__AUTORELOAD__) ((__AUTORELOAD__) <= 0x0000FFFFUL)
823
824#define IS_LPTIM_COMPARE(__COMPARE__) ((__COMPARE__) <= 0x0000FFFFUL)
825
826#define IS_LPTIM_PERIOD(__PERIOD__) ((__PERIOD__) <= 0x0000FFFFUL)
827
828#define IS_LPTIM_PULSE(__PULSE__) ((__PULSE__) <= 0x0000FFFFUL)
829
830/**
831 * @}
832 */
833
834/* Private functions ---------------------------------------------------------*/
835/** @defgroup LPTIM_Private_Functions LPTIM Private Functions
836 * @{
837 */
838void LPTIM_Disable(LPTIM_HandleTypeDef *hlptim);
839/**
840 * @}
841 */
842
843/**
844 * @}
845 */
846
847#endif /* LPTIM1 */
848/**
849 * @}
850 */
851
852#ifdef __cplusplus
853}
854#endif
855
856#endif /* STM32F4xx_HAL_LPTIM_H */
857
858/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Note: See TracBrowser for help on using the repository browser.