stm32l4xx_ll_lptim.h 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623
  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. * Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32L4xx_LL_LPTIM_H
  20. #define STM32L4xx_LL_LPTIM_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32l4xx.h"
  26. /** @addtogroup STM32L4xx_LL_Driver
  27. * @{
  28. */
  29. #if defined (LPTIM1) || defined (LPTIM2)
  30. /** @defgroup LPTIM_LL LPTIM
  31. * @{
  32. */
  33. /* Private types -------------------------------------------------------------*/
  34. /* Private variables ---------------------------------------------------------*/
  35. /* Private constants ---------------------------------------------------------*/
  36. /* Private macros ------------------------------------------------------------*/
  37. #if defined(USE_FULL_LL_DRIVER)
  38. /** @defgroup LPTIM_LL_Private_Macros LPTIM Private Macros
  39. * @{
  40. */
  41. /**
  42. * @}
  43. */
  44. #endif /*USE_FULL_LL_DRIVER*/
  45. /* Exported types ------------------------------------------------------------*/
  46. #if defined(USE_FULL_LL_DRIVER)
  47. /** @defgroup LPTIM_LL_ES_INIT LPTIM Exported Init structure
  48. * @{
  49. */
  50. /**
  51. * @brief LPTIM Init structure definition
  52. */
  53. typedef struct
  54. {
  55. uint32_t ClockSource; /*!< Specifies the source of the clock used by the LPTIM instance.
  56. This parameter can be a value of @ref LPTIM_LL_EC_CLK_SOURCE.
  57. This feature can be modified afterwards using unitary
  58. 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
  62. function @ref LL_LPTIM_SetPrescaler().*/
  63. uint32_t Waveform; /*!< Specifies the waveform shape.
  64. This parameter can be a value of @ref LPTIM_LL_EC_OUTPUT_WAVEFORM.
  65. This feature can be modified afterwards using unitary
  66. function @ref LL_LPTIM_ConfigOutput().*/
  67. uint32_t Polarity; /*!< Specifies waveform polarity.
  68. This parameter can be a value of @ref LPTIM_LL_EC_OUTPUT_POLARITY.
  69. This feature can be modified afterwards using unitary
  70. function @ref LL_LPTIM_ConfigOutput().*/
  71. } LL_LPTIM_InitTypeDef;
  72. /**
  73. * @}
  74. */
  75. #endif /* USE_FULL_LL_DRIVER */
  76. /* Exported constants --------------------------------------------------------*/
  77. /** @defgroup LPTIM_LL_Exported_Constants LPTIM Exported Constants
  78. * @{
  79. */
  80. /** @defgroup LPTIM_LL_EC_GET_FLAG Get Flags Defines
  81. * @brief Flags defines which can be used with LL_LPTIM_ReadReg function
  82. * @{
  83. */
  84. #define LL_LPTIM_ISR_CMPM LPTIM_ISR_CMPM /*!< Compare match */
  85. #define LL_LPTIM_ISR_CMPOK LPTIM_ISR_CMPOK /*!< Compare register update OK */
  86. #define LL_LPTIM_ISR_ARRM LPTIM_ISR_ARRM /*!< Autoreload match */
  87. #define LL_LPTIM_ISR_EXTTRIG LPTIM_ISR_EXTTRIG /*!< External trigger edge event */
  88. #define LL_LPTIM_ISR_ARROK LPTIM_ISR_ARROK /*!< Autoreload register update OK */
  89. #define LL_LPTIM_ISR_UP LPTIM_ISR_UP /*!< Counter direction change down to up */
  90. #define LL_LPTIM_ISR_DOWN LPTIM_ISR_DOWN /*!< Counter direction change up to down */
  91. #if defined(LPTIM_RCR_REP)
  92. #define LL_LPTIM_ISR_UE LPTIM_ISR_UE /*!< Update event */
  93. #define LL_LPTIM_ISR_REPOK LPTIM_ISR_REPOK /*!< Repetition register update OK */
  94. #endif
  95. /**
  96. * @}
  97. */
  98. /** @defgroup LPTIM_LL_EC_IT IT Defines
  99. * @brief IT defines which can be used with LL_LPTIM_ReadReg and LL_LPTIM_WriteReg functions
  100. * @{
  101. */
  102. #define LL_LPTIM_IER_CMPMIE LPTIM_IER_CMPMIE /*!< Compare match */
  103. #define LL_LPTIM_IER_CMPOKIE LPTIM_IER_CMPOKIE /*!< Compare register update OK */
  104. #define LL_LPTIM_IER_ARRMIE LPTIM_IER_ARRMIE /*!< Autoreload match */
  105. #define LL_LPTIM_IER_EXTTRIGIE LPTIM_IER_EXTTRIGIE /*!< External trigger edge event */
  106. #define LL_LPTIM_IER_ARROKIE LPTIM_IER_ARROKIE /*!< Autoreload register update OK */
  107. #define LL_LPTIM_IER_UPIE LPTIM_IER_UPIE /*!< Counter direction change down to up */
  108. #define LL_LPTIM_IER_DOWNIE LPTIM_IER_DOWNIE /*!< Counter direction change up to down */
  109. #if defined(LPTIM_RCR_REP)
  110. #define LL_LPTIM_IER_UEIE LPTIM_IER_UEIE /*!< Update event */
  111. #define LL_LPTIM_IER_REPOKIE LPTIM_IER_REPOKIE /*!< Repetition register update OK */
  112. #endif
  113. /**
  114. * @}
  115. */
  116. /** @defgroup LPTIM_LL_EC_OPERATING_MODE Operating Mode
  117. * @{
  118. */
  119. #define LL_LPTIM_OPERATING_MODE_CONTINUOUS LPTIM_CR_CNTSTRT /*!<LP Timer starts in continuous mode*/
  120. #define LL_LPTIM_OPERATING_MODE_ONESHOT LPTIM_CR_SNGSTRT /*!<LP Tilmer starts in single mode*/
  121. /**
  122. * @}
  123. */
  124. /** @defgroup LPTIM_LL_EC_UPDATE_MODE Update Mode
  125. * @{
  126. */
  127. #define LL_LPTIM_UPDATE_MODE_IMMEDIATE 0x00000000U /*!<Preload is disabled: registers are updated after each APB bus write access*/
  128. #define LL_LPTIM_UPDATE_MODE_ENDOFPERIOD LPTIM_CFGR_PRELOAD /*!<preload is enabled: registers are updated at the end of the current LPTIM period*/
  129. /**
  130. * @}
  131. */
  132. /** @defgroup LPTIM_LL_EC_COUNTER_MODE Counter Mode
  133. * @{
  134. */
  135. #define LL_LPTIM_COUNTER_MODE_INTERNAL 0x00000000U /*!<The counter is incremented following each internal clock pulse*/
  136. #define LL_LPTIM_COUNTER_MODE_EXTERNAL LPTIM_CFGR_COUNTMODE /*!<The counter is incremented following each valid clock pulse on the LPTIM external Input1*/
  137. /**
  138. * @}
  139. */
  140. /** @defgroup LPTIM_LL_EC_OUTPUT_WAVEFORM Output Waveform Type
  141. * @{
  142. */
  143. #define LL_LPTIM_OUTPUT_WAVEFORM_PWM 0x00000000U /*!<LPTIM generates either a PWM waveform or a One pulse waveform depending on chosen operating mode CONTINUOUS or SINGLE*/
  144. #define LL_LPTIM_OUTPUT_WAVEFORM_SETONCE LPTIM_CFGR_WAVE /*!<LPTIM generates a Set Once waveform*/
  145. /**
  146. * @}
  147. */
  148. /** @defgroup LPTIM_LL_EC_OUTPUT_POLARITY Output Polarity
  149. * @{
  150. */
  151. #define LL_LPTIM_OUTPUT_POLARITY_REGULAR 0x00000000U /*!<The LPTIM output reflects the compare results between LPTIMx_ARR and LPTIMx_CMP registers*/
  152. #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*/
  153. /**
  154. * @}
  155. */
  156. /** @defgroup LPTIM_LL_EC_PRESCALER Prescaler Value
  157. * @{
  158. */
  159. #define LL_LPTIM_PRESCALER_DIV1 0x00000000U /*!<Prescaler division factor is set to 1*/
  160. #define LL_LPTIM_PRESCALER_DIV2 LPTIM_CFGR_PRESC_0 /*!<Prescaler division factor is set to 2*/
  161. #define LL_LPTIM_PRESCALER_DIV4 LPTIM_CFGR_PRESC_1 /*!<Prescaler division factor is set to 4*/
  162. #define LL_LPTIM_PRESCALER_DIV8 (LPTIM_CFGR_PRESC_1 | LPTIM_CFGR_PRESC_0) /*!<Prescaler division factor is set to 8*/
  163. #define LL_LPTIM_PRESCALER_DIV16 LPTIM_CFGR_PRESC_2 /*!<Prescaler division factor is set to 16*/
  164. #define LL_LPTIM_PRESCALER_DIV32 (LPTIM_CFGR_PRESC_2 | LPTIM_CFGR_PRESC_0) /*!<Prescaler division factor is set to 32*/
  165. #define LL_LPTIM_PRESCALER_DIV64 (LPTIM_CFGR_PRESC_2 | LPTIM_CFGR_PRESC_1) /*!<Prescaler division factor is set to 64*/
  166. #define LL_LPTIM_PRESCALER_DIV128 LPTIM_CFGR_PRESC /*!<Prescaler division factor is set to 128*/
  167. /**
  168. * @}
  169. */
  170. /** @defgroup LPTIM_LL_EC_TRIG_SOURCE Trigger Source
  171. * @{
  172. */
  173. #define LL_LPTIM_TRIG_SOURCE_GPIO 0x00000000U /*!<External input trigger is connected to TIMx_ETR input*/
  174. #define LL_LPTIM_TRIG_SOURCE_RTCALARMA LPTIM_CFGR_TRIGSEL_0 /*!<External input trigger is connected to RTC Alarm A*/
  175. #define LL_LPTIM_TRIG_SOURCE_RTCALARMB LPTIM_CFGR_TRIGSEL_1 /*!<External input trigger is connected to RTC Alarm B*/
  176. #define LL_LPTIM_TRIG_SOURCE_RTCTAMP1 (LPTIM_CFGR_TRIGSEL_1 | LPTIM_CFGR_TRIGSEL_0) /*!<External input trigger is connected to RTC Tamper 1*/
  177. #define LL_LPTIM_TRIG_SOURCE_RTCTAMP2 LPTIM_CFGR_TRIGSEL_2 /*!<External input trigger is connected to RTC Tamper 2*/
  178. #define LL_LPTIM_TRIG_SOURCE_RTCTAMP3 (LPTIM_CFGR_TRIGSEL_2 | LPTIM_CFGR_TRIGSEL_0) /*!<External input trigger is connected to RTC Tamper 3*/
  179. #define LL_LPTIM_TRIG_SOURCE_COMP1 (LPTIM_CFGR_TRIGSEL_2 | LPTIM_CFGR_TRIGSEL_1) /*!<External input trigger is connected to COMP1 output*/
  180. #define LL_LPTIM_TRIG_SOURCE_COMP2 LPTIM_CFGR_TRIGSEL /*!<External input trigger is connected to COMP2 output*/
  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_OR_OR_0 /*!< For LPTIM1 and LPTIM2 */
  244. #define LL_LPTIM_INPUT1_SRC_COMP2 LPTIM_OR_OR_1 /*!< For LPTIM2 */
  245. #define LL_LPTIM_INPUT1_SRC_COMP1_COMP2 LPTIM_OR_OR /*!< For LPTIM2 */
  246. /**
  247. * @}
  248. */
  249. /** @defgroup LPTIM_EC_INPUT2_SRC Input2 Source
  250. * @{
  251. */
  252. #define LL_LPTIM_INPUT2_SRC_GPIO 0x00000000U /*!< For LPTIM1 */
  253. #define LL_LPTIM_INPUT2_SRC_COMP2 LPTIM_OR_OR_1 /*!< For LPTIM1 */
  254. /**
  255. * @}
  256. */
  257. /**
  258. * @}
  259. */
  260. /* Exported macro ------------------------------------------------------------*/
  261. /** @defgroup LPTIM_LL_Exported_Macros LPTIM Exported Macros
  262. * @{
  263. */
  264. /** @defgroup LPTIM_LL_EM_WRITE_READ Common Write and read registers Macros
  265. * @{
  266. */
  267. /**
  268. * @brief Write a value in LPTIM register
  269. * @param __INSTANCE__ LPTIM Instance
  270. * @param __REG__ Register to be written
  271. * @param __VALUE__ Value to be written in the register
  272. * @retval None
  273. */
  274. #define LL_LPTIM_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG((__INSTANCE__)->__REG__, (__VALUE__))
  275. /**
  276. * @brief Read a value in LPTIM register
  277. * @param __INSTANCE__ LPTIM Instance
  278. * @param __REG__ Register to be read
  279. * @retval Register value
  280. */
  281. #define LL_LPTIM_ReadReg(__INSTANCE__, __REG__) READ_REG((__INSTANCE__)->__REG__)
  282. /**
  283. * @}
  284. */
  285. /**
  286. * @}
  287. */
  288. /* Exported functions --------------------------------------------------------*/
  289. /** @defgroup LPTIM_LL_Exported_Functions LPTIM Exported Functions
  290. * @{
  291. */
  292. /** Legacy definitions for compatibility purpose
  293. @cond 0
  294. */
  295. #define LL_LPTIM_ClearFLAG_CMPM LL_LPTIM_ClearFlag_CMPM
  296. #define LL_LPTIM_ClearFLAG_CC1 LL_LPTIM_ClearFlag_CC1
  297. #define LL_LPTIM_ClearFLAG_CC2 LL_LPTIM_ClearFlag_CC2
  298. #define LL_LPTIM_ClearFLAG_CC1O LL_LPTIM_ClearFlag_CC1O
  299. #define LL_LPTIM_ClearFLAG_CC2O LL_LPTIM_ClearFlag_CC2O
  300. #define LL_LPTIM_ClearFLAG_ARRM LL_LPTIM_ClearFlag_ARRM
  301. /**
  302. @endcond
  303. */
  304. #if defined(USE_FULL_LL_DRIVER)
  305. /** @defgroup LPTIM_LL_EF_Init Initialisation and deinitialisation functions
  306. * @{
  307. */
  308. ErrorStatus LL_LPTIM_DeInit(const LPTIM_TypeDef *LPTIMx);
  309. void LL_LPTIM_StructInit(LL_LPTIM_InitTypeDef *LPTIM_InitStruct);
  310. ErrorStatus LL_LPTIM_Init(LPTIM_TypeDef *LPTIMx, const LL_LPTIM_InitTypeDef *LPTIM_InitStruct);
  311. void LL_LPTIM_Disable(LPTIM_TypeDef *LPTIMx);
  312. /**
  313. * @}
  314. */
  315. #endif /* USE_FULL_LL_DRIVER */
  316. /** @defgroup LPTIM_LL_EF_LPTIM_Configuration LPTIM Configuration
  317. * @{
  318. */
  319. /**
  320. * @brief Enable the LPTIM instance
  321. * @note After setting the ENABLE bit, a delay of two counter clock is needed
  322. * before the LPTIM instance is actually enabled.
  323. * @rmtoll CR ENABLE LL_LPTIM_Enable
  324. * @param LPTIMx Low-Power Timer instance
  325. * @retval None
  326. */
  327. __STATIC_INLINE void LL_LPTIM_Enable(LPTIM_TypeDef *LPTIMx)
  328. {
  329. SET_BIT(LPTIMx->CR, LPTIM_CR_ENABLE);
  330. }
  331. /**
  332. * @brief Indicates whether the LPTIM instance is enabled.
  333. * @rmtoll CR ENABLE LL_LPTIM_IsEnabled
  334. * @param LPTIMx Low-Power Timer instance
  335. * @retval State of bit (1 or 0).
  336. */
  337. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabled(const LPTIM_TypeDef *LPTIMx)
  338. {
  339. return (((READ_BIT(LPTIMx->CR, LPTIM_CR_ENABLE) == LPTIM_CR_ENABLE) ? 1UL : 0UL));
  340. }
  341. /**
  342. * @brief Starts the LPTIM counter in the desired mode.
  343. * @note LPTIM instance must be enabled before starting the counter.
  344. * @note It is possible to change on the fly from One Shot mode to
  345. * Continuous mode.
  346. * @rmtoll CR CNTSTRT LL_LPTIM_StartCounter\n
  347. * CR SNGSTRT LL_LPTIM_StartCounter
  348. * @param LPTIMx Low-Power Timer instance
  349. * @param OperatingMode This parameter can be one of the following values:
  350. * @arg @ref LL_LPTIM_OPERATING_MODE_CONTINUOUS
  351. * @arg @ref LL_LPTIM_OPERATING_MODE_ONESHOT
  352. * @retval None
  353. */
  354. __STATIC_INLINE void LL_LPTIM_StartCounter(LPTIM_TypeDef *LPTIMx, uint32_t OperatingMode)
  355. {
  356. MODIFY_REG(LPTIMx->CR, LPTIM_CR_CNTSTRT | LPTIM_CR_SNGSTRT, OperatingMode);
  357. }
  358. #if defined(LPTIM_CR_RSTARE)
  359. /**
  360. * @brief Enable reset after read.
  361. * @note After calling this function any read access to LPTIM_CNT
  362. * register will asynchronously reset the LPTIM_CNT register content.
  363. * @rmtoll CR RSTARE LL_LPTIM_EnableResetAfterRead
  364. * @param LPTIMx Low-Power Timer instance
  365. * @retval None
  366. */
  367. __STATIC_INLINE void LL_LPTIM_EnableResetAfterRead(LPTIM_TypeDef *LPTIMx)
  368. {
  369. SET_BIT(LPTIMx->CR, LPTIM_CR_RSTARE);
  370. }
  371. /**
  372. * @brief Disable reset after read.
  373. * @rmtoll CR RSTARE LL_LPTIM_DisableResetAfterRead
  374. * @param LPTIMx Low-Power Timer instance
  375. * @retval None
  376. */
  377. __STATIC_INLINE void LL_LPTIM_DisableResetAfterRead(LPTIM_TypeDef *LPTIMx)
  378. {
  379. CLEAR_BIT(LPTIMx->CR, LPTIM_CR_RSTARE);
  380. }
  381. /**
  382. * @brief Indicate whether the reset after read feature is enabled.
  383. * @rmtoll CR RSTARE LL_LPTIM_IsEnabledResetAfterRead
  384. * @param LPTIMx Low-Power Timer instance
  385. * @retval State of bit (1 or 0).
  386. */
  387. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledResetAfterRead(const LPTIM_TypeDef *LPTIMx)
  388. {
  389. return (((READ_BIT(LPTIMx->CR, LPTIM_CR_RSTARE) == LPTIM_CR_RSTARE) ? 1UL : 0UL));
  390. }
  391. #endif
  392. #if defined(LPTIM_CR_COUNTRST)
  393. /**
  394. * @brief Reset of the LPTIM_CNT counter register (synchronous).
  395. * @note Due to the synchronous nature of this reset, it only takes
  396. * place after a synchronization delay of 3 LPTIM core clock cycles
  397. * (LPTIM core clock may be different from APB clock).
  398. * @note COUNTRST is automatically cleared by hardware
  399. * @rmtoll CR COUNTRST LL_LPTIM_ResetCounter\n
  400. * @param LPTIMx Low-Power Timer instance
  401. * @retval None
  402. */
  403. __STATIC_INLINE void LL_LPTIM_ResetCounter(LPTIM_TypeDef *LPTIMx)
  404. {
  405. SET_BIT(LPTIMx->CR, LPTIM_CR_COUNTRST);
  406. }
  407. #endif
  408. /**
  409. * @brief Set the LPTIM registers update mode (enable/disable register preload)
  410. * @note This function must be called when the LPTIM instance is disabled.
  411. * @rmtoll CFGR PRELOAD LL_LPTIM_SetUpdateMode
  412. * @param LPTIMx Low-Power Timer instance
  413. * @param UpdateMode This parameter can be one of the following values:
  414. * @arg @ref LL_LPTIM_UPDATE_MODE_IMMEDIATE
  415. * @arg @ref LL_LPTIM_UPDATE_MODE_ENDOFPERIOD
  416. * @retval None
  417. */
  418. __STATIC_INLINE void LL_LPTIM_SetUpdateMode(LPTIM_TypeDef *LPTIMx, uint32_t UpdateMode)
  419. {
  420. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_PRELOAD, UpdateMode);
  421. }
  422. /**
  423. * @brief Get the LPTIM registers update mode
  424. * @rmtoll CFGR PRELOAD LL_LPTIM_GetUpdateMode
  425. * @param LPTIMx Low-Power Timer instance
  426. * @retval Returned value can be one of the following values:
  427. * @arg @ref LL_LPTIM_UPDATE_MODE_IMMEDIATE
  428. * @arg @ref LL_LPTIM_UPDATE_MODE_ENDOFPERIOD
  429. */
  430. __STATIC_INLINE uint32_t LL_LPTIM_GetUpdateMode(const LPTIM_TypeDef *LPTIMx)
  431. {
  432. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_PRELOAD));
  433. }
  434. /**
  435. * @brief Set the auto reload value
  436. * @note The LPTIMx_ARR register content must only be modified when the LPTIM is enabled
  437. * @note After a write to the LPTIMx_ARR register a new write operation to the
  438. * same register can only be performed when the previous write operation
  439. * is completed. Any successive write before the ARROK flag is set, will
  440. * lead to unpredictable results.
  441. * @note autoreload value be strictly greater than the compare value.
  442. * @rmtoll ARR ARR LL_LPTIM_SetAutoReload
  443. * @param LPTIMx Low-Power Timer instance
  444. * @param AutoReload Value between Min_Data=0x0001 and Max_Data=0xFFFF
  445. * @retval None
  446. */
  447. __STATIC_INLINE void LL_LPTIM_SetAutoReload(LPTIM_TypeDef *LPTIMx, uint32_t AutoReload)
  448. {
  449. MODIFY_REG(LPTIMx->ARR, LPTIM_ARR_ARR, AutoReload);
  450. }
  451. /**
  452. * @brief Get actual auto reload value
  453. * @rmtoll ARR ARR LL_LPTIM_GetAutoReload
  454. * @param LPTIMx Low-Power Timer instance
  455. * @retval AutoReload Value between Min_Data=0x0001 and Max_Data=0xFFFF
  456. */
  457. __STATIC_INLINE uint32_t LL_LPTIM_GetAutoReload(const LPTIM_TypeDef *LPTIMx)
  458. {
  459. return (uint32_t)(READ_BIT(LPTIMx->ARR, LPTIM_ARR_ARR));
  460. }
  461. #if defined(LPTIM_RCR_REP)
  462. /**
  463. * @brief Set the repetition value
  464. * @note The LPTIMx_RCR register content must only be modified when the LPTIM is enabled
  465. * @rmtoll RCR REP LL_LPTIM_SetRepetition
  466. * @param LPTIMx Low-Power Timer instance
  467. * @param Repetition Value between Min_Data=0x00 and Max_Data=0xFF
  468. * @retval None
  469. */
  470. __STATIC_INLINE void LL_LPTIM_SetRepetition(LPTIM_TypeDef *LPTIMx, uint32_t Repetition)
  471. {
  472. MODIFY_REG(LPTIMx->RCR, LPTIM_RCR_REP, Repetition);
  473. }
  474. /**
  475. * @brief Get the repetition value
  476. * @rmtoll RCR REP LL_LPTIM_GetRepetition
  477. * @param LPTIMx Low-Power Timer instance
  478. * @retval Repetition Value between Min_Data=0x00 and Max_Data=0xFF
  479. */
  480. __STATIC_INLINE uint32_t LL_LPTIM_GetRepetition(const LPTIM_TypeDef *LPTIMx)
  481. {
  482. return (uint32_t)(READ_BIT(LPTIMx->RCR, LPTIM_RCR_REP));
  483. }
  484. #endif
  485. /**
  486. * @brief Set the compare value
  487. * @note After a write to the LPTIMx_CMP register a new write operation to the
  488. * same register can only be performed when the previous write operation
  489. * is completed. Any successive write before the CMPOK flag is set, will
  490. * lead to unpredictable results.
  491. * @rmtoll CMP CMP LL_LPTIM_SetCompare
  492. * @param LPTIMx Low-Power Timer instance
  493. * @param CompareValue Value between Min_Data=0x00 and Max_Data=0xFFFF
  494. * @retval None
  495. */
  496. __STATIC_INLINE void LL_LPTIM_SetCompare(LPTIM_TypeDef *LPTIMx, uint32_t CompareValue)
  497. {
  498. MODIFY_REG(LPTIMx->CMP, LPTIM_CMP_CMP, CompareValue);
  499. }
  500. /**
  501. * @brief Get actual compare value
  502. * @rmtoll CMP CMP LL_LPTIM_GetCompare
  503. * @param LPTIMx Low-Power Timer instance
  504. * @retval CompareValue Value between Min_Data=0x00 and Max_Data=0xFFFF
  505. */
  506. __STATIC_INLINE uint32_t LL_LPTIM_GetCompare(const LPTIM_TypeDef *LPTIMx)
  507. {
  508. return (uint32_t)(READ_BIT(LPTIMx->CMP, LPTIM_CMP_CMP));
  509. }
  510. /**
  511. * @brief Get actual counter value
  512. * @note When the LPTIM instance is running with an asynchronous clock, reading
  513. * the LPTIMx_CNT register may return unreliable values. So in this case
  514. * it is necessary to perform two consecutive read accesses and verify
  515. * that the two returned values are identical.
  516. * @rmtoll CNT CNT LL_LPTIM_GetCounter
  517. * @param LPTIMx Low-Power Timer instance
  518. * @retval Counter value
  519. */
  520. __STATIC_INLINE uint32_t LL_LPTIM_GetCounter(const LPTIM_TypeDef *LPTIMx)
  521. {
  522. return (uint32_t)(READ_BIT(LPTIMx->CNT, LPTIM_CNT_CNT));
  523. }
  524. /**
  525. * @brief Set the counter mode (selection of the LPTIM counter clock source).
  526. * @note The counter mode can be set only when the LPTIM instance is disabled.
  527. * @rmtoll CFGR COUNTMODE LL_LPTIM_SetCounterMode
  528. * @param LPTIMx Low-Power Timer instance
  529. * @param CounterMode This parameter can be one of the following values:
  530. * @arg @ref LL_LPTIM_COUNTER_MODE_INTERNAL
  531. * @arg @ref LL_LPTIM_COUNTER_MODE_EXTERNAL
  532. * @retval None
  533. */
  534. __STATIC_INLINE void LL_LPTIM_SetCounterMode(LPTIM_TypeDef *LPTIMx, uint32_t CounterMode)
  535. {
  536. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_COUNTMODE, CounterMode);
  537. }
  538. /**
  539. * @brief Get the counter mode
  540. * @rmtoll CFGR COUNTMODE LL_LPTIM_GetCounterMode
  541. * @param LPTIMx Low-Power Timer instance
  542. * @retval Returned value can be one of the following values:
  543. * @arg @ref LL_LPTIM_COUNTER_MODE_INTERNAL
  544. * @arg @ref LL_LPTIM_COUNTER_MODE_EXTERNAL
  545. */
  546. __STATIC_INLINE uint32_t LL_LPTIM_GetCounterMode(const LPTIM_TypeDef *LPTIMx)
  547. {
  548. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_COUNTMODE));
  549. }
  550. /**
  551. * @brief Configure the LPTIM instance output (LPTIMx_OUT)
  552. * @note This function must be called when the LPTIM instance is disabled.
  553. * @note Regarding the LPTIM output polarity the change takes effect
  554. * immediately, so the output default value will change immediately after
  555. * the polarity is re-configured, even before the timer is enabled.
  556. * @rmtoll CFGR WAVE LL_LPTIM_ConfigOutput\n
  557. * CFGR WAVPOL LL_LPTIM_ConfigOutput
  558. * @param LPTIMx Low-Power Timer instance
  559. * @param Waveform This parameter can be one of the following values:
  560. * @arg @ref LL_LPTIM_OUTPUT_WAVEFORM_PWM
  561. * @arg @ref LL_LPTIM_OUTPUT_WAVEFORM_SETONCE
  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_ConfigOutput(LPTIM_TypeDef *LPTIMx, uint32_t Waveform, uint32_t Polarity)
  568. {
  569. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_WAVE | LPTIM_CFGR_WAVPOL, Waveform | Polarity);
  570. }
  571. /**
  572. * @brief Set waveform shape
  573. * @rmtoll CFGR WAVE LL_LPTIM_SetWaveform
  574. * @param LPTIMx Low-Power Timer instance
  575. * @param Waveform This parameter can be one of the following values:
  576. * @arg @ref LL_LPTIM_OUTPUT_WAVEFORM_PWM
  577. * @arg @ref LL_LPTIM_OUTPUT_WAVEFORM_SETONCE
  578. * @retval None
  579. */
  580. __STATIC_INLINE void LL_LPTIM_SetWaveform(LPTIM_TypeDef *LPTIMx, uint32_t Waveform)
  581. {
  582. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_WAVE, Waveform);
  583. }
  584. /**
  585. * @brief Get actual waveform shape
  586. * @rmtoll CFGR WAVE LL_LPTIM_GetWaveform
  587. * @param LPTIMx Low-Power Timer instance
  588. * @retval Returned value can be one of the following values:
  589. * @arg @ref LL_LPTIM_OUTPUT_WAVEFORM_PWM
  590. * @arg @ref LL_LPTIM_OUTPUT_WAVEFORM_SETONCE
  591. */
  592. __STATIC_INLINE uint32_t LL_LPTIM_GetWaveform(const LPTIM_TypeDef *LPTIMx)
  593. {
  594. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_WAVE));
  595. }
  596. /**
  597. * @brief Set output polarity
  598. * @rmtoll CFGR WAVPOL LL_LPTIM_SetPolarity
  599. * @param LPTIMx Low-Power Timer instance
  600. * @param Polarity This parameter can be one of the following values:
  601. * @arg @ref LL_LPTIM_OUTPUT_POLARITY_REGULAR
  602. * @arg @ref LL_LPTIM_OUTPUT_POLARITY_INVERSE
  603. * @retval None
  604. */
  605. __STATIC_INLINE void LL_LPTIM_SetPolarity(LPTIM_TypeDef *LPTIMx, uint32_t Polarity)
  606. {
  607. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_WAVPOL, Polarity);
  608. }
  609. /**
  610. * @brief Get actual output polarity
  611. * @rmtoll CFGR WAVPOL LL_LPTIM_GetPolarity
  612. * @param LPTIMx Low-Power Timer instance
  613. * @retval Returned value can be one of the following values:
  614. * @arg @ref LL_LPTIM_OUTPUT_POLARITY_REGULAR
  615. * @arg @ref LL_LPTIM_OUTPUT_POLARITY_INVERSE
  616. */
  617. __STATIC_INLINE uint32_t LL_LPTIM_GetPolarity(const LPTIM_TypeDef *LPTIMx)
  618. {
  619. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_WAVPOL));
  620. }
  621. /**
  622. * @brief Set actual prescaler division ratio.
  623. * @note This function must be called when the LPTIM instance is disabled.
  624. * @note When the LPTIM is configured to be clocked by an internal clock source
  625. * and the LPTIM counter is configured to be updated by active edges
  626. * detected on the LPTIM external Input1, the internal clock provided to
  627. * the LPTIM must be not be prescaled.
  628. * @rmtoll CFGR PRESC LL_LPTIM_SetPrescaler
  629. * @param LPTIMx Low-Power Timer instance
  630. * @param Prescaler This parameter can be one of the following values:
  631. * @arg @ref LL_LPTIM_PRESCALER_DIV1
  632. * @arg @ref LL_LPTIM_PRESCALER_DIV2
  633. * @arg @ref LL_LPTIM_PRESCALER_DIV4
  634. * @arg @ref LL_LPTIM_PRESCALER_DIV8
  635. * @arg @ref LL_LPTIM_PRESCALER_DIV16
  636. * @arg @ref LL_LPTIM_PRESCALER_DIV32
  637. * @arg @ref LL_LPTIM_PRESCALER_DIV64
  638. * @arg @ref LL_LPTIM_PRESCALER_DIV128
  639. * @retval None
  640. */
  641. __STATIC_INLINE void LL_LPTIM_SetPrescaler(LPTIM_TypeDef *LPTIMx, uint32_t Prescaler)
  642. {
  643. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_PRESC, Prescaler);
  644. }
  645. /**
  646. * @brief Get actual prescaler division ratio.
  647. * @rmtoll CFGR PRESC LL_LPTIM_GetPrescaler
  648. * @param LPTIMx Low-Power Timer instance
  649. * @retval Returned value can be one of the following values:
  650. * @arg @ref LL_LPTIM_PRESCALER_DIV1
  651. * @arg @ref LL_LPTIM_PRESCALER_DIV2
  652. * @arg @ref LL_LPTIM_PRESCALER_DIV4
  653. * @arg @ref LL_LPTIM_PRESCALER_DIV8
  654. * @arg @ref LL_LPTIM_PRESCALER_DIV16
  655. * @arg @ref LL_LPTIM_PRESCALER_DIV32
  656. * @arg @ref LL_LPTIM_PRESCALER_DIV64
  657. * @arg @ref LL_LPTIM_PRESCALER_DIV128
  658. */
  659. __STATIC_INLINE uint32_t LL_LPTIM_GetPrescaler(const LPTIM_TypeDef *LPTIMx)
  660. {
  661. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_PRESC));
  662. }
  663. /**
  664. * @brief Set LPTIM input 1 source (default GPIO).
  665. * @rmtoll OR OR LL_LPTIM_SetInput1Src
  666. * @param LPTIMx Low-Power Timer instance
  667. * @param Src This parameter can be one of the following values:
  668. * @arg @ref LL_LPTIM_INPUT1_SRC_GPIO
  669. * @arg @ref LL_LPTIM_INPUT1_SRC_COMP1
  670. * @arg @ref LL_LPTIM_INPUT1_SRC_COMP2
  671. * @arg @ref LL_LPTIM_INPUT1_SRC_COMP1_COMP2
  672. * @retval None
  673. */
  674. __STATIC_INLINE void LL_LPTIM_SetInput1Src(LPTIM_TypeDef *LPTIMx, uint32_t Src)
  675. {
  676. MODIFY_REG(LPTIMx->OR, LPTIM_OR_OR, Src);
  677. }
  678. /**
  679. * @brief Set LPTIM input 2 source (default GPIO).
  680. * @rmtoll OR OR LL_LPTIM_SetInput2Src
  681. * @param LPTIMx Low-Power Timer instance
  682. * @param Src This parameter can be one of the following values:
  683. * @arg @ref LL_LPTIM_INPUT2_SRC_GPIO
  684. * @arg @ref LL_LPTIM_INPUT2_SRC_COMP2
  685. * @retval None
  686. */
  687. __STATIC_INLINE void LL_LPTIM_SetInput2Src(LPTIM_TypeDef *LPTIMx, uint32_t Src)
  688. {
  689. MODIFY_REG(LPTIMx->OR, LPTIM_OR_OR, Src);
  690. }
  691. /**
  692. * @}
  693. */
  694. /** @defgroup LPTIM_LL_EF_Trigger_Configuration Trigger Configuration
  695. * @{
  696. */
  697. /**
  698. * @brief Enable the timeout function
  699. * @note This function must be called when the LPTIM instance is disabled.
  700. * @note The first trigger event will start the timer, any successive trigger
  701. * event will reset the counter and the timer will restart.
  702. * @note The timeout value corresponds to the compare value; if no trigger
  703. * occurs within the expected time frame, the MCU is waked-up by the
  704. * compare match event.
  705. * @rmtoll CFGR TIMOUT LL_LPTIM_EnableTimeout
  706. * @param LPTIMx Low-Power Timer instance
  707. * @retval None
  708. */
  709. __STATIC_INLINE void LL_LPTIM_EnableTimeout(LPTIM_TypeDef *LPTIMx)
  710. {
  711. SET_BIT(LPTIMx->CFGR, LPTIM_CFGR_TIMOUT);
  712. }
  713. /**
  714. * @brief Disable the timeout function
  715. * @note This function must be called when the LPTIM instance is disabled.
  716. * @note A trigger event arriving when the timer is already started will be
  717. * ignored.
  718. * @rmtoll CFGR TIMOUT LL_LPTIM_DisableTimeout
  719. * @param LPTIMx Low-Power Timer instance
  720. * @retval None
  721. */
  722. __STATIC_INLINE void LL_LPTIM_DisableTimeout(LPTIM_TypeDef *LPTIMx)
  723. {
  724. CLEAR_BIT(LPTIMx->CFGR, LPTIM_CFGR_TIMOUT);
  725. }
  726. /**
  727. * @brief Indicate whether the timeout function is enabled.
  728. * @rmtoll CFGR TIMOUT LL_LPTIM_IsEnabledTimeout
  729. * @param LPTIMx Low-Power Timer instance
  730. * @retval State of bit (1 or 0).
  731. */
  732. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledTimeout(const LPTIM_TypeDef *LPTIMx)
  733. {
  734. return (((READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_TIMOUT) == LPTIM_CFGR_TIMOUT) ? 1UL : 0UL));
  735. }
  736. /**
  737. * @brief Start the LPTIM counter
  738. * @note This function must be called when the LPTIM instance is disabled.
  739. * @rmtoll CFGR TRIGEN LL_LPTIM_TrigSw
  740. * @param LPTIMx Low-Power Timer instance
  741. * @retval None
  742. */
  743. __STATIC_INLINE void LL_LPTIM_TrigSw(LPTIM_TypeDef *LPTIMx)
  744. {
  745. CLEAR_BIT(LPTIMx->CFGR, LPTIM_CFGR_TRIGEN);
  746. }
  747. /**
  748. * @brief Configure the external trigger used as a trigger event for the LPTIM.
  749. * @note This function must be called when the LPTIM instance is disabled.
  750. * @note An internal clock source must be present when a digital filter is
  751. * required for the trigger.
  752. * @rmtoll CFGR TRIGSEL LL_LPTIM_ConfigTrigger\n
  753. * CFGR TRGFLT LL_LPTIM_ConfigTrigger\n
  754. * CFGR TRIGEN LL_LPTIM_ConfigTrigger
  755. * @param LPTIMx Low-Power Timer instance
  756. * @param Source This parameter can be one of the following values:
  757. * @arg @ref LL_LPTIM_TRIG_SOURCE_GPIO
  758. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCALARMA
  759. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCALARMB
  760. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCTAMP1
  761. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCTAMP2
  762. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCTAMP3
  763. * @arg @ref LL_LPTIM_TRIG_SOURCE_COMP1
  764. * @arg @ref LL_LPTIM_TRIG_SOURCE_COMP2
  765. * @param Filter This parameter can be one of the following values:
  766. * @arg @ref LL_LPTIM_TRIG_FILTER_NONE
  767. * @arg @ref LL_LPTIM_TRIG_FILTER_2
  768. * @arg @ref LL_LPTIM_TRIG_FILTER_4
  769. * @arg @ref LL_LPTIM_TRIG_FILTER_8
  770. * @param Polarity This parameter can be one of the following values:
  771. * @arg @ref LL_LPTIM_TRIG_POLARITY_RISING
  772. * @arg @ref LL_LPTIM_TRIG_POLARITY_FALLING
  773. * @arg @ref LL_LPTIM_TRIG_POLARITY_RISING_FALLING
  774. * @retval None
  775. */
  776. __STATIC_INLINE void LL_LPTIM_ConfigTrigger(LPTIM_TypeDef *LPTIMx, uint32_t Source, uint32_t Filter, uint32_t Polarity)
  777. {
  778. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_TRIGSEL | LPTIM_CFGR_TRGFLT | LPTIM_CFGR_TRIGEN, Source | Filter | Polarity);
  779. }
  780. /**
  781. * @brief Get actual external trigger source.
  782. * @rmtoll CFGR TRIGSEL LL_LPTIM_GetTriggerSource
  783. * @param LPTIMx Low-Power Timer instance
  784. * @retval Returned value can be one of the following values:
  785. * @arg @ref LL_LPTIM_TRIG_SOURCE_GPIO
  786. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCALARMA
  787. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCALARMB
  788. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCTAMP1
  789. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCTAMP2
  790. * @arg @ref LL_LPTIM_TRIG_SOURCE_RTCTAMP3
  791. * @arg @ref LL_LPTIM_TRIG_SOURCE_COMP1
  792. * @arg @ref LL_LPTIM_TRIG_SOURCE_COMP2
  793. */
  794. __STATIC_INLINE uint32_t LL_LPTIM_GetTriggerSource(const LPTIM_TypeDef *LPTIMx)
  795. {
  796. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_TRIGSEL));
  797. }
  798. /**
  799. * @brief Get actual external trigger filter.
  800. * @rmtoll CFGR TRGFLT LL_LPTIM_GetTriggerFilter
  801. * @param LPTIMx Low-Power Timer instance
  802. * @retval Returned value can be one of the following values:
  803. * @arg @ref LL_LPTIM_TRIG_FILTER_NONE
  804. * @arg @ref LL_LPTIM_TRIG_FILTER_2
  805. * @arg @ref LL_LPTIM_TRIG_FILTER_4
  806. * @arg @ref LL_LPTIM_TRIG_FILTER_8
  807. */
  808. __STATIC_INLINE uint32_t LL_LPTIM_GetTriggerFilter(const LPTIM_TypeDef *LPTIMx)
  809. {
  810. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_TRGFLT));
  811. }
  812. /**
  813. * @brief Get actual external trigger polarity.
  814. * @rmtoll CFGR TRIGEN LL_LPTIM_GetTriggerPolarity
  815. * @param LPTIMx Low-Power Timer instance
  816. * @retval Returned value can be one of the following values:
  817. * @arg @ref LL_LPTIM_TRIG_POLARITY_RISING
  818. * @arg @ref LL_LPTIM_TRIG_POLARITY_FALLING
  819. * @arg @ref LL_LPTIM_TRIG_POLARITY_RISING_FALLING
  820. */
  821. __STATIC_INLINE uint32_t LL_LPTIM_GetTriggerPolarity(const LPTIM_TypeDef *LPTIMx)
  822. {
  823. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_TRIGEN));
  824. }
  825. /**
  826. * @}
  827. */
  828. /** @defgroup LPTIM_LL_EF_Clock_Configuration Clock Configuration
  829. * @{
  830. */
  831. /**
  832. * @brief Set the source of the clock used by the LPTIM instance.
  833. * @note This function must be called when the LPTIM instance is disabled.
  834. * @rmtoll CFGR CKSEL LL_LPTIM_SetClockSource
  835. * @param LPTIMx Low-Power Timer instance
  836. * @param ClockSource This parameter can be one of the following values:
  837. * @arg @ref LL_LPTIM_CLK_SOURCE_INTERNAL
  838. * @arg @ref LL_LPTIM_CLK_SOURCE_EXTERNAL
  839. * @retval None
  840. */
  841. __STATIC_INLINE void LL_LPTIM_SetClockSource(LPTIM_TypeDef *LPTIMx, uint32_t ClockSource)
  842. {
  843. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_CKSEL, ClockSource);
  844. }
  845. /**
  846. * @brief Get actual LPTIM instance clock source.
  847. * @rmtoll CFGR CKSEL LL_LPTIM_GetClockSource
  848. * @param LPTIMx Low-Power Timer instance
  849. * @retval Returned value can be one of the following values:
  850. * @arg @ref LL_LPTIM_CLK_SOURCE_INTERNAL
  851. * @arg @ref LL_LPTIM_CLK_SOURCE_EXTERNAL
  852. */
  853. __STATIC_INLINE uint32_t LL_LPTIM_GetClockSource(const LPTIM_TypeDef *LPTIMx)
  854. {
  855. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_CKSEL));
  856. }
  857. /**
  858. * @brief Configure the active edge or edges used by the counter when
  859. the LPTIM is clocked by an external clock source.
  860. * @note This function must be called when the LPTIM instance is disabled.
  861. * @note When both external clock signal edges are considered active ones,
  862. * the LPTIM must also be clocked by an internal clock source with a
  863. * frequency equal to at least four times the external clock frequency.
  864. * @note An internal clock source must be present when a digital filter is
  865. * required for external clock.
  866. * @rmtoll CFGR CKFLT LL_LPTIM_ConfigClock\n
  867. * CFGR CKPOL LL_LPTIM_ConfigClock
  868. * @param LPTIMx Low-Power Timer instance
  869. * @param ClockFilter This parameter can be one of the following values:
  870. * @arg @ref LL_LPTIM_CLK_FILTER_NONE
  871. * @arg @ref LL_LPTIM_CLK_FILTER_2
  872. * @arg @ref LL_LPTIM_CLK_FILTER_4
  873. * @arg @ref LL_LPTIM_CLK_FILTER_8
  874. * @param ClockPolarity This parameter can be one of the following values:
  875. * @arg @ref LL_LPTIM_CLK_POLARITY_RISING
  876. * @arg @ref LL_LPTIM_CLK_POLARITY_FALLING
  877. * @arg @ref LL_LPTIM_CLK_POLARITY_RISING_FALLING
  878. * @retval None
  879. */
  880. __STATIC_INLINE void LL_LPTIM_ConfigClock(LPTIM_TypeDef *LPTIMx, uint32_t ClockFilter, uint32_t ClockPolarity)
  881. {
  882. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_CKFLT | LPTIM_CFGR_CKPOL, ClockFilter | ClockPolarity);
  883. }
  884. /**
  885. * @brief Get actual clock polarity
  886. * @rmtoll CFGR CKPOL LL_LPTIM_GetClockPolarity
  887. * @param LPTIMx Low-Power Timer instance
  888. * @retval Returned value can be one of the following values:
  889. * @arg @ref LL_LPTIM_CLK_POLARITY_RISING
  890. * @arg @ref LL_LPTIM_CLK_POLARITY_FALLING
  891. * @arg @ref LL_LPTIM_CLK_POLARITY_RISING_FALLING
  892. */
  893. __STATIC_INLINE uint32_t LL_LPTIM_GetClockPolarity(const LPTIM_TypeDef *LPTIMx)
  894. {
  895. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_CKPOL));
  896. }
  897. /**
  898. * @brief Get actual clock digital filter
  899. * @rmtoll CFGR CKFLT LL_LPTIM_GetClockFilter
  900. * @param LPTIMx Low-Power Timer instance
  901. * @retval Returned value can be one of the following values:
  902. * @arg @ref LL_LPTIM_CLK_FILTER_NONE
  903. * @arg @ref LL_LPTIM_CLK_FILTER_2
  904. * @arg @ref LL_LPTIM_CLK_FILTER_4
  905. * @arg @ref LL_LPTIM_CLK_FILTER_8
  906. */
  907. __STATIC_INLINE uint32_t LL_LPTIM_GetClockFilter(const LPTIM_TypeDef *LPTIMx)
  908. {
  909. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_CKFLT));
  910. }
  911. /**
  912. * @}
  913. */
  914. /** @defgroup LPTIM_LL_EF_Encoder_Mode Encoder Mode
  915. * @{
  916. */
  917. /**
  918. * @brief Configure the encoder mode.
  919. * @note This function must be called when the LPTIM instance is disabled.
  920. * @rmtoll CFGR CKPOL LL_LPTIM_SetEncoderMode
  921. * @param LPTIMx Low-Power Timer instance
  922. * @param EncoderMode This parameter can be one of the following values:
  923. * @arg @ref LL_LPTIM_ENCODER_MODE_RISING
  924. * @arg @ref LL_LPTIM_ENCODER_MODE_FALLING
  925. * @arg @ref LL_LPTIM_ENCODER_MODE_RISING_FALLING
  926. * @retval None
  927. */
  928. __STATIC_INLINE void LL_LPTIM_SetEncoderMode(LPTIM_TypeDef *LPTIMx, uint32_t EncoderMode)
  929. {
  930. MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_CKPOL, EncoderMode);
  931. }
  932. /**
  933. * @brief Get actual encoder mode.
  934. * @rmtoll CFGR CKPOL LL_LPTIM_GetEncoderMode
  935. * @param LPTIMx Low-Power Timer instance
  936. * @retval Returned value can be one of the following values:
  937. * @arg @ref LL_LPTIM_ENCODER_MODE_RISING
  938. * @arg @ref LL_LPTIM_ENCODER_MODE_FALLING
  939. * @arg @ref LL_LPTIM_ENCODER_MODE_RISING_FALLING
  940. */
  941. __STATIC_INLINE uint32_t LL_LPTIM_GetEncoderMode(const LPTIM_TypeDef *LPTIMx)
  942. {
  943. return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_CKPOL));
  944. }
  945. /**
  946. * @brief Enable the encoder mode
  947. * @note This function must be called when the LPTIM instance is disabled.
  948. * @note In this mode the LPTIM instance must be clocked by an internal clock
  949. * source. Also, the prescaler division ratio must be equal to 1.
  950. * @note LPTIM instance must be configured in continuous mode prior enabling
  951. * the encoder mode.
  952. * @rmtoll CFGR ENC LL_LPTIM_EnableEncoderMode
  953. * @param LPTIMx Low-Power Timer instance
  954. * @retval None
  955. */
  956. __STATIC_INLINE void LL_LPTIM_EnableEncoderMode(LPTIM_TypeDef *LPTIMx)
  957. {
  958. SET_BIT(LPTIMx->CFGR, LPTIM_CFGR_ENC);
  959. }
  960. /**
  961. * @brief Disable the encoder mode
  962. * @note This function must be called when the LPTIM instance is disabled.
  963. * @rmtoll CFGR ENC LL_LPTIM_DisableEncoderMode
  964. * @param LPTIMx Low-Power Timer instance
  965. * @retval None
  966. */
  967. __STATIC_INLINE void LL_LPTIM_DisableEncoderMode(LPTIM_TypeDef *LPTIMx)
  968. {
  969. CLEAR_BIT(LPTIMx->CFGR, LPTIM_CFGR_ENC);
  970. }
  971. /**
  972. * @brief Indicates whether the LPTIM operates in encoder mode.
  973. * @rmtoll CFGR ENC LL_LPTIM_IsEnabledEncoderMode
  974. * @param LPTIMx Low-Power Timer instance
  975. * @retval State of bit (1 or 0).
  976. */
  977. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledEncoderMode(const LPTIM_TypeDef *LPTIMx)
  978. {
  979. return (((READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_ENC) == LPTIM_CFGR_ENC) ? 1UL : 0UL));
  980. }
  981. /**
  982. * @}
  983. */
  984. /** @defgroup LPTIM_LL_EF_FLAG_Management FLAG Management
  985. * @{
  986. */
  987. /**
  988. * @brief Clear the compare match flag (CMPMCF)
  989. * @rmtoll ICR CMPMCF LL_LPTIM_ClearFlag_CMPM
  990. * @param LPTIMx Low-Power Timer instance
  991. * @retval None
  992. */
  993. __STATIC_INLINE void LL_LPTIM_ClearFlag_CMPM(LPTIM_TypeDef *LPTIMx)
  994. {
  995. SET_BIT(LPTIMx->ICR, LPTIM_ICR_CMPMCF);
  996. }
  997. /**
  998. * @brief Inform application whether a compare match interrupt has occurred.
  999. * @rmtoll ISR CMPM LL_LPTIM_IsActiveFlag_CMPM
  1000. * @param LPTIMx Low-Power Timer instance
  1001. * @retval State of bit (1 or 0).
  1002. */
  1003. __STATIC_INLINE uint32_t LL_LPTIM_IsActiveFlag_CMPM(const LPTIM_TypeDef *LPTIMx)
  1004. {
  1005. return (((READ_BIT(LPTIMx->ISR, LPTIM_ISR_CMPM) == LPTIM_ISR_CMPM) ? 1UL : 0UL));
  1006. }
  1007. /**
  1008. * @brief Clear the autoreload match flag (ARRMCF)
  1009. * @rmtoll ICR ARRMCF LL_LPTIM_ClearFlag_ARRM
  1010. * @param LPTIMx Low-Power Timer instance
  1011. * @retval None
  1012. */
  1013. __STATIC_INLINE void LL_LPTIM_ClearFlag_ARRM(LPTIM_TypeDef *LPTIMx)
  1014. {
  1015. SET_BIT(LPTIMx->ICR, LPTIM_ICR_ARRMCF);
  1016. }
  1017. /**
  1018. * @brief Inform application whether a autoreload match interrupt has occurred.
  1019. * @rmtoll ISR ARRM LL_LPTIM_IsActiveFlag_ARRM
  1020. * @param LPTIMx Low-Power Timer instance
  1021. * @retval State of bit (1 or 0).
  1022. */
  1023. __STATIC_INLINE uint32_t LL_LPTIM_IsActiveFlag_ARRM(const LPTIM_TypeDef *LPTIMx)
  1024. {
  1025. return (((READ_BIT(LPTIMx->ISR, LPTIM_ISR_ARRM) == LPTIM_ISR_ARRM) ? 1UL : 0UL));
  1026. }
  1027. /**
  1028. * @brief Clear the external trigger valid edge flag(EXTTRIGCF).
  1029. * @rmtoll ICR EXTTRIGCF LL_LPTIM_ClearFlag_EXTTRIG
  1030. * @param LPTIMx Low-Power Timer instance
  1031. * @retval None
  1032. */
  1033. __STATIC_INLINE void LL_LPTIM_ClearFlag_EXTTRIG(LPTIM_TypeDef *LPTIMx)
  1034. {
  1035. SET_BIT(LPTIMx->ICR, LPTIM_ICR_EXTTRIGCF);
  1036. }
  1037. /**
  1038. * @brief Inform application whether a valid edge on the selected external trigger input has occurred.
  1039. * @rmtoll ISR EXTTRIG LL_LPTIM_IsActiveFlag_EXTTRIG
  1040. * @param LPTIMx Low-Power Timer instance
  1041. * @retval State of bit (1 or 0).
  1042. */
  1043. __STATIC_INLINE uint32_t LL_LPTIM_IsActiveFlag_EXTTRIG(const LPTIM_TypeDef *LPTIMx)
  1044. {
  1045. return (((READ_BIT(LPTIMx->ISR, LPTIM_ISR_EXTTRIG) == LPTIM_ISR_EXTTRIG) ? 1UL : 0UL));
  1046. }
  1047. /**
  1048. * @brief Clear the compare register update interrupt flag (CMPOKCF).
  1049. * @rmtoll ICR CMPOKCF LL_LPTIM_ClearFlag_CMPOK
  1050. * @param LPTIMx Low-Power Timer instance
  1051. * @retval None
  1052. */
  1053. __STATIC_INLINE void LL_LPTIM_ClearFlag_CMPOK(LPTIM_TypeDef *LPTIMx)
  1054. {
  1055. SET_BIT(LPTIMx->ICR, LPTIM_ICR_CMPOKCF);
  1056. }
  1057. /**
  1058. * @brief Informs application whether the APB bus write operation to the LPTIMx_CMP register has been successfully
  1059. completed. If so, a new one can be initiated.
  1060. * @rmtoll ISR CMPOK LL_LPTIM_IsActiveFlag_CMPOK
  1061. * @param LPTIMx Low-Power Timer instance
  1062. * @retval State of bit (1 or 0).
  1063. */
  1064. __STATIC_INLINE uint32_t LL_LPTIM_IsActiveFlag_CMPOK(const LPTIM_TypeDef *LPTIMx)
  1065. {
  1066. return (((READ_BIT(LPTIMx->ISR, LPTIM_ISR_CMPOK) == LPTIM_ISR_CMPOK) ? 1UL : 0UL));
  1067. }
  1068. /**
  1069. * @brief Clear the autoreload register update interrupt flag (ARROKCF).
  1070. * @rmtoll ICR ARROKCF LL_LPTIM_ClearFlag_ARROK
  1071. * @param LPTIMx Low-Power Timer instance
  1072. * @retval None
  1073. */
  1074. __STATIC_INLINE void LL_LPTIM_ClearFlag_ARROK(LPTIM_TypeDef *LPTIMx)
  1075. {
  1076. SET_BIT(LPTIMx->ICR, LPTIM_ICR_ARROKCF);
  1077. }
  1078. /**
  1079. * @brief Informs application whether the APB bus write operation to the LPTIMx_ARR register has been successfully
  1080. completed. If so, a new one can be initiated.
  1081. * @rmtoll ISR ARROK LL_LPTIM_IsActiveFlag_ARROK
  1082. * @param LPTIMx Low-Power Timer instance
  1083. * @retval State of bit (1 or 0).
  1084. */
  1085. __STATIC_INLINE uint32_t LL_LPTIM_IsActiveFlag_ARROK(const LPTIM_TypeDef *LPTIMx)
  1086. {
  1087. return (((READ_BIT(LPTIMx->ISR, LPTIM_ISR_ARROK) == LPTIM_ISR_ARROK) ? 1UL : 0UL));
  1088. }
  1089. /**
  1090. * @brief Clear the counter direction change to up interrupt flag (UPCF).
  1091. * @rmtoll ICR UPCF LL_LPTIM_ClearFlag_UP
  1092. * @param LPTIMx Low-Power Timer instance
  1093. * @retval None
  1094. */
  1095. __STATIC_INLINE void LL_LPTIM_ClearFlag_UP(LPTIM_TypeDef *LPTIMx)
  1096. {
  1097. SET_BIT(LPTIMx->ICR, LPTIM_ICR_UPCF);
  1098. }
  1099. /**
  1100. * @brief Informs the application whether the counter direction has changed from down to up (when the LPTIM instance
  1101. operates in encoder mode).
  1102. * @rmtoll ISR UP LL_LPTIM_IsActiveFlag_UP
  1103. * @param LPTIMx Low-Power Timer instance
  1104. * @retval State of bit (1 or 0).
  1105. */
  1106. __STATIC_INLINE uint32_t LL_LPTIM_IsActiveFlag_UP(const LPTIM_TypeDef *LPTIMx)
  1107. {
  1108. return (((READ_BIT(LPTIMx->ISR, LPTIM_ISR_UP) == LPTIM_ISR_UP) ? 1UL : 0UL));
  1109. }
  1110. /**
  1111. * @brief Clear the counter direction change to down interrupt flag (DOWNCF).
  1112. * @rmtoll ICR DOWNCF LL_LPTIM_ClearFlag_DOWN
  1113. * @param LPTIMx Low-Power Timer instance
  1114. * @retval None
  1115. */
  1116. __STATIC_INLINE void LL_LPTIM_ClearFlag_DOWN(LPTIM_TypeDef *LPTIMx)
  1117. {
  1118. SET_BIT(LPTIMx->ICR, LPTIM_ICR_DOWNCF);
  1119. }
  1120. /**
  1121. * @brief Informs the application whether the counter direction has changed from up to down (when the LPTIM instance
  1122. operates in encoder mode).
  1123. * @rmtoll ISR DOWN LL_LPTIM_IsActiveFlag_DOWN
  1124. * @param LPTIMx Low-Power Timer instance
  1125. * @retval State of bit (1 or 0).
  1126. */
  1127. __STATIC_INLINE uint32_t LL_LPTIM_IsActiveFlag_DOWN(const LPTIM_TypeDef *LPTIMx)
  1128. {
  1129. return (((READ_BIT(LPTIMx->ISR, LPTIM_ISR_DOWN) == LPTIM_ISR_DOWN) ? 1UL : 0UL));
  1130. }
  1131. #if defined(LPTIM_RCR_REP)
  1132. /**
  1133. * @brief Clear the repetition register update interrupt flag (REPOKCF).
  1134. * @rmtoll ICR REPOKCF LL_LPTIM_ClearFlag_REPOK
  1135. * @param LPTIMx Low-Power Timer instance
  1136. * @retval None
  1137. */
  1138. __STATIC_INLINE void LL_LPTIM_ClearFlag_REPOK(LPTIM_TypeDef *LPTIMx)
  1139. {
  1140. SET_BIT(LPTIMx->ICR, LPTIM_ICR_REPOKCF);
  1141. }
  1142. /**
  1143. * @brief Informs application whether the APB bus write operation to the LPTIMx_RCR register has been successfully
  1144. completed; If so, a new one can be initiated.
  1145. * @rmtoll ISR REPOK LL_LPTIM_IsActiveFlag_REPOK
  1146. * @param LPTIMx Low-Power Timer instance
  1147. * @retval State of bit (1 or 0).
  1148. */
  1149. __STATIC_INLINE uint32_t LL_LPTIM_IsActiveFlag_REPOK(const LPTIM_TypeDef *LPTIMx)
  1150. {
  1151. return ((READ_BIT(LPTIMx->ISR, LPTIM_ISR_REPOK) == (LPTIM_ISR_REPOK)) ? 1UL : 0UL);
  1152. }
  1153. /**
  1154. * @brief Clear the update event flag (UECF).
  1155. * @rmtoll ICR UECF LL_LPTIM_ClearFlag_UE
  1156. * @param LPTIMx Low-Power Timer instance
  1157. * @retval None
  1158. */
  1159. __STATIC_INLINE void LL_LPTIM_ClearFlag_UE(LPTIM_TypeDef *LPTIMx)
  1160. {
  1161. SET_BIT(LPTIMx->ICR, LPTIM_ICR_UECF);
  1162. }
  1163. /**
  1164. * @brief Informs application whether the LPTIMx update event has occurred.
  1165. * @rmtoll ISR UE LL_LPTIM_IsActiveFlag_UE
  1166. * @param LPTIMx Low-Power Timer instance
  1167. * @retval State of bit (1 or 0).
  1168. */
  1169. __STATIC_INLINE uint32_t LL_LPTIM_IsActiveFlag_UE(const LPTIM_TypeDef *LPTIMx)
  1170. {
  1171. return ((READ_BIT(LPTIMx->ISR, LPTIM_ISR_UE) == (LPTIM_ISR_UE)) ? 1UL : 0UL);
  1172. }
  1173. #endif
  1174. /**
  1175. * @}
  1176. */
  1177. /** @defgroup LPTIM_LL_EF_IT_Management Interrupt Management
  1178. * @{
  1179. */
  1180. /**
  1181. * @brief Enable compare match interrupt (CMPMIE).
  1182. * @rmtoll IER CMPMIE LL_LPTIM_EnableIT_CMPM
  1183. * @param LPTIMx Low-Power Timer instance
  1184. * @retval None
  1185. */
  1186. __STATIC_INLINE void LL_LPTIM_EnableIT_CMPM(LPTIM_TypeDef *LPTIMx)
  1187. {
  1188. SET_BIT(LPTIMx->IER, LPTIM_IER_CMPMIE);
  1189. }
  1190. /**
  1191. * @brief Disable compare match interrupt (CMPMIE).
  1192. * @rmtoll IER CMPMIE LL_LPTIM_DisableIT_CMPM
  1193. * @param LPTIMx Low-Power Timer instance
  1194. * @retval None
  1195. */
  1196. __STATIC_INLINE void LL_LPTIM_DisableIT_CMPM(LPTIM_TypeDef *LPTIMx)
  1197. {
  1198. CLEAR_BIT(LPTIMx->IER, LPTIM_IER_CMPMIE);
  1199. }
  1200. /**
  1201. * @brief Indicates whether the compare match interrupt (CMPMIE) is enabled.
  1202. * @rmtoll IER CMPMIE LL_LPTIM_IsEnabledIT_CMPM
  1203. * @param LPTIMx Low-Power Timer instance
  1204. * @retval State of bit (1 or 0).
  1205. */
  1206. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledIT_CMPM(const LPTIM_TypeDef *LPTIMx)
  1207. {
  1208. return (((READ_BIT(LPTIMx->IER, LPTIM_IER_CMPMIE) == LPTIM_IER_CMPMIE) ? 1UL : 0UL));
  1209. }
  1210. /**
  1211. * @brief Enable autoreload match interrupt (ARRMIE).
  1212. * @rmtoll IER ARRMIE LL_LPTIM_EnableIT_ARRM
  1213. * @param LPTIMx Low-Power Timer instance
  1214. * @retval None
  1215. */
  1216. __STATIC_INLINE void LL_LPTIM_EnableIT_ARRM(LPTIM_TypeDef *LPTIMx)
  1217. {
  1218. SET_BIT(LPTIMx->IER, LPTIM_IER_ARRMIE);
  1219. }
  1220. /**
  1221. * @brief Disable autoreload match interrupt (ARRMIE).
  1222. * @rmtoll IER ARRMIE LL_LPTIM_DisableIT_ARRM
  1223. * @param LPTIMx Low-Power Timer instance
  1224. * @retval None
  1225. */
  1226. __STATIC_INLINE void LL_LPTIM_DisableIT_ARRM(LPTIM_TypeDef *LPTIMx)
  1227. {
  1228. CLEAR_BIT(LPTIMx->IER, LPTIM_IER_ARRMIE);
  1229. }
  1230. /**
  1231. * @brief Indicates whether the autoreload match interrupt (ARRMIE) is enabled.
  1232. * @rmtoll IER ARRMIE LL_LPTIM_IsEnabledIT_ARRM
  1233. * @param LPTIMx Low-Power Timer instance
  1234. * @retval State of bit (1 or 0).
  1235. */
  1236. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledIT_ARRM(const LPTIM_TypeDef *LPTIMx)
  1237. {
  1238. return (((READ_BIT(LPTIMx->IER, LPTIM_IER_ARRMIE) == LPTIM_IER_ARRMIE) ? 1UL : 0UL));
  1239. }
  1240. /**
  1241. * @brief Enable external trigger valid edge interrupt (EXTTRIGIE).
  1242. * @rmtoll IER EXTTRIGIE LL_LPTIM_EnableIT_EXTTRIG
  1243. * @param LPTIMx Low-Power Timer instance
  1244. * @retval None
  1245. */
  1246. __STATIC_INLINE void LL_LPTIM_EnableIT_EXTTRIG(LPTIM_TypeDef *LPTIMx)
  1247. {
  1248. SET_BIT(LPTIMx->IER, LPTIM_IER_EXTTRIGIE);
  1249. }
  1250. /**
  1251. * @brief Disable external trigger valid edge interrupt (EXTTRIGIE).
  1252. * @rmtoll IER EXTTRIGIE LL_LPTIM_DisableIT_EXTTRIG
  1253. * @param LPTIMx Low-Power Timer instance
  1254. * @retval None
  1255. */
  1256. __STATIC_INLINE void LL_LPTIM_DisableIT_EXTTRIG(LPTIM_TypeDef *LPTIMx)
  1257. {
  1258. CLEAR_BIT(LPTIMx->IER, LPTIM_IER_EXTTRIGIE);
  1259. }
  1260. /**
  1261. * @brief Indicates external trigger valid edge interrupt (EXTTRIGIE) is enabled.
  1262. * @rmtoll IER EXTTRIGIE LL_LPTIM_IsEnabledIT_EXTTRIG
  1263. * @param LPTIMx Low-Power Timer instance
  1264. * @retval State of bit (1 or 0).
  1265. */
  1266. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledIT_EXTTRIG(const LPTIM_TypeDef *LPTIMx)
  1267. {
  1268. return (((READ_BIT(LPTIMx->IER, LPTIM_IER_EXTTRIGIE) == LPTIM_IER_EXTTRIGIE) ? 1UL : 0UL));
  1269. }
  1270. /**
  1271. * @brief Enable compare register write completed interrupt (CMPOKIE).
  1272. * @rmtoll IER CMPOKIE LL_LPTIM_EnableIT_CMPOK
  1273. * @param LPTIMx Low-Power Timer instance
  1274. * @retval None
  1275. */
  1276. __STATIC_INLINE void LL_LPTIM_EnableIT_CMPOK(LPTIM_TypeDef *LPTIMx)
  1277. {
  1278. SET_BIT(LPTIMx->IER, LPTIM_IER_CMPOKIE);
  1279. }
  1280. /**
  1281. * @brief Disable compare register write completed interrupt (CMPOKIE).
  1282. * @rmtoll IER CMPOKIE LL_LPTIM_DisableIT_CMPOK
  1283. * @param LPTIMx Low-Power Timer instance
  1284. * @retval None
  1285. */
  1286. __STATIC_INLINE void LL_LPTIM_DisableIT_CMPOK(LPTIM_TypeDef *LPTIMx)
  1287. {
  1288. CLEAR_BIT(LPTIMx->IER, LPTIM_IER_CMPOKIE);
  1289. }
  1290. /**
  1291. * @brief Indicates whether the compare register write completed interrupt (CMPOKIE) is enabled.
  1292. * @rmtoll IER CMPOKIE LL_LPTIM_IsEnabledIT_CMPOK
  1293. * @param LPTIMx Low-Power Timer instance
  1294. * @retval State of bit (1 or 0).
  1295. */
  1296. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledIT_CMPOK(const LPTIM_TypeDef *LPTIMx)
  1297. {
  1298. return (((READ_BIT(LPTIMx->IER, LPTIM_IER_CMPOKIE) == LPTIM_IER_CMPOKIE) ? 1UL : 0UL));
  1299. }
  1300. /**
  1301. * @brief Enable autoreload register write completed interrupt (ARROKIE).
  1302. * @rmtoll IER ARROKIE LL_LPTIM_EnableIT_ARROK
  1303. * @param LPTIMx Low-Power Timer instance
  1304. * @retval None
  1305. */
  1306. __STATIC_INLINE void LL_LPTIM_EnableIT_ARROK(LPTIM_TypeDef *LPTIMx)
  1307. {
  1308. SET_BIT(LPTIMx->IER, LPTIM_IER_ARROKIE);
  1309. }
  1310. /**
  1311. * @brief Disable autoreload register write completed interrupt (ARROKIE).
  1312. * @rmtoll IER ARROKIE LL_LPTIM_DisableIT_ARROK
  1313. * @param LPTIMx Low-Power Timer instance
  1314. * @retval None
  1315. */
  1316. __STATIC_INLINE void LL_LPTIM_DisableIT_ARROK(LPTIM_TypeDef *LPTIMx)
  1317. {
  1318. CLEAR_BIT(LPTIMx->IER, LPTIM_IER_ARROKIE);
  1319. }
  1320. /**
  1321. * @brief Indicates whether the autoreload register write completed interrupt (ARROKIE) is enabled.
  1322. * @rmtoll IER ARROKIE LL_LPTIM_IsEnabledIT_ARROK
  1323. * @param LPTIMx Low-Power Timer instance
  1324. * @retval State of bit(1 or 0).
  1325. */
  1326. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledIT_ARROK(const LPTIM_TypeDef *LPTIMx)
  1327. {
  1328. return (((READ_BIT(LPTIMx->IER, LPTIM_IER_ARROKIE) == LPTIM_IER_ARROKIE) ? 1UL : 0UL));
  1329. }
  1330. /**
  1331. * @brief Enable direction change to up interrupt (UPIE).
  1332. * @rmtoll IER UPIE LL_LPTIM_EnableIT_UP
  1333. * @param LPTIMx Low-Power Timer instance
  1334. * @retval None
  1335. */
  1336. __STATIC_INLINE void LL_LPTIM_EnableIT_UP(LPTIM_TypeDef *LPTIMx)
  1337. {
  1338. SET_BIT(LPTIMx->IER, LPTIM_IER_UPIE);
  1339. }
  1340. /**
  1341. * @brief Disable direction change to up interrupt (UPIE).
  1342. * @rmtoll IER UPIE LL_LPTIM_DisableIT_UP
  1343. * @param LPTIMx Low-Power Timer instance
  1344. * @retval None
  1345. */
  1346. __STATIC_INLINE void LL_LPTIM_DisableIT_UP(LPTIM_TypeDef *LPTIMx)
  1347. {
  1348. CLEAR_BIT(LPTIMx->IER, LPTIM_IER_UPIE);
  1349. }
  1350. /**
  1351. * @brief Indicates whether the direction change to up interrupt (UPIE) is enabled.
  1352. * @rmtoll IER UPIE LL_LPTIM_IsEnabledIT_UP
  1353. * @param LPTIMx Low-Power Timer instance
  1354. * @retval State of bit(1 or 0).
  1355. */
  1356. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledIT_UP(const LPTIM_TypeDef *LPTIMx)
  1357. {
  1358. return (((READ_BIT(LPTIMx->IER, LPTIM_IER_UPIE) == LPTIM_IER_UPIE) ? 1UL : 0UL));
  1359. }
  1360. /**
  1361. * @brief Enable direction change to down interrupt (DOWNIE).
  1362. * @rmtoll IER DOWNIE LL_LPTIM_EnableIT_DOWN
  1363. * @param LPTIMx Low-Power Timer instance
  1364. * @retval None
  1365. */
  1366. __STATIC_INLINE void LL_LPTIM_EnableIT_DOWN(LPTIM_TypeDef *LPTIMx)
  1367. {
  1368. SET_BIT(LPTIMx->IER, LPTIM_IER_DOWNIE);
  1369. }
  1370. /**
  1371. * @brief Disable direction change to down interrupt (DOWNIE).
  1372. * @rmtoll IER DOWNIE LL_LPTIM_DisableIT_DOWN
  1373. * @param LPTIMx Low-Power Timer instance
  1374. * @retval None
  1375. */
  1376. __STATIC_INLINE void LL_LPTIM_DisableIT_DOWN(LPTIM_TypeDef *LPTIMx)
  1377. {
  1378. CLEAR_BIT(LPTIMx->IER, LPTIM_IER_DOWNIE);
  1379. }
  1380. /**
  1381. * @brief Indicates whether the direction change to down interrupt (DOWNIE) is enabled.
  1382. * @rmtoll IER DOWNIE LL_LPTIM_IsEnabledIT_DOWN
  1383. * @param LPTIMx Low-Power Timer instance
  1384. * @retval State of bit(1 or 0).
  1385. */
  1386. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledIT_DOWN(const LPTIM_TypeDef *LPTIMx)
  1387. {
  1388. return ((READ_BIT(LPTIMx->IER, LPTIM_IER_DOWNIE) == LPTIM_IER_DOWNIE) ? 1UL : 0UL);
  1389. }
  1390. #if defined(LPTIM_RCR_REP)
  1391. /**
  1392. * @brief Enable repetition register update successfully completed interrupt (REPOKIE).
  1393. * @rmtoll IER REPOKIE LL_LPTIM_EnableIT_REPOK
  1394. * @param LPTIMx Low-Power Timer instance
  1395. * @retval None
  1396. */
  1397. __STATIC_INLINE void LL_LPTIM_EnableIT_REPOK(LPTIM_TypeDef *LPTIMx)
  1398. {
  1399. SET_BIT(LPTIMx->IER, LPTIM_IER_REPOKIE);
  1400. }
  1401. /**
  1402. * @brief Disable repetition register update successfully completed interrupt (REPOKIE).
  1403. * @rmtoll IER REPOKIE LL_LPTIM_DisableIT_REPOK
  1404. * @param LPTIMx Low-Power Timer instance
  1405. * @retval None
  1406. */
  1407. __STATIC_INLINE void LL_LPTIM_DisableIT_REPOK(LPTIM_TypeDef *LPTIMx)
  1408. {
  1409. CLEAR_BIT(LPTIMx->IER, LPTIM_IER_REPOKIE);
  1410. }
  1411. /**
  1412. * @brief Indicates whether the repetition register update successfully completed interrupt (REPOKIE) is enabled.
  1413. * @rmtoll IER REPOKIE LL_LPTIM_IsEnabledIT_REPOK
  1414. * @param LPTIMx Low-Power Timer instance
  1415. * @retval State of bit(1 or 0).
  1416. */
  1417. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledIT_REPOK(const LPTIM_TypeDef *LPTIMx)
  1418. {
  1419. return ((READ_BIT(LPTIMx->IER, LPTIM_IER_REPOKIE) == (LPTIM_IER_REPOKIE)) ? 1UL : 0UL);
  1420. }
  1421. /**
  1422. * @brief Enable update event interrupt (UEIE).
  1423. * @rmtoll IER UEIE LL_LPTIM_EnableIT_UE
  1424. * @param LPTIMx Low-Power Timer instance
  1425. * @retval None
  1426. */
  1427. __STATIC_INLINE void LL_LPTIM_EnableIT_UE(LPTIM_TypeDef *LPTIMx)
  1428. {
  1429. SET_BIT(LPTIMx->IER, LPTIM_IER_UEIE);
  1430. }
  1431. /**
  1432. * @brief Disable update event interrupt (UEIE).
  1433. * @rmtoll IER UEIE LL_LPTIM_DisableIT_UE
  1434. * @param LPTIMx Low-Power Timer instance
  1435. * @retval None
  1436. */
  1437. __STATIC_INLINE void LL_LPTIM_DisableIT_UE(LPTIM_TypeDef *LPTIMx)
  1438. {
  1439. CLEAR_BIT(LPTIMx->IER, LPTIM_IER_UEIE);
  1440. }
  1441. /**
  1442. * @brief Indicates whether the update event interrupt (UEIE) is enabled.
  1443. * @rmtoll IER UEIE LL_LPTIM_IsEnabledIT_UE
  1444. * @param LPTIMx Low-Power Timer instance
  1445. *@ retval State of bit(1 or 0).
  1446. */
  1447. __STATIC_INLINE uint32_t LL_LPTIM_IsEnabledIT_UE(const LPTIM_TypeDef *LPTIMx)
  1448. {
  1449. return ((READ_BIT(LPTIMx->IER, LPTIM_IER_UEIE) == (LPTIM_IER_UEIE)) ? 1UL : 0UL);
  1450. }
  1451. #endif
  1452. /**
  1453. * @}
  1454. */
  1455. /**
  1456. * @}
  1457. */
  1458. /**
  1459. * @}
  1460. */
  1461. #endif /* LPTIM1 || LPTIM2 */
  1462. /**
  1463. * @}
  1464. */
  1465. #ifdef __cplusplus
  1466. }
  1467. #endif
  1468. #endif /* STM32L4xx_LL_LPTIM_H */