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.
 
 
 

1185 lines
51 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_rtc_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of RTC HAL Extension module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32H7xx_HAL_RTC_EX_H
  21. #define STM32H7xx_HAL_RTC_EX_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif /* __cplusplus */
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32h7xx_hal_def.h"
  27. /** @addtogroup STM32H7xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup RTCEx
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup RTCEx_Exported_Types RTCEx Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief RTC Tamper structure definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t Tamper; /*!< Specifies the Tamper Pin.
  43. This parameter can be a value of @ref RTCEx_Tamper_Pins_Definitions */
  44. uint32_t Interrupt; /*!< Specifies the Tamper Interrupt.
  45. This parameter can be a value of @ref RTCEx_Tamper_Interrupt_Definitions */
  46. uint32_t Trigger; /*!< Specifies the Tamper Trigger.
  47. This parameter can be a value of @ref RTCEx_Tamper_Trigger_Definitions */
  48. uint32_t NoErase; /*!< Specifies the Tamper no erase mode.
  49. This parameter can be a value of @ref RTCEx_Tamper_EraseBackUp_Definitions */
  50. uint32_t MaskFlag; /*!< Specifies the Tamper Flag masking.
  51. This parameter can be a value of @ref RTCEx_Tamper_MaskFlag_Definitions */
  52. uint32_t Filter; /*!< Specifies the RTC Filter Tamper.
  53. This parameter can be a value of @ref RTCEx_Tamper_Filter_Definitions */
  54. uint32_t SamplingFrequency; /*!< Specifies the sampling frequency.
  55. This parameter can be a value of @ref RTCEx_Tamper_Sampling_Frequencies_Definitions */
  56. uint32_t PrechargeDuration; /*!< Specifies the Precharge Duration .
  57. This parameter can be a value of @ref RTCEx_Tamper_Pin_Precharge_Duration_Definitions */
  58. uint32_t TamperPullUp; /*!< Specifies the Tamper PullUp .
  59. This parameter can be a value of @ref RTCEx_Tamper_Pull_UP_Definitions */
  60. uint32_t TimeStampOnTamperDetection; /*!< Specifies the TimeStampOnTamperDetection.
  61. This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection_Definitions */
  62. }RTC_TamperTypeDef;
  63. /**
  64. * @}
  65. */
  66. /* Exported constants --------------------------------------------------------*/
  67. /** @defgroup RTCEx_Exported_Constants RTCEx Exported Constants
  68. * @{
  69. */
  70. /** @defgroup RTCEx_Output_selection_Definitions RTC Output Selection Definitions
  71. * @{
  72. */
  73. #define RTC_OUTPUT_DISABLE 0x00000000u
  74. #define RTC_OUTPUT_ALARMA RTC_CR_OSEL_0
  75. #define RTC_OUTPUT_ALARMB RTC_CR_OSEL_1
  76. #define RTC_OUTPUT_WAKEUP RTC_CR_OSEL
  77. /**
  78. * @}
  79. */
  80. /** @defgroup RTCEx_Backup_Registers_Definitions RTC Backup Registers Definitions
  81. * @{
  82. */
  83. #define RTC_BKP_DR0 0x00000000u
  84. #define RTC_BKP_DR1 0x00000001u
  85. #define RTC_BKP_DR2 0x00000002u
  86. #define RTC_BKP_DR3 0x00000003u
  87. #define RTC_BKP_DR4 0x00000004u
  88. #define RTC_BKP_DR5 0x00000005u
  89. #define RTC_BKP_DR6 0x00000006u
  90. #define RTC_BKP_DR7 0x00000007u
  91. #define RTC_BKP_DR8 0x00000008u
  92. #define RTC_BKP_DR9 0x00000009u
  93. #define RTC_BKP_DR10 0x0000000Au
  94. #define RTC_BKP_DR11 0x0000000Bu
  95. #define RTC_BKP_DR12 0x0000000Cu
  96. #define RTC_BKP_DR13 0x0000000Du
  97. #define RTC_BKP_DR14 0x0000000Eu
  98. #define RTC_BKP_DR15 0x0000000Fu
  99. #define RTC_BKP_DR16 0x00000010u
  100. #define RTC_BKP_DR17 0x00000011u
  101. #define RTC_BKP_DR18 0x00000012u
  102. #define RTC_BKP_DR19 0x00000013u
  103. #define RTC_BKP_DR20 0x00000014u
  104. #define RTC_BKP_DR21 0x00000015u
  105. #define RTC_BKP_DR22 0x00000016u
  106. #define RTC_BKP_DR23 0x00000017u
  107. #define RTC_BKP_DR24 0x00000018u
  108. #define RTC_BKP_DR25 0x00000019u
  109. #define RTC_BKP_DR26 0x0000001Au
  110. #define RTC_BKP_DR27 0x0000001Bu
  111. #define RTC_BKP_DR28 0x0000001Cu
  112. #define RTC_BKP_DR29 0x0000001Du
  113. #define RTC_BKP_DR30 0x0000001Eu
  114. #define RTC_BKP_DR31 0x0000001Fu
  115. /**
  116. * @}
  117. */
  118. /** @defgroup RTCEx_TimeStamp_Edges_definitions RTC TimeStamp Edges Definitions
  119. *
  120. * @{
  121. */
  122. #define RTC_TIMESTAMPEDGE_RISING 0x00000000u
  123. #define RTC_TIMESTAMPEDGE_FALLING RTC_CR_TSEDGE
  124. /**
  125. * @}
  126. */
  127. /** @defgroup RTCEx_TimeStamp_Pin_Selection RTC TimeStamp Pins Selection
  128. * @{
  129. */
  130. #define RTC_TIMESTAMPPIN_DEFAULT 0x00000000u
  131. /**
  132. * @}
  133. */
  134. /** @defgroup RTCEx_Tamper_Pins_Definitions RTC Tamper Pins Definitions
  135. * @{
  136. */
  137. #define RTC_TAMPER_1 RTC_TAMPCR_TAMP1E
  138. #define RTC_TAMPER_2 RTC_TAMPCR_TAMP2E
  139. #define RTC_TAMPER_3 RTC_TAMPCR_TAMP3E
  140. /**
  141. * @}
  142. */
  143. /** @defgroup RTCEx_Tamper_Interrupt_Definitions RTC Tamper Interrupts Definitions
  144. * @{
  145. */
  146. #define RTC_TAMPER1_INTERRUPT RTC_TAMPCR_TAMP1IE
  147. #define RTC_TAMPER2_INTERRUPT RTC_TAMPCR_TAMP2IE
  148. #define RTC_TAMPER3_INTERRUPT RTC_TAMPCR_TAMP3IE
  149. #define RTC_ALL_TAMPER_INTERRUPT RTC_TAMPCR_TAMPIE
  150. /**
  151. * @}
  152. */
  153. /** @defgroup RTCEx_Tamper_Trigger_Definitions RTC Tamper Triggers Definitions
  154. * @{
  155. */
  156. #define RTC_TAMPERTRIGGER_RISINGEDGE 0x01u /*!< Warning : Filter must be RTC_TAMPERFILTER_DISABLE */
  157. #define RTC_TAMPERTRIGGER_FALLINGEDGE 0x02u /*!< Warning : Filter must be RTC_TAMPERFILTER_DISABLE */
  158. #define RTC_TAMPERTRIGGER_LOWLEVEL 0x04u /*!< Warning : Filter must not be RTC_TAMPERFILTER_DISABLE */
  159. #define RTC_TAMPERTRIGGER_HIGHLEVEL 0x08u /*!< Warning : Filter must not be RTC_TAMPERFILTER_DISABLE */
  160. /**
  161. * @}
  162. */
  163. /** @defgroup RTCEx_Tamper_EraseBackUp_Definitions RTC Tamper EraseBackUp Definitions
  164. * @{
  165. */
  166. #define RTC_TAMPER_ERASE_BACKUP_ENABLE 0x00000000u
  167. #define RTC_TAMPER_ERASE_BACKUP_DISABLE RTC_TAMPCR_TAMP1NOERASE
  168. /**
  169. * @}
  170. */
  171. /** @defgroup RTCEx_Tamper_MaskFlag_Definitions RTC Tamper Mask Flag Definitions
  172. * @{
  173. */
  174. #define RTC_TAMPERMASK_FLAG_DISABLE 0x00000000u
  175. #define RTC_TAMPERMASK_FLAG_ENABLE RTC_TAMPCR_TAMP1MF
  176. /**
  177. * @}
  178. */
  179. /** @defgroup RTCEx_Tamper_Filter_Definitions RTC Tamper Filter Definitions
  180. * @{
  181. */
  182. #define RTC_TAMPERFILTER_DISABLE 0x00000000u /*!< Tamper filter is disabled */
  183. #define RTC_TAMPERFILTER_2SAMPLE RTC_TAMPCR_TAMPFLT_0 /*!< Tamper is activated after 2
  184. consecutive samples at the active level */
  185. #define RTC_TAMPERFILTER_4SAMPLE RTC_TAMPCR_TAMPFLT_1 /*!< Tamper is activated after 4
  186. consecutive samples at the active level */
  187. #define RTC_TAMPERFILTER_8SAMPLE RTC_TAMPCR_TAMPFLT /*!< Tamper is activated after 8
  188. consecutive samples at the active level. */
  189. #define RTC_TAMPERFILTER_MASK RTC_TAMPCR_TAMPFLT /*!< Masking all bits except those of
  190. field TAMPFLT[1:0]. */
  191. /**
  192. * @}
  193. */
  194. /** @defgroup RTCEx_Tamper_Sampling_Frequencies_Definitions RTC Tamper Sampling Frequencies Definitions
  195. * @{
  196. */
  197. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768 0x00000000u /*!< Each of the tamper inputs are sampled
  198. with a frequency = RTCCLK / 32768 */
  199. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384 RTC_TAMPCR_TAMPFREQ_0 /*!< Each of the tamper inputs are sampled
  200. with a frequency = RTCCLK / 16384 */
  201. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192 RTC_TAMPCR_TAMPFREQ_1 /*!< Each of the tamper inputs are sampled
  202. with a frequency = RTCCLK / 8192 */
  203. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096 (RTC_TAMPCR_TAMPFREQ_0 | RTC_TAMPCR_TAMPFREQ_1) /*!< Each of the tamper inputs are sampled
  204. with a frequency = RTCCLK / 4096 */
  205. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048 RTC_TAMPCR_TAMPFREQ_2 /*!< Each of the tamper inputs are sampled
  206. with a frequency = RTCCLK / 2048 */
  207. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024 (RTC_TAMPCR_TAMPFREQ_0 | RTC_TAMPCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled
  208. with a frequency = RTCCLK / 1024 */
  209. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512 (RTC_TAMPCR_TAMPFREQ_1 | RTC_TAMPCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled
  210. with a frequency = RTCCLK / 512 */
  211. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256 RTC_TAMPCR_TAMPFREQ /*!< Each of the tamper inputs are sampled
  212. with a frequency = RTCCLK / 256 */
  213. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_MASK RTC_TAMPCR_TAMPFREQ /*!< Masking all bits except those of
  214. field TAMPFREQ[2:0]*/
  215. #/**
  216. * @}
  217. */
  218. /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration_Definitions RTC Tamper Pin Precharge Duration Definitions
  219. * @{
  220. */
  221. #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK 0x00000000u /*!< Tamper pins are pre-charged before
  222. sampling during 1 RTCCLK cycle */
  223. #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK RTC_TAMPCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before
  224. sampling during 2 RTCCLK cycles */
  225. #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK RTC_TAMPCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before
  226. sampling during 4 RTCCLK cycles */
  227. #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK RTC_TAMPCR_TAMPPRCH /*!< Tamper pins are pre-charged before
  228. sampling during 8 RTCCLK cycles */
  229. #define RTC_TAMPERPRECHARGEDURATION_MASK RTC_TAMPCR_TAMPPRCH /*!< Masking all bits except those of
  230. field TAMPPRCH[1:0] */
  231. /**
  232. * @}
  233. */
  234. /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection_Definitions RTC Tamper TimeStamp On Tamper Detection Definitions
  235. * @{
  236. */
  237. #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE RTC_TAMPCR_TAMPTS /*!< TimeStamp on Tamper Detection event saved */
  238. #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE 0x00000000u /*!< TimeStamp on Tamper Detection event is not saved */
  239. #define RTC_TIMESTAMPONTAMPERDETECTION_MASK RTC_TAMPCR_TAMPTS /*!< Masking all bits except bit TAMPTS */
  240. /**
  241. * @}
  242. */
  243. /** @defgroup RTCEx_Tamper_Pull_UP_Definitions RTC Tamper Pull Up Definitions
  244. * @{
  245. */
  246. #define RTC_TAMPER_PULLUP_ENABLE 0x00000000u /*!< TimeStamp on Tamper Detection event saved */
  247. #define RTC_TAMPER_PULLUP_DISABLE RTC_TAMPCR_TAMPPUDIS /*!< TimeStamp on Tamper Detection event is not saved */
  248. #define RTC_TAMPER_PULLUP_MASK RTC_TAMPCR_TAMPPUDIS /*!< Maskin all bits except bit TAMPPUDIS */
  249. /**
  250. * @}
  251. */
  252. /** @defgroup RTCEx_Wakeup_Timer_Definitions RTC Wakeup Timer Definitions
  253. * @{
  254. */
  255. #define RTC_WAKEUPCLOCK_RTCCLK_DIV16 0x00000000u
  256. #define RTC_WAKEUPCLOCK_RTCCLK_DIV8 RTC_CR_WUCKSEL_0
  257. #define RTC_WAKEUPCLOCK_RTCCLK_DIV4 RTC_CR_WUCKSEL_1
  258. #define RTC_WAKEUPCLOCK_RTCCLK_DIV2 (RTC_CR_WUCKSEL_0 | RTC_CR_WUCKSEL_1)
  259. #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS RTC_CR_WUCKSEL_2
  260. #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_2)
  261. /**
  262. * @}
  263. */
  264. /** @defgroup RTCEx_Smooth_calib_period_Definitions RTC Smooth Calib Period Definitions
  265. * @{
  266. */
  267. #define RTC_SMOOTHCALIB_PERIOD_32SEC 0x00000000u /*!< If RTCCLK = 32768 Hz, Smooth calibration
  268. period is 32s, else 2exp20 RTCCLK pulses */
  269. #define RTC_SMOOTHCALIB_PERIOD_16SEC RTC_CALR_CALW16 /*!< If RTCCLK = 32768 Hz, Smooth calibration
  270. period is 16s, else 2exp19 RTCCLK pulses */
  271. #define RTC_SMOOTHCALIB_PERIOD_8SEC RTC_CALR_CALW8 /*!< If RTCCLK = 32768 Hz, Smooth calibration
  272. period is 8s, else 2exp18 RTCCLK pulses */
  273. /**
  274. * @}
  275. */
  276. /** @defgroup RTCEx_Smooth_calib_Plus_pulses_Definitions RTC Smooth Calib Plus Pulses Definitions
  277. * @{
  278. */
  279. #define RTC_SMOOTHCALIB_PLUSPULSES_SET RTC_CALR_CALP /*!< The number of RTCCLK pulses added
  280. during a X -second window = Y - CALM[8:0]
  281. with Y = 512, 256, 128 when X = 32, 16, 8 */
  282. #define RTC_SMOOTHCALIB_PLUSPULSES_RESET 0x00000000u /*!< The number of RTCCLK pulses subbstited
  283. during a 32-second window = CALM[8:0] */
  284. /**
  285. * @}
  286. */
  287. /** @defgroup RTCEx_Calib_Output_selection_Definitions RTC Calib Output Selection Definitions
  288. * @{
  289. */
  290. #define RTC_CALIBOUTPUT_512HZ 0x00000000u
  291. #define RTC_CALIBOUTPUT_1HZ RTC_CR_COSEL
  292. /**
  293. * @}
  294. */
  295. /** @defgroup RTCEx_Add_1_Second_Parameter_Definitions RTC Add 1 Second Parameter Definitions
  296. * @{
  297. */
  298. #define RTC_SHIFTADD1S_RESET 0x00000000u
  299. #define RTC_SHIFTADD1S_SET RTC_SHIFTR_ADD1S
  300. /**
  301. * @}
  302. */
  303. /**
  304. * @}
  305. */
  306. /* Exported macros -----------------------------------------------------------*/
  307. /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros
  308. * @{
  309. */
  310. /**
  311. * @brief Enable the RTC WakeUp Timer peripheral.
  312. * @param __HANDLE__ specifies the RTC handle.
  313. * @retval None
  314. */
  315. #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_WUTE))
  316. /**
  317. * @brief Disable the RTC WakeUp Timer peripheral.
  318. * @param __HANDLE__ specifies the RTC handle.
  319. * @retval None
  320. */
  321. #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_WUTE))
  322. /**
  323. * @brief Enable the RTC WakeUpTimer interrupt.
  324. * @param __HANDLE__ specifies the RTC handle.
  325. * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be enabled.
  326. * This parameter can be:
  327. * @arg RTC_IT_WUT: WakeUpTimer interrupt
  328. * @retval None
  329. */
  330. #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  331. /**
  332. * @brief Disable the RTC WakeUpTimer interrupt.
  333. * @param __HANDLE__ specifies the RTC handle.
  334. * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be disabled.
  335. * This parameter can be:
  336. * @arg RTC_IT_WUT: WakeUpTimer interrupt
  337. * @retval None
  338. */
  339. #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  340. /**
  341. * @brief Check whether the specified RTC WakeUpTimer interrupt has occurred or not.
  342. * @param __HANDLE__ specifies the RTC handle.
  343. * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to check.
  344. * This parameter can be:
  345. * @arg RTC_IT_WUT: WakeUpTimer interrupt
  346. * @retval None
  347. */
  348. #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & (__INTERRUPT__)) != 0u) ? 1u : 0u)
  349. /**
  350. * @brief Check whether the specified RTC Wake Up timer interrupt is enabled or not.
  351. * @param __HANDLE__ specifies the RTC handle.
  352. * @param __INTERRUPT__ specifies the RTC Wake Up timer interrupt sources to check.
  353. * This parameter can be:
  354. * @arg RTC_IT_WUT: WakeUpTimer interrupt
  355. * @retval None
  356. */
  357. #define __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0u) ? 1u : 0u)
  358. /**
  359. * @brief Get the selected RTC WakeUpTimer's flag status.
  360. * @param __HANDLE__ specifies the RTC handle.
  361. * @param __FLAG__ specifies the RTC WakeUpTimer Flag is pending or not.
  362. * This parameter can be:
  363. * @arg RTC_FLAG_WUTF
  364. * @arg RTC_FLAG_WUTWF
  365. * @retval None
  366. */
  367. #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0u) ? 1u : 0u)
  368. /**
  369. * @brief Clear the RTC Wake Up timer's pending flags.
  370. * @param __HANDLE__ specifies the RTC handle.
  371. * @param __FLAG__ specifies the RTC WakeUpTimer Flag to clear.
  372. * This parameter can be:
  373. * @arg RTC_FLAG_WUTF
  374. * @retval None
  375. */
  376. #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  377. /**
  378. * @brief Enable the RTC Tamper1 input detection.
  379. * @param __HANDLE__ specifies the RTC handle.
  380. * @retval None
  381. */
  382. #define __HAL_RTC_TAMPER1_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR |= (RTC_TAMPCR_TAMP1E))
  383. /**
  384. * @brief Disable the RTC Tamper1 input detection.
  385. * @param __HANDLE__ specifies the RTC handle.
  386. * @retval None
  387. */
  388. #define __HAL_RTC_TAMPER1_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR &= ~(RTC_TAMPCR_TAMP1E))
  389. /**
  390. * @brief Enable the RTC Tamper2 input detection.
  391. * @param __HANDLE__ specifies the RTC handle.
  392. * @retval None
  393. */
  394. #define __HAL_RTC_TAMPER2_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR |= (RTC_TAMPCR_TAMP2E))
  395. /**
  396. * @brief Disable the RTC Tamper2 input detection.
  397. * @param __HANDLE__ specifies the RTC handle.
  398. * @retval None
  399. */
  400. #define __HAL_RTC_TAMPER2_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR &= ~(RTC_TAMPCR_TAMP2E))
  401. /**
  402. * @brief Enable the RTC Tamper3 input detection.
  403. * @param __HANDLE__ specifies the RTC handle.
  404. * @retval None
  405. */
  406. #define __HAL_RTC_TAMPER3_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR |= (RTC_TAMPCR_TAMP3E))
  407. /**
  408. * @brief Disable the RTC Tamper3 input detection.
  409. * @param __HANDLE__ specifies the RTC handle.
  410. * @retval None
  411. */
  412. #define __HAL_RTC_TAMPER3_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR &= ~(RTC_TAMPCR_TAMP3E))
  413. /**
  414. * @brief Enable the RTC Tamper interrupt.
  415. * @param __HANDLE__ specifies the RTC handle.
  416. * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be enabled.
  417. * This parameter can be any combination of the following values:
  418. * @arg RTC_IT_TAMP: All tampers interrupts
  419. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  420. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  421. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  422. * @retval None
  423. */
  424. #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->TAMPCR |= (__INTERRUPT__))
  425. /**
  426. * @brief Disable the RTC Tamper interrupt.
  427. * @param __HANDLE__ specifies the RTC handle.
  428. * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be disabled.
  429. * This parameter can be any combination of the following values:
  430. * @arg RTC_IT_TAMP: All tampers interrupts
  431. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  432. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  433. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  434. * @retval None
  435. */
  436. #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->TAMPCR &= ~(__INTERRUPT__))
  437. /**
  438. * @brief Check whether the specified RTC Tamper interrupt has occurred or not.
  439. * @param __HANDLE__ specifies the RTC handle.
  440. * @param __INTERRUPT__ specifies the RTC Tamper interrupt to check.
  441. * This parameter can be:
  442. * @arg RTC_FLAG_TAMP1F: Tamper1 interrupt flag
  443. * @arg RTC_FLAG_TAMP2F: Tamper2 interrupt flag
  444. * @arg RTC_FLAG_TAMP3F: Tamper3 interrupt flag
  445. * @retval Flag status
  446. */
  447. #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & (__INTERRUPT__)) != 0u) ? 1u : 0u)
  448. /**
  449. * @brief Check whether the specified RTC Tamper interrupt is enabled or not.
  450. * @param __HANDLE__ specifies the RTC handle.
  451. * @param __INTERRUPT__ specifies the RTC Tamper interrupt source to check.
  452. * This parameter can be:
  453. * @arg RTC_IT_TAMP: All tampers interrupts
  454. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  455. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  456. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  457. * @retval Flag status
  458. */
  459. #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->TAMPCR) & (__INTERRUPT__)) != 0u) ? 1u : 0u)
  460. /**
  461. * @brief Get the selected RTC Tamper's flag status.
  462. * @param __HANDLE__ specifies the RTC handle.
  463. * @param __FLAG__ specifies the RTC Tamper Flag is pending or not.
  464. * This parameter can be:
  465. * @arg RTC_FLAG_TAMP1F: Tamper1 flag
  466. * @arg RTC_FLAG_TAMP2F: Tamper2 flag
  467. * @arg RTC_FLAG_TAMP3F: Tamper3 flag
  468. * @retval Flag status
  469. */
  470. #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0u) ? 1u : 0u)
  471. /**
  472. * @brief Clear the RTC Tamper's pending flags.
  473. * @param __HANDLE__ specifies the RTC handle.
  474. * @param __FLAG__ specifies the RTC Tamper Flag sources to clear.
  475. * This parameter can be:
  476. * @arg RTC_FLAG_TAMP1F: Tamper1 flag
  477. * @arg RTC_FLAG_TAMP2F: Tamper2 flag
  478. * @arg RTC_FLAG_TAMP3F: Tamper3 flag
  479. * @retval None
  480. */
  481. #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  482. /**
  483. * @brief Enable the RTC TimeStamp peripheral.
  484. * @param __HANDLE__ specifies the RTC handle.
  485. * @retval None
  486. */
  487. #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TSE))
  488. /**
  489. * @brief Disable the RTC TimeStamp peripheral.
  490. * @param __HANDLE__ specifies the RTC handle.
  491. * @retval None
  492. */
  493. #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TSE))
  494. /**
  495. * @brief Enable the RTC TimeStamp interrupt.
  496. * @param __HANDLE__ specifies the RTC handle.
  497. * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be enabled.
  498. * This parameter can be:
  499. * @arg RTC_IT_TS: TimeStamp interrupt
  500. * @retval None
  501. */
  502. #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  503. /**
  504. * @brief Disable the RTC TimeStamp interrupt.
  505. * @param __HANDLE__ specifies the RTC handle.
  506. * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be disabled.
  507. * This parameter can be:
  508. * @arg RTC_IT_TS: TimeStamp interrupt
  509. * @retval None
  510. */
  511. #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  512. /**
  513. * @brief Check whether the specified RTC TimeStamp interrupt has occurred or not.
  514. * @param __HANDLE__ specifies the RTC handle.
  515. * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt source to check.
  516. * This parameter can be:
  517. * @arg RTC_IT_TS: TimeStamp interrupt
  518. * @retval None
  519. */
  520. #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & (__INTERRUPT__)) != 0u) ? 1u : 0u)
  521. /**
  522. * @brief Check whether the specified RTC Time Stamp interrupt is enabled or not.
  523. * @param __HANDLE__ specifies the RTC handle.
  524. * @param __INTERRUPT__ specifies the RTC Time Stamp interrupt source to check.
  525. * This parameter can be:
  526. * @arg RTC_IT_TS: TimeStamp interrupt
  527. * @retval None
  528. */
  529. #define __HAL_RTC_TIMESTAMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0u) ? 1u : 0u)
  530. /**
  531. * @brief Get the selected RTC TimeStamp's flag status.
  532. * @param __HANDLE__ specifies the RTC handle.
  533. * @param __FLAG__ specifies the RTC TimeStamp Flag is pending or not.
  534. * This parameter can be:
  535. * @arg RTC_FLAG_TSF
  536. * @arg RTC_FLAG_TSOVF
  537. * @retval None
  538. */
  539. #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0u) ? 1u : 0u)
  540. /**
  541. * @brief Clear the RTC Time Stamp's pending flags.
  542. * @param __HANDLE__ specifies the RTC handle.
  543. * @param __FLAG__ specifies the RTC Alarm Flag sources to clear.
  544. * This parameter can be:
  545. * @arg RTC_FLAG_TSF
  546. * @arg RTC_FLAG_TSOVF
  547. * @retval None
  548. */
  549. #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  550. /**
  551. * @brief Enable the RTC internal TimeStamp peripheral.
  552. * @param __HANDLE__ specifies the RTC handle.
  553. * @retval None
  554. */
  555. #define __HAL_RTC_INTERNAL_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ITSE))
  556. /**
  557. * @brief Disable the RTC internal TimeStamp peripheral.
  558. * @param __HANDLE__ specifies the RTC handle.
  559. * @retval None
  560. */
  561. #define __HAL_RTC_INTERNAL_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ITSE))
  562. /**
  563. * @brief Get the selected RTC Internal Time Stamp's flag status.
  564. * @param __HANDLE__ specifies the RTC handle.
  565. * @param __FLAG__ specifies the RTC Internal Time Stamp Flag is pending or not.
  566. * This parameter can be:
  567. * @arg RTC_FLAG_ITSF
  568. * @retval None
  569. */
  570. #define __HAL_RTC_INTERNAL_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0u) ? 1u : 0u)
  571. /**
  572. * @brief Clear the RTC Internal Time Stamp's pending flags.
  573. * @param __HANDLE__ specifies the RTC handle.
  574. * @param __FLAG__ specifies the RTC Internal Time Stamp Flag source to clear.
  575. * This parameter can be:
  576. * @arg RTC_FLAG_ITSF
  577. * @retval None
  578. */
  579. #define __HAL_RTC_INTERNAL_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  580. /**
  581. * @brief Enable the RTC calibration output.
  582. * @param __HANDLE__ specifies the RTC handle.
  583. * @retval None
  584. */
  585. #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_COE))
  586. /**
  587. * @brief Disable the calibration output.
  588. * @param __HANDLE__ specifies the RTC handle.
  589. * @retval None
  590. */
  591. #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_COE))
  592. /**
  593. * @brief Enable the clock reference detection.
  594. * @param __HANDLE__ specifies the RTC handle.
  595. * @retval None
  596. */
  597. #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_REFCKON))
  598. /**
  599. * @brief Disable the clock reference detection.
  600. * @param __HANDLE__ specifies the RTC handle.
  601. * @retval None
  602. */
  603. #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_REFCKON))
  604. /**
  605. * @brief Get the selected RTC shift operation's flag status.
  606. * @param __HANDLE__ specifies the RTC handle.
  607. * @param __FLAG__ specifies the RTC shift operation Flag is pending or not.
  608. * This parameter can be:
  609. * @arg RTC_FLAG_SHPF
  610. * @retval None
  611. */
  612. #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0u) ? 1u : 0u)
  613. /**
  614. * @brief Enable interrupt on the RTC WakeUp Timer associated Exti line.
  615. * @retval None
  616. */
  617. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI_D1->IMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  618. /**
  619. * @brief Disable interrupt on the RTC WakeUp Timer associated Exti line.
  620. * @retval None
  621. */
  622. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI_D1->IMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  623. /**
  624. * @brief Enable event on the RTC WakeUp Timer associated Exti line.
  625. * @retval None
  626. */
  627. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI_D1->EMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  628. /**
  629. * @brief Disable event on the RTC WakeUp Timer associated Exti line.
  630. * @retval None
  631. */
  632. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI_D1->EMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  633. /**
  634. * @brief Enable event on the RTC WakeUp Timer associated D3 Exti line.
  635. * @retval None
  636. */
  637. #define __HAL_RTC_WAKEUPTIMER_EXTID3_ENABLE_EVENT() (EXTI->D3PMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  638. /**
  639. * @brief Disable event on the RTC WakeUp Timer associated D3 Exti line.
  640. * @retval None
  641. */
  642. #define __HAL_RTC_WAKEUPTIMER_EXTID3_DISABLE_EVENT() (EXTI->D3PMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  643. #if defined(DUAL_CORE)
  644. /**
  645. * @brief Enable interrupt on the RTC WakeUp Timer associated D2 Exti line.
  646. * @retval None
  647. */
  648. #define __HAL_RTC_WAKEUPTIMER_EXTID2_ENABLE_IT() (EXTI_D2->IMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  649. /**
  650. * @brief Disable interrupt on the RTC WakeUp Timer associated D2 Exti line.
  651. * @retval None
  652. */
  653. #define __HAL_RTC_WAKEUPTIMER_EXTID2_DISABLE_IT() (EXTI_D2->IMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  654. /**
  655. * @brief Enable event on the RTC WakeUp Timer associated D2 Exti line.
  656. * @retval None
  657. */
  658. #define __HAL_RTC_WAKEUPTIMER_EXTID2_ENABLE_EVENT() (EXTI_D2->EMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  659. /**
  660. * @brief Disable event on the RTC WakeUp Timer associated D2 Exti line.
  661. * @retval None
  662. */
  663. #define __HAL_RTC_WAKEUPTIMER_EXTID2_DISABLE_EVENT() (EXTI_D2->EMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  664. #endif /* DUAL_CORE */
  665. /**
  666. * @brief Enable falling edge trigger on the RTC WakeUp Timer associated Exti line.
  667. * @retval None
  668. */
  669. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  670. /**
  671. * @brief Disable falling edge trigger on the RTC WakeUp Timer associated Exti line.
  672. * @retval None
  673. */
  674. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  675. /**
  676. * @brief Enable rising edge trigger on the RTC WakeUp Timer associated Exti line.
  677. * @retval None
  678. */
  679. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  680. /**
  681. * @brief Disable rising edge trigger on the RTC WakeUp Timer associated Exti line.
  682. * @retval None
  683. */
  684. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  685. /**
  686. * @brief Enable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line.
  687. * @retval None
  688. */
  689. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  690. __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE(); \
  691. __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE(); \
  692. } while(0)
  693. /**
  694. * @brief Disable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line.
  695. * This parameter can be:
  696. * @retval None
  697. */
  698. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  699. __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE(); \
  700. __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE(); \
  701. } while(0)
  702. /**
  703. * @brief Check whether the RTC WakeUp Timer associated Exti line interrupt flag is set or not.
  704. * @retval Line Status.
  705. */
  706. #define __HAL_RTC_WAKEUPTIMER_EXTI_GET_FLAG() (EXTI_D1->PR1 & RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  707. /**
  708. * @brief Clear the RTC WakeUp Timer associated Exti line flag.
  709. * @retval None
  710. */
  711. #define __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG() (EXTI_D1->PR1 = RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  712. /**
  713. * @brief Enable interrupt on the RTC Tamper and Timestamp associated Exti line.
  714. * @retval None
  715. */
  716. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT() (EXTI_D1->IMR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  717. /**
  718. * @brief Disable interrupt on the RTC Tamper and Timestamp associated Exti line.
  719. * @retval None
  720. */
  721. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_IT() (EXTI_D1->IMR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  722. /**
  723. * @brief Enable event on the RTC Tamper and Timestamp associated Exti line.
  724. * @retval None
  725. */
  726. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_EVENT() (EXTI_D1->EMR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  727. /**
  728. * @brief Disable event on the RTC Tamper and Timestamp associated Exti line.
  729. * @retval None
  730. */
  731. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_EVENT() (EXTI_D1->EMR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  732. /**
  733. * @brief Check whether the RTC WakeUp Timer associated D3 Exti line interrupt flag is set or not.
  734. * @retval Line Status
  735. */
  736. #define __HAL_RTC_WAKEUPTIMER_EXTID3_GET_FLAG() (EXTI_D3->PR1 & RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  737. /**
  738. * @brief Clear the RTC WakeUp Timer associated D3 Exti line flag.
  739. * @retval None.
  740. */
  741. #define __HAL_RTC_WAKEUPTIMER_EXTID3_CLEAR_FLAG() (EXTI_D3->PR1 = RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  742. /**
  743. * @brief Generate a Software interrupt on the RTC WakeUp Timer associated Exti line.
  744. * @retval None.
  745. */
  746. #define __HAL_RTC_WAKEUPTIMER_EXTI_GENERATE_SWIT() (EXTI->SWIER1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  747. #if defined(DUAL_CORE)
  748. /**
  749. * @brief Check whether the RTC WakeUp Timer associated D2 Exti line interrupt flag is set or not.
  750. * @retval Line Status.
  751. */
  752. #define __HAL_RTC_WAKEUPTIMER_EXTID2_GET_FLAG() (EXTI_D2->PR1 & RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  753. /**
  754. * @brief Clear the RTC WakeUp Timer associated D2 Exti line flag.
  755. * @retval None.
  756. */
  757. #define __HAL_RTC_WAKEUPTIMER_EXTID2_CLEAR_FLAG() (EXTI_D2->PR1 = RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  758. /**
  759. * @brief Enable interrupt on the RTC Tamper and Timestamp associated D2 Exti line.
  760. * @retval None
  761. */
  762. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTID2_ENABLE_IT() (EXTI_D2->IMR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  763. /**
  764. * @brief Disable interrupt on the RTC Tamper and Timestamp associated D2 Exti line.
  765. * @retval None
  766. */
  767. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTID2_DISABLE_IT() (EXTI_D2->IMR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  768. /**
  769. * @brief Enable event on the RTC Tamper and Timestamp associated D2 Exti line.
  770. * @retval None
  771. */
  772. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTID2_ENABLE_EVENT() (EXTI_D2->EMR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  773. /**
  774. * @brief Disable event on the RTC Tamper and Timestamp associated D2 Exti line.
  775. * @retval None
  776. */
  777. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTID2_DISABLE_EVENT() (EXTI_D2->EMR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  778. #endif
  779. /**
  780. * @brief Enable falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  781. * @retval None
  782. */
  783. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  784. /**
  785. * @brief Disable falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  786. * @retval None
  787. */
  788. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  789. /**
  790. * @brief Enable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
  791. * @retval None
  792. */
  793. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  794. /**
  795. * @brief Disable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
  796. * @retval None
  797. */
  798. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  799. /**
  800. * @brief Enable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  801. * @retval None
  802. */
  803. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  804. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE(); \
  805. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE(); \
  806. } while(0)
  807. /**
  808. * @brief Disable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  809. * @retval None
  810. */
  811. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  812. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE(); \
  813. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE(); \
  814. } while(0)
  815. /**
  816. * @brief Check whether the RTC Tamper and Timestamp associated Exti line interrupt flag is set or not.
  817. * @retval Line Status
  818. */
  819. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GET_FLAG() (EXTI_D1->PR1 & RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  820. /**
  821. * @brief Clear the RTC Tamper and Timestamp associated Exti line flag.
  822. * @retval None
  823. */
  824. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_CLEAR_FLAG() (EXTI_D1->PR1 = RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  825. #if defined(DUAL_CORE)
  826. /**
  827. * @brief Check whether the RTC Tamper and Timestamp associated D2 Exti line interrupt flag is set or not.
  828. * @retval Line Status
  829. */
  830. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTID2_GET_FLAG() (EXTI_D2->PR1 & RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  831. /**
  832. * @brief Clear the RTC Tamper and Timestamp associated D2 Exti line flag.
  833. * @retval None
  834. */
  835. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTID2_CLEAR_FLAG() (EXTI_D2->PR1 = RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  836. #endif
  837. /**
  838. * @brief Generate a Software interrupt on the RTC Tamper and Timestamp associated Exti line
  839. * @retval None
  840. */
  841. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GENERATE_SWIT() (EXTI->SWIER1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  842. /**
  843. * @}
  844. */
  845. /* Exported functions --------------------------------------------------------*/
  846. /** @addtogroup RTCEx_Exported_Functions
  847. * @{
  848. */
  849. /* RTC TimeStamp and Tamper functions *****************************************/
  850. /** @addtogroup RTCEx_Exported_Functions_Group1
  851. * @{
  852. */
  853. HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
  854. HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
  855. HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc);
  856. HAL_StatusTypeDef HAL_RTCEx_SetInternalTimeStamp(RTC_HandleTypeDef *hrtc);
  857. HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTimeStamp(RTC_HandleTypeDef *hrtc);
  858. HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format);
  859. HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper);
  860. HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper);
  861. HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper);
  862. void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc);
  863. void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc);
  864. void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc);
  865. void HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc);
  866. void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc);
  867. HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  868. HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  869. HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  870. HAL_StatusTypeDef HAL_RTCEx_PollForTamper3Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  871. /**
  872. * @}
  873. */
  874. /* RTC Wake-up functions ******************************************************/
  875. /** @addtogroup RTCEx_Exported_Functions_Group2
  876. * @{
  877. */
  878. HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
  879. HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
  880. HAL_StatusTypeDef HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc);
  881. uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc);
  882. void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc);
  883. void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc);
  884. HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  885. /**
  886. * @}
  887. */
  888. /* Extended Control functions ************************************************/
  889. /** @addtogroup RTCEx_Exported_Functions_Group3
  890. * @{
  891. */
  892. void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data);
  893. uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister);
  894. HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue);
  895. HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS);
  896. HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput);
  897. HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc);
  898. HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc);
  899. HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc);
  900. HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc);
  901. HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc);
  902. /**
  903. * @}
  904. */
  905. /* Extended RTC features functions *******************************************/
  906. /** @addtogroup RTCEx_Exported_Functions_Group4
  907. * @{
  908. */
  909. void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc);
  910. HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  911. /**
  912. * @}
  913. */
  914. /**
  915. * @}
  916. */
  917. /* Private types -------------------------------------------------------------*/
  918. /* Private variables ---------------------------------------------------------*/
  919. /* Private constants ---------------------------------------------------------*/
  920. /** @defgroup RTCEx_Private_Constants RTCEx Private Constants
  921. * @{
  922. */
  923. #define RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT EXTI_IMR1_IM18 /*!< External interrupt line 18 Connected to the RTC Tamper and Time Stamp events */
  924. #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT EXTI_IMR1_IM19 /*!< External interrupt line 19 Connected to the RTC Wakeup event */
  925. /* Masks Definition */
  926. #define RTC_TAMPCR_TAMPXE (RTC_TAMPCR_TAMP3E | RTC_TAMPCR_TAMP2E | RTC_TAMPCR_TAMP1E)
  927. #define RTC_TAMPCR_TAMPXIE (RTC_TAMPER1_INTERRUPT | RTC_TAMPER2_INTERRUPT | RTC_TAMPER3_INTERRUPT | RTC_ALL_TAMPER_INTERRUPT)
  928. /**
  929. * @}
  930. */
  931. /* Private macros ------------------------------------------------------------*/
  932. /** @defgroup RTCEx_Private_Macros RTCEx Private Macros
  933. * @{
  934. */
  935. /** @defgroup RTCEx_IS_RTC_Definitions Private macros to check input parameters
  936. * @{
  937. */
  938. #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
  939. ((OUTPUT) == RTC_OUTPUT_ALARMA) || \
  940. ((OUTPUT) == RTC_OUTPUT_ALARMB) || \
  941. ((OUTPUT) == RTC_OUTPUT_WAKEUP))
  942. #define IS_RTC_BKP(BKP) ((BKP) < RTC_BKP_NUMBER)
  943. #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \
  944. ((EDGE) == RTC_TIMESTAMPEDGE_FALLING))
  945. #define IS_RTC_TAMPER(__TAMPER__) ((((__TAMPER__) & (0xFFFFFFFFu ^ RTC_TAMPCR_TAMPXE)) == 0x00u) && ((__TAMPER__) != 0u))
  946. #define IS_RTC_TAMPER_INTERRUPT(__INTERRUPT__) ((((__INTERRUPT__) & (0xFFFFFFFFu ^ RTC_TAMPCR_TAMPXIE)) == 0x00u) && ((__INTERRUPT__) != 0u))
  947. #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TIMESTAMPPIN_DEFAULT))
  948. #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) || \
  949. ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \
  950. ((TRIGGER) == RTC_TAMPERTRIGGER_LOWLEVEL) || \
  951. ((TRIGGER) == RTC_TAMPERTRIGGER_HIGHLEVEL))
  952. #define IS_RTC_TAMPER_ERASE_MODE(MODE) (((MODE) == RTC_TAMPER_ERASE_BACKUP_ENABLE) || \
  953. ((MODE) == RTC_TAMPER_ERASE_BACKUP_DISABLE))
  954. #define IS_RTC_TAMPER_MASKFLAG_STATE(STATE) (((STATE) == RTC_TAMPERMASK_FLAG_ENABLE) || \
  955. ((STATE) == RTC_TAMPERMASK_FLAG_DISABLE))
  956. #define IS_RTC_TAMPER_FILTER(FILTER) (((FILTER) == RTC_TAMPERFILTER_DISABLE) || \
  957. ((FILTER) == RTC_TAMPERFILTER_2SAMPLE) || \
  958. ((FILTER) == RTC_TAMPERFILTER_4SAMPLE) || \
  959. ((FILTER) == RTC_TAMPERFILTER_8SAMPLE))
  960. #define IS_RTC_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \
  961. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \
  962. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \
  963. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \
  964. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \
  965. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \
  966. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512) || \
  967. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256))
  968. #define IS_RTC_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \
  969. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \
  970. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \
  971. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK))
  972. #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \
  973. ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE))
  974. #define IS_RTC_TAMPER_PULLUP_STATE(STATE) (((STATE) == RTC_TAMPER_PULLUP_ENABLE) || \
  975. ((STATE) == RTC_TAMPER_PULLUP_DISABLE))
  976. #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16) || \
  977. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8) || \
  978. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4) || \
  979. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2) || \
  980. ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \
  981. ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS))
  982. #define IS_RTC_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= RTC_WUTR_WUT)
  983. #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \
  984. ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \
  985. ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC))
  986. #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \
  987. ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET))
  988. #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= RTC_CALR_CALM)
  989. #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \
  990. ((SEL) == RTC_SHIFTADD1S_SET))
  991. #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= RTC_SHIFTR_SUBFS)
  992. #define IS_RTC_CALIB_OUTPUT(OUTPUT) (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \
  993. ((OUTPUT) == RTC_CALIBOUTPUT_1HZ))
  994. #define IS_RTC_TAMPER_FILTER_CONFIG_CORRECT(FILTER, TRIGGER) \
  995. ( ( ((FILTER) != RTC_TAMPERFILTER_DISABLE) \
  996. && ( ((TRIGGER) == RTC_TAMPERTRIGGER_LOWLEVEL) \
  997. || ((TRIGGER) == RTC_TAMPERTRIGGER_HIGHLEVEL))) \
  998. || ( ((FILTER) == RTC_TAMPERFILTER_DISABLE) \
  999. && ( ((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) \
  1000. || ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE))))
  1001. /**
  1002. * @}
  1003. */
  1004. /**
  1005. * @}
  1006. */
  1007. /**
  1008. * @}
  1009. */
  1010. /**
  1011. * @}
  1012. */
  1013. #ifdef __cplusplus
  1014. }
  1015. #endif /* __cplusplus */
  1016. #endif /* STM32H7xx_HAL_RTC_EX_H */
  1017. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/