You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

740 lines
31 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f7xx_hal_lptim.h
  4. * @author MCD Application Team
  5. * @version V1.2.2
  6. * @date 14-April-2017
  7. * @brief Header file of LPTIM HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32F7xx_HAL_LPTIM_H
  39. #define __STM32F7xx_HAL_LPTIM_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32f7xx_hal_def.h"
  45. /** @addtogroup STM32F7xx_HAL_Driver
  46. * @{
  47. */
  48. /** @defgroup LPTIM LPTIM
  49. * @brief LPTIM HAL module driver
  50. * @{
  51. */
  52. /* Exported types ------------------------------------------------------------*/
  53. /** @defgroup LPTIM_Exported_Types LPTIM Exported Types
  54. * @{
  55. */
  56. /** @defgroup LPTIM_WAKEUPTIMER_EXTILINE LPTIM WAKEUP Timer EXTI Line
  57. * @{
  58. */
  59. #define LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT ((uint32_t)EXTI_IMR_MR23) /*!< External interrupt line 23 Connected to the LPTIM EXTI Line */
  60. /**
  61. * @}
  62. */
  63. /**
  64. * @brief LPTIM Clock configuration definition
  65. */
  66. typedef struct
  67. {
  68. uint32_t Source; /*!< Selects the clock source.
  69. This parameter can be a value of @ref LPTIM_Clock_Source */
  70. uint32_t Prescaler; /*!< Specifies the counter clock Prescaler.
  71. This parameter can be a value of @ref LPTIM_Clock_Prescaler */
  72. }LPTIM_ClockConfigTypeDef;
  73. /**
  74. * @brief LPTIM Clock configuration definition
  75. */
  76. typedef struct
  77. {
  78. uint32_t Polarity; /*!< Selects the polarity of the active edge for the counter unit
  79. if the ULPTIM input is selected.
  80. Note: This parameter is used only when Ultra low power clock source is used.
  81. Note: If the polarity is configured on 'both edges', an auxiliary clock
  82. (one of the Low power oscillator) must be active.
  83. This parameter can be a value of @ref LPTIM_Clock_Polarity */
  84. uint32_t SampleTime; /*!< Selects the clock sampling time to configure the clock glitch filter.
  85. Note: This parameter is used only when Ultra low power clock source is used.
  86. This parameter can be a value of @ref LPTIM_Clock_Sample_Time */
  87. }LPTIM_ULPClockConfigTypeDef;
  88. /**
  89. * @brief LPTIM Trigger configuration definition
  90. */
  91. typedef struct
  92. {
  93. uint32_t Source; /*!< Selects the Trigger source.
  94. This parameter can be a value of @ref LPTIM_Trigger_Source */
  95. uint32_t ActiveEdge; /*!< Selects the Trigger active edge.
  96. Note: This parameter is used only when an external trigger is used.
  97. This parameter can be a value of @ref LPTIM_External_Trigger_Polarity */
  98. uint32_t SampleTime; /*!< Selects the trigger sampling time to configure the clock glitch filter.
  99. Note: This parameter is used only when an external trigger is used.
  100. This parameter can be a value of @ref LPTIM_Trigger_Sample_Time */
  101. }LPTIM_TriggerConfigTypeDef;
  102. /**
  103. * @brief LPTIM Initialization Structure definition
  104. */
  105. typedef struct
  106. {
  107. LPTIM_ClockConfigTypeDef Clock; /*!< Specifies the clock parameters */
  108. LPTIM_ULPClockConfigTypeDef UltraLowPowerClock; /*!< Specifies the Ultra Low Power clock parameters */
  109. LPTIM_TriggerConfigTypeDef Trigger; /*!< Specifies the Trigger parameters */
  110. uint32_t OutputPolarity; /*!< Specifies the Output polarity.
  111. This parameter can be a value of @ref LPTIM_Output_Polarity */
  112. uint32_t UpdateMode; /*!< Specifies whether the update of the autorelaod and the compare
  113. values is done immediately or after the end of current period.
  114. This parameter can be a value of @ref LPTIM_Updating_Mode */
  115. uint32_t CounterSource; /*!< Specifies whether the counter is incremented each internal event
  116. or each external event.
  117. This parameter can be a value of @ref LPTIM_Counter_Source */
  118. }LPTIM_InitTypeDef;
  119. /**
  120. * @brief HAL LPTIM State structure definition
  121. */
  122. typedef enum __HAL_LPTIM_StateTypeDef
  123. {
  124. HAL_LPTIM_STATE_RESET = 0x00U, /*!< Peripheral not yet initialized or disabled */
  125. HAL_LPTIM_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
  126. HAL_LPTIM_STATE_BUSY = 0x02U, /*!< An internal process is ongoing */
  127. HAL_LPTIM_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
  128. HAL_LPTIM_STATE_ERROR = 0x04U /*!< Internal Process is ongoing */
  129. }HAL_LPTIM_StateTypeDef;
  130. /**
  131. * @brief LPTIM handle Structure definition
  132. */
  133. typedef struct
  134. {
  135. LPTIM_TypeDef *Instance; /*!< Register base address */
  136. LPTIM_InitTypeDef Init; /*!< LPTIM required parameters */
  137. HAL_StatusTypeDef Status; /*!< LPTIM peripheral status */
  138. HAL_LockTypeDef Lock; /*!< LPTIM locking object */
  139. __IO HAL_LPTIM_StateTypeDef State; /*!< LPTIM peripheral state */
  140. }LPTIM_HandleTypeDef;
  141. /**
  142. * @}
  143. */
  144. /* Exported constants --------------------------------------------------------*/
  145. /** @defgroup LPTIM_Exported_Constants LPTIM Exported Constants
  146. * @{
  147. */
  148. /** @defgroup LPTIM_Clock_Source LPTIM Clock Source
  149. * @{
  150. */
  151. #define LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC ((uint32_t)0x00U)
  152. #define LPTIM_CLOCKSOURCE_ULPTIM LPTIM_CFGR_CKSEL
  153. /**
  154. * @}
  155. */
  156. /** @defgroup LPTIM_Clock_Prescaler LPTIM Clock Prescaler
  157. * @{
  158. */
  159. #define LPTIM_PRESCALER_DIV1 ((uint32_t)0x000000U)
  160. #define LPTIM_PRESCALER_DIV2 LPTIM_CFGR_PRESC_0
  161. #define LPTIM_PRESCALER_DIV4 LPTIM_CFGR_PRESC_1
  162. #define LPTIM_PRESCALER_DIV8 ((uint32_t)(LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_1))
  163. #define LPTIM_PRESCALER_DIV16 LPTIM_CFGR_PRESC_2
  164. #define LPTIM_PRESCALER_DIV32 ((uint32_t)(LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_2))
  165. #define LPTIM_PRESCALER_DIV64 ((uint32_t)(LPTIM_CFGR_PRESC_1 | LPTIM_CFGR_PRESC_2))
  166. #define LPTIM_PRESCALER_DIV128 ((uint32_t)LPTIM_CFGR_PRESC)
  167. /**
  168. * @}
  169. */
  170. /** @defgroup LPTIM_Output_Polarity LPTIM Output Polarity
  171. * @{
  172. */
  173. #define LPTIM_OUTPUTPOLARITY_HIGH ((uint32_t)0x00000000U)
  174. #define LPTIM_OUTPUTPOLARITY_LOW (LPTIM_CFGR_WAVPOL)
  175. /**
  176. * @}
  177. */
  178. /** @defgroup LPTIM_Clock_Sample_Time LPTIM Clock Sample Time
  179. * @{
  180. */
  181. #define LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION ((uint32_t)0x00000000U)
  182. #define LPTIM_CLOCKSAMPLETIME_2TRANSITIONS LPTIM_CFGR_CKFLT_0
  183. #define LPTIM_CLOCKSAMPLETIME_4TRANSITIONS LPTIM_CFGR_CKFLT_1
  184. #define LPTIM_CLOCKSAMPLETIME_8TRANSITIONS LPTIM_CFGR_CKFLT
  185. /**
  186. * @}
  187. */
  188. /** @defgroup LPTIM_Clock_Polarity LPTIM Clock Polarity
  189. * @{
  190. */
  191. #define LPTIM_CLOCKPOLARITY_RISING ((uint32_t)0x00000000U)
  192. #define LPTIM_CLOCKPOLARITY_FALLING LPTIM_CFGR_CKPOL_0
  193. #define LPTIM_CLOCKPOLARITY_RISING_FALLING LPTIM_CFGR_CKPOL_1
  194. /**
  195. * @}
  196. */
  197. /** @defgroup LPTIM_Trigger_Source LPTIM Trigger Source
  198. * @{
  199. */
  200. #define LPTIM_TRIGSOURCE_SOFTWARE ((uint32_t)0x0000FFFFU)
  201. #define LPTIM_TRIGSOURCE_0 ((uint32_t)0x00000000U)
  202. #define LPTIM_TRIGSOURCE_1 ((uint32_t)LPTIM_CFGR_TRIGSEL_0)
  203. #define LPTIM_TRIGSOURCE_2 LPTIM_CFGR_TRIGSEL_1
  204. #define LPTIM_TRIGSOURCE_3 ((uint32_t)LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_1)
  205. #define LPTIM_TRIGSOURCE_4 LPTIM_CFGR_TRIGSEL_2
  206. #define LPTIM_TRIGSOURCE_5 ((uint32_t)LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_2)
  207. /**
  208. * @}
  209. */
  210. /** @defgroup LPTIM_External_Trigger_Polarity LPTIM External Trigger Polarity
  211. * @{
  212. */
  213. #define LPTIM_ACTIVEEDGE_RISING LPTIM_CFGR_TRIGEN_0
  214. #define LPTIM_ACTIVEEDGE_FALLING LPTIM_CFGR_TRIGEN_1
  215. #define LPTIM_ACTIVEEDGE_RISING_FALLING LPTIM_CFGR_TRIGEN
  216. /**
  217. * @}
  218. */
  219. /** @defgroup LPTIM_Trigger_Sample_Time LPTIM Trigger Sample Time
  220. * @{
  221. */
  222. #define LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION ((uint32_t)0x00000000U)
  223. #define LPTIM_TRIGSAMPLETIME_2TRANSITIONS LPTIM_CFGR_TRGFLT_0
  224. #define LPTIM_TRIGSAMPLETIME_4TRANSITIONS LPTIM_CFGR_TRGFLT_1
  225. #define LPTIM_TRIGSAMPLETIME_8TRANSITIONS LPTIM_CFGR_TRGFLT
  226. /**
  227. * @}
  228. */
  229. /** @defgroup LPTIM_Updating_Mode LPTIM Updating Mode
  230. * @{
  231. */
  232. #define LPTIM_UPDATE_IMMEDIATE ((uint32_t)0x00000000U)
  233. #define LPTIM_UPDATE_ENDOFPERIOD LPTIM_CFGR_PRELOAD
  234. /**
  235. * @}
  236. */
  237. /** @defgroup LPTIM_Counter_Source LPTIM Counter Source
  238. * @{
  239. */
  240. #define LPTIM_COUNTERSOURCE_INTERNAL ((uint32_t)0x00000000U)
  241. #define LPTIM_COUNTERSOURCE_EXTERNAL LPTIM_CFGR_COUNTMODE
  242. /**
  243. * @}
  244. */
  245. /** @defgroup LPTIM_Flag_Definition LPTIM Flag Definition
  246. * @{
  247. */
  248. #define LPTIM_FLAG_DOWN LPTIM_ISR_DOWN
  249. #define LPTIM_FLAG_UP LPTIM_ISR_UP
  250. #define LPTIM_FLAG_ARROK LPTIM_ISR_ARROK
  251. #define LPTIM_FLAG_CMPOK LPTIM_ISR_CMPOK
  252. #define LPTIM_FLAG_EXTTRIG LPTIM_ISR_EXTTRIG
  253. #define LPTIM_FLAG_ARRM LPTIM_ISR_ARRM
  254. #define LPTIM_FLAG_CMPM LPTIM_ISR_CMPM
  255. /**
  256. * @}
  257. */
  258. /** @defgroup LPTIM_Interrupts_Definition LPTIM Interrupts Definition
  259. * @{
  260. */
  261. #define LPTIM_IT_DOWN LPTIM_IER_DOWNIE
  262. #define LPTIM_IT_UP LPTIM_IER_UPIE
  263. #define LPTIM_IT_ARROK LPTIM_IER_ARROKIE
  264. #define LPTIM_IT_CMPOK LPTIM_IER_CMPOKIE
  265. #define LPTIM_IT_EXTTRIG LPTIM_IER_EXTTRIGIE
  266. #define LPTIM_IT_ARRM LPTIM_IER_ARRMIE
  267. #define LPTIM_IT_CMPM LPTIM_IER_CMPMIE
  268. /**
  269. * @}
  270. */
  271. /**
  272. * @}
  273. */
  274. /* Exported macro ------------------------------------------------------------*/
  275. /** @defgroup LPTIM_Exported_Macros LPTIM Exported Macros
  276. * @{
  277. */
  278. /** @brief Reset LPTIM handle state
  279. * @param __HANDLE__: LPTIM handle
  280. * @retval None
  281. */
  282. #define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LPTIM_STATE_RESET)
  283. /**
  284. * @brief Enable/Disable the LPTIM peripheral.
  285. * @param __HANDLE__: LPTIM handle
  286. * @retval None
  287. */
  288. #define __HAL_LPTIM_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (LPTIM_CR_ENABLE))
  289. #define __HAL_LPTIM_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(LPTIM_CR_ENABLE))
  290. /**
  291. * @brief Starts the LPTIM peripheral in Continuous or in single mode.
  292. * @param __HANDLE__: DMA handle
  293. * @retval None
  294. */
  295. #define __HAL_LPTIM_START_CONTINUOUS(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_CNTSTRT)
  296. #define __HAL_LPTIM_START_SINGLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_SNGSTRT)
  297. /**
  298. * @brief Writes the passed parameter in the Autoreload register.
  299. * @param __HANDLE__: LPTIM handle
  300. * @param __VALUE__ : Autoreload value
  301. * @retval None
  302. */
  303. #define __HAL_LPTIM_AUTORELOAD_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->ARR = (__VALUE__))
  304. /**
  305. * @brief Writes the passed parameter in the Compare register.
  306. * @param __HANDLE__: LPTIM handle
  307. * @param __VALUE__ : Compare value
  308. * @retval None
  309. */
  310. #define __HAL_LPTIM_COMPARE_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->CMP = (__VALUE__))
  311. /**
  312. * @brief Checks whether the specified LPTIM flag is set or not.
  313. * @param __HANDLE__: LPTIM handle
  314. * @param __FLAG__ : LPTIM flag to check
  315. * This parameter can be a value of:
  316. * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag.
  317. * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag.
  318. * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag.
  319. * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag.
  320. * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
  321. * @arg LPTIM_FLAG_ARRM : Autoreload match Flag.
  322. * @arg LPTIM_FLAG_CMPM : Compare match Flag.
  323. * @retval The state of the specified flag (SET or RESET).
  324. */
  325. #define __HAL_LPTIM_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR &(__FLAG__)) == (__FLAG__))
  326. /**
  327. * @brief Clears the specified LPTIM flag.
  328. * @param __HANDLE__: LPTIM handle.
  329. * @param __FLAG__ : LPTIM flag to clear.
  330. * This parameter can be a value of:
  331. * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag.
  332. * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag.
  333. * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag.
  334. * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag.
  335. * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
  336. * @arg LPTIM_FLAG_ARRM : Autoreload match Flag.
  337. * @arg LPTIM_FLAG_CMPM : Compare match Flag.
  338. * @retval None.
  339. */
  340. #define __HAL_LPTIM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
  341. /**
  342. * @brief Enable the specified LPTIM interrupt.
  343. * @param __HANDLE__ : LPTIM handle.
  344. * @param __INTERRUPT__ : LPTIM interrupt to set.
  345. * This parameter can be a value of:
  346. * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
  347. * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
  348. * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
  349. * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
  350. * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
  351. * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
  352. * @arg LPTIM_IT_CMPM : Compare match Interrupt.
  353. * @retval None.
  354. */
  355. #define __HAL_LPTIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
  356. /**
  357. * @brief Disable the specified LPTIM interrupt.
  358. * @param __HANDLE__ : LPTIM handle.
  359. * @param __INTERRUPT__ : LPTIM interrupt to set.
  360. * This parameter can be a value of:
  361. * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
  362. * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
  363. * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
  364. * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
  365. * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
  366. * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
  367. * @arg LPTIM_IT_CMPM : Compare match Interrupt.
  368. * @retval None.
  369. */
  370. #define __HAL_LPTIM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= (~(__INTERRUPT__)))
  371. /**
  372. * @brief Checks whether the specified LPTIM interrupt is set or not.
  373. * @param __HANDLE__ : LPTIM handle.
  374. * @param __INTERRUPT__ : LPTIM interrupt to check.
  375. * This parameter can be a value of:
  376. * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
  377. * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
  378. * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
  379. * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
  380. * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
  381. * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
  382. * @arg LPTIM_IT_CMPM : Compare match Interrupt.
  383. * @retval Interrupt status.
  384. */
  385. #define __HAL_LPTIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
  386. /**
  387. * @brief Enable interrupt on the LPTIM Wake-up Timer associated Exti line.
  388. * @retval None
  389. */
  390. #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
  391. /**
  392. * @brief Disable interrupt on the LPTIM Wake-up Timer associated Exti line.
  393. * @retval None
  394. */
  395. #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
  396. /**
  397. * @brief Enable event on the LPTIM Wake-up Timer associated Exti line.
  398. * @retval None.
  399. */
  400. #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
  401. /**
  402. * @brief Disable event on the LPTIM Wake-up Timer associated Exti line.
  403. * @retval None.
  404. */
  405. #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
  406. /**
  407. * @brief Enable falling edge trigger on the LPTIM Wake-up Timer associated Exti line.
  408. * @retval None.
  409. */
  410. #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
  411. /**
  412. * @brief Disable falling edge trigger on the LPTIM Wake-up Timer associated Exti line.
  413. * @retval None.
  414. */
  415. #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
  416. /**
  417. * @brief Enable rising edge trigger on the LPTIM Wake-up Timer associated Exti line.
  418. * @retval None.
  419. */
  420. #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
  421. /**
  422. * @brief Disable rising edge trigger on the LPTIM Wake-up Timer associated Exti line.
  423. * @retval None.
  424. */
  425. #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT))
  426. /**
  427. * @brief Enable rising & falling edge trigger on the LPTIM Wake-up Timer associated Exti line.
  428. * @retval None.
  429. */
  430. #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_RISING_FALLING_EDGE() do{__HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE();\
  431. __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE();\
  432. }while(0)
  433. /**
  434. * @brief Disable rising & falling edge trigger on the LPTIM Wake-up Timer associated Exti line.
  435. * This parameter can be:
  436. * @retval None.
  437. */
  438. #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_RISING_FALLING_EDGE() do{__HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE();\
  439. __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE();\
  440. }while(0)
  441. /**
  442. * @brief Check whether the LPTIM Wake-up Timer associated Exti line interrupt flag is set or not.
  443. * @retval Line Status.
  444. */
  445. #define __HAL_LPTIM_WAKEUPTIMER_EXTI_GET_FLAG() (EXTI->PR & LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
  446. /**
  447. * @brief Clear the LPTIM Wake-up Timer associated Exti line flag.
  448. * @retval None.
  449. */
  450. #define __HAL_LPTIM_WAKEUPTIMER_EXTI_CLEAR_FLAG() (EXTI->PR = LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
  451. /**
  452. * @brief Generate a Software interrupt on the LPTIM Wake-up Timer associated Exti line.
  453. * @retval None.
  454. */
  455. #define __HAL_LPTIM_WAKEUPTIMER_EXTI_GENERATE_SWIT() (EXTI->SWIER |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)
  456. /**
  457. * @}
  458. */
  459. /* Exported functions --------------------------------------------------------*/
  460. /** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions
  461. * @{
  462. */
  463. /* Initialization/de-initialization functions ********************************/
  464. HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
  465. HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim);
  466. /* MSP functions *************************************************************/
  467. void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim);
  468. void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim);
  469. /* Start/Stop operation functions *********************************************/
  470. /* ################################# PWM Mode ################################*/
  471. /* Blocking mode: Polling */
  472. HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
  473. HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim);
  474. /* Non-Blocking mode: Interrupt */
  475. HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
  476. HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim);
  477. /* ############################# One Pulse Mode ##############################*/
  478. /* Blocking mode: Polling */
  479. HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
  480. HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim);
  481. /* Non-Blocking mode: Interrupt */
  482. HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
  483. HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim);
  484. /* ############################## Set once Mode ##############################*/
  485. /* Blocking mode: Polling */
  486. HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
  487. HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim);
  488. /* Non-Blocking mode: Interrupt */
  489. HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
  490. HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim);
  491. /* ############################### Encoder Mode ##############################*/
  492. /* Blocking mode: Polling */
  493. HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
  494. HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim);
  495. /* Non-Blocking mode: Interrupt */
  496. HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
  497. HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim);
  498. /* ############################# Time out Mode ##############################*/
  499. /* Blocking mode: Polling */
  500. HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
  501. HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim);
  502. /* Non-Blocking mode: Interrupt */
  503. HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
  504. HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim);
  505. /* ############################## Counter Mode ###############################*/
  506. /* Blocking mode: Polling */
  507. HAL_StatusTypeDef HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
  508. HAL_StatusTypeDef HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef *hlptim);
  509. /* Non-Blocking mode: Interrupt */
  510. HAL_StatusTypeDef HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
  511. HAL_StatusTypeDef HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef *hlptim);
  512. /* Reading operation functions ************************************************/
  513. uint32_t HAL_LPTIM_ReadCounter(LPTIM_HandleTypeDef *hlptim);
  514. uint32_t HAL_LPTIM_ReadAutoReload(LPTIM_HandleTypeDef *hlptim);
  515. uint32_t HAL_LPTIM_ReadCompare(LPTIM_HandleTypeDef *hlptim);
  516. /* LPTIM IRQ functions *******************************************************/
  517. void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim);
  518. /* CallBack functions ********************************************************/
  519. void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim);
  520. void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim);
  521. void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef *hlptim);
  522. void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef *hlptim);
  523. void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef *hlptim);
  524. void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef *hlptim);
  525. void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef *hlptim);
  526. /* Peripheral State functions ************************************************/
  527. HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(LPTIM_HandleTypeDef *hlptim);
  528. /**
  529. * @}
  530. */
  531. /* Private types -------------------------------------------------------------*/
  532. /** @defgroup LPTIM_Private_Types LPTIM Private Types
  533. * @{
  534. */
  535. /**
  536. * @}
  537. */
  538. /* Private variables ---------------------------------------------------------*/
  539. /** @defgroup LPTIM_Private_Variables LPTIM Private Variables
  540. * @{
  541. */
  542. /**
  543. * @}
  544. */
  545. /* Private constants ---------------------------------------------------------*/
  546. /** @defgroup LPTIM_Private_Constants LPTIM Private Constants
  547. * @{
  548. */
  549. /**
  550. * @}
  551. */
  552. /* Private macros ------------------------------------------------------------*/
  553. /** @defgroup LPTIM_Private_Macros LPTIM Private Macros
  554. * @{
  555. */
  556. #define IS_LPTIM_CLOCK_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_CLOCKSOURCE_ULPTIM) || \
  557. ((__SOURCE__) == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC))
  558. #define IS_LPTIM_CLOCK_PRESCALER(__PRESCALER__) (((__PRESCALER__) == LPTIM_PRESCALER_DIV1 ) || \
  559. ((__PRESCALER__) == LPTIM_PRESCALER_DIV2 ) || \
  560. ((__PRESCALER__) == LPTIM_PRESCALER_DIV4 ) || \
  561. ((__PRESCALER__) == LPTIM_PRESCALER_DIV8 ) || \
  562. ((__PRESCALER__) == LPTIM_PRESCALER_DIV16 ) || \
  563. ((__PRESCALER__) == LPTIM_PRESCALER_DIV32 ) || \
  564. ((__PRESCALER__) == LPTIM_PRESCALER_DIV64 ) || \
  565. ((__PRESCALER__) == LPTIM_PRESCALER_DIV128))
  566. #define IS_LPTIM_CLOCK_PRESCALERDIV1(__PRESCALER__) ((__PRESCALER__) == LPTIM_PRESCALER_DIV1)
  567. #define IS_LPTIM_OUTPUT_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_OUTPUTPOLARITY_LOW ) || \
  568. ((__POLARITY__) == LPTIM_OUTPUTPOLARITY_HIGH))
  569. #define IS_LPTIM_CLOCK_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION) || \
  570. ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_2TRANSITIONS) || \
  571. ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_4TRANSITIONS) || \
  572. ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_8TRANSITIONS))
  573. #define IS_LPTIM_CLOCK_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING) || \
  574. ((__POLARITY__) == LPTIM_CLOCKPOLARITY_FALLING) || \
  575. ((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING_FALLING))
  576. #define IS_LPTIM_TRG_SOURCE(__TRIG__) (((__TRIG__) == LPTIM_TRIGSOURCE_SOFTWARE) || \
  577. ((__TRIG__) == LPTIM_TRIGSOURCE_0) || \
  578. ((__TRIG__) == LPTIM_TRIGSOURCE_1) || \
  579. ((__TRIG__) == LPTIM_TRIGSOURCE_2) || \
  580. ((__TRIG__) == LPTIM_TRIGSOURCE_3) || \
  581. ((__TRIG__) == LPTIM_TRIGSOURCE_4) || \
  582. ((__TRIG__) == LPTIM_TRIGSOURCE_5))
  583. #define IS_LPTIM_EXT_TRG_POLARITY(__POLAR__) (((__POLAR__) == LPTIM_ACTIVEEDGE_RISING ) || \
  584. ((__POLAR__) == LPTIM_ACTIVEEDGE_FALLING ) || \
  585. ((__POLAR__) == LPTIM_ACTIVEEDGE_RISING_FALLING ))
  586. #define IS_LPTIM_TRIG_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION) || \
  587. ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_2TRANSITIONS ) || \
  588. ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_4TRANSITIONS ) || \
  589. ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_8TRANSITIONS ))
  590. #define IS_LPTIM_UPDATE_MODE(__MODE__) (((__MODE__) == LPTIM_UPDATE_IMMEDIATE) || \
  591. ((__MODE__) == LPTIM_UPDATE_ENDOFPERIOD))
  592. #define IS_LPTIM_COUNTER_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_COUNTERSOURCE_INTERNAL) || \
  593. ((__SOURCE__) == LPTIM_COUNTERSOURCE_EXTERNAL))
  594. #define IS_LPTIM_AUTORELOAD(__AUTORELOAD__) ((__AUTORELOAD__) <= 0x0000FFFFU)
  595. #define IS_LPTIM_COMPARE(__COMPARE__) ((__COMPARE__) <= 0x0000FFFFU)
  596. #define IS_LPTIM_PERIOD(PERIOD) ((PERIOD) <= 0x0000FFFFU)
  597. #define IS_LPTIM_PULSE(PULSE) ((PULSE) <= 0x0000FFFFU)
  598. /**
  599. * @}
  600. */
  601. /* Private functions ---------------------------------------------------------*/
  602. /** @defgroup LPTIM_Private_Functions LPTIM Private Functions
  603. * @{
  604. */
  605. /**
  606. * @}
  607. */
  608. /**
  609. * @}
  610. */
  611. /**
  612. * @}
  613. */
  614. #ifdef __cplusplus
  615. }
  616. #endif
  617. #endif /* __STM32F7xx_HAL_LPTIM_H */
  618. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/