stm32l4xx_ll_lptim.h 54 KB

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