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.
 
 
 

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