2 ******************************************************************************
3 * @file stm32f4xx_hal_lptim.h
4 * @author MCD Application Team
7 * @brief Header file of LPTIM HAL module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F4xx_HAL_LPTIM_H
40 #define __STM32F4xx_HAL_LPTIM_H
46 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F413xx) || defined(STM32F423xx)
47 /* Includes ------------------------------------------------------------------*/
48 #include "stm32f4xx_hal_def.h"
50 /** @addtogroup STM32F4xx_HAL_Driver
54 /** @defgroup LPTIM LPTIM
55 * @brief LPTIM HAL module driver
59 /* Exported types ------------------------------------------------------------*/
60 /** @defgroup LPTIM_Exported_Types LPTIM Exported Types
64 /** @defgroup LPTIM_WAKEUPTIMER_EXTILINE LPTIM WAKEUP Timer EXTI Line
67 #define LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT ((uint32_t)EXTI_IMR_MR23) /*!< External interrupt line 23 Connected to the LPTIM EXTI Line */
73 * @brief LPTIM Clock configuration definition
77 uint32_t Source
; /*!< Selects the clock source.
78 This parameter can be a value of @ref LPTIM_Clock_Source */
80 uint32_t Prescaler
; /*!< Specifies the counter clock Prescaler.
81 This parameter can be a value of @ref LPTIM_Clock_Prescaler */
83 }LPTIM_ClockConfigTypeDef
;
86 * @brief LPTIM Clock configuration definition
90 uint32_t Polarity
; /*!< Selects the polarity of the active edge for the counter unit
91 if the ULPTIM input is selected.
92 Note: This parameter is used only when Ultra low power clock source is used.
93 Note: If the polarity is configured on 'both edges', an auxiliary clock
94 (one of the Low power oscillator) must be active.
95 This parameter can be a value of @ref LPTIM_Clock_Polarity */
97 uint32_t SampleTime
; /*!< Selects the clock sampling time to configure the clock glitch filter.
98 Note: This parameter is used only when Ultra low power clock source is used.
99 This parameter can be a value of @ref LPTIM_Clock_Sample_Time */
101 }LPTIM_ULPClockConfigTypeDef
;
104 * @brief LPTIM Trigger configuration definition
108 uint32_t Source
; /*!< Selects the Trigger source.
109 This parameter can be a value of @ref LPTIM_Trigger_Source */
111 uint32_t ActiveEdge
; /*!< Selects the Trigger active edge.
112 Note: This parameter is used only when an external trigger is used.
113 This parameter can be a value of @ref LPTIM_External_Trigger_Polarity */
115 uint32_t SampleTime
; /*!< Selects the trigger sampling time to configure the clock glitch filter.
116 Note: This parameter is used only when an external trigger is used.
117 This parameter can be a value of @ref LPTIM_Trigger_Sample_Time */
118 }LPTIM_TriggerConfigTypeDef
;
121 * @brief LPTIM Initialization Structure definition
125 LPTIM_ClockConfigTypeDef Clock
; /*!< Specifies the clock parameters */
127 LPTIM_ULPClockConfigTypeDef UltraLowPowerClock
; /*!< Specifies the Ultra Low Power clock parameters */
129 LPTIM_TriggerConfigTypeDef Trigger
; /*!< Specifies the Trigger parameters */
131 uint32_t OutputPolarity
; /*!< Specifies the Output polarity.
132 This parameter can be a value of @ref LPTIM_Output_Polarity */
134 uint32_t UpdateMode
; /*!< Specifies whether the update of the autorelaod and the compare
135 values is done immediately or after the end of current period.
136 This parameter can be a value of @ref LPTIM_Updating_Mode */
138 uint32_t CounterSource
; /*!< Specifies whether the counter is incremented each internal event
139 or each external event.
140 This parameter can be a value of @ref LPTIM_Counter_Source */
145 * @brief HAL LPTIM State structure definition
147 typedef enum __HAL_LPTIM_StateTypeDef
149 HAL_LPTIM_STATE_RESET
= 0x00U
, /*!< Peripheral not yet initialized or disabled */
150 HAL_LPTIM_STATE_READY
= 0x01U
, /*!< Peripheral Initialized and ready for use */
151 HAL_LPTIM_STATE_BUSY
= 0x02U
, /*!< An internal process is ongoing */
152 HAL_LPTIM_STATE_TIMEOUT
= 0x03U
, /*!< Timeout state */
153 HAL_LPTIM_STATE_ERROR
= 0x04U
/*!< Internal Process is ongoing */
154 }HAL_LPTIM_StateTypeDef
;
157 * @brief LPTIM handle Structure definition
161 LPTIM_TypeDef
*Instance
; /*!< Register base address */
163 LPTIM_InitTypeDef Init
; /*!< LPTIM required parameters */
165 HAL_StatusTypeDef Status
; /*!< LPTIM peripheral status */
167 HAL_LockTypeDef Lock
; /*!< LPTIM locking object */
169 __IO HAL_LPTIM_StateTypeDef State
; /*!< LPTIM peripheral state */
171 }LPTIM_HandleTypeDef
;
177 /* Exported constants --------------------------------------------------------*/
178 /** @defgroup LPTIM_Exported_Constants LPTIM Exported Constants
182 /** @defgroup LPTIM_Clock_Source LPTIM Clock Source
185 #define LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC 0x00U
186 #define LPTIM_CLOCKSOURCE_ULPTIM LPTIM_CFGR_CKSEL
191 /** @defgroup LPTIM_Clock_Prescaler LPTIM Clock Prescaler
194 #define LPTIM_PRESCALER_DIV1 0x00000000U
195 #define LPTIM_PRESCALER_DIV2 LPTIM_CFGR_PRESC_0
196 #define LPTIM_PRESCALER_DIV4 LPTIM_CFGR_PRESC_1
197 #define LPTIM_PRESCALER_DIV8 ((uint32_t)(LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_1))
198 #define LPTIM_PRESCALER_DIV16 LPTIM_CFGR_PRESC_2
199 #define LPTIM_PRESCALER_DIV32 ((uint32_t)(LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_2))
200 #define LPTIM_PRESCALER_DIV64 ((uint32_t)(LPTIM_CFGR_PRESC_1 | LPTIM_CFGR_PRESC_2))
201 #define LPTIM_PRESCALER_DIV128 ((uint32_t)LPTIM_CFGR_PRESC)
206 /** @defgroup LPTIM_Output_Polarity LPTIM Output Polarity
210 #define LPTIM_OUTPUTPOLARITY_HIGH 0x00000000U
211 #define LPTIM_OUTPUTPOLARITY_LOW (LPTIM_CFGR_WAVPOL)
216 /** @defgroup LPTIM_Clock_Sample_Time LPTIM Clock Sample Time
219 #define LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION 0x00000000U
220 #define LPTIM_CLOCKSAMPLETIME_2TRANSITIONS LPTIM_CFGR_CKFLT_0
221 #define LPTIM_CLOCKSAMPLETIME_4TRANSITIONS LPTIM_CFGR_CKFLT_1
222 #define LPTIM_CLOCKSAMPLETIME_8TRANSITIONS LPTIM_CFGR_CKFLT
227 /** @defgroup LPTIM_Clock_Polarity LPTIM Clock Polarity
231 #define LPTIM_CLOCKPOLARITY_RISING 0x00000000U
232 #define LPTIM_CLOCKPOLARITY_FALLING LPTIM_CFGR_CKPOL_0
233 #define LPTIM_CLOCKPOLARITY_RISING_FALLING LPTIM_CFGR_CKPOL_1
238 /** @defgroup LPTIM_Trigger_Source LPTIM Trigger Source
241 #define LPTIM_TRIGSOURCE_SOFTWARE 0x0000FFFFU
242 #define LPTIM_TRIGSOURCE_0 0x00000000U
243 #define LPTIM_TRIGSOURCE_1 ((uint32_t)LPTIM_CFGR_TRIGSEL_0)
244 #define LPTIM_TRIGSOURCE_2 LPTIM_CFGR_TRIGSEL_1
245 #define LPTIM_TRIGSOURCE_3 ((uint32_t)LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_1)
246 #define LPTIM_TRIGSOURCE_4 LPTIM_CFGR_TRIGSEL_2
247 #define LPTIM_TRIGSOURCE_5 ((uint32_t)LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_2)
252 /** @defgroup LPTIM_External_Trigger_Polarity LPTIM External Trigger Polarity
255 #define LPTIM_ACTIVEEDGE_RISING LPTIM_CFGR_TRIGEN_0
256 #define LPTIM_ACTIVEEDGE_FALLING LPTIM_CFGR_TRIGEN_1
257 #define LPTIM_ACTIVEEDGE_RISING_FALLING LPTIM_CFGR_TRIGEN
262 /** @defgroup LPTIM_Trigger_Sample_Time LPTIM Trigger Sample Time
265 #define LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION 0x00000000U
266 #define LPTIM_TRIGSAMPLETIME_2TRANSITIONS LPTIM_CFGR_TRGFLT_0
267 #define LPTIM_TRIGSAMPLETIME_4TRANSITIONS LPTIM_CFGR_TRGFLT_1
268 #define LPTIM_TRIGSAMPLETIME_8TRANSITIONS LPTIM_CFGR_TRGFLT
273 /** @defgroup LPTIM_Updating_Mode LPTIM Updating Mode
277 #define LPTIM_UPDATE_IMMEDIATE 0x00000000U
278 #define LPTIM_UPDATE_ENDOFPERIOD LPTIM_CFGR_PRELOAD
283 /** @defgroup LPTIM_Counter_Source LPTIM Counter Source
287 #define LPTIM_COUNTERSOURCE_INTERNAL 0x00000000U
288 #define LPTIM_COUNTERSOURCE_EXTERNAL LPTIM_CFGR_COUNTMODE
293 /** @defgroup LPTIM_Flag_Definition LPTIM Flag Definition
297 #define LPTIM_FLAG_DOWN LPTIM_ISR_DOWN
298 #define LPTIM_FLAG_UP LPTIM_ISR_UP
299 #define LPTIM_FLAG_ARROK LPTIM_ISR_ARROK
300 #define LPTIM_FLAG_CMPOK LPTIM_ISR_CMPOK
301 #define LPTIM_FLAG_EXTTRIG LPTIM_ISR_EXTTRIG
302 #define LPTIM_FLAG_ARRM LPTIM_ISR_ARRM
303 #define LPTIM_FLAG_CMPM LPTIM_ISR_CMPM
308 /** @defgroup LPTIM_Interrupts_Definition LPTIM Interrupts Definition
312 #define LPTIM_IT_DOWN LPTIM_IER_DOWNIE
313 #define LPTIM_IT_UP LPTIM_IER_UPIE
314 #define LPTIM_IT_ARROK LPTIM_IER_ARROKIE
315 #define LPTIM_IT_CMPOK LPTIM_IER_CMPOKIE
316 #define LPTIM_IT_EXTTRIG LPTIM_IER_EXTTRIGIE
317 #define LPTIM_IT_ARRM LPTIM_IER_ARRMIE
318 #define LPTIM_IT_CMPM LPTIM_IER_CMPMIE
323 /** @defgroup LPTIM_Option Register Definition
326 #define LPTIM_OP_PAD_AF 0x00000000U
327 #define LPTIM_OP_PAD_PA4 LPTIM_OR_LPT_IN1_RMP_0
328 #define LPTIM_OP_PAD_PB9 LPTIM_OR_LPT_IN1_RMP_1
329 #define LPTIM_OP_TIM_DAC LPTIM_OR_LPT_IN1_RMP
339 /* Exported macro ------------------------------------------------------------*/
340 /** @defgroup LPTIM_Exported_Macros LPTIM Exported Macros
344 /** @brief Reset LPTIM handle state
345 * @param __HANDLE__: LPTIM handle
348 #define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LPTIM_STATE_RESET)
351 * @brief Enable/Disable the LPTIM peripheral.
352 * @param __HANDLE__: LPTIM handle
355 #define __HAL_LPTIM_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (LPTIM_CR_ENABLE))
356 #define __HAL_LPTIM_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(LPTIM_CR_ENABLE))
359 * @brief Starts the LPTIM peripheral in Continuous or in single mode.
360 * @param __HANDLE__: DMA handle
363 #define __HAL_LPTIM_START_CONTINUOUS(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_CNTSTRT)
364 #define __HAL_LPTIM_START_SINGLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_SNGSTRT)
368 * @brief Writes the passed parameter in the Autoreload register.
369 * @param __HANDLE__: LPTIM handle
370 * @param __VALUE__ : Autoreload value
373 #define __HAL_LPTIM_AUTORELOAD_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->ARR = (__VALUE__))
376 * @brief Writes the passed parameter in the Compare register.
377 * @param __HANDLE__: LPTIM handle
378 * @param __VALUE__ : Compare value
381 #define __HAL_LPTIM_COMPARE_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->CMP = (__VALUE__))
384 * @brief Checks whether the specified LPTIM flag is set or not.
385 * @param __HANDLE__: LPTIM handle
386 * @param __FLAG__ : LPTIM flag to check
387 * This parameter can be a value of:
388 * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag.
389 * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag.
390 * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag.
391 * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag.
392 * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
393 * @arg LPTIM_FLAG_ARRM : Autoreload match Flag.
394 * @arg LPTIM_FLAG_CMPM : Compare match Flag.
395 * @retval The state of the specified flag (SET or RESET).
397 #define __HAL_LPTIM_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR &(__FLAG__)) == (__FLAG__))
400 * @brief Clears the specified LPTIM flag.
401 * @param __HANDLE__: LPTIM handle.
402 * @param __FLAG__ : LPTIM flag to clear.
403 * This parameter can be a value of:
404 * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag.
405 * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag.
406 * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag.
407 * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag.
408 * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
409 * @arg LPTIM_FLAG_ARRM : Autoreload match Flag.
410 * @arg LPTIM_FLAG_CMPM : Compare match Flag.
413 #define __HAL_LPTIM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
416 * @brief Enable the specified LPTIM interrupt.
417 * @param __HANDLE__ : LPTIM handle.
418 * @param __INTERRUPT__ : LPTIM interrupt to set.
419 * This parameter can be a value of:
420 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
421 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
422 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
423 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
424 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
425 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
426 * @arg LPTIM_IT_CMPM : Compare match Interrupt.
429 #define __HAL_LPTIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
432 * @brief Disable the specified LPTIM interrupt.
433 * @param __HANDLE__ : LPTIM handle.
434 * @param __INTERRUPT__ : LPTIM interrupt to set.
435 * This parameter can be a value of:
436 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
437 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
438 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
439 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
440 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
441 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
442 * @arg LPTIM_IT_CMPM : Compare match Interrupt.
445 #define __HAL_LPTIM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= (~(__INTERRUPT__)))
448 * @brief Checks whether the specified LPTIM interrupt is set or not.
449 * @param __HANDLE__ : LPTIM handle.
450 * @param __INTERRUPT__ : LPTIM interrupt to check.
451 * This parameter can be a value of:
452 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
453 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
454 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
455 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
456 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
457 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
458 * @arg LPTIM_IT_CMPM : Compare match Interrupt.
459 * @retval Interrupt status.
462 #define __HAL_LPTIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
464 /** @brief LPTIM Option Register
465 * @param __HANDLE__: LPTIM handle
466 * @param __VALUE__: This parameter can be a value of :
467 * @arg LPTIM_OP_PAD_AF
468 * @arg LPTIM_OP_PAD_PA4
469 * @arg LPTIM_OP_PAD_PB9
470 * @arg LPTIM_OP_TIM_DAC
473 #define __HAL_LPTIM_OPTR_CONFIG(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->OR = (__VALUE__))
476 * @brief Enable interrupt on the LPTIM Wake-up Timer associated Exti line.
479 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
482 * @brief Disable interrupt on the LPTIM Wake-up Timer associated Exti line.
485 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
488 * @brief Enable event on the LPTIM Wake-up Timer associated Exti line.
491 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
494 * @brief Disable event on the LPTIM Wake-up Timer associated Exti line.
497 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
500 * @brief Enable falling edge trigger on the LPTIM Wake-up Timer associated Exti line.
503 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
506 * @brief Disable falling edge trigger on the LPTIM Wake-up Timer associated Exti line.
509 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
512 * @brief Enable rising edge trigger on the LPTIM Wake-up Timer associated Exti line.
515 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
518 * @brief Disable rising edge trigger on the LPTIM Wake-up Timer associated Exti line.
521 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
524 * @brief Enable rising & falling edge trigger on the LPTIM Wake-up Timer associated Exti line.
527 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_RISING_FALLING_EDGE() do{__HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE();\
528 __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE();\
532 * @brief Disable rising & falling edge trigger on the LPTIM Wake-up Timer associated Exti line.
533 * This parameter can be:
536 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_RISING_FALLING_EDGE() do{__HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE();\
537 __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE();\
541 * @brief Check whether the LPTIM Wake-up Timer associated Exti line interrupt flag is set or not.
542 * @retval Line Status.
544 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_GET_FLAG() (EXTI->PR & LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
547 * @brief Clear the LPTIM Wake-up Timer associated Exti line flag.
550 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_CLEAR_FLAG() (EXTI->PR = LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
553 * @brief Generate a Software interrupt on the LPTIM Wake-up Timer associated Exti line.
556 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_GENERATE_SWIT() (EXTI->SWIER |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
561 /* Exported functions --------------------------------------------------------*/
562 /** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions
566 /* Initialization/de-initialization functions ********************************/
567 HAL_StatusTypeDef
HAL_LPTIM_Init(LPTIM_HandleTypeDef
*hlptim
);
568 HAL_StatusTypeDef
HAL_LPTIM_DeInit(LPTIM_HandleTypeDef
*hlptim
);
570 /* MSP functions *************************************************************/
571 void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef
*hlptim
);
572 void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef
*hlptim
);
574 /* Start/Stop operation functions *********************************************/
575 /* ################################# PWM Mode ################################*/
576 /* Blocking mode: Polling */
577 HAL_StatusTypeDef
HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef
*hlptim
, uint32_t Period
, uint32_t Pulse
);
578 HAL_StatusTypeDef
HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef
*hlptim
);
579 /* Non-Blocking mode: Interrupt */
580 HAL_StatusTypeDef
HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef
*hlptim
, uint32_t Period
, uint32_t Pulse
);
581 HAL_StatusTypeDef
HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef
*hlptim
);
583 /* ############################# One Pulse Mode ##############################*/
584 /* Blocking mode: Polling */
585 HAL_StatusTypeDef
HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef
*hlptim
, uint32_t Period
, uint32_t Pulse
);
586 HAL_StatusTypeDef
HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef
*hlptim
);
587 /* Non-Blocking mode: Interrupt */
588 HAL_StatusTypeDef
HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef
*hlptim
, uint32_t Period
, uint32_t Pulse
);
589 HAL_StatusTypeDef
HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef
*hlptim
);
591 /* ############################## Set once Mode ##############################*/
592 /* Blocking mode: Polling */
593 HAL_StatusTypeDef
HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef
*hlptim
, uint32_t Period
, uint32_t Pulse
);
594 HAL_StatusTypeDef
HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef
*hlptim
);
595 /* Non-Blocking mode: Interrupt */
596 HAL_StatusTypeDef
HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef
*hlptim
, uint32_t Period
, uint32_t Pulse
);
597 HAL_StatusTypeDef
HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef
*hlptim
);
599 /* ############################### Encoder Mode ##############################*/
600 /* Blocking mode: Polling */
601 HAL_StatusTypeDef
HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef
*hlptim
, uint32_t Period
);
602 HAL_StatusTypeDef
HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef
*hlptim
);
603 /* Non-Blocking mode: Interrupt */
604 HAL_StatusTypeDef
HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef
*hlptim
, uint32_t Period
);
605 HAL_StatusTypeDef
HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef
*hlptim
);
607 /* ############################# Time out Mode ##############################*/
608 /* Blocking mode: Polling */
609 HAL_StatusTypeDef
HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef
*hlptim
, uint32_t Period
, uint32_t Timeout
);
610 HAL_StatusTypeDef
HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef
*hlptim
);
611 /* Non-Blocking mode: Interrupt */
612 HAL_StatusTypeDef
HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef
*hlptim
, uint32_t Period
, uint32_t Timeout
);
613 HAL_StatusTypeDef
HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef
*hlptim
);
615 /* ############################## Counter Mode ###############################*/
616 /* Blocking mode: Polling */
617 HAL_StatusTypeDef
HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef
*hlptim
, uint32_t Period
);
618 HAL_StatusTypeDef
HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef
*hlptim
);
619 /* Non-Blocking mode: Interrupt */
620 HAL_StatusTypeDef
HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef
*hlptim
, uint32_t Period
);
621 HAL_StatusTypeDef
HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef
*hlptim
);
623 /* Reading operation functions ************************************************/
624 uint32_t HAL_LPTIM_ReadCounter(LPTIM_HandleTypeDef
*hlptim
);
625 uint32_t HAL_LPTIM_ReadAutoReload(LPTIM_HandleTypeDef
*hlptim
);
626 uint32_t HAL_LPTIM_ReadCompare(LPTIM_HandleTypeDef
*hlptim
);
628 /* LPTIM IRQ functions *******************************************************/
629 void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef
*hlptim
);
631 /* CallBack functions ********************************************************/
632 void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef
*hlptim
);
633 void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef
*hlptim
);
634 void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef
*hlptim
);
635 void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef
*hlptim
);
636 void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef
*hlptim
);
637 void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef
*hlptim
);
638 void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef
*hlptim
);
640 /* Peripheral State functions ************************************************/
641 HAL_LPTIM_StateTypeDef
HAL_LPTIM_GetState(LPTIM_HandleTypeDef
*hlptim
);
647 /* Private types -------------------------------------------------------------*/
648 /** @defgroup LPTIM_Private_Types LPTIM Private Types
656 /* Private variables ---------------------------------------------------------*/
657 /** @defgroup LPTIM_Private_Variables LPTIM Private Variables
665 /* Private constants ---------------------------------------------------------*/
666 /** @defgroup LPTIM_Private_Constants LPTIM Private Constants
674 /* Private macros ------------------------------------------------------------*/
675 /** @defgroup LPTIM_Private_Macros LPTIM Private Macros
679 #define IS_LPTIM_CLOCK_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_CLOCKSOURCE_ULPTIM) || \
680 ((__SOURCE__) == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC))
682 #define IS_LPTIM_CLOCK_PRESCALER(__PRESCALER__) (((__PRESCALER__) == LPTIM_PRESCALER_DIV1 ) || \
683 ((__PRESCALER__) == LPTIM_PRESCALER_DIV2 ) || \
684 ((__PRESCALER__) == LPTIM_PRESCALER_DIV4 ) || \
685 ((__PRESCALER__) == LPTIM_PRESCALER_DIV8 ) || \
686 ((__PRESCALER__) == LPTIM_PRESCALER_DIV16 ) || \
687 ((__PRESCALER__) == LPTIM_PRESCALER_DIV32 ) || \
688 ((__PRESCALER__) == LPTIM_PRESCALER_DIV64 ) || \
689 ((__PRESCALER__) == LPTIM_PRESCALER_DIV128))
690 #define IS_LPTIM_CLOCK_PRESCALERDIV1(__PRESCALER__) ((__PRESCALER__) == LPTIM_PRESCALER_DIV1)
692 #define IS_LPTIM_OUTPUT_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_OUTPUTPOLARITY_LOW ) || \
693 ((__POLARITY__) == LPTIM_OUTPUTPOLARITY_HIGH))
695 #define IS_LPTIM_CLOCK_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION) || \
696 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_2TRANSITIONS) || \
697 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_4TRANSITIONS) || \
698 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_8TRANSITIONS))
700 #define IS_LPTIM_CLOCK_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING) || \
701 ((__POLARITY__) == LPTIM_CLOCKPOLARITY_FALLING) || \
702 ((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING_FALLING))
704 #define IS_LPTIM_TRG_SOURCE(__TRIG__) (((__TRIG__) == LPTIM_TRIGSOURCE_SOFTWARE) || \
705 ((__TRIG__) == LPTIM_TRIGSOURCE_0) || \
706 ((__TRIG__) == LPTIM_TRIGSOURCE_1) || \
707 ((__TRIG__) == LPTIM_TRIGSOURCE_2) || \
708 ((__TRIG__) == LPTIM_TRIGSOURCE_3) || \
709 ((__TRIG__) == LPTIM_TRIGSOURCE_4) || \
710 ((__TRIG__) == LPTIM_TRIGSOURCE_5))
712 #define IS_LPTIM_EXT_TRG_POLARITY(__POLAR__) (((__POLAR__) == LPTIM_ACTIVEEDGE_RISING ) || \
713 ((__POLAR__) == LPTIM_ACTIVEEDGE_FALLING ) || \
714 ((__POLAR__) == LPTIM_ACTIVEEDGE_RISING_FALLING ))
716 #define IS_LPTIM_TRIG_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION) || \
717 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_2TRANSITIONS ) || \
718 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_4TRANSITIONS ) || \
719 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_8TRANSITIONS ))
721 #define IS_LPTIM_UPDATE_MODE(__MODE__) (((__MODE__) == LPTIM_UPDATE_IMMEDIATE) || \
722 ((__MODE__) == LPTIM_UPDATE_ENDOFPERIOD))
724 #define IS_LPTIM_COUNTER_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_COUNTERSOURCE_INTERNAL) || \
725 ((__SOURCE__) == LPTIM_COUNTERSOURCE_EXTERNAL))
727 #define IS_LPTIM_AUTORELOAD(__AUTORELOAD__) ((__AUTORELOAD__) <= 0x0000FFFFU)
729 #define IS_LPTIM_COMPARE(__COMPARE__) ((__COMPARE__) <= 0x0000FFFFU)
731 #define IS_LPTIM_PERIOD(PERIOD) ((PERIOD) <= 0x0000FFFFU)
733 #define IS_LPTIM_PULSE(PULSE) ((PULSE) <= 0x0000FFFFU)
739 /* Private functions ---------------------------------------------------------*/
740 /** @defgroup LPTIM_Private_Functions LPTIM Private Functions
756 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx || STM32F413xx || STM32F423xx */
761 #endif /* __STM32F4xx_HAL_LPTIM_H */
763 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/