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.
 
 
 

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