Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

1070 righe
45 KiB

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