stm32g4xx_hal_lptim.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  1. /**
  2. ******************************************************************************
  3. * @file stm32g4xx_hal_lptim.h
  4. * @author MCD Application Team
  5. * @brief Header file of LPTIM HAL 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_HAL_LPTIM_H
  20. #define STM32G4xx_HAL_LPTIM_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32g4xx_hal_def.h"
  26. /** @addtogroup STM32G4xx_HAL_Driver
  27. * @{
  28. */
  29. /** @addtogroup LPTIM
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /** @defgroup LPTIM_Exported_Types LPTIM Exported Types
  34. * @{
  35. */
  36. #define LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT EXTI_IMR2_IM37 /*!< External interrupt line 37 Connected to the LPTIM EXTI Line */
  37. /**
  38. * @brief LPTIM Clock configuration definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t Source; /*!< Selects the clock source.
  43. This parameter can be a value of @ref LPTIM_Clock_Source */
  44. uint32_t Prescaler; /*!< Specifies the counter clock Prescaler.
  45. This parameter can be a value of @ref LPTIM_Clock_Prescaler */
  46. } LPTIM_ClockConfigTypeDef;
  47. /**
  48. * @brief LPTIM Clock configuration definition
  49. */
  50. typedef struct
  51. {
  52. uint32_t Polarity; /*!< Selects the polarity of the active edge for the counter unit
  53. if the ULPTIM input is selected.
  54. Note: This parameter is used only when Ultra low power clock source is used.
  55. Note: If the polarity is configured on 'both edges', an auxiliary clock
  56. (one of the Low power oscillator) must be active.
  57. This parameter can be a value of @ref LPTIM_Clock_Polarity */
  58. uint32_t SampleTime; /*!< Selects the clock sampling time to configure the clock glitch filter.
  59. Note: This parameter is used only when Ultra low power clock source is used.
  60. This parameter can be a value of @ref LPTIM_Clock_Sample_Time */
  61. } LPTIM_ULPClockConfigTypeDef;
  62. /**
  63. * @brief LPTIM Trigger configuration definition
  64. */
  65. typedef struct
  66. {
  67. uint32_t Source; /*!< Selects the Trigger source.
  68. This parameter can be a value of @ref LPTIM_Trigger_Source */
  69. uint32_t ActiveEdge; /*!< Selects the Trigger active edge.
  70. Note: This parameter is used only when an external trigger is used.
  71. This parameter can be a value of @ref LPTIM_External_Trigger_Polarity */
  72. uint32_t SampleTime; /*!< Selects the trigger sampling time to configure the clock glitch filter.
  73. Note: This parameter is used only when an external trigger is used.
  74. This parameter can be a value of @ref LPTIM_Trigger_Sample_Time */
  75. } LPTIM_TriggerConfigTypeDef;
  76. /**
  77. * @brief LPTIM Initialization Structure definition
  78. */
  79. typedef struct
  80. {
  81. LPTIM_ClockConfigTypeDef Clock; /*!< Specifies the clock parameters */
  82. LPTIM_ULPClockConfigTypeDef UltraLowPowerClock;/*!< Specifies the Ultra Low Power clock parameters */
  83. LPTIM_TriggerConfigTypeDef Trigger; /*!< Specifies the Trigger parameters */
  84. uint32_t OutputPolarity; /*!< Specifies the Output polarity.
  85. This parameter can be a value of @ref LPTIM_Output_Polarity */
  86. uint32_t UpdateMode; /*!< Specifies whether the update of the autoreload and the compare
  87. values is done immediately or after the end of current period.
  88. This parameter can be a value of @ref LPTIM_Updating_Mode */
  89. uint32_t CounterSource; /*!< Specifies whether the counter is incremented each internal event
  90. or each external event.
  91. This parameter can be a value of @ref LPTIM_Counter_Source */
  92. uint32_t Input1Source; /*!< Specifies source selected for input1 (GPIO or comparator output).
  93. This parameter can be a value of @ref LPTIM_Input1_Source */
  94. uint32_t Input2Source; /*!< Specifies source selected for input2 (GPIO or comparator output).
  95. Note: This parameter is used only for encoder feature so is used only
  96. for LPTIM1 instance.
  97. This parameter can be a value of @ref LPTIM_Input2_Source */
  98. } LPTIM_InitTypeDef;
  99. /**
  100. * @brief HAL LPTIM State structure definition
  101. */
  102. typedef enum
  103. {
  104. HAL_LPTIM_STATE_RESET = 0x00U, /*!< Peripheral not yet initialized or disabled */
  105. HAL_LPTIM_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
  106. HAL_LPTIM_STATE_BUSY = 0x02U, /*!< An internal process is ongoing */
  107. HAL_LPTIM_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
  108. HAL_LPTIM_STATE_ERROR = 0x04U /*!< Internal Process is ongoing */
  109. } HAL_LPTIM_StateTypeDef;
  110. /**
  111. * @brief LPTIM handle Structure definition
  112. */
  113. #if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
  114. typedef struct __LPTIM_HandleTypeDef
  115. #else
  116. typedef struct
  117. #endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
  118. {
  119. LPTIM_TypeDef *Instance; /*!< Register base address */
  120. LPTIM_InitTypeDef Init; /*!< LPTIM required parameters */
  121. HAL_StatusTypeDef Status; /*!< LPTIM peripheral status */
  122. HAL_LockTypeDef Lock; /*!< LPTIM locking object */
  123. __IO HAL_LPTIM_StateTypeDef State; /*!< LPTIM peripheral state */
  124. #if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
  125. void (* MspInitCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Base Msp Init Callback */
  126. void (* MspDeInitCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Base Msp DeInit Callback */
  127. void (* CompareMatchCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Compare match Callback */
  128. void (* AutoReloadMatchCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Auto-reload match Callback */
  129. void (* TriggerCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< External trigger event detection Callback */
  130. void (* CompareWriteCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Compare register write complete Callback */
  131. void (* AutoReloadWriteCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Auto-reload register write complete Callback */
  132. void (* DirectionUpCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Up-counting direction change Callback */
  133. void (* DirectionDownCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Down-counting direction change Callback */
  134. #endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
  135. } LPTIM_HandleTypeDef;
  136. #if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
  137. /**
  138. * @brief HAL LPTIM Callback ID enumeration definition
  139. */
  140. typedef enum
  141. {
  142. HAL_LPTIM_MSPINIT_CB_ID = 0x00U, /*!< LPTIM Base Msp Init Callback ID */
  143. HAL_LPTIM_MSPDEINIT_CB_ID = 0x01U, /*!< LPTIM Base Msp DeInit Callback ID */
  144. HAL_LPTIM_COMPARE_MATCH_CB_ID = 0x02U, /*!< Compare match Callback ID */
  145. HAL_LPTIM_AUTORELOAD_MATCH_CB_ID = 0x03U, /*!< Auto-reload match Callback ID */
  146. HAL_LPTIM_TRIGGER_CB_ID = 0x04U, /*!< External trigger event detection Callback ID */
  147. HAL_LPTIM_COMPARE_WRITE_CB_ID = 0x05U, /*!< Compare register write complete Callback ID */
  148. HAL_LPTIM_AUTORELOAD_WRITE_CB_ID = 0x06U, /*!< Auto-reload register write complete Callback ID */
  149. HAL_LPTIM_DIRECTION_UP_CB_ID = 0x07U, /*!< Up-counting direction change Callback ID */
  150. HAL_LPTIM_DIRECTION_DOWN_CB_ID = 0x08U, /*!< Down-counting direction change Callback ID */
  151. } HAL_LPTIM_CallbackIDTypeDef;
  152. /**
  153. * @brief HAL TIM Callback pointer definition
  154. */
  155. typedef void (*pLPTIM_CallbackTypeDef)(LPTIM_HandleTypeDef *hlptim); /*!< pointer to the LPTIM callback function */
  156. #endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
  157. /**
  158. * @}
  159. */
  160. /* Exported constants --------------------------------------------------------*/
  161. /** @defgroup LPTIM_Exported_Constants LPTIM Exported Constants
  162. * @{
  163. */
  164. /** @defgroup LPTIM_Clock_Source LPTIM Clock Source
  165. * @{
  166. */
  167. #define LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC 0x00000000U
  168. #define LPTIM_CLOCKSOURCE_ULPTIM LPTIM_CFGR_CKSEL
  169. /**
  170. * @}
  171. */
  172. /** @defgroup LPTIM_Clock_Prescaler LPTIM Clock Prescaler
  173. * @{
  174. */
  175. #define LPTIM_PRESCALER_DIV1 0x00000000U
  176. #define LPTIM_PRESCALER_DIV2 LPTIM_CFGR_PRESC_0
  177. #define LPTIM_PRESCALER_DIV4 LPTIM_CFGR_PRESC_1
  178. #define LPTIM_PRESCALER_DIV8 (LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_1)
  179. #define LPTIM_PRESCALER_DIV16 LPTIM_CFGR_PRESC_2
  180. #define LPTIM_PRESCALER_DIV32 (LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_2)
  181. #define LPTIM_PRESCALER_DIV64 (LPTIM_CFGR_PRESC_1 | LPTIM_CFGR_PRESC_2)
  182. #define LPTIM_PRESCALER_DIV128 LPTIM_CFGR_PRESC
  183. /**
  184. * @}
  185. */
  186. /** @defgroup LPTIM_Output_Polarity LPTIM Output Polarity
  187. * @{
  188. */
  189. #define LPTIM_OUTPUTPOLARITY_HIGH 0x00000000U
  190. #define LPTIM_OUTPUTPOLARITY_LOW LPTIM_CFGR_WAVPOL
  191. /**
  192. * @}
  193. */
  194. /** @defgroup LPTIM_Clock_Sample_Time LPTIM Clock Sample Time
  195. * @{
  196. */
  197. #define LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION 0x00000000U
  198. #define LPTIM_CLOCKSAMPLETIME_2TRANSITIONS LPTIM_CFGR_CKFLT_0
  199. #define LPTIM_CLOCKSAMPLETIME_4TRANSITIONS LPTIM_CFGR_CKFLT_1
  200. #define LPTIM_CLOCKSAMPLETIME_8TRANSITIONS LPTIM_CFGR_CKFLT
  201. /**
  202. * @}
  203. */
  204. /** @defgroup LPTIM_Clock_Polarity LPTIM Clock Polarity
  205. * @{
  206. */
  207. #define LPTIM_CLOCKPOLARITY_RISING 0x00000000U
  208. #define LPTIM_CLOCKPOLARITY_FALLING LPTIM_CFGR_CKPOL_0
  209. #define LPTIM_CLOCKPOLARITY_RISING_FALLING LPTIM_CFGR_CKPOL_1
  210. /**
  211. * @}
  212. */
  213. /** @defgroup LPTIM_Trigger_Source LPTIM Trigger Source
  214. * @{
  215. */
  216. #define LPTIM_TRIGSOURCE_SOFTWARE 0x0000FFFFU
  217. #define LPTIM_TRIGSOURCE_0 0x00000000U
  218. #define LPTIM_TRIGSOURCE_1 LPTIM_CFGR_TRIGSEL_0
  219. #define LPTIM_TRIGSOURCE_2 LPTIM_CFGR_TRIGSEL_1
  220. #define LPTIM_TRIGSOURCE_3 (LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_1)
  221. #define LPTIM_TRIGSOURCE_4 LPTIM_CFGR_TRIGSEL_2
  222. #define LPTIM_TRIGSOURCE_5 (LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_2)
  223. #define LPTIM_TRIGSOURCE_6 (LPTIM_CFGR_TRIGSEL_1 | LPTIM_CFGR_TRIGSEL_2)
  224. #define LPTIM_TRIGSOURCE_7 (LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_1 | LPTIM_CFGR_TRIGSEL_2)
  225. #define LPTIM_TRIGSOURCE_8 LPTIM_CFGR_TRIGSEL_3
  226. #define LPTIM_TRIGSOURCE_9 (LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_3)
  227. #define LPTIM_TRIGSOURCE_10 (LPTIM_CFGR_TRIGSEL_1 | LPTIM_CFGR_TRIGSEL_3)
  228. #define LPTIM_TRIGSOURCE_11 (LPTIM_CFGR_TRIGSEL_0 |LPTIM_CFGR_TRIGSEL_1 | LPTIM_CFGR_TRIGSEL_3)
  229. #define LPTIM_TRIGSOURCE_12 (LPTIM_CFGR_TRIGSEL_2 | LPTIM_CFGR_TRIGSEL_3)
  230. /**
  231. * @}
  232. */
  233. /** @defgroup LPTIM_External_Trigger_Polarity LPTIM External Trigger Polarity
  234. * @{
  235. */
  236. #define LPTIM_ACTIVEEDGE_RISING LPTIM_CFGR_TRIGEN_0
  237. #define LPTIM_ACTIVEEDGE_FALLING LPTIM_CFGR_TRIGEN_1
  238. #define LPTIM_ACTIVEEDGE_RISING_FALLING LPTIM_CFGR_TRIGEN
  239. /**
  240. * @}
  241. */
  242. /** @defgroup LPTIM_Trigger_Sample_Time LPTIM Trigger Sample Time
  243. * @{
  244. */
  245. #define LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION 0x00000000U
  246. #define LPTIM_TRIGSAMPLETIME_2TRANSITIONS LPTIM_CFGR_TRGFLT_0
  247. #define LPTIM_TRIGSAMPLETIME_4TRANSITIONS LPTIM_CFGR_TRGFLT_1
  248. #define LPTIM_TRIGSAMPLETIME_8TRANSITIONS LPTIM_CFGR_TRGFLT
  249. /**
  250. * @}
  251. */
  252. /** @defgroup LPTIM_Updating_Mode LPTIM Updating Mode
  253. * @{
  254. */
  255. #define LPTIM_UPDATE_IMMEDIATE 0x00000000U
  256. #define LPTIM_UPDATE_ENDOFPERIOD LPTIM_CFGR_PRELOAD
  257. /**
  258. * @}
  259. */
  260. /** @defgroup LPTIM_Counter_Source LPTIM Counter Source
  261. * @{
  262. */
  263. #define LPTIM_COUNTERSOURCE_INTERNAL 0x00000000U
  264. #define LPTIM_COUNTERSOURCE_EXTERNAL LPTIM_CFGR_COUNTMODE
  265. /**
  266. * @}
  267. */
  268. /** @defgroup LPTIM_Input1_Source LPTIM Input1 Source
  269. * @{
  270. */
  271. #define LPTIM_INPUT1SOURCE_GPIO 0x00000000U
  272. #define LPTIM_INPUT1SOURCE_COMP1 LPTIM_OR_IN1_0
  273. #define LPTIM_INPUT1SOURCE_COMP3 (LPTIM_OR_IN1_1 | LPTIM_OR_IN1_0)
  274. #if defined(COMP5)
  275. #define LPTIM_INPUT1SOURCE_COMP5 (LPTIM_OR_IN1_2 | LPTIM_OR_IN1_0)
  276. #endif /* COMP5 */
  277. #if defined(COMP7)
  278. #define LPTIM_INPUT1SOURCE_COMP7 (LPTIM_OR_IN1_2 | LPTIM_OR_IN1_1 | LPTIM_OR_IN1_0)
  279. #endif /* COMP7 */
  280. /**
  281. * @}
  282. */
  283. /** @defgroup LPTIM_Input2_Source LPTIM Input2 Source
  284. * @{
  285. */
  286. #define LPTIM_INPUT2SOURCE_GPIO 0x00000000U
  287. #define LPTIM_INPUT2SOURCE_COMP2 LPTIM_OR_IN2_0
  288. #define LPTIM_INPUT2SOURCE_COMP4 (LPTIM_OR_IN2_1 | LPTIM_OR_IN2_0)
  289. #if defined(COMP6)
  290. #define LPTIM_INPUT2SOURCE_COMP6 (LPTIM_OR_IN2_2 | LPTIM_OR_IN2_0)
  291. #endif /* COMP6 */
  292. /**
  293. * @}
  294. */
  295. /** @defgroup LPTIM_Flag_Definition LPTIM Flags Definition
  296. * @{
  297. */
  298. #define LPTIM_FLAG_DOWN LPTIM_ISR_DOWN
  299. #define LPTIM_FLAG_UP LPTIM_ISR_UP
  300. #define LPTIM_FLAG_ARROK LPTIM_ISR_ARROK
  301. #define LPTIM_FLAG_CMPOK LPTIM_ISR_CMPOK
  302. #define LPTIM_FLAG_EXTTRIG LPTIM_ISR_EXTTRIG
  303. #define LPTIM_FLAG_ARRM LPTIM_ISR_ARRM
  304. #define LPTIM_FLAG_CMPM LPTIM_ISR_CMPM
  305. /**
  306. * @}
  307. */
  308. /** @defgroup LPTIM_Interrupts_Definition LPTIM Interrupts Definition
  309. * @{
  310. */
  311. #define LPTIM_IT_DOWN LPTIM_IER_DOWNIE
  312. #define LPTIM_IT_UP LPTIM_IER_UPIE
  313. #define LPTIM_IT_ARROK LPTIM_IER_ARROKIE
  314. #define LPTIM_IT_CMPOK LPTIM_IER_CMPOKIE
  315. #define LPTIM_IT_EXTTRIG LPTIM_IER_EXTTRIGIE
  316. #define LPTIM_IT_ARRM LPTIM_IER_ARRMIE
  317. #define LPTIM_IT_CMPM LPTIM_IER_CMPMIE
  318. /**
  319. * @}
  320. */
  321. /**
  322. * @}
  323. */
  324. /* Exported macros -----------------------------------------------------------*/
  325. /** @defgroup LPTIM_Exported_Macros LPTIM Exported Macros
  326. * @{
  327. */
  328. /** @brief Reset LPTIM handle state.
  329. * @param __HANDLE__ LPTIM handle
  330. * @retval None
  331. */
  332. #if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
  333. #define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) do { \
  334. (__HANDLE__)->State = HAL_LPTIM_STATE_RESET; \
  335. (__HANDLE__)->MspInitCallback = NULL; \
  336. (__HANDLE__)->MspDeInitCallback = NULL; \
  337. } while(0)
  338. #else
  339. #define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LPTIM_STATE_RESET)
  340. #endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
  341. /**
  342. * @brief Enable the LPTIM peripheral.
  343. * @param __HANDLE__ LPTIM handle
  344. * @retval None
  345. */
  346. #define __HAL_LPTIM_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (LPTIM_CR_ENABLE))
  347. /**
  348. * @brief Disable the LPTIM peripheral.
  349. * @param __HANDLE__ LPTIM handle
  350. * @note The following sequence is required to solve LPTIM disable HW limitation.
  351. * Please check Errata Sheet ES0335 for more details under "MCU may remain
  352. * stuck in LPTIM interrupt when entering Stop mode" section.
  353. * @note Please call @ref HAL_LPTIM_GetState() after a call to __HAL_LPTIM_DISABLE to
  354. * check for TIMEOUT.
  355. * @retval None
  356. */
  357. #define __HAL_LPTIM_DISABLE(__HANDLE__) LPTIM_Disable(__HANDLE__)
  358. /**
  359. * @brief Start the LPTIM peripheral in Continuous mode.
  360. * @param __HANDLE__ LPTIM handle
  361. * @retval None
  362. */
  363. #define __HAL_LPTIM_START_CONTINUOUS(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_CNTSTRT)
  364. /**
  365. * @brief Start the LPTIM peripheral in single mode.
  366. * @param __HANDLE__ LPTIM handle
  367. * @retval None
  368. */
  369. #define __HAL_LPTIM_START_SINGLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_SNGSTRT)
  370. /**
  371. * @brief Reset the LPTIM Counter register in synchronous mode.
  372. * @param __HANDLE__ LPTIM handle
  373. * @retval None
  374. */
  375. #define __HAL_LPTIM_RESET_COUNTER(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_COUNTRST)
  376. /**
  377. * @brief Reset after read of the LPTIM Counter register in asynchronous mode.
  378. * @param __HANDLE__ LPTIM handle
  379. * @retval None
  380. */
  381. #define __HAL_LPTIM_RESET_COUNTER_AFTERREAD(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_RSTARE)
  382. /**
  383. * @brief Write the passed parameter in the Autoreload register.
  384. * @param __HANDLE__ LPTIM handle
  385. * @param __VALUE__ Autoreload value
  386. * This parameter must be a value between Min_Data = 0x0001 and Max_Data = 0xFFFF.
  387. * @retval None
  388. * @note The ARR register can only be modified when the LPTIM instance is enabled.
  389. */
  390. #define __HAL_LPTIM_AUTORELOAD_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->ARR = (__VALUE__))
  391. /**
  392. * @brief Write the passed parameter in the Compare register.
  393. * @param __HANDLE__ LPTIM handle
  394. * @param __VALUE__ Compare value
  395. * @retval None
  396. * @note The CMP register can only be modified when the LPTIM instance is enabled.
  397. */
  398. #define __HAL_LPTIM_COMPARE_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->CMP = (__VALUE__))
  399. /**
  400. * @brief Check whether the specified LPTIM flag is set or not.
  401. * @param __HANDLE__ LPTIM handle
  402. * @param __FLAG__ LPTIM flag to check
  403. * This parameter can be a value of:
  404. * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag.
  405. * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag.
  406. * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag.
  407. * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag.
  408. * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
  409. * @arg LPTIM_FLAG_ARRM : Autoreload match Flag.
  410. * @arg LPTIM_FLAG_CMPM : Compare match Flag.
  411. * @retval The state of the specified flag (SET or RESET).
  412. */
  413. #define __HAL_LPTIM_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR &(__FLAG__)) == (__FLAG__))
  414. /**
  415. * @brief Clear the specified LPTIM flag.
  416. * @param __HANDLE__ LPTIM handle.
  417. * @param __FLAG__ LPTIM flag to clear.
  418. * This parameter can be a value of:
  419. * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag.
  420. * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag.
  421. * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag.
  422. * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag.
  423. * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
  424. * @arg LPTIM_FLAG_ARRM : Autoreload match Flag.
  425. * @arg LPTIM_FLAG_CMPM : Compare match Flag.
  426. * @retval None.
  427. */
  428. #define __HAL_LPTIM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
  429. /**
  430. * @brief Enable the specified LPTIM interrupt.
  431. * @param __HANDLE__ LPTIM handle.
  432. * @param __INTERRUPT__ LPTIM interrupt to set.
  433. * This parameter can be a value of:
  434. * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
  435. * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
  436. * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
  437. * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
  438. * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
  439. * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
  440. * @arg LPTIM_IT_CMPM : Compare match Interrupt.
  441. * @retval None.
  442. * @note The LPTIM interrupts can only be enabled when the LPTIM instance is disabled.
  443. */
  444. #define __HAL_LPTIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
  445. /**
  446. * @brief Disable the specified LPTIM interrupt.
  447. * @param __HANDLE__ LPTIM handle.
  448. * @param __INTERRUPT__ LPTIM interrupt to set.
  449. * This parameter can be a value of:
  450. * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
  451. * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
  452. * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
  453. * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
  454. * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
  455. * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
  456. * @arg LPTIM_IT_CMPM : Compare match Interrupt.
  457. * @retval None.
  458. * @note The LPTIM interrupts can only be disabled when the LPTIM instance is disabled.
  459. */
  460. #define __HAL_LPTIM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= (~(__INTERRUPT__)))
  461. /**
  462. * @brief Check whether the specified LPTIM interrupt source is enabled or not.
  463. * @param __HANDLE__ LPTIM handle.
  464. * @param __INTERRUPT__ LPTIM interrupt to check.
  465. * This parameter can be a value of:
  466. * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
  467. * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
  468. * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
  469. * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
  470. * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
  471. * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
  472. * @arg LPTIM_IT_CMPM : Compare match Interrupt.
  473. * @retval Interrupt status.
  474. */
  475. #define __HAL_LPTIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER\
  476. & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
  477. /**
  478. * @brief Enable interrupt on the LPTIM Wake-up Timer associated Exti line.
  479. * @retval None
  480. */
  481. #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR2\
  482. |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
  483. /**
  484. * @brief Disable interrupt on the LPTIM Wake-up Timer associated Exti line.
  485. * @retval None
  486. */
  487. #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR2\
  488. &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
  489. /**
  490. * @brief Enable event on the LPTIM Wake-up Timer associated Exti line.
  491. * @retval None.
  492. */
  493. #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR2\
  494. |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
  495. /**
  496. * @brief Disable event on the LPTIM Wake-up Timer associated Exti line.
  497. * @retval None.
  498. */
  499. #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR2\
  500. &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
  501. /**
  502. * @}
  503. */
  504. /* Exported functions --------------------------------------------------------*/
  505. /** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions
  506. * @{
  507. */
  508. /** @addtogroup LPTIM_Exported_Functions_Group1
  509. * @brief Initialization and Configuration functions.
  510. * @{
  511. */
  512. /* Initialization/de-initialization functions ********************************/
  513. HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
  514. HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim);
  515. /* MSP functions *************************************************************/
  516. void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim);
  517. void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim);
  518. /**
  519. * @}
  520. */
  521. /** @addtogroup LPTIM_Exported_Functions_Group2
  522. * @brief Start-Stop operation functions.
  523. * @{
  524. */
  525. /* Start/Stop operation functions *********************************************/
  526. /* ################################# PWM Mode ################################*/
  527. /* Blocking mode: Polling */
  528. HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
  529. HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim);
  530. /* Non-Blocking mode: Interrupt */
  531. HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
  532. HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim);
  533. /* ############################# One Pulse Mode ##############################*/
  534. /* Blocking mode: Polling */
  535. HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
  536. HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim);
  537. /* Non-Blocking mode: Interrupt */
  538. HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
  539. HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim);
  540. /* ############################## Set once Mode ##############################*/
  541. /* Blocking mode: Polling */
  542. HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
  543. HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim);
  544. /* Non-Blocking mode: Interrupt */
  545. HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
  546. HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim);
  547. /* ############################### Encoder Mode ##############################*/
  548. /* Blocking mode: Polling */
  549. HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
  550. HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim);
  551. /* Non-Blocking mode: Interrupt */
  552. HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
  553. HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim);
  554. /* ############################# Time out Mode ##############################*/
  555. /* Blocking mode: Polling */
  556. HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
  557. HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim);
  558. /* Non-Blocking mode: Interrupt */
  559. HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
  560. HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim);
  561. /* ############################## Counter Mode ###############################*/
  562. /* Blocking mode: Polling */
  563. HAL_StatusTypeDef HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
  564. HAL_StatusTypeDef HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef *hlptim);
  565. /* Non-Blocking mode: Interrupt */
  566. HAL_StatusTypeDef HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
  567. HAL_StatusTypeDef HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef *hlptim);
  568. /**
  569. * @}
  570. */
  571. /** @addtogroup LPTIM_Exported_Functions_Group3
  572. * @brief Read operation functions.
  573. * @{
  574. */
  575. /* Reading operation functions ************************************************/
  576. uint32_t HAL_LPTIM_ReadCounter(const LPTIM_HandleTypeDef *hlptim);
  577. uint32_t HAL_LPTIM_ReadAutoReload(const LPTIM_HandleTypeDef *hlptim);
  578. uint32_t HAL_LPTIM_ReadCompare(const LPTIM_HandleTypeDef *hlptim);
  579. /**
  580. * @}
  581. */
  582. /** @addtogroup LPTIM_Exported_Functions_Group4
  583. * @brief LPTIM IRQ handler and callback functions.
  584. * @{
  585. */
  586. /* LPTIM IRQ functions *******************************************************/
  587. void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim);
  588. /* CallBack functions ********************************************************/
  589. void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim);
  590. void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim);
  591. void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef *hlptim);
  592. void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef *hlptim);
  593. void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef *hlptim);
  594. void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef *hlptim);
  595. void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef *hlptim);
  596. /* Callbacks Register/UnRegister functions ***********************************/
  597. #if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
  598. HAL_StatusTypeDef HAL_LPTIM_RegisterCallback(LPTIM_HandleTypeDef *lphtim, HAL_LPTIM_CallbackIDTypeDef CallbackID,
  599. pLPTIM_CallbackTypeDef pCallback);
  600. HAL_StatusTypeDef HAL_LPTIM_UnRegisterCallback(LPTIM_HandleTypeDef *lphtim, HAL_LPTIM_CallbackIDTypeDef CallbackID);
  601. #endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
  602. /**
  603. * @}
  604. */
  605. /** @addtogroup LPTIM_Group5
  606. * @brief Peripheral State functions.
  607. * @{
  608. */
  609. /* Peripheral State functions ************************************************/
  610. HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(const LPTIM_HandleTypeDef *hlptim);
  611. /**
  612. * @}
  613. */
  614. /**
  615. * @}
  616. */
  617. /* Private types -------------------------------------------------------------*/
  618. /** @defgroup LPTIM_Private_Types LPTIM Private Types
  619. * @{
  620. */
  621. /**
  622. * @}
  623. */
  624. /* Private variables ---------------------------------------------------------*/
  625. /** @defgroup LPTIM_Private_Variables LPTIM Private Variables
  626. * @{
  627. */
  628. /**
  629. * @}
  630. */
  631. /* Private constants ---------------------------------------------------------*/
  632. /** @defgroup LPTIM_Private_Constants LPTIM Private Constants
  633. * @{
  634. */
  635. /**
  636. * @}
  637. */
  638. /* Private macros ------------------------------------------------------------*/
  639. /** @defgroup LPTIM_Private_Macros LPTIM Private Macros
  640. * @{
  641. */
  642. #define IS_LPTIM_CLOCK_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_CLOCKSOURCE_ULPTIM) || \
  643. ((__SOURCE__) == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC))
  644. #define IS_LPTIM_CLOCK_PRESCALER(__PRESCALER__) (((__PRESCALER__) == LPTIM_PRESCALER_DIV1 ) || \
  645. ((__PRESCALER__) == LPTIM_PRESCALER_DIV2 ) || \
  646. ((__PRESCALER__) == LPTIM_PRESCALER_DIV4 ) || \
  647. ((__PRESCALER__) == LPTIM_PRESCALER_DIV8 ) || \
  648. ((__PRESCALER__) == LPTIM_PRESCALER_DIV16 ) || \
  649. ((__PRESCALER__) == LPTIM_PRESCALER_DIV32 ) || \
  650. ((__PRESCALER__) == LPTIM_PRESCALER_DIV64 ) || \
  651. ((__PRESCALER__) == LPTIM_PRESCALER_DIV128))
  652. #define IS_LPTIM_CLOCK_PRESCALERDIV1(__PRESCALER__) ((__PRESCALER__) == LPTIM_PRESCALER_DIV1)
  653. #define IS_LPTIM_OUTPUT_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_OUTPUTPOLARITY_LOW ) || \
  654. ((__POLARITY__) == LPTIM_OUTPUTPOLARITY_HIGH))
  655. #define IS_LPTIM_CLOCK_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION) || \
  656. ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_2TRANSITIONS) || \
  657. ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_4TRANSITIONS) || \
  658. ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_8TRANSITIONS))
  659. #define IS_LPTIM_CLOCK_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING) || \
  660. ((__POLARITY__) == LPTIM_CLOCKPOLARITY_FALLING) || \
  661. ((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING_FALLING))
  662. #if defined(STM32G414xx) || defined(STM32G473xx) || defined(STM32G483xx) || defined(STM32G474xx) || defined(STM32G484xx)
  663. #define IS_LPTIM_TRG_SOURCE(__TRIG__) (((__TRIG__) == LPTIM_TRIGSOURCE_SOFTWARE) || \
  664. ((__TRIG__) == LPTIM_TRIGSOURCE_0) || \
  665. ((__TRIG__) == LPTIM_TRIGSOURCE_1) || \
  666. ((__TRIG__) == LPTIM_TRIGSOURCE_2) || \
  667. ((__TRIG__) == LPTIM_TRIGSOURCE_3) || \
  668. ((__TRIG__) == LPTIM_TRIGSOURCE_4) || \
  669. ((__TRIG__) == LPTIM_TRIGSOURCE_5) || \
  670. ((__TRIG__) == LPTIM_TRIGSOURCE_6) || \
  671. ((__TRIG__) == LPTIM_TRIGSOURCE_7) || \
  672. ((__TRIG__) == LPTIM_TRIGSOURCE_8) || \
  673. ((__TRIG__) == LPTIM_TRIGSOURCE_9) || \
  674. ((__TRIG__) == LPTIM_TRIGSOURCE_10)|| \
  675. ((__TRIG__) == LPTIM_TRIGSOURCE_11)|| \
  676. ((__TRIG__) == LPTIM_TRIGSOURCE_12))
  677. #else
  678. #define IS_LPTIM_TRG_SOURCE(__TRIG__) (((__TRIG__) == LPTIM_TRIGSOURCE_SOFTWARE) || \
  679. ((__TRIG__) == LPTIM_TRIGSOURCE_0) || \
  680. ((__TRIG__) == LPTIM_TRIGSOURCE_1) || \
  681. ((__TRIG__) == LPTIM_TRIGSOURCE_2) || \
  682. ((__TRIG__) == LPTIM_TRIGSOURCE_3) || \
  683. ((__TRIG__) == LPTIM_TRIGSOURCE_4) || \
  684. ((__TRIG__) == LPTIM_TRIGSOURCE_5) || \
  685. ((__TRIG__) == LPTIM_TRIGSOURCE_6) || \
  686. ((__TRIG__) == LPTIM_TRIGSOURCE_7) || \
  687. ((__TRIG__) == LPTIM_TRIGSOURCE_8) || \
  688. ((__TRIG__) == LPTIM_TRIGSOURCE_9))
  689. #endif /* STM32G414xx || STM32G473xx || STM32G483xx || STM32G474xx || STM32G484xx */
  690. #define IS_LPTIM_EXT_TRG_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING ) || \
  691. ((__POLARITY__) == LPTIM_ACTIVEEDGE_FALLING ) || \
  692. ((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING_FALLING ))
  693. #define IS_LPTIM_TRIG_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION) || \
  694. ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_2TRANSITIONS ) || \
  695. ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_4TRANSITIONS ) || \
  696. ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_8TRANSITIONS ))
  697. #define IS_LPTIM_UPDATE_MODE(__MODE__) (((__MODE__) == LPTIM_UPDATE_IMMEDIATE) || \
  698. ((__MODE__) == LPTIM_UPDATE_ENDOFPERIOD))
  699. #define IS_LPTIM_COUNTER_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_COUNTERSOURCE_INTERNAL) || \
  700. ((__SOURCE__) == LPTIM_COUNTERSOURCE_EXTERNAL))
  701. #define IS_LPTIM_COMPARE(__COMPARE__) ((__COMPARE__) <= 0x0000FFFFUL)
  702. #define IS_LPTIM_PERIOD(__PERIOD__) ((0x00000001UL <= (__PERIOD__)) &&\
  703. ((__PERIOD__) <= 0x0000FFFFUL))
  704. #define IS_LPTIM_PULSE(__PULSE__) ((__PULSE__) <= 0x0000FFFFUL)
  705. #if defined(COMP5) && defined(COMP6) && defined(COMP7)
  706. #define IS_LPTIM_INPUT1_SOURCE(__INSTANCE__, __SOURCE__) \
  707. ((((__INSTANCE__) == LPTIM1) && \
  708. (((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO) || \
  709. ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1) || \
  710. ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP3) || \
  711. ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP5) || \
  712. ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP7))))
  713. #else
  714. #define IS_LPTIM_INPUT1_SOURCE(__INSTANCE__, __SOURCE__) \
  715. ((((__INSTANCE__) == LPTIM1) && \
  716. (((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO) || \
  717. ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1) || \
  718. ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP3))))
  719. #endif /* COMP5 && COMP6 && COMP7 */
  720. #if defined(COMP5) && defined(COMP6) && defined(COMP7)
  721. #define IS_LPTIM_INPUT2_SOURCE(__INSTANCE__, __SOURCE__) \
  722. (((__INSTANCE__) == LPTIM1) && \
  723. (((__SOURCE__) == LPTIM_INPUT2SOURCE_GPIO) || \
  724. ((__SOURCE__) == LPTIM_INPUT2SOURCE_COMP2) || \
  725. ((__SOURCE__) == LPTIM_INPUT2SOURCE_COMP4) || \
  726. ((__SOURCE__) == LPTIM_INPUT2SOURCE_COMP6)))
  727. #else
  728. #define IS_LPTIM_INPUT2_SOURCE(__INSTANCE__, __SOURCE__) \
  729. (((__INSTANCE__) == LPTIM1) && \
  730. (((__SOURCE__) == LPTIM_INPUT2SOURCE_GPIO) || \
  731. ((__SOURCE__) == LPTIM_INPUT2SOURCE_COMP2) || \
  732. ((__SOURCE__) == LPTIM_INPUT2SOURCE_COMP4)))
  733. #endif /* COMP5 && COMP6 && COMP7 */
  734. /**
  735. * @}
  736. */
  737. /* Private functions ---------------------------------------------------------*/
  738. /** @defgroup LPTIM_Private_Functions LPTIM Private Functions
  739. * @{
  740. */
  741. void LPTIM_Disable(LPTIM_HandleTypeDef *hlptim);
  742. /**
  743. * @}
  744. */
  745. /**
  746. * @}
  747. */
  748. /**
  749. * @}
  750. */
  751. #ifdef __cplusplus
  752. }
  753. #endif
  754. #endif /* STM32G4xx_HAL_LPTIM_H */