stm32f7xx_ll_lptim.h 51 KB

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