Moved IO_GPIOPortIdx to platform (#14127)
[betaflight.git] / lib / main / STM32F7 / Drivers / STM32F7xx_HAL_Driver / Inc / stm32f7xx_hal_lptim.h
blobf2faade479ddb9807670acfd528846beae36a27a
1 /**
2 ******************************************************************************
3 * @file stm32f7xx_hal_lptim.h
4 * @author MCD Application Team
5 * @brief Header file of LPTIM HAL module.
6 ******************************************************************************
7 * @attention
9 * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
10 * All rights reserved.</center></h2>
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
17 ******************************************************************************
18 */
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef __STM32F7xx_HAL_LPTIM_H
22 #define __STM32F7xx_HAL_LPTIM_H
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32f7xx_hal_def.h"
31 /** @addtogroup STM32F7xx_HAL_Driver
32 * @{
35 /** @defgroup LPTIM LPTIM
36 * @brief LPTIM HAL module driver
37 * @{
40 /* Exported types ------------------------------------------------------------*/
41 /** @defgroup LPTIM_Exported_Types LPTIM Exported Types
42 * @{
45 /** @defgroup LPTIM_WAKEUPTIMER_EXTILINE LPTIM WAKEUP Timer EXTI Line
46 * @{
48 #define LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT ((uint32_t)EXTI_IMR_MR23) /*!< External interrupt line 23 Connected to the LPTIM EXTI Line */
49 /**
50 * @}
53 /**
54 * @brief LPTIM Clock configuration definition
56 typedef struct
58 uint32_t Source; /*!< Selects the clock source.
59 This parameter can be a value of @ref LPTIM_Clock_Source */
61 uint32_t Prescaler; /*!< Specifies the counter clock Prescaler.
62 This parameter can be a value of @ref LPTIM_Clock_Prescaler */
64 }LPTIM_ClockConfigTypeDef;
66 /**
67 * @brief LPTIM Clock configuration definition
69 typedef struct
71 uint32_t Polarity; /*!< Selects the polarity of the active edge for the counter unit
72 if the ULPTIM input is selected.
73 Note: This parameter is used only when Ultra low power clock source is used.
74 Note: If the polarity is configured on 'both edges', an auxiliary clock
75 (one of the Low power oscillator) must be active.
76 This parameter can be a value of @ref LPTIM_Clock_Polarity */
78 uint32_t SampleTime; /*!< Selects the clock sampling time to configure the clock glitch filter.
79 Note: This parameter is used only when Ultra low power clock source is used.
80 This parameter can be a value of @ref LPTIM_Clock_Sample_Time */
82 }LPTIM_ULPClockConfigTypeDef;
84 /**
85 * @brief LPTIM Trigger configuration definition
87 typedef struct
89 uint32_t Source; /*!< Selects the Trigger source.
90 This parameter can be a value of @ref LPTIM_Trigger_Source */
92 uint32_t ActiveEdge; /*!< Selects the Trigger active edge.
93 Note: This parameter is used only when an external trigger is used.
94 This parameter can be a value of @ref LPTIM_External_Trigger_Polarity */
96 uint32_t SampleTime; /*!< Selects the trigger sampling time to configure the clock glitch filter.
97 Note: This parameter is used only when an external trigger is used.
98 This parameter can be a value of @ref LPTIM_Trigger_Sample_Time */
99 }LPTIM_TriggerConfigTypeDef;
101 /**
102 * @brief LPTIM Initialization Structure definition
104 typedef struct
106 LPTIM_ClockConfigTypeDef Clock; /*!< Specifies the clock parameters */
108 LPTIM_ULPClockConfigTypeDef UltraLowPowerClock; /*!< Specifies the Ultra Low Power clock parameters */
110 LPTIM_TriggerConfigTypeDef Trigger; /*!< Specifies the Trigger parameters */
112 uint32_t OutputPolarity; /*!< Specifies the Output polarity.
113 This parameter can be a value of @ref LPTIM_Output_Polarity */
115 uint32_t UpdateMode; /*!< Specifies whether the update of the autorelaod and the compare
116 values is done immediately or after the end of current period.
117 This parameter can be a value of @ref LPTIM_Updating_Mode */
119 uint32_t CounterSource; /*!< Specifies whether the counter is incremented each internal event
120 or each external event.
121 This parameter can be a value of @ref LPTIM_Counter_Source */
123 }LPTIM_InitTypeDef;
125 /**
126 * @brief HAL LPTIM State structure definition
128 typedef enum __HAL_LPTIM_StateTypeDef
130 HAL_LPTIM_STATE_RESET = 0x00U, /*!< Peripheral not yet initialized or disabled */
131 HAL_LPTIM_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
132 HAL_LPTIM_STATE_BUSY = 0x02U, /*!< An internal process is ongoing */
133 HAL_LPTIM_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
134 HAL_LPTIM_STATE_ERROR = 0x04U /*!< Internal Process is ongoing */
135 }HAL_LPTIM_StateTypeDef;
137 /**
138 * @brief LPTIM handle Structure definition
140 typedef struct __LPTIM_HandleTypeDef
142 LPTIM_TypeDef *Instance; /*!< Register base address */
143 LPTIM_InitTypeDef Init; /*!< LPTIM required parameters */
144 HAL_StatusTypeDef Status; /*!< LPTIM peripheral status */
145 HAL_LockTypeDef Lock; /*!< LPTIM locking object */
146 __IO HAL_LPTIM_StateTypeDef State; /*!< LPTIM peripheral state */
148 #if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
149 void (* MspInitCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Msp Init Callback */
150 void (* MspDeInitCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Msp DeInit Callback */
152 void (* CompareMatchCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Compare Match Callback */
153 void (* AutoReloadMatchCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Auto Reload Match Callback */
154 void (* TriggerCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Trigger Callback */
155 void (* CompareWriteCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Compare Write Callback */
156 void (* AutoReloadWriteCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Auto Reload Write Callback */
157 void (* DirectionUpCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Direction Up Callback */
158 void (* DirectionDownCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Direction Down Callback */
159 #endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
161 }LPTIM_HandleTypeDef;
163 #if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
165 * @brief HAL LPTIM Callback ID enumeration definition
167 typedef enum
169 HAL_LPTIM_MSPINIT_CB_ID = 0x00U, /*!< LPTIM MspInit Callback ID */
170 HAL_LPTIM_MSPDEINIT_CB_ID = 0x01U, /*!< LPTIM MspDeInit Callback ID */
172 HAL_LPTIM_COMPARE_MATCH_CB_ID = 0x02U, /*!< LPTIM Compare Match Callback ID */
173 HAL_LPTIM_AUTO_RELOAD_MATCH_CB_ID = 0x03U, /*!< LPTIM Auto Reload Match Callback ID */
174 HAL_LPTIM_TRIGGER_CB_ID = 0x04U, /*!< LPTIM Trigger Callback ID */
175 HAL_LPTIM_COMPARE_WRITE_CB_ID = 0x05U, /*!< LPTIM Compare Write Callback ID */
176 HAL_LPTIM_AUTO_RELOAD_WRITE_CB_ID = 0x06U, /*!< LPTIM Auto Reload Write Callback ID */
177 HAL_LPTIM_DIRECTION_UP_CB_ID = 0x07U, /*!< LPTIM Direction Up Callback ID */
178 HAL_LPTIM_DIRECTION_DOWN_CB_ID = 0x08U, /*!< LPTIM Direction Down Callback ID */
179 }HAL_LPTIM_CallbackIDTypeDef;
182 * @brief HAL LPTIM Callback pointer definition
184 typedef void (*pLPTIM_CallbackTypeDef)(LPTIM_HandleTypeDef * hlptim); /*!< pointer to the LPTIM callback function */
186 #endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
189 * @}
192 /* Exported constants --------------------------------------------------------*/
193 /** @defgroup LPTIM_Exported_Constants LPTIM Exported Constants
194 * @{
197 /** @defgroup LPTIM_Clock_Source LPTIM Clock Source
198 * @{
200 #define LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC ((uint32_t)0x00U)
201 #define LPTIM_CLOCKSOURCE_ULPTIM LPTIM_CFGR_CKSEL
202 /**
203 * @}
206 /** @defgroup LPTIM_Clock_Prescaler LPTIM Clock Prescaler
207 * @{
209 #define LPTIM_PRESCALER_DIV1 ((uint32_t)0x000000U)
210 #define LPTIM_PRESCALER_DIV2 LPTIM_CFGR_PRESC_0
211 #define LPTIM_PRESCALER_DIV4 LPTIM_CFGR_PRESC_1
212 #define LPTIM_PRESCALER_DIV8 ((uint32_t)(LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_1))
213 #define LPTIM_PRESCALER_DIV16 LPTIM_CFGR_PRESC_2
214 #define LPTIM_PRESCALER_DIV32 ((uint32_t)(LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_2))
215 #define LPTIM_PRESCALER_DIV64 ((uint32_t)(LPTIM_CFGR_PRESC_1 | LPTIM_CFGR_PRESC_2))
216 #define LPTIM_PRESCALER_DIV128 ((uint32_t)LPTIM_CFGR_PRESC)
218 * @}
221 /** @defgroup LPTIM_Output_Polarity LPTIM Output Polarity
222 * @{
225 #define LPTIM_OUTPUTPOLARITY_HIGH ((uint32_t)0x00000000U)
226 #define LPTIM_OUTPUTPOLARITY_LOW (LPTIM_CFGR_WAVPOL)
228 * @}
231 /** @defgroup LPTIM_Clock_Sample_Time LPTIM Clock Sample Time
232 * @{
234 #define LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION ((uint32_t)0x00000000U)
235 #define LPTIM_CLOCKSAMPLETIME_2TRANSITIONS LPTIM_CFGR_CKFLT_0
236 #define LPTIM_CLOCKSAMPLETIME_4TRANSITIONS LPTIM_CFGR_CKFLT_1
237 #define LPTIM_CLOCKSAMPLETIME_8TRANSITIONS LPTIM_CFGR_CKFLT
239 * @}
242 /** @defgroup LPTIM_Clock_Polarity LPTIM Clock Polarity
243 * @{
246 #define LPTIM_CLOCKPOLARITY_RISING ((uint32_t)0x00000000U)
247 #define LPTIM_CLOCKPOLARITY_FALLING LPTIM_CFGR_CKPOL_0
248 #define LPTIM_CLOCKPOLARITY_RISING_FALLING LPTIM_CFGR_CKPOL_1
250 * @}
253 /** @defgroup LPTIM_Trigger_Source LPTIM Trigger Source
254 * @{
256 #define LPTIM_TRIGSOURCE_SOFTWARE ((uint32_t)0x0000FFFFU)
257 #define LPTIM_TRIGSOURCE_0 ((uint32_t)0x00000000U)
258 #define LPTIM_TRIGSOURCE_1 ((uint32_t)LPTIM_CFGR_TRIGSEL_0)
259 #define LPTIM_TRIGSOURCE_2 LPTIM_CFGR_TRIGSEL_1
260 #define LPTIM_TRIGSOURCE_3 ((uint32_t)LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_1)
261 #define LPTIM_TRIGSOURCE_4 LPTIM_CFGR_TRIGSEL_2
262 #define LPTIM_TRIGSOURCE_5 ((uint32_t)LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_2)
264 * @}
267 /** @defgroup LPTIM_External_Trigger_Polarity LPTIM External Trigger Polarity
268 * @{
270 #define LPTIM_ACTIVEEDGE_RISING LPTIM_CFGR_TRIGEN_0
271 #define LPTIM_ACTIVEEDGE_FALLING LPTIM_CFGR_TRIGEN_1
272 #define LPTIM_ACTIVEEDGE_RISING_FALLING LPTIM_CFGR_TRIGEN
274 * @}
277 /** @defgroup LPTIM_Trigger_Sample_Time LPTIM Trigger Sample Time
278 * @{
280 #define LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION ((uint32_t)0x00000000U)
281 #define LPTIM_TRIGSAMPLETIME_2TRANSITIONS LPTIM_CFGR_TRGFLT_0
282 #define LPTIM_TRIGSAMPLETIME_4TRANSITIONS LPTIM_CFGR_TRGFLT_1
283 #define LPTIM_TRIGSAMPLETIME_8TRANSITIONS LPTIM_CFGR_TRGFLT
285 * @}
288 /** @defgroup LPTIM_Updating_Mode LPTIM Updating Mode
289 * @{
292 #define LPTIM_UPDATE_IMMEDIATE ((uint32_t)0x00000000U)
293 #define LPTIM_UPDATE_ENDOFPERIOD LPTIM_CFGR_PRELOAD
295 * @}
298 /** @defgroup LPTIM_Counter_Source LPTIM Counter Source
299 * @{
302 #define LPTIM_COUNTERSOURCE_INTERNAL ((uint32_t)0x00000000U)
303 #define LPTIM_COUNTERSOURCE_EXTERNAL LPTIM_CFGR_COUNTMODE
305 * @}
308 /** @defgroup LPTIM_Flag_Definition LPTIM Flag Definition
309 * @{
312 #define LPTIM_FLAG_DOWN LPTIM_ISR_DOWN
313 #define LPTIM_FLAG_UP LPTIM_ISR_UP
314 #define LPTIM_FLAG_ARROK LPTIM_ISR_ARROK
315 #define LPTIM_FLAG_CMPOK LPTIM_ISR_CMPOK
316 #define LPTIM_FLAG_EXTTRIG LPTIM_ISR_EXTTRIG
317 #define LPTIM_FLAG_ARRM LPTIM_ISR_ARRM
318 #define LPTIM_FLAG_CMPM LPTIM_ISR_CMPM
320 * @}
323 /** @defgroup LPTIM_Interrupts_Definition LPTIM Interrupts Definition
324 * @{
327 #define LPTIM_IT_DOWN LPTIM_IER_DOWNIE
328 #define LPTIM_IT_UP LPTIM_IER_UPIE
329 #define LPTIM_IT_ARROK LPTIM_IER_ARROKIE
330 #define LPTIM_IT_CMPOK LPTIM_IER_CMPOKIE
331 #define LPTIM_IT_EXTTRIG LPTIM_IER_EXTTRIGIE
332 #define LPTIM_IT_ARRM LPTIM_IER_ARRMIE
333 #define LPTIM_IT_CMPM LPTIM_IER_CMPMIE
335 * @}
339 * @}
342 /* Exported macro ------------------------------------------------------------*/
343 /** @defgroup LPTIM_Exported_Macros LPTIM Exported Macros
344 * @{
347 /** @brief Reset LPTIM handle state
348 * @param __HANDLE__ LPTIM handle
349 * @retval None
351 #define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LPTIM_STATE_RESET)
354 * @brief Enable/Disable the LPTIM peripheral.
355 * @param __HANDLE__ LPTIM handle
356 * @retval None
358 #define __HAL_LPTIM_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (LPTIM_CR_ENABLE))
359 #define __HAL_LPTIM_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(LPTIM_CR_ENABLE))
362 * @brief Starts the LPTIM peripheral in Continuous or in single mode.
363 * @param __HANDLE__ DMA handle
364 * @retval None
366 #define __HAL_LPTIM_START_CONTINUOUS(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_CNTSTRT)
367 #define __HAL_LPTIM_START_SINGLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_SNGSTRT)
371 * @brief Writes the passed parameter in the Autoreload register.
372 * @param __HANDLE__ LPTIM handle
373 * @param __VALUE__ Autoreload value
374 * @retval None
376 #define __HAL_LPTIM_AUTORELOAD_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->ARR = (__VALUE__))
379 * @brief Writes the passed parameter in the Compare register.
380 * @param __HANDLE__ LPTIM handle
381 * @param __VALUE__ Compare value
382 * @retval None
384 #define __HAL_LPTIM_COMPARE_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->CMP = (__VALUE__))
387 * @brief Checks whether the specified LPTIM flag is set or not.
388 * @param __HANDLE__ LPTIM handle
389 * @param __FLAG__ LPTIM flag to check
390 * This parameter can be a value of:
391 * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag.
392 * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag.
393 * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag.
394 * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag.
395 * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
396 * @arg LPTIM_FLAG_ARRM : Autoreload match Flag.
397 * @arg LPTIM_FLAG_CMPM : Compare match Flag.
398 * @retval The state of the specified flag (SET or RESET).
400 #define __HAL_LPTIM_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR &(__FLAG__)) == (__FLAG__))
403 * @brief Clears the specified LPTIM flag.
404 * @param __HANDLE__ LPTIM handle.
405 * @param __FLAG__ LPTIM flag to clear.
406 * This parameter can be a value of:
407 * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag.
408 * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag.
409 * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag.
410 * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag.
411 * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
412 * @arg LPTIM_FLAG_ARRM : Autoreload match Flag.
413 * @arg LPTIM_FLAG_CMPM : Compare match Flag.
414 * @retval None.
416 #define __HAL_LPTIM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
419 * @brief Enable the specified LPTIM interrupt.
420 * @param __HANDLE__ LPTIM handle.
421 * @param __INTERRUPT__ LPTIM interrupt to set.
422 * This parameter can be a value of:
423 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
424 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
425 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
426 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
427 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
428 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
429 * @arg LPTIM_IT_CMPM : Compare match Interrupt.
430 * @retval None.
432 #define __HAL_LPTIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
435 * @brief Disable the specified LPTIM interrupt.
436 * @param __HANDLE__ LPTIM handle.
437 * @param __INTERRUPT__ LPTIM interrupt to set.
438 * This parameter can be a value of:
439 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
440 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
441 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
442 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
443 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
444 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
445 * @arg LPTIM_IT_CMPM : Compare match Interrupt.
446 * @retval None.
448 #define __HAL_LPTIM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= (~(__INTERRUPT__)))
451 * @brief Checks whether the specified LPTIM interrupt is set or not.
452 * @param __HANDLE__ LPTIM handle.
453 * @param __INTERRUPT__ LPTIM interrupt to check.
454 * This parameter can be a value of:
455 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
456 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
457 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
458 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
459 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
460 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
461 * @arg LPTIM_IT_CMPM : Compare match Interrupt.
462 * @retval Interrupt status.
465 #define __HAL_LPTIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
468 * @brief Enable interrupt on the LPTIM Wake-up Timer associated Exti line.
469 * @retval None
471 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
474 * @brief Disable interrupt on the LPTIM Wake-up Timer associated Exti line.
475 * @retval None
477 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
480 * @brief Enable event on the LPTIM Wake-up Timer associated Exti line.
481 * @retval None.
483 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
486 * @brief Disable event on the LPTIM Wake-up Timer associated Exti line.
487 * @retval None.
489 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
492 * @brief Enable falling edge trigger on the LPTIM Wake-up Timer associated Exti line.
493 * @retval None.
495 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
498 * @brief Disable falling edge trigger on the LPTIM Wake-up Timer associated Exti line.
499 * @retval None.
501 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
504 * @brief Enable rising edge trigger on the LPTIM Wake-up Timer associated Exti line.
505 * @retval None.
507 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
510 * @brief Disable rising edge trigger on the LPTIM Wake-up Timer associated Exti line.
511 * @retval None.
513 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
516 * @brief Enable rising & falling edge trigger on the LPTIM Wake-up Timer associated Exti line.
517 * @retval None.
519 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_RISING_FALLING_EDGE() do{__HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE();\
520 __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE();\
521 }while(0)
524 * @brief Disable rising & falling edge trigger on the LPTIM Wake-up Timer associated Exti line.
525 * This parameter can be:
526 * @retval None.
528 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_RISING_FALLING_EDGE() do{__HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE();\
529 __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE();\
530 }while(0)
533 * @brief Check whether the LPTIM Wake-up Timer associated Exti line interrupt flag is set or not.
534 * @retval Line Status.
536 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_GET_FLAG() (EXTI->PR & LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
539 * @brief Clear the LPTIM Wake-up Timer associated Exti line flag.
540 * @retval None.
542 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_CLEAR_FLAG() (EXTI->PR = LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
545 * @brief Generate a Software interrupt on the LPTIM Wake-up Timer associated Exti line.
546 * @retval None.
548 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_GENERATE_SWIT() (EXTI->SWIER |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
551 * @}
554 /* Exported functions --------------------------------------------------------*/
555 /** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions
556 * @{
559 /* Initialization/de-initialization functions ********************************/
560 HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
561 HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim);
563 /* MSP functions *************************************************************/
564 void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim);
565 void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim);
567 /* Start/Stop operation functions *********************************************/
568 /* ################################# PWM Mode ################################*/
569 /* Blocking mode: Polling */
570 HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
571 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim);
572 /* Non-Blocking mode: Interrupt */
573 HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
574 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim);
576 /* ############################# One Pulse Mode ##############################*/
577 /* Blocking mode: Polling */
578 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
579 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim);
580 /* Non-Blocking mode: Interrupt */
581 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
582 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim);
584 /* ############################## Set once Mode ##############################*/
585 /* Blocking mode: Polling */
586 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
587 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim);
588 /* Non-Blocking mode: Interrupt */
589 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
590 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim);
592 /* ############################### Encoder Mode ##############################*/
593 /* Blocking mode: Polling */
594 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
595 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim);
596 /* Non-Blocking mode: Interrupt */
597 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
598 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim);
600 /* ############################# Time out Mode ##############################*/
601 /* Blocking mode: Polling */
602 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
603 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim);
604 /* Non-Blocking mode: Interrupt */
605 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
606 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim);
608 /* ############################## Counter Mode ###############################*/
609 /* Blocking mode: Polling */
610 HAL_StatusTypeDef HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
611 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef *hlptim);
612 /* Non-Blocking mode: Interrupt */
613 HAL_StatusTypeDef HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
614 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef *hlptim);
616 /* Reading operation functions ************************************************/
617 uint32_t HAL_LPTIM_ReadCounter(LPTIM_HandleTypeDef *hlptim);
618 uint32_t HAL_LPTIM_ReadAutoReload(LPTIM_HandleTypeDef *hlptim);
619 uint32_t HAL_LPTIM_ReadCompare(LPTIM_HandleTypeDef *hlptim);
621 /* LPTIM IRQ functions *******************************************************/
622 void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim);
624 /* CallBack functions ********************************************************/
625 void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim);
626 void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim);
627 void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef *hlptim);
628 void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef *hlptim);
629 void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef *hlptim);
630 void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef *hlptim);
631 void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef *hlptim);
633 /* Callbacks Register/UnRegister functions ***********************************/
634 #if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
635 HAL_StatusTypeDef HAL_LPTIM_RegisterCallback(LPTIM_HandleTypeDef *hlptim, HAL_LPTIM_CallbackIDTypeDef CallbackID, pLPTIM_CallbackTypeDef pCallback);
636 HAL_StatusTypeDef HAL_LPTIM_UnRegisterCallback(LPTIM_HandleTypeDef *hlptim, HAL_LPTIM_CallbackIDTypeDef CallbackID);
637 #endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
639 /* Peripheral State functions ************************************************/
640 HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(LPTIM_HandleTypeDef *hlptim);
643 * @}
646 /* Private types -------------------------------------------------------------*/
647 /** @defgroup LPTIM_Private_Types LPTIM Private Types
648 * @{
652 * @}
655 /* Private variables ---------------------------------------------------------*/
656 /** @defgroup LPTIM_Private_Variables LPTIM Private Variables
657 * @{
661 * @}
664 /* Private constants ---------------------------------------------------------*/
665 /** @defgroup LPTIM_Private_Constants LPTIM Private Constants
666 * @{
670 * @}
673 /* Private macros ------------------------------------------------------------*/
674 /** @defgroup LPTIM_Private_Macros LPTIM Private Macros
675 * @{
678 #define IS_LPTIM_CLOCK_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_CLOCKSOURCE_ULPTIM) || \
679 ((__SOURCE__) == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC))
681 #define IS_LPTIM_CLOCK_PRESCALER(__PRESCALER__) (((__PRESCALER__) == LPTIM_PRESCALER_DIV1 ) || \
682 ((__PRESCALER__) == LPTIM_PRESCALER_DIV2 ) || \
683 ((__PRESCALER__) == LPTIM_PRESCALER_DIV4 ) || \
684 ((__PRESCALER__) == LPTIM_PRESCALER_DIV8 ) || \
685 ((__PRESCALER__) == LPTIM_PRESCALER_DIV16 ) || \
686 ((__PRESCALER__) == LPTIM_PRESCALER_DIV32 ) || \
687 ((__PRESCALER__) == LPTIM_PRESCALER_DIV64 ) || \
688 ((__PRESCALER__) == LPTIM_PRESCALER_DIV128))
689 #define IS_LPTIM_CLOCK_PRESCALERDIV1(__PRESCALER__) ((__PRESCALER__) == LPTIM_PRESCALER_DIV1)
691 #define IS_LPTIM_OUTPUT_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_OUTPUTPOLARITY_LOW ) || \
692 ((__POLARITY__) == LPTIM_OUTPUTPOLARITY_HIGH))
694 #define IS_LPTIM_CLOCK_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION) || \
695 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_2TRANSITIONS) || \
696 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_4TRANSITIONS) || \
697 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_8TRANSITIONS))
699 #define IS_LPTIM_CLOCK_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING) || \
700 ((__POLARITY__) == LPTIM_CLOCKPOLARITY_FALLING) || \
701 ((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING_FALLING))
703 #define IS_LPTIM_TRG_SOURCE(__TRIG__) (((__TRIG__) == LPTIM_TRIGSOURCE_SOFTWARE) || \
704 ((__TRIG__) == LPTIM_TRIGSOURCE_0) || \
705 ((__TRIG__) == LPTIM_TRIGSOURCE_1) || \
706 ((__TRIG__) == LPTIM_TRIGSOURCE_2) || \
707 ((__TRIG__) == LPTIM_TRIGSOURCE_3) || \
708 ((__TRIG__) == LPTIM_TRIGSOURCE_4) || \
709 ((__TRIG__) == LPTIM_TRIGSOURCE_5))
711 #define IS_LPTIM_EXT_TRG_POLARITY(__POLAR__) (((__POLAR__) == LPTIM_ACTIVEEDGE_RISING ) || \
712 ((__POLAR__) == LPTIM_ACTIVEEDGE_FALLING ) || \
713 ((__POLAR__) == LPTIM_ACTIVEEDGE_RISING_FALLING ))
715 #define IS_LPTIM_TRIG_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION) || \
716 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_2TRANSITIONS ) || \
717 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_4TRANSITIONS ) || \
718 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_8TRANSITIONS ))
720 #define IS_LPTIM_UPDATE_MODE(__MODE__) (((__MODE__) == LPTIM_UPDATE_IMMEDIATE) || \
721 ((__MODE__) == LPTIM_UPDATE_ENDOFPERIOD))
723 #define IS_LPTIM_COUNTER_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_COUNTERSOURCE_INTERNAL) || \
724 ((__SOURCE__) == LPTIM_COUNTERSOURCE_EXTERNAL))
726 #define IS_LPTIM_AUTORELOAD(__AUTORELOAD__) ((__AUTORELOAD__) <= 0x0000FFFFU)
728 #define IS_LPTIM_COMPARE(__COMPARE__) ((__COMPARE__) <= 0x0000FFFFU)
730 #define IS_LPTIM_PERIOD(PERIOD) ((PERIOD) <= 0x0000FFFFU)
732 #define IS_LPTIM_PULSE(PULSE) ((PULSE) <= 0x0000FFFFU)
735 * @}
738 /* Private functions ---------------------------------------------------------*/
739 /** @defgroup LPTIM_Private_Functions LPTIM Private Functions
740 * @{
744 * @}
748 * @}
752 * @}
755 #ifdef __cplusplus
757 #endif
759 #endif /* __STM32F7xx_HAL_LPTIM_H */
761 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/