stm32g0xx_ll_lptim.h 56 KB

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