You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1481 lines
54 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32wbxx_ll_lptim.h
  4. * @author MCD Application Team
  5. * @brief Header file of LPTIM LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2019 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. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32WBxx_LL_LPTIM_H
  21. #define STM32WBxx_LL_LPTIM_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32wbxx.h"
  27. /** @addtogroup STM32WBxx_LL_Driver
  28. * @{
  29. */
  30. #if defined (LPTIM1) || defined (LPTIM2)
  31. /** @defgroup LPTIM_LL LPTIM
  32. * @{
  33. */
  34. /* Private types -------------------------------------------------------------*/
  35. /* Private variables ---------------------------------------------------------*/
  36. /* Private constants ---------------------------------------------------------*/
  37. /* Private macros ------------------------------------------------------------*/
  38. #if defined(USE_FULL_LL_DRIVER)
  39. /** @defgroup LPTIM_LL_Private_Macros LPTIM Private Macros
  40. * @{
  41. */
  42. /**
  43. * @}
  44. */
  45. #endif /*USE_FULL_LL_DRIVER*/
  46. /* Exported types ------------------------------------------------------------*/
  47. #if defined(USE_FULL_LL_DRIVER)
  48. /** @defgroup LPTIM_LL_ES_INIT LPTIM Exported Init structure
  49. * @{
  50. */
  51. /**
  52. * @brief LPTIM Init structure definition
  53. */
  54. typedef struct
  55. {
  56. uint32_t ClockSource; /*!< Specifies the source of the clock used by the LPTIM instance.
  57. This parameter can be a value of @ref LPTIM_LL_EC_CLK_SOURCE.
  58. This feature can be modified afterwards using unitary function @ref LL_LPTIM_SetClockSource().*/
  59. uint32_t Prescaler; /*!< Specifies the prescaler division ratio.
  60. This parameter can be a value of @ref LPTIM_LL_EC_PRESCALER.
  61. This feature can be modified afterwards using using unitary function @ref LL_LPTIM_SetPrescaler().*/
  62. uint32_t Waveform; /*!< Specifies the waveform shape.
  63. This parameter can be a value of @ref LPTIM_LL_EC_OUTPUT_WAVEFORM.
  64. This feature can be modified afterwards using unitary function @ref LL_LPTIM_ConfigOutput().*/
  65. uint32_t Polarity; /*!< Specifies waveform polarity.
  66. This parameter can be a value of @ref LPTIM_LL_EC_OUTPUT_POLARITY.
  67. This feature can be modified afterwards using unitary function @ref LL_LPTIM_ConfigOutput().*/
  68. } LL_LPTIM_InitTypeDef;
  69. /**
  70. * @}
  71. */
  72. #endif /* USE_FULL_LL_DRIVER */
  73. /* Exported constants --------------------------------------------------------*/
  74. /** @defgroup LPTIM_LL_Exported_Constants LPTIM Exported Constants
  75. * @{
  76. */
  77. /** @defgroup LPTIM_LL_EC_GET_FLAG Get Flags Defines
  78. * @brief Flags defines which can be used with LL_LPTIM_ReadReg function
  79. * @{
  80. */
  81. #define LL_LPTIM_ISR_CMPM LPTIM_ISR_CMPM /*!< Compare match */
  82. #define LL_LPTIM_ISR_ARRM LPTIM_ISR_ARRM /*!< Autoreload match */
  83. #define LL_LPTIM_ISR_EXTTRIG LPTIM_ISR_EXTTRIG /*!< External trigger edge event */
  84. #define LL_LPTIM_ISR_CMPOK LPTIM_ISR_CMPOK /*!< Compare register update OK */
  85. #define LL_LPTIM_ISR_ARROK LPTIM_ISR_ARROK /*!< Autoreload register update OK */
  86. #define LL_LPTIM_ISR_UP LPTIM_ISR_UP /*!< Counter direction change down to up */
  87. #define LL_LPTIM_ISR_DOWN LPTIM_ISR_DOWN /*!< Counter direction change up to down */
  88. /**
  89. * @}
  90. */
  91. /** @defgroup LPTIM_LL_EC_IT IT Defines
  92. * @brief IT defines which can be used with LL_LPTIM_ReadReg and LL_LPTIM_WriteReg functions
  93. * @{
  94. */
  95. #define LL_LPTIM_IER_CMPMIE LPTIM_IER_CMPMIE /*!< Compare match Interrupt Enable */
  96. #define LL_LPTIM_IER_ARRMIE LPTIM_IER_ARRMIE /*!< Autoreload match Interrupt Enable */
  97. #define LL_LPTIM_IER_EXTTRIGIE LPTIM_IER_EXTTRIGIE /*!< External trigger valid edge Interrupt Enable */
  98. #define LL_LPTIM_IER_CMPOKIE LPTIM_IER_CMPOKIE /*!< Compare register update OK Interrupt Enable */
  99. #define LL_LPTIM_IER_ARROKIE LPTIM_IER_ARROKIE /*!< Autoreload register update OK Interrupt Enable */
  100. #define LL_LPTIM_IER_UPIE LPTIM_IER_UPIE /*!< Direction change to UP Interrupt Enable */
  101. #define LL_LPTIM_IER_DOWNIE LPTIM_IER_DOWNIE /*!< Direction change to down Interrupt Enable */
  102. /**
  103. * @}
  104. */
  105. /** @defgroup LPTIM_LL_EC_OPERATING_MODE Operating Mode
  106. * @{
  107. */
  108. #define LL_LPTIM_OPERATING_MODE_CONTINUOUS LPTIM_CR_CNTSTRT /*!<LP Timer starts in continuous mode*/
  109. #define LL_LPTIM_OPERATING_MODE_ONESHOT LPTIM_CR_SNGSTRT /*!<LP Tilmer starts in single mode*/
  110. /**
  111. * @}
  112. */
  113. /** @defgroup LPTIM_LL_EC_UPDATE_MODE Update Mode
  114. * @{
  115. */
  116. #define LL_LPTIM_UPDATE_MODE_IMMEDIATE 0x00000000U /*!<Preload is disabled: registers are updated after each APB bus write access*/
  117. #define LL_LPTIM_UPDATE_MODE_ENDOFPERIOD LPTIM_CFGR_PRELOAD /*!<preload is enabled: registers are updated at the end of the current LPTIM period*/
  118. /**
  119. * @}
  120. */
  121. /** @defgroup LPTIM_LL_EC_COUNTER_MODE Counter Mode
  122. * @{
  123. */
  124. #define LL_LPTIM_COUNTER_MODE_INTERNAL 0x00000000U /*!<The counter is incremented following each internal clock pulse*/
  125. #define LL_LPTIM_COUNTER_MODE_EXTERNAL LPTIM_CFGR_COUNTMODE /*!<The counter is incremented following each valid clock pulse on the LPTIM external Input1*/
  126. /**
  127. * @}
  128. */
  129. /** @defgroup LPTIM_LL_EC_OUTPUT_WAVEFORM Output Waveform Type
  130. * @{
  131. */
  132. #define LL_LPTIM_OUTPUT_WAVEFORM_PWM 0x00000000U /*!<LPTIM generates either a PWM waveform or a One pulse waveform depending on chosen operating mode CONTINOUS or SINGLE*/
  133. #define LL_LPTIM_OUTPUT_WAVEFORM_SETONCE LPTIM_CFGR_WAVE /*!<LPTIM generates a Set Once waveform*/
  134. /**
  135. * @}
  136. */
  137. /** @defgroup LPTIM_LL_EC_OUTPUT_POLARITY Output Polarity
  138. * @{
  139. */
  140. #define LL_LPTIM_OUTPUT_POLARITY_REGULAR 0x00000000U /*!<The LPTIM output reflects the compare results between LPTIMx_ARR and LPTIMx_CMP registers*/
  141. #define LL_LPTIM_OUTPUT_POLARITY_INVERSE LPTIM_CFGR_WAVPOL /*!<The LPTIM output reflects the inverse of the compare results between LPTIMx_ARR and LPTIMx_CMP registers*/
  142. /**
  143. * @}
  144. */
  145. /** @defgroup LPTIM_LL_EC_PRESCALER Prescaler Value
  146. * @{
  147. */
  148. #define LL_LPTIM_PRESCALER_DIV1 0x00000000U /*!<Prescaler division factor is set to 1*/
  149. #define LL_LPTIM_PRESCALER_DIV2 LPTIM_CFGR_PRESC_0 /*!<Prescaler division factor is set to 2*/
  150. #define LL_LPTIM_PRESCALER_DIV4 LPTIM_CFGR_PRESC_1 /*!<Prescaler division factor is set to 4*/
  151. #define LL_LPTIM_PRESCALER_DIV8 (LPTIM_CFGR_PRESC_1 | LPTIM_CFGR_PRESC_0) /*!<Prescaler division factor is set to 8*/
  152. #define LL_LPTIM_PRESCALER_DIV16 LPTIM_CFGR_PRESC_2 /*!<Prescaler division factor is set to 16*/
  153. #define LL_LPTIM_PRESCALER_DIV32 (LPTIM_CFGR_PRESC_2 | LPTIM_CFGR_PRESC_0) /*!<Prescaler division factor is set to 32*/
  154. #define LL_LPTIM_PRESCALER_DIV64 (LPTIM_CFGR_PRESC_2 | LPTIM_CFGR_PRESC_1) /*!<Prescaler division factor is set to 64*/
  155. #define LL_LPTIM_PRESCALER_DIV128 LPTIM_CFGR_PRESC /*!<Prescaler division factor is set to 128*/
  156. /**
  157. * @}
  158. */
  159. /** @defgroup LPTIM_LL_EC_TRIG_SOURCE Trigger Source
  160. * @{
  161. */
  162. #define LL_LPTIM_TRIG_SOURCE_GPIO 0x00000000U /*!<External input trigger is connected to TIMx_ETR input*/
  163. #define LL_LPTIM_TRIG_SOURCE_RTCALARMA LPTIM_CFGR_TRIGSEL_0 /*!<External input trigger is connected to RTC Alarm A*/
  164. #define LL_LPTIM_TRIG_SOURCE_RTCALARMB LPTIM_CFGR_TRIGSEL_1 /*!<External input trigger is connected to RTC Alarm B*/
  165. #if defined(RTC_TAMPER1_SUPPORT)
  166. #define LL_LPTIM_TRIG_SOURCE_RTCTAMP1 (LPTIM_CFGR_TRIGSEL_1 | LPTIM_CFGR_TRIGSEL_0) /*!<External input trigger is connected to RTC Tamper 1*/
  167. #endif /* RTC_TAMPER1_SUPPORT */
  168. #define LL_LPTIM_TRIG_SOURCE_RTCTAMP2 LPTIM_CFGR_TRIGSEL_2 /*!<External input trigger is connected to RTC Tamper 2*/
  169. #if defined(RTC_TAMPER3_SUPPORT)
  170. #define LL_LPTIM_TRIG_SOURCE_RTCTAMP3 (LPTIM_CFGR_TRIGSEL_2 | LPTIM_CFGR_TRIGSEL_0) /*!<External input trigger is connected to RTC Tamper 3*/
  171. #endif /* RTC_TAMPER3_SUPPORT */
  172. #if defined(COMP1)
  173. #define LL_LPTIM_TRIG_SOURCE_COMP1 (LPTIM_CFGR_TRIGSEL_2 | LPTIM_CFGR_TRIGSEL_1) /*!<External input trigger is connected to COMP1 output*/
  174. #endif /* COMP1 */
  175. #if defined(COMP2)
  176. #define LL_LPTIM_TRIG_SOURCE_COMP2 LPTIM_CFGR_TRIGSEL /*!<External input trigger is connected to COMP2 output*/
  177. #endif /* COMP2 */
  178. /**
  179. * @}
  180. */
  181. /** @defgroup LPTIM_LL_EC_TRIG_FILTER Trigger Filter
  182. * @{
  183. */
  184. #define LL_LPTIM_TRIG_FILTER_NONE 0x00000000U /*!<Any trigger active level change is considered as a valid trigger*/
  185. #define LL_LPTIM_TRIG_FILTER_2 LPTIM_CFGR_TRGFLT_0 /*!<Trigger active level change must be stable for at least 2 clock periods before it is considered as valid trigger*/
  186. #define LL_LPTIM_TRIG_FILTER_4 LPTIM_CFGR_TRGFLT_1 /*!<Trigger active level change must be stable for at least 4 clock periods before it is considered as valid trigger*/
  187. #define LL_LPTIM_TRIG_FILTER_8 LPTIM_CFGR_TRGFLT /*!<Trigger active level change must be stable for at least 8 clock periods before it is considered as valid trigger*/
  188. /**
  189. * @}
  190. */
  191. /** @defgroup LPTIM_LL_EC_TRIG_POLARITY Trigger Polarity
  192. * @{
  193. */
  194. #define LL_LPTIM_TRIG_POLARITY_RISING LPTIM_CFGR_TRIGEN_0 /*!<LPTIM counter starts when a rising edge is detected*/
  195. #define LL_LPTIM_TRIG_POLARITY_FALLING LPTIM_CFGR_TRIGEN_1 /*!<LPTIM counter starts when a falling edge is detected*/
  196. #define LL_LPTIM_TRIG_POLARITY_RISING_FALLING LPTIM_CFGR_TRIGEN /*!<LPTIM counter starts when a rising or a falling edge is detected*/
  197. /**
  198. * @}
  199. */
  200. /** @defgroup LPTIM_LL_EC_CLK_SOURCE Clock Source
  201. * @{
  202. */
  203. #define LL_LPTIM_CLK_SOURCE_INTERNAL 0x00000000U /*!<LPTIM is clocked by internal clock source (APB clock or any of the embedded oscillators)*/
  204. #define LL_LPTIM_CLK_SOURCE_EXTERNAL LPTIM_CFGR_CKSEL /*!<LPTIM is clocked by an external clock source through the LPTIM external Input1*/
  205. /**
  206. * @}
  207. */
  208. /** @defgroup LPTIM_LL_EC_CLK_FILTER Clock Filter
  209. * @{
  210. */
  211. #define LL_LPTIM_CLK_FILTER_NONE 0x00000000U /*!<Any external clock signal level change is considered as a valid transition*/
  212. #define LL_LPTIM_CLK_FILTER_2 LPTIM_CFGR_CKFLT_0 /*!<External clock signal level change must be stable for at least 2 clock periods before it is considered as valid transition*/
  213. #define LL_LPTIM_CLK_FILTER_4 LPTIM_CFGR_CKFLT_1 /*!<External clock signal level change must be stable for at least 4 clock periods before it is considered as valid transition*/
  214. #define LL_LPTIM_CLK_FILTER_8 LPTIM_CFGR_CKFLT /*!<External clock signal level change must be stable for at least 8 clock periods before it is considered as valid transition*/
  215. /**
  216. * @}
  217. */
  218. /** @defgroup LPTIM_LL_EC_CLK_POLARITY Clock Polarity
  219. * @{
  220. */
  221. #define LL_LPTIM_CLK_POLARITY_RISING 0x00000000U /*!< The rising edge is the active edge used for counting*/
  222. #define LL_LPTIM_CLK_POLARITY_FALLING LPTIM_CFGR_CKPOL_0 /*!< The falling edge is the active edge used for counting*/
  223. #define LL_LPTIM_CLK_POLARITY_RISING_FALLING LPTIM_CFGR_CKPOL_1 /*!< Both edges are active edges*/
  224. /**
  225. * @}
  226. */
  227. /** @defgroup LPTIM_LL_EC_ENCODER_MODE Encoder Mode
  228. * @{
  229. */
  230. #define LL_LPTIM_ENCODER_MODE_RISING 0x00000000U /*!< The rising edge is the active edge used for counting*/
  231. #define LL_LPTIM_ENCODER_MODE_FALLING LPTIM_CFGR_CKPOL_0 /*!< The falling edge is the active edge used for counting*/
  232. #define LL_LPTIM_ENCODER_MODE_RISING_FALLING LPTIM_CFGR_CKPOL_1 /*!< Both edges are active edges*/
  233. /**
  234. * @}
  235. */
  236. #if defined(LPTIM_OR_OR)
  237. /** @defgroup LPTIM_EC_INPUT1_SRC Input1 Source
  238. * @{
  239. */
  240. #define LL_LPTIM_INPUT1_SRC_GPIO 0x00000000U /*!< For LPTIM1 and LPTIM2 */
  241. #if defined(COMP1)
  242. #define LL_LPTIM_INPUT1_SRC_COMP1 LPTIM_OR_OR_0 /*!< For LPTIM1 and LPTIM2 */
  243. #endif
  244. #if defined(COMP2)
  245. #define LL_LPTIM_INPUT1_SRC_COMP2 LPTIM_OR_OR_1 /*!< For LPTIM2 */
  246. #define LL_LPTIM_INPUT1_SRC_COMP1_COMP2 LPTIM_OR_OR /*!< For LPTIM2 */
  247. #endif
  248. /**
  249. * @}
  250. */
  251. #endif /* LPTIM_OR_OR */
  252. #if defined(LPTIM_OR_OR)
  253. /** @defgroup LPTIM_EC_INPUT2_SRC Input2 Source
  254. * @{
  255. */
  256. #define LL_LPTIM_INPUT2_SRC_GPIO 0x00000000U /*!< For LPTIM1 */
  257. #if defined(COMP2)
  258. #define LL_LPTIM_INPUT2_SRC_COMP2 LPTIM_OR_OR_1 /*!< For LPTIM1 */
  259. #endif
  260. /**
  261. * @}
  262. */
  263. #endif /* LPTIM_OR_OR */
  264. /**
  265. * @}
  266. */
  267. /* Exported macro ------------------------------------------------------------*/
  268. /** @defgroup LPTIM_LL_Exported_Macros LPTIM Exported Macros
  269. * @{
  270. */
  271. /** @defgroup LPTIM_LL_EM_WRITE_READ Common Write and read registers Macros
  272. * @{
  273. */
  274. /**
  275. * @brief Write a value in LPTIM register
  276. * @param __INSTANCE__ LPTIM Instance
  277. * @param __REG__ Register to be written
  278. * @param __VALUE__ Value to be written in the register
  279. * @retval None
  280. */
  281. #define LL_LPTIM_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG((__INSTANCE__)->__REG__, (__VALUE__))
  282. /**
  283. * @brief Read a value in LPTIM register
  284. * @param __INSTANCE__ LPTIM Instance
  285. * @param __REG__ Register to be read
  286. * @retval Register value
  287. */
  288. #define LL_LPTIM_ReadReg(__INSTANCE__, __REG__) READ_REG((__INSTANCE__)->__REG__)
  289. /**
  290. * @}
  291. */
  292. /**
  293. * @}
  294. */
  295. /* Exported functions --------------------------------------------------------*/
  296. /** @defgroup LPTIM_LL_Exported_Functions LPTIM Exported Functions
  297. * @{
  298. */
  299. #if defined(USE_FULL_LL_DRIVER)
  300. /** @defgroup LPTIM_LL_EF_Init Initialisation and deinitialisation functions
  301. * @{
  302. */
  303. ErrorStatus LL_LPTIM_DeInit(LPTIM_TypeDef *LPTIMx);
  304. void LL_LPTIM_StructInit(LL_LPTIM_InitTypeDef *LPTIM_InitStruct);
  305. ErrorStatus LL_LPTIM_Init(LPTIM_TypeDef *LPTIMx, LL_LPTIM_InitTypeDef *LPTIM_InitStruct);
  306. void LL_LPTIM_Disable(LPTIM_TypeDef *LPTIMx);
  307. /**
  308. * @}
  309. */
  310. #endif /* USE_FULL_LL_DRIVER */
  311. /** @defgroup LPTIM_LL_EF_LPTIM_Configuration LPTIM Configuration
  312. * @{
  313. */
  314. /**
  315. * @brief Enable the LPTIM instance
  316. * @note After setting the ENABLE bit, a delay of two counter clock is needed
  317. * before the LPTIM instance is actually enabled.
  318. * @rmtoll CR ENABLE LL_LPTIM_Enable
  319. * @param LPTIMx Low-Power Timer instance
  320. * @retval None
  321. */
  322. __STATIC_INLINE void LL_LPTIM_Enable(LPTIM_TypeDef *LPTIMx)
  323. {
  324. SET_BIT(LPTIMx->CR, LPTIM_CR_ENABLE);
  325. }
  326. /**
  327. * @brief Indicates whether the LPTIM instance is enabled.
  328. * @rmtoll CR ENABLE LL_LPTIM_IsEnabled
  329. * @param LPTIMx Low-Power Timer instance
  330. * @retval State of bit (1 or 0).
  331. */
  332. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabled(LPTIM_TypeDef *LPTIMx)
  333. {
  334. return (((READ_BIT(LPTIMx->CR, LPTIM_CR_ENABLE) == LPTIM_CR_ENABLE) ? 1UL : 0UL));
  335. }
  336. /**
  337. * @brief Starts the LPTIM counter in the desired mode.
  338. * @note LPTIM instance must be enabled before starting the counter.
  339. * @note It is possible to change on the fly from One Shot mode to
  340. * Continuous mode.
  341. * @rmtoll CR CNTSTRT LL_LPTIM_StartCounter\n
  342. * CR SNGSTRT LL_LPTIM_StartCounter
  343. * @param LPTIMx Low-Power Timer instance
  344. * @param OperatingMode This parameter can be one of the following values:
  345. * @arg @ref LL_LPTIM_OPERATING_MODE_CONTINUOUS
  346. * @arg @ref LL_LPTIM_OPERATING_MODE_ONESHOT
  347. * @retval None
  348. */
  349. __STATIC_INLINE void LL_LPTIM_StartCounter(LPTIM_TypeDef *LPTIMx, uint32_t OperatingMode)
  350. {
  351. MODIFY_REG(LPTIMx->CR, LPTIM_CR_CNTSTRT | LPTIM_CR_SNGSTRT, OperatingMode);
  352. }
  353. /**
  354. * @brief Enable reset after read.
  355. * @note After calling this function any read access to LPTIM_CNT
  356. * register will asynchronously reset the LPTIM_CNT register content.
  357. * @rmtoll CR RSTARE LL_LPTIM_EnableResetAfterRead
  358. * @param LPTIMx Low-Power Timer instance
  359. * @retval None
  360. */
  361. __STATIC_INLINE void LL_LPTIM_EnableResetAfterRead(LPTIM_TypeDef *LPTIMx)
  362. {
  363. SET_BIT(LPTIMx->CR, LPTIM_CR_RSTARE);
  364. }
  365. /**
  366. * @brief Disable reset after read.
  367. * @rmtoll CR RSTARE LL_LPTIM_DisableResetAfterRead
  368. * @param LPTIMx Low-Power Timer instance
  369. * @retval None
  370. */
  371. __STATIC_INLINE void LL_LPTIM_DisableResetAfterRead(LPTIM_TypeDef *LPTIMx)
  372. {
  373. CLEAR_BIT(LPTIMx->CR, LPTIM_CR_RSTARE);
  374. }
  375. /**
  376. * @brief Indicate whether the reset after read feature is enabled.
  377. * @rmtoll CR RSTARE LL_LPTIM_IsEnabledResetAfterRead
  378. * @param LPTIMx Low-Power Timer instance
  379. * @retval State of bit (1 or 0).
  380. */
  381. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledResetAfterRead(LPTIM_TypeDef *LPTIMx)
  382. {
  383. return (((READ_BIT(LPTIMx->CR, LPTIM_CR_RSTARE) == LPTIM_CR_RSTARE) ? 1UL : 0UL));
  384. }
  385. /**
  386. * @brief Reset of the LPTIM_CNT counter register (synchronous).
  387. * @note Due to the synchronous nature of this reset, it only takes
  388. * place after a synchronization delay of 3 LPTIM core clock cycles
  389. * (LPTIM core clock may be different from APB clock).
  390. * @note COUNTRST is automatically cleared by hardware
  391. * @rmtoll CR COUNTRST LL_LPTIM_ResetCounter\n
  392. * @param LPTIMx Low-Power Timer instance
  393. * @retval None
  394. */
  395. __STATIC_INLINE void LL_LPTIM_ResetCounter(LPTIM_TypeDef *LPTIMx)
  396. {
  397. SET_BIT(LPTIMx->CR, LPTIM_CR_COUNTRST);
  398. }
  399. /**
  400. * @brief Set the LPTIM registers update mode (enable/disable register preload)
  401. * @note This function must be called when the LPTIM instance is disabled.
  402. * @rmtoll CFGR PRELOAD LL_LPTIM_SetUpdateMode
  403. * @param LPTIMx Low-Power Timer instance
  404. * @param UpdateMode This parameter can be one of the following values:
  405. * @arg @ref LL_LPTIM_UPDATE_MODE_IMMEDIATE
  406. * @arg @ref LL_LPTIM_UPDATE_MODE_ENDOFPERIOD
  407. * @retval None
  408. */
  409. __STATIC_INLINE void LL_LPTIM_SetUpdateMode(LPTIM_TypeDef *LPTIMx, uint32_t UpdateMode)
  410. {
  411. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_PRELOAD, UpdateMode);
  412. }
  413. /**
  414. * @brief Get the LPTIM registers update mode
  415. * @rmtoll CFGR PRELOAD LL_LPTIM_GetUpdateMode
  416. * @param LPTIMx Low-Power Timer instance
  417. * @retval Returned value can be one of the following values:
  418. * @arg @ref LL_LPTIM_UPDATE_MODE_IMMEDIATE
  419. * @arg @ref LL_LPTIM_UPDATE_MODE_ENDOFPERIOD
  420. */
  421. __STATIC_INLINE uint32_t LL_LPTIM_GetUpdateMode(LPTIM_TypeDef *LPTIMx)
  422. {
  423. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_PRELOAD));
  424. }
  425. /**
  426. * @brief Set the auto reload value
  427. * @note The LPTIMx_ARR register content must only be modified when the LPTIM is enabled
  428. * @note After a write to the LPTIMx_ARR register a new write operation to the
  429. * same register can only be performed when the previous write operation
  430. * is completed. Any successive write before the ARROK flag is set, will
  431. * lead to unpredictable results.
  432. * @note autoreload value be strictly greater than the compare value.
  433. * @rmtoll ARR ARR LL_LPTIM_SetAutoReload
  434. * @param LPTIMx Low-Power Timer instance
  435. * @param AutoReload Value between Min_Data=0x00 and Max_Data=0xFFFF
  436. * @retval None
  437. */
  438. __STATIC_INLINE void LL_LPTIM_SetAutoReload(LPTIM_TypeDef *LPTIMx, uint32_t AutoReload)
  439. {
  440. MODIFY_REG(LPTIMx->ARR, LPTIM_ARR_ARR, AutoReload);
  441. }
  442. /**
  443. * @brief Get actual auto reload value
  444. * @rmtoll ARR ARR LL_LPTIM_GetAutoReload
  445. * @param LPTIMx Low-Power Timer instance
  446. * @retval AutoReload Value between Min_Data=0x00 and Max_Data=0xFFFF
  447. */
  448. __STATIC_INLINE uint32_t LL_LPTIM_GetAutoReload(LPTIM_TypeDef *LPTIMx)
  449. {
  450. return (uint32_t)(READ_BIT(LPTIMx->ARR, LPTIM_ARR_ARR));
  451. }
  452. /**
  453. * @brief Set the compare value
  454. * @note After a write to the LPTIMx_CMP register a new write operation to the
  455. * same register can only be performed when the previous write operation
  456. * is completed. Any successive write before the CMPOK flag is set, will
  457. * lead to unpredictable results.
  458. * @rmtoll CMP CMP LL_LPTIM_SetCompare
  459. * @param LPTIMx Low-Power Timer instance
  460. * @param CompareValue Value between Min_Data=0x00 and Max_Data=0xFFFF
  461. * @retval None
  462. */
  463. __STATIC_INLINE void LL_LPTIM_SetCompare(LPTIM_TypeDef *LPTIMx, uint32_t CompareValue)
  464. {
  465. MODIFY_REG(LPTIMx->CMP, LPTIM_CMP_CMP, CompareValue);
  466. }
  467. /**
  468. * @brief Get actual compare value
  469. * @rmtoll CMP CMP LL_LPTIM_GetCompare
  470. * @param LPTIMx Low-Power Timer instance
  471. * @retval CompareValue Value between Min_Data=0x00 and Max_Data=0xFFFF
  472. */
  473. __STATIC_INLINE uint32_t LL_LPTIM_GetCompare(LPTIM_TypeDef *LPTIMx)
  474. {
  475. return (uint32_t)(READ_BIT(LPTIMx->CMP, LPTIM_CMP_CMP));
  476. }
  477. /**
  478. * @brief Get actual counter value
  479. * @note When the LPTIM instance is running with an asynchronous clock, reading
  480. * the LPTIMx_CNT register may return unreliable values. So in this case
  481. * it is necessary to perform two consecutive read accesses and verify
  482. * that the two returned values are identical.
  483. * @rmtoll CNT CNT LL_LPTIM_GetCounter
  484. * @param LPTIMx Low-Power Timer instance
  485. * @retval Counter value
  486. */
  487. __STATIC_INLINE uint32_t LL_LPTIM_GetCounter(LPTIM_TypeDef *LPTIMx)
  488. {
  489. return (uint32_t)(READ_BIT(LPTIMx->CNT, LPTIM_CNT_CNT));
  490. }
  491. /**
  492. * @brief Set the counter mode (selection of the LPTIM counter clock source).
  493. * @note The counter mode can be set only when the LPTIM instance is disabled.
  494. * @rmtoll CFGR COUNTMODE LL_LPTIM_SetCounterMode
  495. * @param LPTIMx Low-Power Timer instance
  496. * @param CounterMode This parameter can be one of the following values:
  497. * @arg @ref LL_LPTIM_COUNTER_MODE_INTERNAL
  498. * @arg @ref LL_LPTIM_COUNTER_MODE_EXTERNAL
  499. * @retval None
  500. */
  501. __STATIC_INLINE void LL_LPTIM_SetCounterMode(LPTIM_TypeDef *LPTIMx, uint32_t CounterMode)
  502. {
  503. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_COUNTMODE, CounterMode);
  504. }
  505. /**
  506. * @brief Get the counter mode
  507. * @rmtoll CFGR COUNTMODE LL_LPTIM_GetCounterMode
  508. * @param LPTIMx Low-Power Timer instance
  509. * @retval Returned value can be one of the following values:
  510. * @arg @ref LL_LPTIM_COUNTER_MODE_INTERNAL
  511. * @arg @ref LL_LPTIM_COUNTER_MODE_EXTERNAL
  512. */
  513. __STATIC_INLINE uint32_t LL_LPTIM_GetCounterMode(LPTIM_TypeDef *LPTIMx)
  514. {
  515. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_COUNTMODE));
  516. }
  517. /**
  518. * @brief Configure the LPTIM instance output (LPTIMx_OUT)
  519. * @note This function must be called when the LPTIM instance is disabled.
  520. * @note Regarding the LPTIM output polarity the change takes effect
  521. * immediately, so the output default value will change immediately after
  522. * the polarity is re-configured, even before the timer is enabled.
  523. * @rmtoll CFGR WAVE LL_LPTIM_ConfigOutput\n
  524. * CFGR WAVPOL LL_LPTIM_ConfigOutput
  525. * @param LPTIMx Low-Power Timer instance
  526. * @param Waveform This parameter can be one of the following values:
  527. * @arg @ref LL_LPTIM_OUTPUT_WAVEFORM_PWM
  528. * @arg @ref LL_LPTIM_OUTPUT_WAVEFORM_SETONCE
  529. * @param Polarity This parameter can be one of the following values:
  530. * @arg @ref LL_LPTIM_OUTPUT_POLARITY_REGULAR
  531. * @arg @ref LL_LPTIM_OUTPUT_POLARITY_INVERSE
  532. * @retval None
  533. */
  534. __STATIC_INLINE void LL_LPTIM_ConfigOutput(LPTIM_TypeDef *LPTIMx, uint32_t Waveform, uint32_t Polarity)
  535. {
  536. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_WAVE | LPTIM_CFGR_WAVPOL, Waveform | Polarity);
  537. }
  538. /**
  539. * @brief Set waveform shape
  540. * @rmtoll CFGR WAVE LL_LPTIM_SetWaveform
  541. * @param LPTIMx Low-Power Timer instance
  542. * @param Waveform This parameter can be one of the following values:
  543. * @arg @ref LL_LPTIM_OUTPUT_WAVEFORM_PWM
  544. * @arg @ref LL_LPTIM_OUTPUT_WAVEFORM_SETONCE
  545. * @retval None
  546. */
  547. __STATIC_INLINE void LL_LPTIM_SetWaveform(LPTIM_TypeDef *LPTIMx, uint32_t Waveform)
  548. {
  549. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_WAVE, Waveform);
  550. }
  551. /**
  552. * @brief Get actual waveform shape
  553. * @rmtoll CFGR WAVE LL_LPTIM_GetWaveform
  554. * @param LPTIMx Low-Power Timer instance
  555. * @retval Returned value can be one of the following values:
  556. * @arg @ref LL_LPTIM_OUTPUT_WAVEFORM_PWM
  557. * @arg @ref LL_LPTIM_OUTPUT_WAVEFORM_SETONCE
  558. */
  559. __STATIC_INLINE uint32_t LL_LPTIM_GetWaveform(LPTIM_TypeDef *LPTIMx)
  560. {
  561. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_WAVE));
  562. }
  563. /**
  564. * @brief Set output polarity
  565. * @rmtoll CFGR WAVPOL LL_LPTIM_SetPolarity
  566. * @param LPTIMx Low-Power Timer instance
  567. * @param Polarity This parameter can be one of the following values:
  568. * @arg @ref LL_LPTIM_OUTPUT_POLARITY_REGULAR
  569. * @arg @ref LL_LPTIM_OUTPUT_POLARITY_INVERSE
  570. * @retval None
  571. */
  572. __STATIC_INLINE void LL_LPTIM_SetPolarity(LPTIM_TypeDef *LPTIMx, uint32_t Polarity)
  573. {
  574. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_WAVPOL, Polarity);
  575. }
  576. /**
  577. * @brief Get actual output polarity
  578. * @rmtoll CFGR WAVPOL LL_LPTIM_GetPolarity
  579. * @param LPTIMx Low-Power Timer instance
  580. * @retval Returned value can be one of the following values:
  581. * @arg @ref LL_LPTIM_OUTPUT_POLARITY_REGULAR
  582. * @arg @ref LL_LPTIM_OUTPUT_POLARITY_INVERSE
  583. */
  584. __STATIC_INLINE uint32_t LL_LPTIM_GetPolarity(LPTIM_TypeDef *LPTIMx)
  585. {
  586. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_WAVPOL));
  587. }
  588. /**
  589. * @brief Set actual prescaler division ratio.
  590. * @note This function must be called when the LPTIM instance is disabled.
  591. * @note When the LPTIM is configured to be clocked by an internal clock source
  592. * and the LPTIM counter is configured to be updated by active edges
  593. * detected on the LPTIM external Input1, the internal clock provided to
  594. * the LPTIM must be not be prescaled.
  595. * @rmtoll CFGR PRESC LL_LPTIM_SetPrescaler
  596. * @param LPTIMx Low-Power Timer instance
  597. * @param Prescaler This parameter can be one of the following values:
  598. * @arg @ref LL_LPTIM_PRESCALER_DIV1
  599. * @arg @ref LL_LPTIM_PRESCALER_DIV2
  600. * @arg @ref LL_LPTIM_PRESCALER_DIV4
  601. * @arg @ref LL_LPTIM_PRESCALER_DIV8
  602. * @arg @ref LL_LPTIM_PRESCALER_DIV16
  603. * @arg @ref LL_LPTIM_PRESCALER_DIV32
  604. * @arg @ref LL_LPTIM_PRESCALER_DIV64
  605. * @arg @ref LL_LPTIM_PRESCALER_DIV128
  606. * @retval None
  607. */
  608. __STATIC_INLINE void LL_LPTIM_SetPrescaler(LPTIM_TypeDef *LPTIMx, uint32_t Prescaler)
  609. {
  610. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_PRESC, Prescaler);
  611. }
  612. /**
  613. * @brief Get actual prescaler division ratio.
  614. * @rmtoll CFGR PRESC LL_LPTIM_GetPrescaler
  615. * @param LPTIMx Low-Power Timer instance
  616. * @retval Returned value can be one of the following values:
  617. * @arg @ref LL_LPTIM_PRESCALER_DIV1
  618. * @arg @ref LL_LPTIM_PRESCALER_DIV2
  619. * @arg @ref LL_LPTIM_PRESCALER_DIV4
  620. * @arg @ref LL_LPTIM_PRESCALER_DIV8
  621. * @arg @ref LL_LPTIM_PRESCALER_DIV16
  622. * @arg @ref LL_LPTIM_PRESCALER_DIV32
  623. * @arg @ref LL_LPTIM_PRESCALER_DIV64
  624. * @arg @ref LL_LPTIM_PRESCALER_DIV128
  625. */
  626. __STATIC_INLINE uint32_t LL_LPTIM_GetPrescaler(LPTIM_TypeDef *LPTIMx)
  627. {
  628. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_PRESC));
  629. }
  630. #if defined(LPTIM_OR_OR)
  631. /**
  632. * @brief Set LPTIM input 1 source (default GPIO).
  633. * @rmtoll OR OR LL_LPTIM_SetInput1Src
  634. * @param LPTIMx Low-Power Timer instance
  635. * @param Src This parameter can be one of the following values:
  636. * @arg @ref LL_LPTIM_INPUT1_SRC_GPIO
  637. * @arg @ref LL_LPTIM_INPUT1_SRC_COMP1
  638. * @arg @ref LL_LPTIM_INPUT1_SRC_COMP2 (*)
  639. * @arg @ref LL_LPTIM_INPUT1_SRC_COMP1_COMP2 (*)
  640. * (*) Value not defined for all devices
  641. * @retval None
  642. */
  643. __STATIC_INLINE void LL_LPTIM_SetInput1Src(LPTIM_TypeDef *LPTIMx, uint32_t Src)
  644. {
  645. MODIFY_REG(LPTIMx->OR, LPTIM_OR_OR, Src);
  646. }
  647. #endif /* LPTIM_OR_OR */
  648. #if defined(LPTIM_OR_OR)
  649. /**
  650. * @brief Set LPTIM input 2 source (default GPIO).
  651. * @rmtoll OR OR LL_LPTIM_SetInput2Src
  652. * @param LPTIMx Low-Power Timer instance
  653. * @param Src This parameter can be one of the following values:
  654. * @arg @ref LL_LPTIM_INPUT2_SRC_GPIO
  655. * @arg @ref LL_LPTIM_INPUT2_SRC_COMP2
  656. * @retval None
  657. */
  658. __STATIC_INLINE void LL_LPTIM_SetInput2Src(LPTIM_TypeDef *LPTIMx, uint32_t Src)
  659. {
  660. MODIFY_REG(LPTIMx->OR, LPTIM_OR_OR, Src);
  661. }
  662. #endif /* LPTIM_OR_OR */
  663. /**
  664. * @}
  665. */
  666. /** @defgroup LPTIM_LL_EF_Trigger_Configuration Trigger Configuration
  667. * @{
  668. */
  669. /**
  670. * @brief Enable the timeout function
  671. * @note This function must be called when the LPTIM instance is disabled.
  672. * @note The first trigger event will start the timer, any successive trigger
  673. * event will reset the counter and the timer will restart.
  674. * @note The timeout value corresponds to the compare value; if no trigger
  675. * occurs within the expected time frame, the MCU is waked-up by the
  676. * compare match event.
  677. * @rmtoll CFGR TIMOUT LL_LPTIM_EnableTimeout
  678. * @param LPTIMx Low-Power Timer instance
  679. * @retval None
  680. */
  681. __STATIC_INLINE void LL_LPTIM_EnableTimeout(LPTIM_TypeDef *LPTIMx)
  682. {
  683. SET_BIT(LPTIMx->CFGR, LPTIM_CFGR_TIMOUT);
  684. }
  685. /**
  686. * @brief Disable the timeout function
  687. * @note This function must be called when the LPTIM instance is disabled.
  688. * @note A trigger event arriving when the timer is already started will be
  689. * ignored.
  690. * @rmtoll CFGR TIMOUT LL_LPTIM_DisableTimeout
  691. * @param LPTIMx Low-Power Timer instance
  692. * @retval None
  693. */
  694. __STATIC_INLINE void LL_LPTIM_DisableTimeout(LPTIM_TypeDef *LPTIMx)
  695. {
  696. CLEAR_BIT(LPTIMx->CFGR, LPTIM_CFGR_TIMOUT);
  697. }
  698. /**
  699. * @brief Indicate whether the timeout function is enabled.
  700. * @rmtoll CFGR TIMOUT LL_LPTIM_IsEnabledTimeout
  701. * @param LPTIMx Low-Power Timer instance
  702. * @retval State of bit (1 or 0).
  703. */
  704. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledTimeout(LPTIM_TypeDef *LPTIMx)
  705. {
  706. return (((READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_TIMOUT) == LPTIM_CFGR_TIMOUT) ? 1UL : 0UL));
  707. }
  708. /**
  709. * @brief Start the LPTIM counter
  710. * @note This function must be called when the LPTIM instance is disabled.
  711. * @rmtoll CFGR TRIGEN LL_LPTIM_TrigSw
  712. * @param LPTIMx Low-Power Timer instance
  713. * @retval None
  714. */
  715. __STATIC_INLINE void LL_LPTIM_TrigSw(LPTIM_TypeDef *LPTIMx)
  716. {
  717. CLEAR_BIT(LPTIMx->CFGR, LPTIM_CFGR_TRIGEN);
  718. }
  719. /**
  720. * @brief Configure the external trigger used as a trigger event for the LPTIM.
  721. * @note This function must be called when the LPTIM instance is disabled.
  722. * @note An internal clock source must be present when a digital filter is
  723. * required for the trigger.
  724. * @rmtoll CFGR TRIGSEL LL_LPTIM_ConfigTrigger\n
  725. * CFGR TRGFLT LL_LPTIM_ConfigTrigger\n
  726. * CFGR TRIGEN LL_LPTIM_ConfigTrigger
  727. * @param LPTIMx Low-Power Timer instance
  728. * @param Source This parameter can be one of the following values:
  729. * @arg @ref LL_LPTIM_TRIG_SOURCE_GPIO
  730. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCALARMA
  731. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCALARMB
  732. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCTAMP1 (*)
  733. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCTAMP2
  734. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCTAMP3 (*)
  735. * @arg @ref LL_LPTIM_TRIG_SOURCE_COMP1 (*)
  736. * @arg @ref LL_LPTIM_TRIG_SOURCE_COMP2 (*)
  737. *
  738. * (*) Value not defined in all devices. \n
  739. *
  740. * @param Filter This parameter can be one of the following values:
  741. * @arg @ref LL_LPTIM_TRIG_FILTER_NONE
  742. * @arg @ref LL_LPTIM_TRIG_FILTER_2
  743. * @arg @ref LL_LPTIM_TRIG_FILTER_4
  744. * @arg @ref LL_LPTIM_TRIG_FILTER_8
  745. * @param Polarity This parameter can be one of the following values:
  746. * @arg @ref LL_LPTIM_TRIG_POLARITY_RISING
  747. * @arg @ref LL_LPTIM_TRIG_POLARITY_FALLING
  748. * @arg @ref LL_LPTIM_TRIG_POLARITY_RISING_FALLING
  749. * @retval None
  750. */
  751. __STATIC_INLINE void LL_LPTIM_ConfigTrigger(LPTIM_TypeDef *LPTIMx, uint32_t Source, uint32_t Filter, uint32_t Polarity)
  752. {
  753. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_TRIGSEL | LPTIM_CFGR_TRGFLT | LPTIM_CFGR_TRIGEN, Source | Filter | Polarity);
  754. }
  755. /**
  756. * @brief Get actual external trigger source.
  757. * @rmtoll CFGR TRIGSEL LL_LPTIM_GetTriggerSource
  758. * @param LPTIMx Low-Power Timer instance
  759. * @retval Returned value can be one of the following values:
  760. * @arg @ref LL_LPTIM_TRIG_SOURCE_GPIO
  761. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCALARMA
  762. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCALARMB
  763. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCTAMP1 (*)
  764. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCTAMP2
  765. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCTAMP3 (*)
  766. * @arg @ref LL_LPTIM_TRIG_SOURCE_COMP1 (*)
  767. * @arg @ref LL_LPTIM_TRIG_SOURCE_COMP2 (*)
  768. *
  769. * (*) Value not defined in all devices. \n
  770. *
  771. */
  772. __STATIC_INLINE uint32_t LL_LPTIM_GetTriggerSource(LPTIM_TypeDef *LPTIMx)
  773. {
  774. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_TRIGSEL));
  775. }
  776. /**
  777. * @brief Get actual external trigger filter.
  778. * @rmtoll CFGR TRGFLT LL_LPTIM_GetTriggerFilter
  779. * @param LPTIMx Low-Power Timer instance
  780. * @retval Returned value can be one of the following values:
  781. * @arg @ref LL_LPTIM_TRIG_FILTER_NONE
  782. * @arg @ref LL_LPTIM_TRIG_FILTER_2
  783. * @arg @ref LL_LPTIM_TRIG_FILTER_4
  784. * @arg @ref LL_LPTIM_TRIG_FILTER_8
  785. */
  786. __STATIC_INLINE uint32_t LL_LPTIM_GetTriggerFilter(LPTIM_TypeDef *LPTIMx)
  787. {
  788. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_TRGFLT));
  789. }
  790. /**
  791. * @brief Get actual external trigger polarity.
  792. * @rmtoll CFGR TRIGEN LL_LPTIM_GetTriggerPolarity
  793. * @param LPTIMx Low-Power Timer instance
  794. * @retval Returned value can be one of the following values:
  795. * @arg @ref LL_LPTIM_TRIG_POLARITY_RISING
  796. * @arg @ref LL_LPTIM_TRIG_POLARITY_FALLING
  797. * @arg @ref LL_LPTIM_TRIG_POLARITY_RISING_FALLING
  798. */
  799. __STATIC_INLINE uint32_t LL_LPTIM_GetTriggerPolarity(LPTIM_TypeDef *LPTIMx)
  800. {
  801. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_TRIGEN));
  802. }
  803. /**
  804. * @}
  805. */
  806. /** @defgroup LPTIM_LL_EF_Clock_Configuration Clock Configuration
  807. * @{
  808. */
  809. /**
  810. * @brief Set the source of the clock used by the LPTIM instance.
  811. * @note This function must be called when the LPTIM instance is disabled.
  812. * @rmtoll CFGR CKSEL LL_LPTIM_SetClockSource
  813. * @param LPTIMx Low-Power Timer instance
  814. * @param ClockSource This parameter can be one of the following values:
  815. * @arg @ref LL_LPTIM_CLK_SOURCE_INTERNAL
  816. * @arg @ref LL_LPTIM_CLK_SOURCE_EXTERNAL
  817. * @retval None
  818. */
  819. __STATIC_INLINE void LL_LPTIM_SetClockSource(LPTIM_TypeDef *LPTIMx, uint32_t ClockSource)
  820. {
  821. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_CKSEL, ClockSource);
  822. }
  823. /**
  824. * @brief Get actual LPTIM instance clock source.
  825. * @rmtoll CFGR CKSEL LL_LPTIM_GetClockSource
  826. * @param LPTIMx Low-Power Timer instance
  827. * @retval Returned value can be one of the following values:
  828. * @arg @ref LL_LPTIM_CLK_SOURCE_INTERNAL
  829. * @arg @ref LL_LPTIM_CLK_SOURCE_EXTERNAL
  830. */
  831. __STATIC_INLINE uint32_t LL_LPTIM_GetClockSource(LPTIM_TypeDef *LPTIMx)
  832. {
  833. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_CKSEL));
  834. }
  835. /**
  836. * @brief Configure the active edge or edges used by the counter when the LPTIM is clocked by an external clock source.
  837. * @note This function must be called when the LPTIM instance is disabled.
  838. * @note When both external clock signal edges are considered active ones,
  839. * the LPTIM must also be clocked by an internal clock source with a
  840. * frequency equal to at least four times the external clock frequency.
  841. * @note An internal clock source must be present when a digital filter is
  842. * required for external clock.
  843. * @rmtoll CFGR CKFLT LL_LPTIM_ConfigClock\n
  844. * CFGR CKPOL LL_LPTIM_ConfigClock
  845. * @param LPTIMx Low-Power Timer instance
  846. * @param ClockFilter This parameter can be one of the following values:
  847. * @arg @ref LL_LPTIM_CLK_FILTER_NONE
  848. * @arg @ref LL_LPTIM_CLK_FILTER_2
  849. * @arg @ref LL_LPTIM_CLK_FILTER_4
  850. * @arg @ref LL_LPTIM_CLK_FILTER_8
  851. * @param ClockPolarity This parameter can be one of the following values:
  852. * @arg @ref LL_LPTIM_CLK_POLARITY_RISING
  853. * @arg @ref LL_LPTIM_CLK_POLARITY_FALLING
  854. * @arg @ref LL_LPTIM_CLK_POLARITY_RISING_FALLING
  855. * @retval None
  856. */
  857. __STATIC_INLINE void LL_LPTIM_ConfigClock(LPTIM_TypeDef *LPTIMx, uint32_t ClockFilter, uint32_t ClockPolarity)
  858. {
  859. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_CKFLT | LPTIM_CFGR_CKPOL, ClockFilter | ClockPolarity);
  860. }
  861. /**
  862. * @brief Get actual clock polarity
  863. * @rmtoll CFGR CKPOL LL_LPTIM_GetClockPolarity
  864. * @param LPTIMx Low-Power Timer instance
  865. * @retval Returned value can be one of the following values:
  866. * @arg @ref LL_LPTIM_CLK_POLARITY_RISING
  867. * @arg @ref LL_LPTIM_CLK_POLARITY_FALLING
  868. * @arg @ref LL_LPTIM_CLK_POLARITY_RISING_FALLING
  869. */
  870. __STATIC_INLINE uint32_t LL_LPTIM_GetClockPolarity(LPTIM_TypeDef *LPTIMx)
  871. {
  872. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_CKPOL));
  873. }
  874. /**
  875. * @brief Get actual clock digital filter
  876. * @rmtoll CFGR CKFLT LL_LPTIM_GetClockFilter
  877. * @param LPTIMx Low-Power Timer instance
  878. * @retval Returned value can be one of the following values:
  879. * @arg @ref LL_LPTIM_CLK_FILTER_NONE
  880. * @arg @ref LL_LPTIM_CLK_FILTER_2
  881. * @arg @ref LL_LPTIM_CLK_FILTER_4
  882. * @arg @ref LL_LPTIM_CLK_FILTER_8
  883. */
  884. __STATIC_INLINE uint32_t LL_LPTIM_GetClockFilter(LPTIM_TypeDef *LPTIMx)
  885. {
  886. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_CKFLT));
  887. }
  888. /**
  889. * @}
  890. */
  891. /** @defgroup LPTIM_LL_EF_Encoder_Mode Encoder Mode
  892. * @{
  893. */
  894. /**
  895. * @brief Configure the encoder mode.
  896. * @note This function must be called when the LPTIM instance is disabled.
  897. * @rmtoll CFGR CKPOL LL_LPTIM_SetEncoderMode
  898. * @param LPTIMx Low-Power Timer instance
  899. * @param EncoderMode This parameter can be one of the following values:
  900. * @arg @ref LL_LPTIM_ENCODER_MODE_RISING
  901. * @arg @ref LL_LPTIM_ENCODER_MODE_FALLING
  902. * @arg @ref LL_LPTIM_ENCODER_MODE_RISING_FALLING
  903. * @retval None
  904. */
  905. __STATIC_INLINE void LL_LPTIM_SetEncoderMode(LPTIM_TypeDef *LPTIMx, uint32_t EncoderMode)
  906. {
  907. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_CKPOL, EncoderMode);
  908. }
  909. /**
  910. * @brief Get actual encoder mode.
  911. * @rmtoll CFGR CKPOL LL_LPTIM_GetEncoderMode
  912. * @param LPTIMx Low-Power Timer instance
  913. * @retval Returned value can be one of the following values:
  914. * @arg @ref LL_LPTIM_ENCODER_MODE_RISING
  915. * @arg @ref LL_LPTIM_ENCODER_MODE_FALLING
  916. * @arg @ref LL_LPTIM_ENCODER_MODE_RISING_FALLING
  917. */
  918. __STATIC_INLINE uint32_t LL_LPTIM_GetEncoderMode(LPTIM_TypeDef *LPTIMx)
  919. {
  920. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_CKPOL));
  921. }
  922. /**
  923. * @brief Enable the encoder mode
  924. * @note This function must be called when the LPTIM instance is disabled.
  925. * @note In this mode the LPTIM instance must be clocked by an internal clock
  926. * source. Also, the prescaler division ratio must be equal to 1.
  927. * @note LPTIM instance must be configured in continuous mode prior enabling
  928. * the encoder mode.
  929. * @rmtoll CFGR ENC LL_LPTIM_EnableEncoderMode
  930. * @param LPTIMx Low-Power Timer instance
  931. * @retval None
  932. */
  933. __STATIC_INLINE void LL_LPTIM_EnableEncoderMode(LPTIM_TypeDef *LPTIMx)
  934. {
  935. SET_BIT(LPTIMx->CFGR, LPTIM_CFGR_ENC);
  936. }
  937. /**
  938. * @brief Disable the encoder mode
  939. * @note This function must be called when the LPTIM instance is disabled.
  940. * @rmtoll CFGR ENC LL_LPTIM_DisableEncoderMode
  941. * @param LPTIMx Low-Power Timer instance
  942. * @retval None
  943. */
  944. __STATIC_INLINE void LL_LPTIM_DisableEncoderMode(LPTIM_TypeDef *LPTIMx)
  945. {
  946. CLEAR_BIT(LPTIMx->CFGR, LPTIM_CFGR_ENC);
  947. }
  948. /**
  949. * @brief Indicates whether the LPTIM operates in encoder mode.
  950. * @rmtoll CFGR ENC LL_LPTIM_IsEnabledEncoderMode
  951. * @param LPTIMx Low-Power Timer instance
  952. * @retval State of bit (1 or 0).
  953. */
  954. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledEncoderMode(LPTIM_TypeDef *LPTIMx)
  955. {
  956. return (((READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_ENC) == LPTIM_CFGR_ENC) ? 1UL : 0UL));
  957. }
  958. /**
  959. * @}
  960. */
  961. /** @defgroup LPTIM_LL_EF_FLAG_Management FLAG Management
  962. * @{
  963. */
  964. /**
  965. * @brief Clear the compare match flag (CMPMCF)
  966. * @rmtoll ICR CMPMCF LL_LPTIM_ClearFLAG_CMPM
  967. * @param LPTIMx Low-Power Timer instance
  968. * @retval None
  969. */
  970. __STATIC_INLINE void LL_LPTIM_ClearFLAG_CMPM(LPTIM_TypeDef *LPTIMx)
  971. {
  972. SET_BIT(LPTIMx->ICR, LPTIM_ICR_CMPMCF);
  973. }
  974. /**
  975. * @brief Inform application whether a compare match interrupt has occurred.
  976. * @rmtoll ISR CMPM LL_LPTIM_IsActiveFlag_CMPM
  977. * @param LPTIMx Low-Power Timer instance
  978. * @retval State of bit (1 or 0).
  979. */
  980. __STATIC_INLINE uint32_t LL_LPTIM_IsActiveFlag_CMPM(LPTIM_TypeDef *LPTIMx)
  981. {
  982. return (((READ_BIT(LPTIMx->ISR, LPTIM_ISR_CMPM) == LPTIM_ISR_CMPM) ? 1UL : 0UL));
  983. }
  984. /**
  985. * @brief Clear the autoreload match flag (ARRMCF)
  986. * @rmtoll ICR ARRMCF LL_LPTIM_ClearFLAG_ARRM
  987. * @param LPTIMx Low-Power Timer instance
  988. * @retval None
  989. */
  990. __STATIC_INLINE void LL_LPTIM_ClearFLAG_ARRM(LPTIM_TypeDef *LPTIMx)
  991. {
  992. SET_BIT(LPTIMx->ICR, LPTIM_ICR_ARRMCF);
  993. }
  994. /**
  995. * @brief Inform application whether a autoreload match interrupt has occurred.
  996. * @rmtoll ISR ARRM LL_LPTIM_IsActiveFlag_ARRM
  997. * @param LPTIMx Low-Power Timer instance
  998. * @retval State of bit (1 or 0).
  999. */
  1000. __STATIC_INLINE uint32_t LL_LPTIM_IsActiveFlag_ARRM(LPTIM_TypeDef *LPTIMx)
  1001. {
  1002. return (((READ_BIT(LPTIMx->ISR, LPTIM_ISR_ARRM) == LPTIM_ISR_ARRM) ? 1UL : 0UL));
  1003. }
  1004. /**
  1005. * @brief Clear the external trigger valid edge flag(EXTTRIGCF).
  1006. * @rmtoll ICR EXTTRIGCF LL_LPTIM_ClearFlag_EXTTRIG
  1007. * @param LPTIMx Low-Power Timer instance
  1008. * @retval None
  1009. */
  1010. __STATIC_INLINE void LL_LPTIM_ClearFlag_EXTTRIG(LPTIM_TypeDef *LPTIMx)
  1011. {
  1012. SET_BIT(LPTIMx->ICR, LPTIM_ICR_EXTTRIGCF);
  1013. }
  1014. /**
  1015. * @brief Inform application whether a valid edge on the selected external trigger input has occurred.
  1016. * @rmtoll ISR EXTTRIG LL_LPTIM_IsActiveFlag_EXTTRIG
  1017. * @param LPTIMx Low-Power Timer instance
  1018. * @retval State of bit (1 or 0).
  1019. */
  1020. __STATIC_INLINE uint32_t LL_LPTIM_IsActiveFlag_EXTTRIG(LPTIM_TypeDef *LPTIMx)
  1021. {
  1022. return (((READ_BIT(LPTIMx->ISR, LPTIM_ISR_EXTTRIG) == LPTIM_ISR_EXTTRIG) ? 1UL : 0UL));
  1023. }
  1024. /**
  1025. * @brief Clear the compare register update interrupt flag (CMPOKCF).
  1026. * @rmtoll ICR CMPOKCF LL_LPTIM_ClearFlag_CMPOK
  1027. * @param LPTIMx Low-Power Timer instance
  1028. * @retval None
  1029. */
  1030. __STATIC_INLINE void LL_LPTIM_ClearFlag_CMPOK(LPTIM_TypeDef *LPTIMx)
  1031. {
  1032. SET_BIT(LPTIMx->ICR, LPTIM_ICR_CMPOKCF);
  1033. }
  1034. /**
  1035. * @brief Informs application whether the APB bus write operation to the LPTIMx_CMP register has been successfully completed. If so, a new one can be initiated.
  1036. * @rmtoll ISR CMPOK LL_LPTIM_IsActiveFlag_CMPOK
  1037. * @param LPTIMx Low-Power Timer instance
  1038. * @retval State of bit (1 or 0).
  1039. */
  1040. __STATIC_INLINE uint32_t LL_LPTIM_IsActiveFlag_CMPOK(LPTIM_TypeDef *LPTIMx)
  1041. {
  1042. return (((READ_BIT(LPTIMx->ISR, LPTIM_ISR_CMPOK) == LPTIM_ISR_CMPOK) ? 1UL : 0UL));
  1043. }
  1044. /**
  1045. * @brief Clear the autoreload register update interrupt flag (ARROKCF).
  1046. * @rmtoll ICR ARROKCF LL_LPTIM_ClearFlag_ARROK
  1047. * @param LPTIMx Low-Power Timer instance
  1048. * @retval None
  1049. */
  1050. __STATIC_INLINE void LL_LPTIM_ClearFlag_ARROK(LPTIM_TypeDef *LPTIMx)
  1051. {
  1052. SET_BIT(LPTIMx->ICR, LPTIM_ICR_ARROKCF);
  1053. }
  1054. /**
  1055. * @brief Informs application whether the APB bus write operation to the LPTIMx_ARR register has been successfully completed. If so, a new one can be initiated.
  1056. * @rmtoll ISR ARROK LL_LPTIM_IsActiveFlag_ARROK
  1057. * @param LPTIMx Low-Power Timer instance
  1058. * @retval State of bit (1 or 0).
  1059. */
  1060. __STATIC_INLINE uint32_t LL_LPTIM_IsActiveFlag_ARROK(LPTIM_TypeDef *LPTIMx)
  1061. {
  1062. return (((READ_BIT(LPTIMx->ISR, LPTIM_ISR_ARROK) == LPTIM_ISR_ARROK) ? 1UL : 0UL));
  1063. }
  1064. /**
  1065. * @brief Clear the counter direction change to up interrupt flag (UPCF).
  1066. * @rmtoll ICR UPCF LL_LPTIM_ClearFlag_UP
  1067. * @param LPTIMx Low-Power Timer instance
  1068. * @retval None
  1069. */
  1070. __STATIC_INLINE void LL_LPTIM_ClearFlag_UP(LPTIM_TypeDef *LPTIMx)
  1071. {
  1072. SET_BIT(LPTIMx->ICR, LPTIM_ICR_UPCF);
  1073. }
  1074. /**
  1075. * @brief Informs the application whether the counter direction has changed from down to up (when the LPTIM instance operates in encoder mode).
  1076. * @rmtoll ISR UP LL_LPTIM_IsActiveFlag_UP
  1077. * @param LPTIMx Low-Power Timer instance
  1078. * @retval State of bit (1 or 0).
  1079. */
  1080. __STATIC_INLINE uint32_t LL_LPTIM_IsActiveFlag_UP(LPTIM_TypeDef *LPTIMx)
  1081. {
  1082. return (((READ_BIT(LPTIMx->ISR, LPTIM_ISR_UP) == LPTIM_ISR_UP) ? 1UL : 0UL));
  1083. }
  1084. /**
  1085. * @brief Clear the counter direction change to down interrupt flag (DOWNCF).
  1086. * @rmtoll ICR DOWNCF LL_LPTIM_ClearFlag_DOWN
  1087. * @param LPTIMx Low-Power Timer instance
  1088. * @retval None
  1089. */
  1090. __STATIC_INLINE void LL_LPTIM_ClearFlag_DOWN(LPTIM_TypeDef *LPTIMx)
  1091. {
  1092. SET_BIT(LPTIMx->ICR, LPTIM_ICR_DOWNCF);
  1093. }
  1094. /**
  1095. * @brief Informs the application whether the counter direction has changed from up to down (when the LPTIM instance operates in encoder mode).
  1096. * @rmtoll ISR DOWN LL_LPTIM_IsActiveFlag_DOWN
  1097. * @param LPTIMx Low-Power Timer instance
  1098. * @retval State of bit (1 or 0).
  1099. */
  1100. __STATIC_INLINE uint32_t LL_LPTIM_IsActiveFlag_DOWN(LPTIM_TypeDef *LPTIMx)
  1101. {
  1102. return (((READ_BIT(LPTIMx->ISR, LPTIM_ISR_DOWN) == LPTIM_ISR_DOWN) ? 1UL : 0UL));
  1103. }
  1104. /**
  1105. * @}
  1106. */
  1107. /** @defgroup LPTIM_LL_EF_IT_Management Interrupt Management
  1108. * @{
  1109. */
  1110. /**
  1111. * @brief Enable compare match interrupt (CMPMIE).
  1112. * @rmtoll IER CMPMIE LL_LPTIM_EnableIT_CMPM
  1113. * @param LPTIMx Low-Power Timer instance
  1114. * @retval None
  1115. */
  1116. __STATIC_INLINE void LL_LPTIM_EnableIT_CMPM(LPTIM_TypeDef *LPTIMx)
  1117. {
  1118. SET_BIT(LPTIMx->IER, LPTIM_IER_CMPMIE);
  1119. }
  1120. /**
  1121. * @brief Disable compare match interrupt (CMPMIE).
  1122. * @rmtoll IER CMPMIE LL_LPTIM_DisableIT_CMPM
  1123. * @param LPTIMx Low-Power Timer instance
  1124. * @retval None
  1125. */
  1126. __STATIC_INLINE void LL_LPTIM_DisableIT_CMPM(LPTIM_TypeDef *LPTIMx)
  1127. {
  1128. CLEAR_BIT(LPTIMx->IER, LPTIM_IER_CMPMIE);
  1129. }
  1130. /**
  1131. * @brief Indicates whether the compare match interrupt (CMPMIE) is enabled.
  1132. * @rmtoll IER CMPMIE LL_LPTIM_IsEnabledIT_CMPM
  1133. * @param LPTIMx Low-Power Timer instance
  1134. * @retval State of bit (1 or 0).
  1135. */
  1136. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledIT_CMPM(LPTIM_TypeDef *LPTIMx)
  1137. {
  1138. return (((READ_BIT(LPTIMx->IER, LPTIM_IER_CMPMIE) == LPTIM_IER_CMPMIE) ? 1UL : 0UL));
  1139. }
  1140. /**
  1141. * @brief Enable autoreload match interrupt (ARRMIE).
  1142. * @rmtoll IER ARRMIE LL_LPTIM_EnableIT_ARRM
  1143. * @param LPTIMx Low-Power Timer instance
  1144. * @retval None
  1145. */
  1146. __STATIC_INLINE void LL_LPTIM_EnableIT_ARRM(LPTIM_TypeDef *LPTIMx)
  1147. {
  1148. SET_BIT(LPTIMx->IER, LPTIM_IER_ARRMIE);
  1149. }
  1150. /**
  1151. * @brief Disable autoreload match interrupt (ARRMIE).
  1152. * @rmtoll IER ARRMIE LL_LPTIM_DisableIT_ARRM
  1153. * @param LPTIMx Low-Power Timer instance
  1154. * @retval None
  1155. */
  1156. __STATIC_INLINE void LL_LPTIM_DisableIT_ARRM(LPTIM_TypeDef *LPTIMx)
  1157. {
  1158. CLEAR_BIT(LPTIMx->IER, LPTIM_IER_ARRMIE);
  1159. }
  1160. /**
  1161. * @brief Indicates whether the autoreload match interrupt (ARRMIE) is enabled.
  1162. * @rmtoll IER ARRMIE LL_LPTIM_IsEnabledIT_ARRM
  1163. * @param LPTIMx Low-Power Timer instance
  1164. * @retval State of bit (1 or 0).
  1165. */
  1166. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledIT_ARRM(LPTIM_TypeDef *LPTIMx)
  1167. {
  1168. return (((READ_BIT(LPTIMx->IER, LPTIM_IER_ARRMIE) == LPTIM_IER_ARRMIE) ? 1UL : 0UL));
  1169. }
  1170. /**
  1171. * @brief Enable external trigger valid edge interrupt (EXTTRIGIE).
  1172. * @rmtoll IER EXTTRIGIE LL_LPTIM_EnableIT_EXTTRIG
  1173. * @param LPTIMx Low-Power Timer instance
  1174. * @retval None
  1175. */
  1176. __STATIC_INLINE void LL_LPTIM_EnableIT_EXTTRIG(LPTIM_TypeDef *LPTIMx)
  1177. {
  1178. SET_BIT(LPTIMx->IER, LPTIM_IER_EXTTRIGIE);
  1179. }
  1180. /**
  1181. * @brief Disable external trigger valid edge interrupt (EXTTRIGIE).
  1182. * @rmtoll IER EXTTRIGIE LL_LPTIM_DisableIT_EXTTRIG
  1183. * @param LPTIMx Low-Power Timer instance
  1184. * @retval None
  1185. */
  1186. __STATIC_INLINE void LL_LPTIM_DisableIT_EXTTRIG(LPTIM_TypeDef *LPTIMx)
  1187. {
  1188. CLEAR_BIT(LPTIMx->IER, LPTIM_IER_EXTTRIGIE);
  1189. }
  1190. /**
  1191. * @brief Indicates external trigger valid edge interrupt (EXTTRIGIE) is enabled.
  1192. * @rmtoll IER EXTTRIGIE LL_LPTIM_IsEnabledIT_EXTTRIG
  1193. * @param LPTIMx Low-Power Timer instance
  1194. * @retval State of bit (1 or 0).
  1195. */
  1196. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledIT_EXTTRIG(LPTIM_TypeDef *LPTIMx)
  1197. {
  1198. return (((READ_BIT(LPTIMx->IER, LPTIM_IER_EXTTRIGIE) == LPTIM_IER_EXTTRIGIE) ? 1UL : 0UL));
  1199. }
  1200. /**
  1201. * @brief Enable compare register write completed interrupt (CMPOKIE).
  1202. * @rmtoll IER CMPOKIE LL_LPTIM_EnableIT_CMPOK
  1203. * @param LPTIMx Low-Power Timer instance
  1204. * @retval None
  1205. */
  1206. __STATIC_INLINE void LL_LPTIM_EnableIT_CMPOK(LPTIM_TypeDef *LPTIMx)
  1207. {
  1208. SET_BIT(LPTIMx->IER, LPTIM_IER_CMPOKIE);
  1209. }
  1210. /**
  1211. * @brief Disable compare register write completed interrupt (CMPOKIE).
  1212. * @rmtoll IER CMPOKIE LL_LPTIM_DisableIT_CMPOK
  1213. * @param LPTIMx Low-Power Timer instance
  1214. * @retval None
  1215. */
  1216. __STATIC_INLINE void LL_LPTIM_DisableIT_CMPOK(LPTIM_TypeDef *LPTIMx)
  1217. {
  1218. CLEAR_BIT(LPTIMx->IER, LPTIM_IER_CMPOKIE);
  1219. }
  1220. /**
  1221. * @brief Indicates whether the compare register write completed interrupt (CMPOKIE) is enabled.
  1222. * @rmtoll IER CMPOKIE LL_LPTIM_IsEnabledIT_CMPOK
  1223. * @param LPTIMx Low-Power Timer instance
  1224. * @retval State of bit (1 or 0).
  1225. */
  1226. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledIT_CMPOK(LPTIM_TypeDef *LPTIMx)
  1227. {
  1228. return (((READ_BIT(LPTIMx->IER, LPTIM_IER_CMPOKIE) == LPTIM_IER_CMPOKIE) ? 1UL : 0UL));
  1229. }
  1230. /**
  1231. * @brief Enable autoreload register write completed interrupt (ARROKIE).
  1232. * @rmtoll IER ARROKIE LL_LPTIM_EnableIT_ARROK
  1233. * @param LPTIMx Low-Power Timer instance
  1234. * @retval None
  1235. */
  1236. __STATIC_INLINE void LL_LPTIM_EnableIT_ARROK(LPTIM_TypeDef *LPTIMx)
  1237. {
  1238. SET_BIT(LPTIMx->IER, LPTIM_IER_ARROKIE);
  1239. }
  1240. /**
  1241. * @brief Disable autoreload register write completed interrupt (ARROKIE).
  1242. * @rmtoll IER ARROKIE LL_LPTIM_DisableIT_ARROK
  1243. * @param LPTIMx Low-Power Timer instance
  1244. * @retval None
  1245. */
  1246. __STATIC_INLINE void LL_LPTIM_DisableIT_ARROK(LPTIM_TypeDef *LPTIMx)
  1247. {
  1248. CLEAR_BIT(LPTIMx->IER, LPTIM_IER_ARROKIE);
  1249. }
  1250. /**
  1251. * @brief Indicates whether the autoreload register write completed interrupt (ARROKIE) is enabled.
  1252. * @rmtoll IER ARROKIE LL_LPTIM_IsEnabledIT_ARROK
  1253. * @param LPTIMx Low-Power Timer instance
  1254. * @retval State of bit(1 or 0).
  1255. */
  1256. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledIT_ARROK(LPTIM_TypeDef *LPTIMx)
  1257. {
  1258. return (((READ_BIT(LPTIMx->IER, LPTIM_IER_ARROKIE) == LPTIM_IER_ARROKIE) ? 1UL : 0UL));
  1259. }
  1260. /**
  1261. * @brief Enable direction change to up interrupt (UPIE).
  1262. * @rmtoll IER UPIE LL_LPTIM_EnableIT_UP
  1263. * @param LPTIMx Low-Power Timer instance
  1264. * @retval None
  1265. */
  1266. __STATIC_INLINE void LL_LPTIM_EnableIT_UP(LPTIM_TypeDef *LPTIMx)
  1267. {
  1268. SET_BIT(LPTIMx->IER, LPTIM_IER_UPIE);
  1269. }
  1270. /**
  1271. * @brief Disable direction change to up interrupt (UPIE).
  1272. * @rmtoll IER UPIE LL_LPTIM_DisableIT_UP
  1273. * @param LPTIMx Low-Power Timer instance
  1274. * @retval None
  1275. */
  1276. __STATIC_INLINE void LL_LPTIM_DisableIT_UP(LPTIM_TypeDef *LPTIMx)
  1277. {
  1278. CLEAR_BIT(LPTIMx->IER, LPTIM_IER_UPIE);
  1279. }
  1280. /**
  1281. * @brief Indicates whether the direction change to up interrupt (UPIE) is enabled.
  1282. * @rmtoll IER UPIE LL_LPTIM_IsEnabledIT_UP
  1283. * @param LPTIMx Low-Power Timer instance
  1284. * @retval State of bit(1 or 0).
  1285. */
  1286. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledIT_UP(LPTIM_TypeDef *LPTIMx)
  1287. {
  1288. return (((READ_BIT(LPTIMx->IER, LPTIM_IER_UPIE) == LPTIM_IER_UPIE) ? 1UL : 0UL));
  1289. }
  1290. /**
  1291. * @brief Enable direction change to down interrupt (DOWNIE).
  1292. * @rmtoll IER DOWNIE LL_LPTIM_EnableIT_DOWN
  1293. * @param LPTIMx Low-Power Timer instance
  1294. * @retval None
  1295. */
  1296. __STATIC_INLINE void LL_LPTIM_EnableIT_DOWN(LPTIM_TypeDef *LPTIMx)
  1297. {
  1298. SET_BIT(LPTIMx->IER, LPTIM_IER_DOWNIE);
  1299. }
  1300. /**
  1301. * @brief Disable direction change to down interrupt (DOWNIE).
  1302. * @rmtoll IER DOWNIE LL_LPTIM_DisableIT_DOWN
  1303. * @param LPTIMx Low-Power Timer instance
  1304. * @retval None
  1305. */
  1306. __STATIC_INLINE void LL_LPTIM_DisableIT_DOWN(LPTIM_TypeDef *LPTIMx)
  1307. {
  1308. CLEAR_BIT(LPTIMx->IER, LPTIM_IER_DOWNIE);
  1309. }
  1310. /**
  1311. * @brief Indicates whether the direction change to down interrupt (DOWNIE) is enabled.
  1312. * @rmtoll IER DOWNIE LL_LPTIM_IsEnabledIT_DOWN
  1313. * @param LPTIMx Low-Power Timer instance
  1314. * @retval State of bit(1 or 0).
  1315. */
  1316. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledIT_DOWN(LPTIM_TypeDef *LPTIMx)
  1317. {
  1318. return ((READ_BIT(LPTIMx->IER, LPTIM_IER_DOWNIE) == LPTIM_IER_DOWNIE) ? 1UL : 0UL);
  1319. }
  1320. /**
  1321. * @}
  1322. */
  1323. /**
  1324. * @}
  1325. */
  1326. /**
  1327. * @}
  1328. */
  1329. #endif /* LPTIM1 || LPTIM2 */
  1330. /**
  1331. * @}
  1332. */
  1333. #ifdef __cplusplus
  1334. }
  1335. #endif
  1336. #endif /* STM32WBxx_LL_LPTIM_H */
  1337. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/