stm32g4xx_ll_lptim.h 55 KB

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