stm32f0xx_hal_rtc_ex.h 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  1. /**
  2. ******************************************************************************
  3. * @file stm32f0xx_hal_rtc_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of RTC HAL Extended module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 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 STM32F0xx_HAL_RTC_EX_H
  20. #define STM32F0xx_HAL_RTC_EX_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f0xx_hal_def.h"
  26. /** @addtogroup STM32F0xx_HAL_Driver
  27. * @{
  28. */
  29. /** @addtogroup RTCEx
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /** @defgroup RTCEx_Exported_Types RTCEx Exported Types
  34. * @{
  35. */
  36. /**
  37. * @brief RTC Tamper structure definition
  38. */
  39. typedef struct
  40. {
  41. uint32_t Tamper; /*!< Specifies the Tamper Pin.
  42. This parameter can be a value of @ref RTCEx_Tamper_Pin_Definitions */
  43. uint32_t Trigger; /*!< Specifies the Tamper Trigger.
  44. This parameter can be a value of @ref RTCEx_Tamper_Trigger_Definitions */
  45. uint32_t Filter; /*!< Specifies the RTC Filter Tamper.
  46. This parameter can be a value of @ref RTCEx_Tamper_Filter_Definitions */
  47. uint32_t SamplingFrequency; /*!< Specifies the sampling frequency.
  48. This parameter can be a value of @ref RTCEx_Tamper_Sampling_Frequencies_Definitions */
  49. uint32_t PrechargeDuration; /*!< Specifies the Precharge Duration .
  50. This parameter can be a value of @ref RTCEx_Tamper_Pin_Precharge_Duration_Definitions */
  51. uint32_t TamperPullUp; /*!< Specifies the Tamper PullUp .
  52. This parameter can be a value of @ref RTCEx_Tamper_Pull_Up_Definitions */
  53. uint32_t TimeStampOnTamperDetection; /*!< Specifies the TimeStampOnTamperDetection.
  54. This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection_Definitions */
  55. } RTC_TamperTypeDef;
  56. /**
  57. * @}
  58. */
  59. /* Exported constants --------------------------------------------------------*/
  60. /** @defgroup RTCEx_Exported_Constants RTCEx Exported Constants
  61. * @{
  62. */
  63. #if defined(RTC_BACKUP_SUPPORT)
  64. /** @defgroup RTCEx_Backup_Registers_Definitions RTCEx Backup Registers Definitions
  65. * @{
  66. */
  67. #define RTC_BKP_DR0 0x00000000U
  68. #define RTC_BKP_DR1 0x00000001U
  69. #define RTC_BKP_DR2 0x00000002U
  70. #define RTC_BKP_DR3 0x00000003U
  71. #define RTC_BKP_DR4 0x00000004U
  72. /**
  73. * @}
  74. */
  75. #endif /* RTC_BACKUP_SUPPORT */
  76. /** @defgroup RTCEx_Timestamp_Edges_Definitions RTCEx Timestamp Edges Definitions
  77. * @{
  78. */
  79. #define RTC_TIMESTAMPEDGE_RISING 0x00000000U
  80. #define RTC_TIMESTAMPEDGE_FALLING RTC_CR_TSEDGE
  81. /**
  82. * @}
  83. */
  84. /** @defgroup RTCEx_Timestamp_Pin_Selection RTC Timestamp Pin Selection
  85. * @{
  86. */
  87. #define RTC_TIMESTAMPPIN_DEFAULT 0x00000000U
  88. /**
  89. * @}
  90. */
  91. /** @defgroup RTCEx_Tamper_Pin_Definitions RTCEx Tamper Pins Definitions
  92. * @{
  93. */
  94. #define RTC_TAMPER_1 RTC_TAFCR_TAMP1E
  95. #define RTC_TAMPER_2 RTC_TAFCR_TAMP2E
  96. #if defined(RTC_TAMPER3_SUPPORT)
  97. #define RTC_TAMPER_3 RTC_TAFCR_TAMP3E
  98. #endif /* RTC_TAMPER3_SUPPORT */
  99. /**
  100. * @}
  101. */
  102. /** @defgroup RTCEx_Tamper_Pin_Selection RTC tamper Pins Selection
  103. * @{
  104. */
  105. #define RTC_TAMPERPIN_DEFAULT 0x00000000U
  106. /**
  107. * @}
  108. */
  109. /** @defgroup RTCEx_Tamper_Interrupt_Definitions RTCEx Tamper Interrupt Definitions
  110. * @{
  111. */
  112. #define RTC_IT_TAMP RTC_TAFCR_TAMPIE /*!< Enable global Tamper Interrupt */
  113. /**
  114. * @}
  115. */
  116. /** @defgroup RTCEx_Tamper_Trigger_Definitions RTCEx Tamper Triggers Definitions
  117. * @{
  118. */
  119. #define RTC_TAMPERTRIGGER_RISINGEDGE 0x00000000U
  120. #define RTC_TAMPERTRIGGER_FALLINGEDGE 0x00000002U
  121. #define RTC_TAMPERTRIGGER_LOWLEVEL RTC_TAMPERTRIGGER_RISINGEDGE
  122. #define RTC_TAMPERTRIGGER_HIGHLEVEL RTC_TAMPERTRIGGER_FALLINGEDGE
  123. /**
  124. * @}
  125. */
  126. /** @defgroup RTCEx_Tamper_Filter_Definitions RTCEx Tamper Filter Definitions
  127. * @{
  128. */
  129. #define RTC_TAMPERFILTER_DISABLE 0x00000000U /*!< Tamper filter is disabled */
  130. #define RTC_TAMPERFILTER_2SAMPLE RTC_TAFCR_TAMPFLT_0 /*!< Tamper is activated after 2
  131. consecutive samples at the active level */
  132. #define RTC_TAMPERFILTER_4SAMPLE RTC_TAFCR_TAMPFLT_1 /*!< Tamper is activated after 4
  133. consecutive samples at the active level */
  134. #define RTC_TAMPERFILTER_8SAMPLE RTC_TAFCR_TAMPFLT /*!< Tamper is activated after 8
  135. consecutive samples at the active level */
  136. #define RTC_TAMPERFILTER_MASK RTC_TAFCR_TAMPFLT /*!< Masking all bits except those of
  137. field TAMPFLT */
  138. /**
  139. * @}
  140. */
  141. /** @defgroup RTCEx_Tamper_Sampling_Frequencies_Definitions RTCEx Tamper Sampling Frequencies Definitions
  142. * @{
  143. */
  144. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768 0x00000000U /*!< Each of the tamper inputs are sampled
  145. with a frequency = RTCCLK / 32768 */
  146. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384 RTC_TAFCR_TAMPFREQ_0 /*!< Each of the tamper inputs are sampled
  147. with a frequency = RTCCLK / 16384 */
  148. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192 RTC_TAFCR_TAMPFREQ_1 /*!< Each of the tamper inputs are sampled
  149. with a frequency = RTCCLK / 8192 */
  150. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096 (RTC_TAFCR_TAMPFREQ_0 | RTC_TAFCR_TAMPFREQ_1) /*!< Each of the tamper inputs are sampled
  151. with a frequency = RTCCLK / 4096 */
  152. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048 RTC_TAFCR_TAMPFREQ_2 /*!< Each of the tamper inputs are sampled
  153. with a frequency = RTCCLK / 2048 */
  154. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024 (RTC_TAFCR_TAMPFREQ_0 | RTC_TAFCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled
  155. with a frequency = RTCCLK / 1024 */
  156. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512 (RTC_TAFCR_TAMPFREQ_1 | RTC_TAFCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled
  157. with a frequency = RTCCLK / 512 */
  158. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256 RTC_TAFCR_TAMPFREQ /*!< Each of the tamper inputs are sampled
  159. with a frequency = RTCCLK / 256 */
  160. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_MASK RTC_TAFCR_TAMPFREQ /*!< Masking all bits except those of
  161. field TAMPFREQ */
  162. /**
  163. * @}
  164. */
  165. /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration_Definitions RTCEx Tamper Pin Precharge Duration Definitions
  166. * @{
  167. */
  168. #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK 0x00000000U /*!< Tamper pins are pre-charged before
  169. sampling during 1 RTCCLK cycle */
  170. #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK RTC_TAFCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before
  171. sampling during 2 RTCCLK cycles */
  172. #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK RTC_TAFCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before
  173. sampling during 4 RTCCLK cycles */
  174. #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK RTC_TAFCR_TAMPPRCH /*!< Tamper pins are pre-charged before
  175. sampling during 8 RTCCLK cycles */
  176. #define RTC_TAMPERPRECHARGEDURATION_MASK RTC_TAFCR_TAMPPRCH /*!< Masking all bits except those of
  177. field TAMPPRCH */
  178. /**
  179. * @}
  180. */
  181. /** @defgroup RTCEx_Tamper_Pull_Up_Definitions RTCEx Tamper Pull Up Definitions
  182. * @{
  183. */
  184. #define RTC_TAMPER_PULLUP_ENABLE 0x00000000U /*!< Tamper pins are pre-charged before sampling */
  185. #define RTC_TAMPER_PULLUP_DISABLE RTC_TAFCR_TAMPPUDIS /*!< Tamper pins are not pre-charged before sampling */
  186. #define RTC_TAMPER_PULLUP_MASK RTC_TAFCR_TAMPPUDIS /*!< Masking all bits except bit TAMPPUDIS */
  187. /**
  188. * @}
  189. */
  190. /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection_Definitions RTCEx Tamper TimeStamp On Tamper Detection Definitions
  191. * @{
  192. */
  193. #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE RTC_TAFCR_TAMPTS /*!< TimeStamp on Tamper Detection event saved */
  194. #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE 0x00000000U /*!< TimeStamp on Tamper Detection event is not saved */
  195. #define RTC_TIMESTAMPONTAMPERDETECTION_MASK RTC_TAFCR_TAMPTS /*!< Masking all bits except bit TAMPTS */
  196. /**
  197. * @}
  198. */
  199. #if defined(RTC_WAKEUP_SUPPORT)
  200. /** @defgroup RTCEx_Wakeup_Timer_Definitions RTCEx Wakeup Timer Definitions
  201. * @{
  202. */
  203. #define RTC_WAKEUPCLOCK_RTCCLK_DIV16 0x00000000U
  204. #define RTC_WAKEUPCLOCK_RTCCLK_DIV8 RTC_CR_WUCKSEL_0
  205. #define RTC_WAKEUPCLOCK_RTCCLK_DIV4 RTC_CR_WUCKSEL_1
  206. #define RTC_WAKEUPCLOCK_RTCCLK_DIV2 (RTC_CR_WUCKSEL_0 | RTC_CR_WUCKSEL_1)
  207. #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS RTC_CR_WUCKSEL_2
  208. #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_2)
  209. /**
  210. * @}
  211. */
  212. #endif /* RTC_WAKEUP_SUPPORT */
  213. /** @defgroup RTCEx_Smooth_calib_period_Definitions RTCEx Smooth Calib Period Definitions
  214. * @{
  215. */
  216. #define RTC_SMOOTHCALIB_PERIOD_32SEC 0x00000000U /*!< If RTCCLK = 32768 Hz, smooth calibration
  217. period is 32s, otherwise 2^20 RTCCLK pulses */
  218. #define RTC_SMOOTHCALIB_PERIOD_16SEC RTC_CALR_CALW16 /*!< If RTCCLK = 32768 Hz, smooth calibration
  219. period is 16s, otherwise 2^19 RTCCLK pulses */
  220. #define RTC_SMOOTHCALIB_PERIOD_8SEC RTC_CALR_CALW8 /*!< If RTCCLK = 32768 Hz, smooth calibration
  221. period is 8s, otherwise 2^18 RTCCLK pulses */
  222. /**
  223. * @}
  224. */
  225. /** @defgroup RTCEx_Smooth_calib_Plus_pulses_Definitions RTCEx Smooth Calib Plus Pulses Definitions
  226. * @{
  227. */
  228. #define RTC_SMOOTHCALIB_PLUSPULSES_SET RTC_CALR_CALP /*!< The number of RTCCLK pulses added
  229. during a X -second window = Y - CALM[8:0]
  230. with Y = 512, 256, 128 when X = 32, 16, 8 */
  231. #define RTC_SMOOTHCALIB_PLUSPULSES_RESET 0x00000000U /*!< The number of RTCCLK pulses subbstited
  232. during a 32-second window = CALM[8:0] */
  233. /**
  234. * @}
  235. */
  236. /** @defgroup RTCEx_Add_1_Second_Parameter_Definitions RTCEx Add 1 Second Parameter Definitions
  237. * @{
  238. */
  239. #define RTC_SHIFTADD1S_RESET 0x00000000U
  240. #define RTC_SHIFTADD1S_SET RTC_SHIFTR_ADD1S
  241. /**
  242. * @}
  243. */
  244. /** @defgroup RTCEx_Calib_Output_selection_Definitions RTCEx Calib Output Selection Definitions
  245. * @{
  246. */
  247. #define RTC_CALIBOUTPUT_512HZ 0x00000000U
  248. #define RTC_CALIBOUTPUT_1HZ RTC_CR_COSEL
  249. /**
  250. * @}
  251. */
  252. /**
  253. * @}
  254. */
  255. /* Exported macros -----------------------------------------------------------*/
  256. /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros
  257. * @{
  258. */
  259. #if defined(RTC_WAKEUP_SUPPORT)
  260. /* ---------------------------------WAKEUPTIMER-------------------------------*/
  261. /** @defgroup RTCEx_WakeUp_Timer RTCEx WakeUp Timer
  262. * @{
  263. */
  264. /**
  265. * @brief Enable the RTC WakeUp Timer peripheral.
  266. * @param __HANDLE__ specifies the RTC handle.
  267. * @retval None
  268. */
  269. #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_WUTE))
  270. /**
  271. * @brief Disable the RTC Wakeup Timer peripheral.
  272. * @param __HANDLE__ specifies the RTC handle.
  273. * @retval None
  274. */
  275. #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_WUTE))
  276. /**
  277. * @brief Enable the RTC Wakeup Timer interrupt.
  278. * @param __HANDLE__ specifies the RTC handle.
  279. * @param __INTERRUPT__ specifies the RTC Wakeup Timer interrupt sources to be enabled or disabled.
  280. * This parameter can be:
  281. * @arg RTC_IT_WUT: Wakeup Timer interrupt
  282. * @retval None
  283. */
  284. #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  285. /**
  286. * @brief Disable the RTC Wakeup Timer interrupt.
  287. * @param __HANDLE__ specifies the RTC handle.
  288. * @param __INTERRUPT__ specifies the RTC Wakeup Timer interrupt sources to be enabled or disabled.
  289. * This parameter can be:
  290. * @arg RTC_IT_WUT: Wakeup Timer interrupt
  291. * @retval None
  292. */
  293. #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  294. /**
  295. * @brief Check whether the specified RTC Wakeup Timer interrupt has occurred or not.
  296. * @param __HANDLE__ specifies the RTC handle.
  297. * @param __INTERRUPT__ specifies the RTC Wakeup Timer interrupt to check.
  298. * This parameter can be:
  299. * @arg RTC_IT_WUT: Wakeup Timer interrupt
  300. * @retval None
  301. */
  302. #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__) >> 4U)) != 0U) ? 1U : 0U)
  303. /**
  304. * @brief Check whether the specified RTC Wakeup timer interrupt has been enabled or not.
  305. * @param __HANDLE__ specifies the RTC handle.
  306. * @param __INTERRUPT__ specifies the RTC Wakeup timer interrupt sources to check.
  307. * This parameter can be:
  308. * @arg RTC_IT_WUT: WakeUpTimer interrupt
  309. * @retval None
  310. */
  311. #define __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
  312. /**
  313. * @brief Get the selected RTC Wakeup Timer's flag status.
  314. * @param __HANDLE__ specifies the RTC handle.
  315. * @param __FLAG__ specifies the RTC Wakeup Timer flag to check.
  316. * This parameter can be:
  317. * @arg RTC_FLAG_WUTF: Wakeup Timer interrupt flag
  318. * @arg RTC_FLAG_WUTWF: Wakeup Timer 'write allowed' flag
  319. * @retval None
  320. */
  321. #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U)? 1U : 0U)
  322. /**
  323. * @brief Clear the RTC Wakeup timer's pending flags.
  324. * @param __HANDLE__ specifies the RTC handle.
  325. * @param __FLAG__ specifies the RTC Wakeup Timer Flag to clear.
  326. * This parameter can be:
  327. * @arg RTC_FLAG_WUTF: Wakeup Timer interrupt Flag
  328. * @retval None
  329. */
  330. #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  331. /**
  332. * @brief Enable interrupt on the RTC Wakeup Timer associated EXTI line.
  333. * @retval None
  334. */
  335. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  336. /**
  337. * @brief Disable interrupt on the RTC Wakeup Timer associated EXTI line.
  338. * @retval None
  339. */
  340. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR &= ~RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  341. /**
  342. * @brief Enable event on the RTC Wakeup Timer associated EXTI line.
  343. * @retval None.
  344. */
  345. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  346. /**
  347. * @brief Disable event on the RTC Wakeup Timer associated EXTI line.
  348. * @retval None.
  349. */
  350. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  351. /**
  352. * @brief Enable falling edge trigger on the RTC Wakeup Timer associated EXTI line.
  353. * @retval None.
  354. */
  355. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  356. /**
  357. * @brief Disable falling edge trigger on the RTC Wakeup Timer associated EXTI line.
  358. * @retval None.
  359. */
  360. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  361. /**
  362. * @brief Enable rising edge trigger on the RTC Wakeup Timer associated EXTI line.
  363. * @retval None.
  364. */
  365. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  366. /**
  367. * @brief Disable rising edge trigger on the RTC Wakeup Timer associated EXTI line.
  368. * @retval None.
  369. */
  370. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  371. /**
  372. * @brief Enable rising & falling edge trigger on the RTC Wakeup Timer associated EXTI line.
  373. * @retval None.
  374. */
  375. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  376. __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE(); \
  377. __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE(); \
  378. } while(0U)
  379. /**
  380. * @brief Disable rising & falling edge trigger on the RTC Wakeup Timer associated EXTI line.
  381. * This parameter can be:
  382. * @retval None.
  383. */
  384. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  385. __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE(); \
  386. __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE(); \
  387. } while(0U)
  388. /**
  389. * @brief Check whether the RTC Wakeup Timer associated EXTI line interrupt flag is set or not.
  390. * @retval Line Status.
  391. */
  392. #define __HAL_RTC_WAKEUPTIMER_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  393. /**
  394. * @brief Clear the RTC Wakeup Timer associated EXTI line flag.
  395. * @retval None.
  396. */
  397. #define __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  398. /**
  399. * @brief Generate a Software interrupt on the RTC Wakeup Timer associated EXTI line.
  400. * @retval None.
  401. */
  402. #define __HAL_RTC_WAKEUPTIMER_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  403. /**
  404. * @}
  405. */
  406. #endif /* RTC_WAKEUP_SUPPORT */
  407. /* ---------------------------------TIMESTAMP---------------------------------*/
  408. /** @defgroup RTCEx_Timestamp RTCEx Timestamp
  409. * @{
  410. */
  411. /**
  412. * @brief Enable the RTC Timestamp peripheral.
  413. * @param __HANDLE__ specifies the RTC handle.
  414. * @retval None
  415. */
  416. #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TSE))
  417. /**
  418. * @brief Disable the RTC Timestamp peripheral.
  419. * @param __HANDLE__ specifies the RTC handle.
  420. * @retval None
  421. */
  422. #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TSE))
  423. /**
  424. * @brief Enable the RTC Timestamp interrupt.
  425. * @param __HANDLE__ specifies the RTC handle.
  426. * @param __INTERRUPT__ specifies the RTC Timestamp interrupt sources to be enabled or disabled.
  427. * This parameter can be:
  428. * @arg RTC_IT_TS: TimeStamp interrupt
  429. * @retval None
  430. */
  431. #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  432. /**
  433. * @brief Disable the RTC Timestamp interrupt.
  434. * @param __HANDLE__ specifies the RTC handle.
  435. * @param __INTERRUPT__ specifies the RTC Timestamp interrupt sources to be enabled or disabled.
  436. * This parameter can be:
  437. * @arg RTC_IT_TS: TimeStamp interrupt
  438. * @retval None
  439. */
  440. #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  441. /**
  442. * @brief Check whether the specified RTC Timestamp interrupt has occurred or not.
  443. * @param __HANDLE__ specifies the RTC handle.
  444. * @param __INTERRUPT__ specifies the RTC Timestamp interrupt to check.
  445. * This parameter can be:
  446. * @arg RTC_IT_TS: TimeStamp interrupt
  447. * @retval None
  448. */
  449. #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__) >> 4U)) != 0U) ? 1U : 0U)
  450. /**
  451. * @brief Check whether the specified RTC Timestamp interrupt has been enabled or not.
  452. * @param __HANDLE__ specifies the RTC handle.
  453. * @param __INTERRUPT__ specifies the RTC Timestamp interrupt source to check.
  454. * This parameter can be:
  455. * @arg RTC_IT_TS: TimeStamp interrupt
  456. * @retval None
  457. */
  458. #define __HAL_RTC_TIMESTAMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
  459. /**
  460. * @brief Get the selected RTC Timestamp's flag status.
  461. * @param __HANDLE__ specifies the RTC handle.
  462. * @param __FLAG__ specifies the RTC Timestamp flag to check.
  463. * This parameter can be:
  464. * @arg RTC_FLAG_TSF: Timestamp interrupt flag
  465. * @arg RTC_FLAG_TSOVF: Timestamp overflow flag
  466. * @retval None
  467. */
  468. #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U)? 1U : 0U)
  469. /**
  470. * @brief Clear the RTC Timestamp's pending flags.
  471. * @param __HANDLE__ specifies the RTC handle.
  472. * @param __FLAG__ specifies the RTC Timestamp flag to clear.
  473. * This parameter can be:
  474. * @arg RTC_FLAG_TSF: Timestamp interrupt flag
  475. * @arg RTC_FLAG_TSOVF: Timestamp overflow flag
  476. * @retval None
  477. */
  478. #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  479. /**
  480. * @}
  481. */
  482. /* ---------------------------------TAMPER------------------------------------*/
  483. /** @defgroup RTCEx_Tamper RTCEx Tamper
  484. * @{
  485. */
  486. /**
  487. * @brief Enable the RTC Tamper1 input detection.
  488. * @param __HANDLE__ specifies the RTC handle.
  489. * @retval None
  490. */
  491. #define __HAL_RTC_TAMPER1_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAFCR |= (RTC_TAFCR_TAMP1E))
  492. /**
  493. * @brief Disable the RTC Tamper1 input detection.
  494. * @param __HANDLE__ specifies the RTC handle.
  495. * @retval None
  496. */
  497. #define __HAL_RTC_TAMPER1_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAFCR &= ~(RTC_TAFCR_TAMP1E))
  498. /**
  499. * @brief Enable the RTC Tamper2 input detection.
  500. * @param __HANDLE__ specifies the RTC handle.
  501. * @retval None
  502. */
  503. #define __HAL_RTC_TAMPER2_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAFCR |= (RTC_TAFCR_TAMP2E))
  504. /**
  505. * @brief Disable the RTC Tamper2 input detection.
  506. * @param __HANDLE__ specifies the RTC handle.
  507. * @retval None
  508. */
  509. #define __HAL_RTC_TAMPER2_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAFCR &= ~(RTC_TAFCR_TAMP2E))
  510. #if defined(RTC_TAMPER3_SUPPORT)
  511. /**
  512. * @brief Enable the RTC Tamper3 input detection.
  513. * @param __HANDLE__ specifies the RTC handle.
  514. * @retval None
  515. */
  516. #define __HAL_RTC_TAMPER3_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAFCR |= (RTC_TAFCR_TAMP3E))
  517. /**
  518. * @brief Disable the RTC Tamper3 input detection.
  519. * @param __HANDLE__ specifies the RTC handle.
  520. * @retval None
  521. */
  522. #define __HAL_RTC_TAMPER3_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAFCR &= ~(RTC_TAFCR_TAMP3E))
  523. #endif /* RTC_TAMPER3_SUPPORT */
  524. /**
  525. * @brief Enable the RTC Tamper interrupt.
  526. * @param __HANDLE__ specifies the RTC handle.
  527. * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be enabled.
  528. * This parameter can be any combination of the following values:
  529. * @arg RTC_IT_TAMP: Tamper global interrupt
  530. * @retval None
  531. */
  532. #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->TAFCR |= (__INTERRUPT__))
  533. /**
  534. * @brief Disable the RTC Tamper interrupt.
  535. * @param __HANDLE__ specifies the RTC handle.
  536. * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be disabled.
  537. * This parameter can be any combination of the following values:
  538. * @arg RTC_IT_TAMP: Tamper global interrupt
  539. * @retval None
  540. */
  541. #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->TAFCR &= ~(__INTERRUPT__))
  542. /**
  543. * @brief Check whether the specified RTC Tamper interrupt has occurred or not.
  544. * @param __HANDLE__ specifies the RTC handle.
  545. * @param __INTERRUPT__ specifies the RTC Tamper interrupt to check.
  546. * This parameter can be:
  547. * @arg RTC_IT_TAMP1: Tamper 1 interrupt
  548. * @arg RTC_IT_TAMP2: Tamper 2 interrupt
  549. * @arg RTC_IT_TAMP3: Tamper 3 interrupt
  550. * @note RTC_IT_TAMP3 is not applicable to all devices.
  551. * @retval None
  552. */
  553. #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__) >> 4U)) != 0U) ? 1U : 0U)
  554. /**
  555. * @brief Check whether the specified RTC Tamper interrupt has been enabled or not.
  556. * @param __HANDLE__ specifies the RTC handle.
  557. * @param __INTERRUPT__ specifies the RTC Tamper interrupt source to check.
  558. * This parameter can be:
  559. * @arg RTC_IT_TAMP: Tamper global interrupt
  560. * @retval None
  561. */
  562. #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->TAFCR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
  563. /**
  564. * @brief Get the selected RTC Tamper's flag status.
  565. * @param __HANDLE__ specifies the RTC handle.
  566. * @param __FLAG__ specifies the RTC Tamper flag to be checked.
  567. * This parameter can be:
  568. * @arg RTC_FLAG_TAMP1F: Tamper 1 interrupt flag
  569. * @arg RTC_FLAG_TAMP2F: Tamper 2 interrupt flag
  570. * @arg RTC_FLAG_TAMP3F: Tamper 3 interrupt flag
  571. * @note RTC_FLAG_TAMP3F is not applicable to all devices.
  572. * @retval None
  573. */
  574. #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U)? 1U : 0U)
  575. /**
  576. * @brief Clear the RTC Tamper's pending flags.
  577. * @param __HANDLE__ specifies the RTC handle.
  578. * @param __FLAG__ specifies the RTC Tamper Flag to clear.
  579. * This parameter can be:
  580. * @arg RTC_FLAG_TAMP1F: Tamper 1 interrupt flag
  581. * @arg RTC_FLAG_TAMP2F: Tamper 2 interrupt flag
  582. * @arg RTC_FLAG_TAMP3F: Tamper 3 interrupt flag
  583. * @note RTC_FLAG_TAMP3F is not applicable to all devices.
  584. * @retval None
  585. */
  586. #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  587. /**
  588. * @}
  589. */
  590. /* --------------------------TAMPER/TIMESTAMP---------------------------------*/
  591. /** @defgroup RTCEx_Tamper_Timestamp EXTI RTC Tamper Timestamp EXTI
  592. * @{
  593. */
  594. /**
  595. * @brief Enable interrupt on the RTC Tamper and Timestamp associated EXTI line.
  596. * @retval None
  597. */
  598. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  599. /**
  600. * @brief Disable interrupt on the RTC Tamper and Timestamp associated EXTI line.
  601. * @retval None
  602. */
  603. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_IT() (EXTI->IMR &= ~RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  604. /**
  605. * @brief Enable event on the RTC Tamper and Timestamp associated EXTI line.
  606. * @retval None.
  607. */
  608. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  609. /**
  610. * @brief Disable event on the RTC Tamper and Timestamp associated EXTI line.
  611. * @retval None.
  612. */
  613. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  614. /**
  615. * @brief Enable falling edge trigger on the RTC Tamper and Timestamp associated EXTI line.
  616. * @retval None.
  617. */
  618. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  619. /**
  620. * @brief Disable falling edge trigger on the RTC Tamper and Timestamp associated EXTI line.
  621. * @retval None.
  622. */
  623. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  624. /**
  625. * @brief Enable rising edge trigger on the RTC Tamper and Timestamp associated EXTI line.
  626. * @retval None.
  627. */
  628. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  629. /**
  630. * @brief Disable rising edge trigger on the RTC Tamper and Timestamp associated EXTI line.
  631. * @retval None.
  632. */
  633. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  634. /**
  635. * @brief Enable rising & falling edge trigger on the RTC Tamper and Timestamp associated EXTI line.
  636. * @retval None.
  637. */
  638. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  639. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE(); \
  640. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE(); \
  641. } while(0U)
  642. /**
  643. * @brief Disable rising & falling edge trigger on the RTC Tamper and Timestamp associated EXTI line.
  644. * This parameter can be:
  645. * @retval None.
  646. */
  647. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  648. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE(); \
  649. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE(); \
  650. } while(0U)
  651. /**
  652. * @brief Check whether the RTC Tamper and Timestamp associated EXTI line interrupt flag is set or not.
  653. * @retval Line Status.
  654. */
  655. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  656. /**
  657. * @brief Clear the RTC Tamper and Timestamp associated EXTI line flag.
  658. * @retval None.
  659. */
  660. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  661. /**
  662. * @brief Generate a Software interrupt on the RTC Tamper and Timestamp associated EXTI line
  663. * @retval None.
  664. */
  665. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  666. /**
  667. * @}
  668. */
  669. /* ------------------------------CALIBRATION----------------------------------*/
  670. /** @defgroup RTCEx_Calibration RTCEx Calibration
  671. * @{
  672. */
  673. /**
  674. * @brief Enable the RTC calibration output.
  675. * @param __HANDLE__ specifies the RTC handle.
  676. * @retval None
  677. */
  678. #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_COE))
  679. /**
  680. * @brief Disable the calibration output.
  681. * @param __HANDLE__ specifies the RTC handle.
  682. * @retval None
  683. */
  684. #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_COE))
  685. /**
  686. * @brief Enable the clock reference detection.
  687. * @param __HANDLE__ specifies the RTC handle.
  688. * @retval None
  689. */
  690. #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_REFCKON))
  691. /**
  692. * @brief Disable the clock reference detection.
  693. * @param __HANDLE__ specifies the RTC handle.
  694. * @retval None
  695. */
  696. #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_REFCKON))
  697. /**
  698. * @brief Get the selected RTC shift operation's flag status.
  699. * @param __HANDLE__ specifies the RTC handle.
  700. * @param __FLAG__ specifies the RTC shift operation Flag is pending or not.
  701. * This parameter can be:
  702. * @arg RTC_FLAG_SHPF: Shift pending flag
  703. * @retval None
  704. */
  705. #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U)? 1U : 0U)
  706. /**
  707. * @}
  708. */
  709. /**
  710. * @}
  711. */
  712. /* Exported functions --------------------------------------------------------*/
  713. /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions
  714. * @{
  715. */
  716. /** @addtogroup RTCEx_Exported_Functions_Group1
  717. * @{
  718. */
  719. /* RTC Timestamp and Tamper functions *****************************************/
  720. HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t RTC_TimeStampEdge, uint32_t RTC_TimeStampPin);
  721. HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t RTC_TimeStampEdge, uint32_t RTC_TimeStampPin);
  722. HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc);
  723. HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format);
  724. HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper);
  725. HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper);
  726. HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper);
  727. void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc);
  728. void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc);
  729. void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc);
  730. #if defined(RTC_TAMPER3_SUPPORT)
  731. void HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc);
  732. #endif /* RTC_TAMPER3_SUPPORT */
  733. void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc);
  734. HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  735. HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  736. HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  737. #if defined(RTC_TAMPER3_SUPPORT)
  738. HAL_StatusTypeDef HAL_RTCEx_PollForTamper3Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  739. #endif /* RTC_TAMPER3_SUPPORT */
  740. /**
  741. * @}
  742. */
  743. #if defined(RTC_WAKEUP_SUPPORT)
  744. /** @addtogroup RTCEx_Exported_Functions_Group2
  745. * @{
  746. */
  747. /* RTC Wakeup functions ******************************************************/
  748. HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
  749. HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
  750. HAL_StatusTypeDef HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc);
  751. uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc);
  752. void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc);
  753. void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc);
  754. HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  755. /**
  756. * @}
  757. */
  758. #endif /* RTC_WAKEUP_SUPPORT */
  759. /** @addtogroup RTCEx_Exported_Functions_Group3
  760. * @{
  761. */
  762. /* Extended Control functions ************************************************/
  763. #if defined(RTC_BACKUP_SUPPORT)
  764. void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data);
  765. uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister);
  766. #endif /* RTC_BACKUP_SUPPORT */
  767. HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue);
  768. HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS);
  769. HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput);
  770. HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc);
  771. HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc);
  772. HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc);
  773. HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc);
  774. HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc);
  775. /**
  776. * @}
  777. */
  778. /**
  779. * @}
  780. */
  781. /* Private types -------------------------------------------------------------*/
  782. /* Private variables ---------------------------------------------------------*/
  783. /* Private constants ---------------------------------------------------------*/
  784. /** @defgroup RTCEx_Private_Constants RTCEx Private Constants
  785. * @{
  786. */
  787. #define RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT EXTI_IMR_MR19 /*!< External interrupt line 19 Connected to the RTC Tamper and Timestamp event */
  788. #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT EXTI_IMR_MR20 /*!< External interrupt line 20 Connected to the RTC Wakeup event */
  789. /**
  790. * @}
  791. */
  792. /** @defgroup RTCEx_Private_Constants RTCEx Private Constants
  793. * @{
  794. */
  795. /* Masks Definition */
  796. #if defined(RTC_TAMPER3_SUPPORT)
  797. #define RTC_TAMPER_ENABLE_BITS_MASK ((uint32_t) (RTC_TAMPER_1 | \
  798. RTC_TAMPER_2 | \
  799. RTC_TAMPER_3))
  800. #define RTC_TAMPER_FLAGS_MASK ((uint32_t) (RTC_FLAG_TAMP1F | \
  801. RTC_FLAG_TAMP2F | \
  802. RTC_FLAG_TAMP3F))
  803. #else /* RTC_TAMPER3_SUPPORT */
  804. #define RTC_TAMPER_ENABLE_BITS_MASK ((uint32_t) (RTC_TAMPER_1 | \
  805. RTC_TAMPER_2))
  806. #define RTC_TAMPER_FLAGS_MASK ((uint32_t) (RTC_FLAG_TAMP1F | \
  807. RTC_FLAG_TAMP2F))
  808. #endif /* RTC_TAMPER3_SUPPORT */
  809. /**
  810. * @}
  811. */
  812. /* Private macros ------------------------------------------------------------*/
  813. /** @defgroup RTCEx_Private_Macros RTCEx Private Macros
  814. * @{
  815. */
  816. /** @defgroup RTCEx_IS_RTC_Definitions Private macros to check input parameters
  817. * @{
  818. */
  819. #define IS_RTC_BKP(BKP) ((BKP) < (uint32_t) RTC_BKP_NUMBER)
  820. #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \
  821. ((EDGE) == RTC_TIMESTAMPEDGE_FALLING))
  822. #define IS_RTC_TAMPER(TAMPER) ((((TAMPER) & ((uint32_t)~RTC_TAMPER_ENABLE_BITS_MASK)) == 0x00U) && ((TAMPER) != 0U))
  823. #define IS_RTC_TAMPER_PIN(PIN) ((PIN) == RTC_TAMPERPIN_DEFAULT)
  824. #define IS_RTC_TIMESTAMP_PIN(PIN) ((PIN) == RTC_TIMESTAMPPIN_DEFAULT)
  825. #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) || \
  826. ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \
  827. ((TRIGGER) == RTC_TAMPERTRIGGER_LOWLEVEL) || \
  828. ((TRIGGER) == RTC_TAMPERTRIGGER_HIGHLEVEL))
  829. #define IS_RTC_TAMPER_FILTER(FILTER) (((FILTER) == RTC_TAMPERFILTER_DISABLE) || \
  830. ((FILTER) == RTC_TAMPERFILTER_2SAMPLE) || \
  831. ((FILTER) == RTC_TAMPERFILTER_4SAMPLE) || \
  832. ((FILTER) == RTC_TAMPERFILTER_8SAMPLE))
  833. #define IS_RTC_TAMPER_FILTER_CONFIG_CORRECT(FILTER, TRIGGER) \
  834. ( ( ((FILTER) != RTC_TAMPERFILTER_DISABLE) \
  835. && ( ((TRIGGER) == RTC_TAMPERTRIGGER_LOWLEVEL) \
  836. || ((TRIGGER) == RTC_TAMPERTRIGGER_HIGHLEVEL))) \
  837. || ( ((FILTER) == RTC_TAMPERFILTER_DISABLE) \
  838. && ( ((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) \
  839. || ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE))))
  840. #define IS_RTC_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \
  841. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \
  842. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \
  843. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \
  844. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \
  845. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \
  846. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512) || \
  847. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256))
  848. #define IS_RTC_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \
  849. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \
  850. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \
  851. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK))
  852. #define IS_RTC_TAMPER_PULLUP_STATE(STATE) (((STATE) == RTC_TAMPER_PULLUP_ENABLE) || \
  853. ((STATE) == RTC_TAMPER_PULLUP_DISABLE))
  854. #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \
  855. ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE))
  856. #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16) || \
  857. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8) || \
  858. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4) || \
  859. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2) || \
  860. ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \
  861. ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS))
  862. #define IS_RTC_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= RTC_WUTR_WUT)
  863. #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \
  864. ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \
  865. ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC))
  866. #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \
  867. ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET))
  868. #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= RTC_CALR_CALM)
  869. #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \
  870. ((SEL) == RTC_SHIFTADD1S_SET))
  871. #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= RTC_SHIFTR_SUBFS)
  872. #define IS_RTC_CALIB_OUTPUT(OUTPUT) (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \
  873. ((OUTPUT) == RTC_CALIBOUTPUT_1HZ))
  874. /**
  875. * @}
  876. */
  877. /**
  878. * @}
  879. */
  880. /**
  881. * @}
  882. */
  883. /**
  884. * @}
  885. */
  886. #ifdef __cplusplus
  887. }
  888. #endif
  889. #endif /* STM32F0xx_HAL_RTC_EX_H */