stm32l4xx_ll_lptim.h 58 KB

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