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.
 
 
 

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