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.
 
 
 

1457 lines
54 KiB

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