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.
 
 
 

1496 lines
62 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32wbxx_hal_rtc_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of RTC HAL Extended module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2019 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 STM32WBxx_HAL_RTC_EX_H
  21. #define STM32WBxx_HAL_RTC_EX_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32wbxx_hal_def.h"
  27. /** @addtogroup STM32WBxx_HAL_Driver
  28. * @{
  29. */
  30. /** @defgroup RTCEx 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 RTCEx Output Selection Definition
  71. * @{
  72. */
  73. #define RTC_OUTPUT_DISABLE ((uint32_t)0x00000000U)
  74. #define RTC_OUTPUT_ALARMA ((uint32_t)RTC_CR_OSEL_0)
  75. #define RTC_OUTPUT_ALARMB ((uint32_t)RTC_CR_OSEL_1)
  76. #define RTC_OUTPUT_WAKEUP ((uint32_t)RTC_CR_OSEL)
  77. /**
  78. * @}
  79. */
  80. /** @defgroup RTCEx_Backup_Registers_Definitions RTCEx Backup Registers Definition
  81. * @{
  82. */
  83. #define RTC_BKP_DR0 ((uint32_t)0x00000000U)
  84. #define RTC_BKP_DR1 ((uint32_t)0x00000001U)
  85. #define RTC_BKP_DR2 ((uint32_t)0x00000002U)
  86. #define RTC_BKP_DR3 ((uint32_t)0x00000003U)
  87. #define RTC_BKP_DR4 ((uint32_t)0x00000004U)
  88. #define RTC_BKP_DR5 ((uint32_t)0x00000005U)
  89. #define RTC_BKP_DR6 ((uint32_t)0x00000006U)
  90. #define RTC_BKP_DR7 ((uint32_t)0x00000007U)
  91. #define RTC_BKP_DR8 ((uint32_t)0x00000008U)
  92. #define RTC_BKP_DR9 ((uint32_t)0x00000009U)
  93. #define RTC_BKP_DR10 ((uint32_t)0x0000000AU)
  94. #define RTC_BKP_DR11 ((uint32_t)0x0000000BU)
  95. #define RTC_BKP_DR12 ((uint32_t)0x0000000CU)
  96. #define RTC_BKP_DR13 ((uint32_t)0x0000000DU)
  97. #define RTC_BKP_DR14 ((uint32_t)0x0000000EU)
  98. #define RTC_BKP_DR15 ((uint32_t)0x0000000FU)
  99. #define RTC_BKP_DR16 ((uint32_t)0x00000010U)
  100. #define RTC_BKP_DR17 ((uint32_t)0x00000011U)
  101. #define RTC_BKP_DR18 ((uint32_t)0x00000012U)
  102. #define RTC_BKP_DR19 ((uint32_t)0x00000013U)
  103. /**
  104. * @}
  105. */
  106. /** @defgroup RTCEx_Time_Stamp_Edges_definitions RTCEx Time Stamp Edges definition
  107. * @{
  108. */
  109. #define RTC_TIMESTAMPEDGE_RISING ((uint32_t)0x00000000U)
  110. #define RTC_TIMESTAMPEDGE_FALLING RTC_CR_TSEDGE
  111. /**
  112. * @}
  113. */
  114. /** @defgroup RTCEx_TimeStamp_Pin_Selections RTCEx TimeStamp Pin Selection
  115. * @{
  116. */
  117. #define RTC_TIMESTAMPPIN_DEFAULT ((uint32_t)0x00000000U)
  118. /**
  119. * @}
  120. */
  121. /** @defgroup RTCEx_Tamper_Pins_Definitions RTCEx Tamper Pins Definition
  122. * @{
  123. */
  124. #if defined(RTC_TAMPER1_SUPPORT)
  125. #define RTC_TAMPER_1 RTC_TAMPCR_TAMP1E
  126. #endif /* RTC_TAMPER1_SUPPORT */
  127. #define RTC_TAMPER_2 RTC_TAMPCR_TAMP2E
  128. #if defined(RTC_TAMPER3_SUPPORT)
  129. #define RTC_TAMPER_3 RTC_TAMPCR_TAMP3E
  130. #endif /* RTC_TAMPER3_SUPPORT */
  131. /**
  132. * @}
  133. */
  134. /** @defgroup RTCEx_Tamper_Interrupt_Definitions RTCEx Tamper Interrupt Definitions
  135. * @{
  136. */
  137. #if defined(RTC_TAMPER1_SUPPORT)
  138. #define RTC_TAMPER1_INTERRUPT RTC_TAMPCR_TAMP1IE
  139. #endif /* RTC_TAMPER1_SUPPORT */
  140. #define RTC_TAMPER2_INTERRUPT RTC_TAMPCR_TAMP2IE
  141. #if defined(RTC_TAMPER3_SUPPORT)
  142. #define RTC_TAMPER3_INTERRUPT RTC_TAMPCR_TAMP3IE
  143. #endif /* RTC_TAMPER3_SUPPORT */
  144. #define RTC_ALL_TAMPER_INTERRUPT RTC_TAMPCR_TAMPIE
  145. /**
  146. * @}
  147. */
  148. /** @defgroup RTCEx_Tamper_Trigger_Definitions RTCEx Tamper Trigger Definitions
  149. * @{
  150. */
  151. #define RTC_TAMPERTRIGGER_RISINGEDGE ((uint32_t)0x00000000U)
  152. #define RTC_TAMPERTRIGGER_FALLINGEDGE ((uint32_t)0x00000002U)
  153. #define RTC_TAMPERTRIGGER_LOWLEVEL RTC_TAMPERTRIGGER_RISINGEDGE
  154. #define RTC_TAMPERTRIGGER_HIGHLEVEL RTC_TAMPERTRIGGER_FALLINGEDGE
  155. /**
  156. * @}
  157. */
  158. /** @defgroup RTCEx_Tamper_EraseBackUp_Definitions RTCEx Tamper EraseBackUp Definitions
  159. * @{
  160. */
  161. #define RTC_TAMPER_ERASE_BACKUP_ENABLE ((uint32_t)0x00000000U)
  162. #define RTC_TAMPER_ERASE_BACKUP_DISABLE ((uint32_t)0x00020000U)
  163. /**
  164. * @}
  165. */
  166. /** @defgroup RTCEx_Tamper_MaskFlag_Definitions RTCEx Tamper MaskFlag Definitions
  167. * @{
  168. */
  169. #define RTC_TAMPERMASK_FLAG_DISABLE ((uint32_t)0x00000000U)
  170. #define RTC_TAMPERMASK_FLAG_ENABLE ((uint32_t)0x00040000U)
  171. /**
  172. * @}
  173. */
  174. /** @defgroup RTCEx_Tamper_Filter_Definitions RTCEx Tamper Filter Definitions
  175. * @{
  176. */
  177. #define RTC_TAMPERFILTER_DISABLE ((uint32_t)0x00000000U) /*!< Tamper filter is disabled */
  178. #define RTC_TAMPERFILTER_2SAMPLE RTC_TAMPCR_TAMPFLT_0 /*!< Tamper is activated after 2
  179. consecutive samples at the active level */
  180. #define RTC_TAMPERFILTER_4SAMPLE RTC_TAMPCR_TAMPFLT_1 /*!< Tamper is activated after 4
  181. consecutive samples at the active level */
  182. #define RTC_TAMPERFILTER_8SAMPLE RTC_TAMPCR_TAMPFLT /*!< Tamper is activated after 8
  183. consecutive samples at the active leve. */
  184. /**
  185. * @}
  186. */
  187. /** @defgroup RTCEx_Tamper_Sampling_Frequencies_Definitions RTCEx Tamper Sampling Frequencies Definitions
  188. * @{
  189. */
  190. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768 ((uint32_t)0x00000000U) /*!< Each of the tamper inputs are sampled
  191. with a frequency = RTCCLK / 32768 */
  192. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384 RTC_TAMPCR_TAMPFREQ_0 /*!< Each of the tamper inputs are sampled
  193. with a frequency = RTCCLK / 16384 */
  194. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192 RTC_TAMPCR_TAMPFREQ_1 /*!< Each of the tamper inputs are sampled
  195. with a frequency = RTCCLK / 8192 */
  196. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096 ((uint32_t) (RTC_TAMPCR_TAMPFREQ_0 | RTC_TAMPCR_TAMPFREQ_1)) /*!< Each of the tamper inputs are sampled
  197. with a frequency = RTCCLK / 4096 */
  198. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048 RTC_TAMPCR_TAMPFREQ_2 /*!< Each of the tamper inputs are sampled
  199. with a frequency = RTCCLK / 2048 */
  200. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024 ((uint32_t) (RTC_TAMPCR_TAMPFREQ_0 | RTC_TAMPCR_TAMPFREQ_2)) /*!< Each of the tamper inputs are sampled
  201. with a frequency = RTCCLK / 1024 */
  202. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512 ((uint32_t) (RTC_TAMPCR_TAMPFREQ_1 | RTC_TAMPCR_TAMPFREQ_2)) /*!< Each of the tamper inputs are sampled
  203. with a frequency = RTCCLK / 512 */
  204. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256 ((uint32_t) (RTC_TAMPCR_TAMPFREQ_0 | RTC_TAMPCR_TAMPFREQ_1 | \
  205. RTC_TAMPCR_TAMPFREQ_2)) /*!< Each of the tamper inputs are sampled
  206. with a frequency = RTCCLK / 256 */
  207. /**
  208. * @}
  209. */
  210. /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration_Definitions RTCEx Tamper Pin Precharge Duration Definitions
  211. * @{
  212. */
  213. #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK ((uint32_t)0x00000000U) /*!< Tamper pins are pre-charged before
  214. sampling during 1 RTCCLK cycle */
  215. #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK RTC_TAMPCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before
  216. sampling during 2 RTCCLK cycles */
  217. #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK RTC_TAMPCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before
  218. sampling during 4 RTCCLK cycles */
  219. #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK ((uint32_t)(RTC_TAMPCR_TAMPPRCH_0 | RTC_TAMPCR_TAMPPRCH_1)) /*!< Tamper pins are pre-charged before
  220. sampling during 8 RTCCLK cycles */
  221. /**
  222. * @}
  223. */
  224. /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection_Definitions RTCEx Tamper TimeStampOnTamperDetection Definitions
  225. * @{
  226. */
  227. #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE RTC_TAMPCR_TAMPTS /*!< TimeStamp on Tamper Detection event saved */
  228. #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE ((uint32_t)0x00000000U) /*!< TimeStamp on Tamper Detection event is not saved */
  229. /**
  230. * @}
  231. */
  232. /** @defgroup RTCEx_Tamper_Pull_UP_Definitions RTCEx Tamper Pull UP Definitions
  233. * @{
  234. */
  235. #define RTC_TAMPER_PULLUP_ENABLE ((uint32_t)0x00000000U) /*!< Tamper pins are pre-charged before sampling */
  236. #define RTC_TAMPER_PULLUP_DISABLE RTC_TAMPCR_TAMPPUDIS /*!< Tamper pins pre-charge is disabled */
  237. /**
  238. * @}
  239. */
  240. /** @defgroup RTCEx_Wakeup_Timer_Definitions RTCEx Wakeup Timer Definitions
  241. * @{
  242. */
  243. #define RTC_WAKEUPCLOCK_RTCCLK_DIV16 ((uint32_t)0x00000000U)
  244. #define RTC_WAKEUPCLOCK_RTCCLK_DIV8 RTC_CR_WUCKSEL_0
  245. #define RTC_WAKEUPCLOCK_RTCCLK_DIV4 RTC_CR_WUCKSEL_1
  246. #define RTC_WAKEUPCLOCK_RTCCLK_DIV2 ((uint32_t) (RTC_CR_WUCKSEL_0 | RTC_CR_WUCKSEL_1))
  247. #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS RTC_CR_WUCKSEL_2
  248. #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS ((uint32_t) (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_2))
  249. /**
  250. * @}
  251. */
  252. /** @defgroup RTCEx_Smooth_calib_period_Definitions RTCEx Smooth calib period Definitions
  253. * @{
  254. */
  255. #define RTC_SMOOTHCALIB_PERIOD_32SEC ((uint32_t)0x00000000U) /*!< If RTCCLK = 32768 Hz, Smooth calibation
  256. period is 32s, else 2exp20 RTCCLK pulses */
  257. #define RTC_SMOOTHCALIB_PERIOD_16SEC RTC_CALR_CALW16 /*!< If RTCCLK = 32768 Hz, Smooth calibation
  258. period is 16s, else 2exp19 RTCCLK pulses */
  259. #define RTC_SMOOTHCALIB_PERIOD_8SEC RTC_CALR_CALW8 /*!< If RTCCLK = 32768 Hz, Smooth calibation
  260. period is 8s, else 2exp18 RTCCLK pulses */
  261. /**
  262. * @}
  263. */
  264. /** @defgroup RTCEx_Smooth_calib_Plus_pulses_Definitions RTCEx Smooth calib Plus pulses Definitions
  265. * @{
  266. */
  267. #define RTC_SMOOTHCALIB_PLUSPULSES_SET RTC_CALR_CALP /*!< The number of RTCCLK pulses added
  268. during a X -second window = Y - CALM[8:0]
  269. with Y = 512, 256, 128 when X = 32, 16, 8 */
  270. #define RTC_SMOOTHCALIB_PLUSPULSES_RESET ((uint32_t)0x00000000U) /*!< The number of RTCCLK pulses subbstited
  271. during a 32-second window = CALM[8:0] */
  272. /**
  273. * @}
  274. */
  275. /** @defgroup RTCEx_Calib_Output_selection_Definitions RTCEx Calib Output selection Definitions
  276. * @{
  277. */
  278. #define RTC_CALIBOUTPUT_512HZ ((uint32_t)0x00000000U)
  279. #define RTC_CALIBOUTPUT_1HZ RTC_CR_COSEL
  280. /**
  281. * @}
  282. */
  283. /** @defgroup RTCEx_Add_1_Second_Parameter_Definition RTCEx Add 1 Second Parameter Definitions
  284. * @{
  285. */
  286. #define RTC_SHIFTADD1S_RESET ((uint32_t)0x00000000U)
  287. #define RTC_SHIFTADD1S_SET RTC_SHIFTR_ADD1S
  288. /**
  289. * @}
  290. */
  291. /** @defgroup RTCEx_Interrupts_Definitions RTCEx Interrupts Definitions
  292. * @{
  293. */
  294. #if defined(RTC_TAMPER3_SUPPORT)
  295. #define RTC_IT_TAMP3 ((uint32_t)RTC_TAMPCR_TAMP3IE) /*!< Enable Tamper 3 Interrupt */
  296. #endif
  297. /**
  298. * @}
  299. */
  300. /** @defgroup RTCEx_Flags_Definitions RTCEx Flags Definitions
  301. * @{
  302. */
  303. #if defined(RTC_TAMPER3_SUPPORT)
  304. #define RTC_FLAG_TAMP3F ((uint32_t)RTC_ISR_TAMP3F)
  305. #endif
  306. /**
  307. * @}
  308. */
  309. /**
  310. * @}
  311. */
  312. /* Exported macros -----------------------------------------------------------*/
  313. /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros
  314. * @{
  315. */
  316. /* ---------------------------------WAKEUPTIMER---------------------------------*/
  317. /** @defgroup RTCEx_WakeUp_Timer RTC WakeUp Timer
  318. * @{
  319. */
  320. /**
  321. * @brief Enable the RTC WakeUp Timer peripheral.
  322. * @param __HANDLE__ specifies the RTC handle.
  323. * @retval None
  324. */
  325. #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_WUTE))
  326. /**
  327. * @brief Disable the RTC WakeUp Timer peripheral.
  328. * @param __HANDLE__ specifies the RTC handle.
  329. * @retval None
  330. */
  331. #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_WUTE))
  332. /**
  333. * @brief Enable the RTC WakeUpTimer interrupt.
  334. * @param __HANDLE__ specifies the RTC handle.
  335. * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be enabled.
  336. * This parameter can be:
  337. * @arg RTC_IT_WUT: WakeUpTimer interrupt
  338. * @retval None
  339. */
  340. #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  341. /**
  342. * @brief Disable the RTC WakeUpTimer interrupt.
  343. * @param __HANDLE__ specifies the RTC handle.
  344. * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be disabled.
  345. * This parameter can be:
  346. * @arg RTC_IT_WUT: WakeUpTimer interrupt
  347. * @retval None
  348. */
  349. #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  350. /**
  351. * @brief Check whether the specified RTC WakeUpTimer interrupt has occurred or not.
  352. * @param __HANDLE__ specifies the RTC handle.
  353. * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt to check.
  354. * This parameter can be:
  355. * @arg RTC_IT_WUT: WakeUpTimer interrupt
  356. * @retval None
  357. */
  358. #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 4U)) != 0U) ? 1U : 0U)
  359. /**
  360. * @brief Check whether the specified RTC Wake Up timer interrupt has been enabled or not.
  361. * @param __HANDLE__ specifies the RTC handle.
  362. * @param __INTERRUPT__ specifies the RTC Wake Up timer interrupt sources to check.
  363. * This parameter can be:
  364. * @arg RTC_IT_WUT: WakeUpTimer interrupt
  365. * @retval None
  366. */
  367. #define __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
  368. /**
  369. * @brief Get the selected RTC WakeUpTimer's flag status.
  370. * @param __HANDLE__ specifies the RTC handle.
  371. * @param __FLAG__ specifies the RTC WakeUpTimer Flag is pending or not.
  372. * This parameter can be:
  373. * @arg RTC_FLAG_WUTF
  374. * @arg RTC_FLAG_WUTWF
  375. * @retval None
  376. */
  377. #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
  378. /**
  379. * @brief Clear the RTC Wake Up timer's pending flags.
  380. * @param __HANDLE__ specifies the RTC handle.
  381. * @param __FLAG__ specifies the RTC WakeUpTimer Flag to clear.
  382. * This parameter can be:
  383. * @arg RTC_FLAG_WUTF
  384. * @retval None
  385. */
  386. #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  387. /**
  388. * @brief Enable interrupt on the RTC WakeUp Timer associated Exti line of core 1.
  389. * @retval None
  390. */
  391. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  392. /**
  393. * @brief Disable interrupt on the RTC WakeUp Timer associated Exti line of core 1.
  394. * @retval None
  395. */
  396. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  397. /**
  398. * @brief Enable interrupt on the RTC WakeUp Timer associated Exti line of core 2.
  399. * @retval None
  400. */
  401. #define __HAL_RTC_WAKEUPTIMER_EXTIC2_ENABLE_IT() (EXTI->C2IMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  402. /**
  403. * @brief Disable interrupt on the RTC WakeUp Timer associated Exti line of core 2.
  404. * @retval None
  405. */
  406. #define __HAL_RTC_WAKEUPTIMER_EXTIC2_DISABLE_IT() (EXTI->C2IMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  407. /**
  408. * @brief Enable event on the RTC WakeUp Timer associated Exti line of core 1.
  409. * @retval None.
  410. */
  411. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  412. /**
  413. * @brief Enable event on the RTC WakeUp Timer associated Exti line of core 2.
  414. * @retval None.
  415. */
  416. #define __HAL_RTC_WAKEUPTIMER_EXTIC2_ENABLE_EVENT() (EXTI->C2EMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  417. /**
  418. * @brief Disable event on the RTC WakeUp Timer associated Exti line of core 1.
  419. * @retval None.
  420. */
  421. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  422. /**
  423. * @brief Disable event on the RTC WakeUp Timer associated Exti line of core 2.
  424. * @retval None.
  425. */
  426. #define __HAL_RTC_WAKEUPTIMER_EXTIC2_DISABLE_EVENT() (EXTI->C2EMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  427. /*---------------*/
  428. /**
  429. * @brief Enable falling edge trigger on the RTC WakeUp Timer associated Exti line.
  430. * @retval None.
  431. */
  432. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  433. /**
  434. * @brief Disable falling edge trigger on the RTC WakeUp Timer associated Exti line.
  435. * @retval None.
  436. */
  437. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  438. /**
  439. * @brief Enable rising edge trigger on the RTC WakeUp Timer associated Exti line.
  440. * @retval None.
  441. */
  442. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  443. /**
  444. * @brief Disable rising edge trigger on the RTC WakeUp Timer associated Exti line.
  445. * @retval None.
  446. */
  447. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  448. /**
  449. * @brief Enable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line.
  450. * @retval None
  451. */
  452. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  453. __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE(); \
  454. __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE(); \
  455. } while(0U)
  456. /**
  457. * @brief Disable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line.
  458. * This parameter can be:
  459. * @retval None
  460. */
  461. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  462. __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE(); \
  463. __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE(); \
  464. } while(0U)
  465. /**
  466. * @brief Check whether the RTC WakeUp Timer associated Exti line interrupt flag is set or not of core 1.
  467. * @retval Line Status.
  468. */
  469. #define __HAL_RTC_WAKEUPTIMER_EXTI_GET_FLAG() (EXTI->PR1 & RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  470. /**
  471. * @brief Check whether the RTC WakeUp Timer associated Exti line interrupt flag is set or not of core 2.
  472. * @retval Line Status.
  473. */
  474. #define __HAL_RTC_WAKEUPTIMER_EXTIC2_GET_FLAG() (EXTI->PR1 & RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  475. /**
  476. * @brief Clear the RTC WakeUp Timer associated Exti line flag of core 1.
  477. * @retval None.
  478. */
  479. #define __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG() (EXTI->PR1 = RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  480. /**
  481. * @brief Clear the RTC WakeUp Timer associated Exti line flag of core 2.
  482. * @retval None.
  483. */
  484. #define __HAL_RTC_WAKEUPTIMER_EXTIC2_CLEAR_FLAG() (EXTI->PR1 = RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  485. /*---------------*/
  486. /**
  487. * @brief Generate a Software interrupt on the RTC WakeUp Timer associated Exti line.
  488. * @retval None.
  489. */
  490. #define __HAL_RTC_WAKEUPTIMER_EXTI_GENERATE_SWIT() (EXTI->SWIER1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  491. /*---------------*/
  492. /**
  493. * @}
  494. */
  495. /* ---------------------------------TIMESTAMP---------------------------------*/
  496. /** @defgroup RTCEx_Timestamp RTC Timestamp
  497. * @{
  498. */
  499. /**
  500. * @brief Enable the RTC TimeStamp peripheral.
  501. * @param __HANDLE__ specifies the RTC handle.
  502. * @retval None
  503. */
  504. #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TSE))
  505. /**
  506. * @brief Disable the RTC TimeStamp peripheral.
  507. * @param __HANDLE__ specifies the RTC handle.
  508. * @retval None
  509. */
  510. #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TSE))
  511. /**
  512. * @brief Enable the RTC TimeStamp interrupt.
  513. * @param __HANDLE__ specifies the RTC handle.
  514. * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be enabled.
  515. * This parameter can be:
  516. * @arg RTC_IT_TS: TimeStamp interrupt
  517. * @retval None
  518. */
  519. #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  520. /**
  521. * @brief Disable the RTC TimeStamp interrupt.
  522. * @param __HANDLE__ specifies the RTC handle.
  523. * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be disabled.
  524. * This parameter can be:
  525. * @arg RTC_IT_TS: TimeStamp interrupt
  526. * @retval None
  527. */
  528. #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  529. /**
  530. * @brief Check whether the specified RTC TimeStamp interrupt has occurred or not.
  531. * @param __HANDLE__ specifies the RTC handle.
  532. * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt to check.
  533. * This parameter can be:
  534. * @arg RTC_IT_TS: TimeStamp interrupt
  535. * @retval None
  536. */
  537. #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 4U)) != 0U) ? 1U : 0U)
  538. /**
  539. * @brief Check whether the specified RTC Time Stamp interrupt has been enabled or not.
  540. * @param __HANDLE__ specifies the RTC handle.
  541. * @param __INTERRUPT__ specifies the RTC Time Stamp interrupt source to check.
  542. * This parameter can be:
  543. * @arg RTC_IT_TS: TimeStamp interrupt
  544. * @retval None
  545. */
  546. #define __HAL_RTC_TIMESTAMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
  547. /**
  548. * @brief Get the selected RTC TimeStamp's flag status.
  549. * @param __HANDLE__ specifies the RTC handle.
  550. * @param __FLAG__ specifies the RTC TimeStamp Flag is pending or not.
  551. * This parameter can be:
  552. * @arg RTC_FLAG_TSF
  553. * @arg RTC_FLAG_TSOVF
  554. * @retval None
  555. */
  556. #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
  557. /**
  558. * @brief Clear the RTC Time Stamp's pending flags.
  559. * @param __HANDLE__ specifies the RTC handle.
  560. * @param __FLAG__ specifies the RTC TimeStamp Flag to clear.
  561. * This parameter can be:
  562. * @arg RTC_FLAG_TSF
  563. * @arg RTC_FLAG_TSOVF
  564. * @retval None
  565. */
  566. #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  567. /**
  568. * @}
  569. */
  570. /* ---------------------------------TAMPER------------------------------------*/
  571. /** @defgroup RTCEx_Tamper RTC Tamper
  572. * @{
  573. */
  574. #if defined(RTC_TAMPER1_SUPPORT)
  575. /**
  576. * @brief Enable the RTC Tamper1 input detection.
  577. * @param __HANDLE__ specifies the RTC handle.
  578. * @retval None
  579. */
  580. #define __HAL_RTC_TAMPER1_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR |= (RTC_TAMPCR_TAMP1E))
  581. /**
  582. * @brief Disable the RTC Tamper1 input detection.
  583. * @param __HANDLE__ specifies the RTC handle.
  584. * @retval None
  585. */
  586. #define __HAL_RTC_TAMPER1_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR &= ~(RTC_TAMPCR_TAMP1E))
  587. #endif /* RTC_TAMPER1_SUPPORT */
  588. /**
  589. * @brief Enable the RTC Tamper2 input detection.
  590. * @param __HANDLE__ specifies the RTC handle.
  591. * @retval None
  592. */
  593. #define __HAL_RTC_TAMPER2_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR |= (RTC_TAMPCR_TAMP2E))
  594. /**
  595. * @brief Disable the RTC Tamper2 input detection.
  596. * @param __HANDLE__ specifies the RTC handle.
  597. * @retval None
  598. */
  599. #define __HAL_RTC_TAMPER2_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR &= ~(RTC_TAMPCR_TAMP2E))
  600. #if defined(RTC_TAMPER3_SUPPORT)
  601. /**
  602. * @brief Enable the RTC Tamper3 input detection.
  603. * @param __HANDLE__ specifies the RTC handle.
  604. * @retval None
  605. */
  606. #define __HAL_RTC_TAMPER3_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR |= (RTC_TAMPCR_TAMP3E))
  607. /**
  608. * @brief Disable the RTC Tamper3 input detection.
  609. * @param __HANDLE__ specifies the RTC handle.
  610. * @retval None
  611. */
  612. #define __HAL_RTC_TAMPER3_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR &= ~(RTC_TAMPCR_TAMP3E))
  613. #endif /* RTC_TAMPER3_SUPPORT */
  614. /**************************************************************************************************/
  615. #if defined(RTC_TAMPER1_SUPPORT) && defined(RTC_TAMPER3_SUPPORT)
  616. /**
  617. * @brief Enable the RTC Tamper interrupt.
  618. * @param __HANDLE__ specifies the RTC handle.
  619. * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be enabled.
  620. * This parameter can be any combination of the following values:
  621. * @arg RTC_IT_TAMP: All tampers interrupts
  622. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  623. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  624. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  625. * @retval None
  626. */
  627. #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->TAMPCR |= (__INTERRUPT__))
  628. /**
  629. * @brief Disable the RTC Tamper interrupt.
  630. * @param __HANDLE__ specifies the RTC handle.
  631. * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be disabled.
  632. * This parameter can be any combination of the following values:
  633. * @arg RTC_IT_TAMP: All tampers interrupts
  634. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  635. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  636. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  637. * @retval None
  638. */
  639. #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->TAMPCR &= ~(__INTERRUPT__))
  640. #elif defined(RTC_TAMPER1_SUPPORT)
  641. /**
  642. * @brief Enable the RTC Tamper interrupt.
  643. * @param __HANDLE__ specifies the RTC handle.
  644. * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be enabled.
  645. * This parameter can be any combination of the following values:
  646. * @arg RTC_IT_TAMP: All tampers interrupts
  647. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  648. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  649. * @retval None
  650. */
  651. #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->TAMPCR |= (__INTERRUPT__))
  652. /**
  653. * @brief Disable the RTC Tamper interrupt.
  654. * @param __HANDLE__ specifies the RTC handle.
  655. * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be disabled.
  656. * This parameter can be any combination of the following values:
  657. * @arg RTC_IT_TAMP: All tampers interrupts
  658. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  659. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  660. * @retval None
  661. */
  662. #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->TAMPCR &= ~(__INTERRUPT__))
  663. #elif defined(RTC_TAMPER3_SUPPORT)
  664. /**
  665. * @brief Enable the RTC Tamper interrupt.
  666. * @param __HANDLE__ specifies the RTC handle.
  667. * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be enabled.
  668. * This parameter can be any combination of the following values:
  669. * @arg RTC_IT_TAMP: All tampers interrupts
  670. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  671. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  672. * @retval None
  673. */
  674. #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->TAMPCR |= (__INTERRUPT__))
  675. /**
  676. * @brief Disable the RTC Tamper interrupt.
  677. * @param __HANDLE__ specifies the RTC handle.
  678. * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be disabled.
  679. * This parameter can be any combination of the following values:
  680. * @arg RTC_IT_TAMP: All tampers interrupts
  681. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  682. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  683. * @retval None
  684. */
  685. #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->TAMPCR &= ~(__INTERRUPT__))
  686. #endif
  687. /**************************************************************************************************/
  688. #if defined(RTC_TAMPER1_SUPPORT) && defined(RTC_TAMPER3_SUPPORT)
  689. /**
  690. * @brief Check whether the specified RTC Tamper interrupt has occurred or not.
  691. * @param __HANDLE__ specifies the RTC handle.
  692. * @param __INTERRUPT__ specifies the RTC Tamper interrupt to check.
  693. * This parameter can be:
  694. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  695. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  696. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  697. * @retval None
  698. */
  699. #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) == RTC_IT_TAMP1) ? (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 3U)) != 0U) ? 1U : 0U) : \
  700. ((__INTERRUPT__) == RTC_IT_TAMP2) ? (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 5U)) != 0U) ? 1U : 0U) : \
  701. ((__INTERRUPT__) == RTC_IT_TAMP3) ? (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 7U)) != 0U) ? 1U : 0U))
  702. #elif defined(RTC_TAMPER1_SUPPORT)
  703. /**
  704. * @brief Check whether the specified RTC Tamper interrupt has occurred or not.
  705. * @param __HANDLE__ specifies the RTC handle.
  706. * @param __INTERRUPT__ specifies the RTC Tamper interrupt to check.
  707. * This parameter can be:
  708. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  709. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  710. * @retval None
  711. */
  712. #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) == RTC_IT_TAMP1) ? (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 3U)) != 0U) ? 1U : 0U) : \
  713. ((__INTERRUPT__) == RTC_IT_TAMP2) ? (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 5U)) != 0U) ? 1U : 0U))
  714. #elif defined(RTC_TAMPER3_SUPPORT)
  715. /**
  716. * @brief Check whether the specified RTC Tamper interrupt has occurred or not.
  717. * @param __HANDLE__ specifies the RTC handle.
  718. * @param __INTERRUPT__ specifies the RTC Tamper interrupt to check.
  719. * This parameter can be:
  720. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  721. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  722. * @retval None
  723. */
  724. #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) == RTC_IT_TAMP2) ? (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 5U)) != 0U) ? 1U : 0U) : \
  725. ((__INTERRUPT__) == RTC_IT_TAMP3) ? (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 7U)) != 0U) ? 1U : 0U))
  726. #endif
  727. /**************************************************************************************************/
  728. #if defined(RTC_TAMPER1_SUPPORT) && defined(RTC_TAMPER3_SUPPORT)
  729. /**
  730. * @brief Check whether the specified RTC Tamper interrupt has been enabled or not.
  731. * @param __HANDLE__ specifies the RTC handle.
  732. * @param __INTERRUPT__ specifies the RTC Tamper interrupt source to check.
  733. * This parameter can be:
  734. * @arg RTC_IT_TAMP: All tampers interrupts
  735. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  736. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  737. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  738. * @retval None
  739. */
  740. #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->TAMPCR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
  741. /**
  742. * @brief Get the selected RTC Tamper's flag status.
  743. * @param __HANDLE__ specifies the RTC handle.
  744. * @param __FLAG__ specifies the RTC Tamper Flag is pending or not.
  745. * This parameter can be:
  746. * @arg RTC_FLAG_TAMP1F: Tamper1 flag
  747. * @arg RTC_FLAG_TAMP2F: Tamper2 flag
  748. * @arg RTC_FLAG_TAMP3F: Tamper3 flag
  749. * @retval None
  750. */
  751. #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
  752. /**
  753. * @brief Clear the RTC Tamper's pending flags.
  754. * @param __HANDLE__ specifies the RTC handle.
  755. * @param __FLAG__ specifies the RTC Tamper Flag to clear.
  756. * This parameter can be:
  757. * @arg RTC_FLAG_TAMP1F: Tamper1 flag
  758. * @arg RTC_FLAG_TAMP2F: Tamper2 flag
  759. * @arg RTC_FLAG_TAMP3F: Tamper3 flag
  760. * @retval None
  761. */
  762. #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  763. #elif defined(RTC_TAMPER1_SUPPORT)
  764. /**
  765. * @brief Check whether the specified RTC Tamper interrupt has been enabled or not.
  766. * @param __HANDLE__ specifies the RTC handle.
  767. * @param __INTERRUPT__ specifies the RTC Tamper interrupt source to check.
  768. * This parameter can be:
  769. * @arg RTC_IT_TAMP: All tampers interrupts
  770. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  771. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  772. * @retval None
  773. */
  774. #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->TAMPCR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
  775. /**
  776. * @brief Get the selected RTC Tamper's flag status.
  777. * @param __HANDLE__ specifies the RTC handle.
  778. * @param __FLAG__ specifies the RTC Tamper Flag is pending or not.
  779. * This parameter can be:
  780. * @arg RTC_FLAG_TAMP1F: Tamper1 flag
  781. * @arg RTC_FLAG_TAMP2F: Tamper2 flag
  782. * @retval None
  783. */
  784. #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
  785. /**
  786. * @brief Clear the RTC Tamper's pending flags.
  787. * @param __HANDLE__ specifies the RTC handle.
  788. * @param __FLAG__ specifies the RTC Tamper Flag to clear.
  789. * This parameter can be:
  790. * @arg RTC_FLAG_TAMP1F: Tamper1 flag
  791. * @arg RTC_FLAG_TAMP2F: Tamper2 flag
  792. * @retval None
  793. */
  794. #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  795. #elif defined(RTC_TAMPER3_SUPPORT)
  796. /**
  797. * @brief Check whether the specified RTC Tamper interrupt has been enabled or not.
  798. * @param __HANDLE__ specifies the RTC handle.
  799. * @param __INTERRUPT__ specifies the RTC Tamper interrupt source to check.
  800. * This parameter can be:
  801. * @arg RTC_IT_TAMP: All tampers interrupts
  802. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  803. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  804. * @retval None
  805. */
  806. #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->TAMPCR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
  807. /**
  808. * @brief Get the selected RTC Tamper's flag status.
  809. * @param __HANDLE__ specifies the RTC handle.
  810. * @param __FLAG__ specifies the RTC Tamper Flag is pending or not.
  811. * This parameter can be:
  812. * @arg RTC_FLAG_TAMP2F: Tamper2 flag
  813. * @arg RTC_FLAG_TAMP3F: Tamper3 flag
  814. * @retval None
  815. */
  816. #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
  817. /**
  818. * @brief Clear the RTC Tamper's pending flags.
  819. * @param __HANDLE__ specifies the RTC handle.
  820. * @param __FLAG__ specifies the RTC Tamper Flag to clear.
  821. * This parameter can be:
  822. * @arg RTC_FLAG_TAMP2F: Tamper2 flag
  823. * @arg RTC_FLAG_TAMP3F: Tamper3 flag
  824. * @retval None
  825. */
  826. #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  827. #endif
  828. /**************************************************************************************************/
  829. #if defined(RTC_INTERNALTS_SUPPORT)
  830. /**
  831. * @brief Enable the RTC internal TimeStamp peripheral.
  832. * @param __HANDLE__ specifies the RTC handle.
  833. * @retval None
  834. */
  835. #define __HAL_RTC_INTERNAL_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ITSE))
  836. /**
  837. * @brief Disable the RTC internal TimeStamp peripheral.
  838. * @param __HANDLE__ specifies the RTC handle.
  839. * @retval None
  840. */
  841. #define __HAL_RTC_INTERNAL_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ITSE))
  842. /**
  843. * @brief Get the selected RTC Internal Time Stamp's flag status.
  844. * @param __HANDLE__ specifies the RTC handle.
  845. * @param __FLAG__ specifies the RTC Internal Time Stamp Flag is pending or not.
  846. * This parameter can be:
  847. * @arg RTC_FLAG_ITSF
  848. * @retval None
  849. */
  850. #define __HAL_RTC_INTERNAL_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
  851. /**
  852. * @brief Clear the RTC Internal Time Stamp's pending flags.
  853. * @param __HANDLE__ specifies the RTC handle.
  854. * @param __FLAG__ specifies the RTC Internal Time Stamp Flag source to clear.
  855. * This parameter can be:
  856. * @arg RTC_FLAG_ITSF
  857. * @retval None
  858. */
  859. #define __HAL_RTC_INTERNAL_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  860. #endif
  861. /**************************************************************************************************/
  862. /**
  863. * @}
  864. */
  865. /* --------------------------TAMPER/TIMESTAMP---------------------------------*/
  866. /** @defgroup RTCEx_Tamper_Timestamp EXTI RTC Tamper Timestamp EXTI
  867. * @{
  868. */
  869. /* TAMPER TIMESTAMP EXTI */
  870. /* --------------------- */
  871. /**
  872. * @brief Enable interrupt on the RTC Tamper and Timestamp associated Exti line of core 1.
  873. * @retval None
  874. */
  875. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  876. /**
  877. * @brief Enable interrupt on the RTC Tamper and Timestamp associated Exti line of core 2.
  878. * @retval None
  879. */
  880. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTIC2_ENABLE_IT() (EXTI->C2IMR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  881. /**
  882. * @brief Disable interrupt on the RTC Tamper and Timestamp associated Exti line of core 1.
  883. * @retval None
  884. */
  885. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  886. /**
  887. * @brief Disable interrupt on the RTC Tamper and Timestamp associated Exti line of core 2.
  888. * @retval None
  889. */
  890. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTIC2_DISABLE_IT() (EXTI->C2IMR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  891. /**
  892. * @brief Enable event on the RTC Tamper and Timestamp associated Exti line of core 1.
  893. * @retval None.
  894. */
  895. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  896. /**
  897. * @brief Enable event on the RTC Tamper and Timestamp associated Exti line of core 2.
  898. * @retval None.
  899. */
  900. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTIC2_ENABLE_EVENT() (EXTI->C2EMR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  901. /**
  902. * @brief Disable event on the RTC Tamper and Timestamp associated Exti line of core 1.
  903. * @retval None.
  904. */
  905. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  906. /**
  907. * @brief Disable event on the RTC Tamper and Timestamp associated Exti line of core 2.
  908. * @retval None.
  909. */
  910. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTIC2_DISABLE_EVENT() (EXTI->C2EMR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  911. /*-----------------*/
  912. /**
  913. * @brief Enable falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  914. * @retval None.
  915. */
  916. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  917. /**
  918. * @brief Disable falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  919. * @retval None.
  920. */
  921. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  922. /**
  923. * @brief Enable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
  924. * @retval None.
  925. */
  926. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  927. /**
  928. * @brief Disable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
  929. * @retval None.
  930. */
  931. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  932. /**
  933. * @brief Enable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  934. * @retval None.
  935. */
  936. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  937. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE(); \
  938. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE(); \
  939. } while(0U)
  940. /**
  941. * @brief Disable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  942. * This parameter can be:
  943. * @retval None.
  944. */
  945. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  946. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE(); \
  947. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE(); \
  948. } while(0U)
  949. /**
  950. * @brief Check whether the RTC Tamper and Timestamp associated Exti line interrupt flag is set or not of core 1.
  951. * @retval Line Status.
  952. */
  953. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GET_FLAG() (EXTI->PR1 & RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  954. /**
  955. * @brief Check whether the RTC Tamper and Timestamp associated Exti line interrupt flag is set or not of core 2.
  956. * @retval Line Status.
  957. */
  958. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTIC2_GET_FLAG() (EXTI->PR2 & RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  959. /**
  960. * @brief Clear the RTC Tamper and Timestamp associated Exti line flag of core 1.
  961. * @retval None.
  962. */
  963. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_CLEAR_FLAG() (EXTI->PR1 = RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  964. /**
  965. * @brief Clear the RTC Tamper and Timestamp associated Exti line flag of core 2.
  966. * @retval None.
  967. */
  968. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTIC2_CLEAR_FLAG() (EXTI->PR1 = RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  969. /**
  970. * @brief Generate a Software interrupt on the RTC Tamper and Timestamp associated Exti line
  971. * @retval None.
  972. */
  973. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GENERATE_SWIT() (EXTI->SWIER1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  974. /**
  975. * @}
  976. */
  977. /* ------------------------------Calibration----------------------------------*/
  978. /** @defgroup RTCEx_Calibration RTC Calibration
  979. * @{
  980. */
  981. /**
  982. * @brief Enable the RTC calibration output.
  983. * @param __HANDLE__ specifies the RTC handle.
  984. * @retval None
  985. */
  986. #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_COE))
  987. /**
  988. * @brief Disable the calibration output.
  989. * @param __HANDLE__ specifies the RTC handle.
  990. * @retval None
  991. */
  992. #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_COE))
  993. /**
  994. * @brief Enable the clock reference detection.
  995. * @param __HANDLE__ specifies the RTC handle.
  996. * @retval None
  997. */
  998. #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_REFCKON))
  999. /**
  1000. * @brief Disable the clock reference detection.
  1001. * @param __HANDLE__ specifies the RTC handle.
  1002. * @retval None
  1003. */
  1004. #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_REFCKON))
  1005. /**
  1006. * @brief Get the selected RTC shift operation's flag status.
  1007. * @param __HANDLE__ specifies the RTC handle.
  1008. * @param __FLAG__ specifies the RTC shift operation Flag is pending or not.
  1009. * This parameter can be:
  1010. * @arg RTC_FLAG_SHPF
  1011. * @retval None
  1012. */
  1013. #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U)? 1U : 0U)
  1014. /**
  1015. * @}
  1016. */
  1017. /**
  1018. * @}
  1019. */
  1020. /* Exported functions --------------------------------------------------------*/
  1021. /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions
  1022. * @{
  1023. */
  1024. /* RTC TimeStamp and Tamper functions *****************************************/
  1025. /** @defgroup RTCEx_Exported_Functions_Group1 Extended RTC TimeStamp and Tamper functions
  1026. * @{
  1027. */
  1028. HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
  1029. HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
  1030. HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc);
  1031. #if defined(RTC_INTERNALTS_SUPPORT)
  1032. HAL_StatusTypeDef HAL_RTCEx_SetInternalTimeStamp(RTC_HandleTypeDef *hrtc);
  1033. HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTimeStamp(RTC_HandleTypeDef *hrtc);
  1034. #endif
  1035. HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format);
  1036. HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper);
  1037. HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper);
  1038. HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper);
  1039. void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc);
  1040. #if defined(RTC_TAMPER1_SUPPORT)
  1041. void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc);
  1042. #endif /* RTC_TAMPER1_SUPPORT */
  1043. void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc);
  1044. #if defined(RTC_TAMPER3_SUPPORT)
  1045. void HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc);
  1046. #endif /* RTC_TAMPER3_SUPPORT */
  1047. void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc);
  1048. HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  1049. #if defined(RTC_TAMPER1_SUPPORT)
  1050. HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  1051. #endif /* RTC_TAMPER1_SUPPORT */
  1052. HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  1053. #if defined(RTC_TAMPER3_SUPPORT)
  1054. HAL_StatusTypeDef HAL_RTCEx_PollForTamper3Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  1055. #endif /* RTC_TAMPER3_SUPPORT */
  1056. /**
  1057. * @}
  1058. */
  1059. /* RTC Wake-up functions ******************************************************/
  1060. /** @defgroup RTCEx_Exported_Functions_Group2 Extended RTC Wake-up functions
  1061. * @{
  1062. */
  1063. HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
  1064. HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
  1065. HAL_StatusTypeDef HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc);
  1066. uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc);
  1067. void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc);
  1068. void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc);
  1069. HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  1070. /**
  1071. * @}
  1072. */
  1073. /* Extended Control functions ************************************************/
  1074. /** @defgroup RTCEx_Exported_Functions_Group3 Extended Peripheral Control functions
  1075. * @{
  1076. */
  1077. void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data);
  1078. uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister);
  1079. HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue);
  1080. HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS);
  1081. HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput);
  1082. HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc);
  1083. HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc);
  1084. HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc);
  1085. HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc);
  1086. HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc);
  1087. /**
  1088. * @}
  1089. */
  1090. /* Extended RTC features functions *******************************************/
  1091. /** @defgroup RTCEx_Exported_Functions_Group4 Extended features functions
  1092. * @{
  1093. */
  1094. void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc);
  1095. HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  1096. /**
  1097. * @}
  1098. */
  1099. /**
  1100. * @}
  1101. */
  1102. /* Private types -------------------------------------------------------------*/
  1103. /* Private variables ---------------------------------------------------------*/
  1104. /* Private constants ---------------------------------------------------------*/
  1105. /** @defgroup RTCEx_Private_Constants RTCEx Private Constants
  1106. * @{
  1107. */
  1108. /* Masks Definition */
  1109. #if defined(RTC_TAMPER1_SUPPORT) && defined(RTC_TAMPER3_SUPPORT)
  1110. #define RTC_FLAGS_MASK ((uint32_t) (RTC_FLAG_RECALPF | RTC_FLAG_TAMP3F | RTC_FLAG_TAMP2F | \
  1111. RTC_FLAG_TAMP1F| RTC_FLAG_TSOVF | RTC_FLAG_TSF | \
  1112. RTC_FLAG_WUTF | RTC_FLAG_ALRBF | RTC_FLAG_ALRAF | \
  1113. RTC_FLAG_INITF | RTC_FLAG_RSF | \
  1114. RTC_FLAG_INITS | RTC_FLAG_SHPF | RTC_FLAG_WUTWF | \
  1115. RTC_FLAG_ALRBWF | RTC_FLAG_ALRAWF))
  1116. #define RTC_TAMPCR_TAMPXE ((uint32_t) (RTC_TAMPCR_TAMP3E | RTC_TAMPCR_TAMP2E | RTC_TAMPCR_TAMP1E))
  1117. #define RTC_TAMPCR_TAMPXIE ((uint32_t) (RTC_TAMPER1_INTERRUPT | RTC_TAMPER2_INTERRUPT | \
  1118. RTC_TAMPER3_INTERRUPT | RTC_ALL_TAMPER_INTERRUPT))
  1119. #elif defined(RTC_TAMPER1_SUPPORT)
  1120. #define RTC_FLAGS_MASK ((uint32_t) (RTC_FLAG_RECALPF | RTC_FLAG_TAMP2F | RTC_FLAG_TAMP1F| \
  1121. RTC_FLAG_TSOVF | RTC_FLAG_TSF | RTC_FLAG_WUTF | \
  1122. RTC_FLAG_ALRBF | RTC_FLAG_ALRAF | \
  1123. RTC_FLAG_INITF | RTC_FLAG_RSF | RTC_FLAG_INITS | \
  1124. RTC_FLAG_SHPF | RTC_FLAG_WUTWF |RTC_FLAG_ALRBWF | \
  1125. RTC_FLAG_ALRAWF))
  1126. #define RTC_TAMPCR_TAMPXE ((uint32_t) (RTC_TAMPCR_TAMP2E | RTC_TAMPCR_TAMP1E))
  1127. #define RTC_TAMPCR_TAMPXIE ((uint32_t) (RTC_TAMPER1_INTERRUPT | RTC_TAMPER2_INTERRUPT | \
  1128. RTC_ALL_TAMPER_INTERRUPT))
  1129. #elif defined(RTC_TAMPER3_SUPPORT)
  1130. #define RTC_FLAGS_MASK ((uint32_t) (RTC_FLAG_RECALPF | RTC_FLAG_TAMP3F | RTC_FLAG_TAMP2F | \
  1131. RTC_FLAG_TSOVF | RTC_FLAG_TSF | \
  1132. RTC_FLAG_WUTF | RTC_FLAG_ALRBF | RTC_FLAG_ALRAF | \
  1133. RTC_FLAG_INITF | RTC_FLAG_RSF | \
  1134. RTC_FLAG_INITS | RTC_FLAG_SHPF | RTC_FLAG_WUTWF | \
  1135. RTC_FLAG_ALRBWF | RTC_FLAG_ALRAWF))
  1136. #define RTC_TAMPCR_TAMPXE ((uint32_t) (RTC_TAMPCR_TAMP3E | RTC_TAMPCR_TAMP2E))
  1137. #define RTC_TAMPCR_TAMPXIE ((uint32_t) (RTC_TAMPER2_INTERRUPT | \
  1138. RTC_TAMPER3_INTERRUPT | RTC_ALL_TAMPER_INTERRUPT))
  1139. #endif
  1140. #define RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT (EXTI_IMR1_IM18) /*!< External interrupt line 18 Connected to the RTC Tamper and Time Stamp events */
  1141. #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT (EXTI_IMR1_IM19) /*!< External interrupt line 19 Connected to the RTC Wakeup event */
  1142. /**
  1143. * @}
  1144. */
  1145. /* Private macros ------------------------------------------------------------*/
  1146. /** @defgroup RTCEx_Private_Macros RTCEx Private Macros
  1147. * @{
  1148. */
  1149. /** @defgroup RTCEx_IS_RTC_Definitions Private macros to check input parameters
  1150. * @{
  1151. */
  1152. #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
  1153. ((OUTPUT) == RTC_OUTPUT_ALARMA) || \
  1154. ((OUTPUT) == RTC_OUTPUT_ALARMB) || \
  1155. ((OUTPUT) == RTC_OUTPUT_WAKEUP))
  1156. #define IS_RTC_BKP(BKP) ((BKP) < (uint32_t) RTC_BKP_NUMBER)
  1157. #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \
  1158. ((EDGE) == RTC_TIMESTAMPEDGE_FALLING))
  1159. #define IS_RTC_TAMPER(TAMPER) ((((TAMPER) & ((uint32_t)(0xFFFFFFFFU ^ RTC_TAMPCR_TAMPXE))) == 0x00U) && ((TAMPER) != 0U))
  1160. #define IS_RTC_TAMPER_INTERRUPT(INTERRUPT) ((((INTERRUPT) & (uint32_t)(0xFFFFFFFFU ^ RTC_TAMPCR_TAMPXIE)) == 0x00U) && ((INTERRUPT) != 0U))
  1161. #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TIMESTAMPPIN_DEFAULT))
  1162. #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) || \
  1163. ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \
  1164. ((TRIGGER) == RTC_TAMPERTRIGGER_LOWLEVEL) || \
  1165. ((TRIGGER) == RTC_TAMPERTRIGGER_HIGHLEVEL))
  1166. #define IS_RTC_TAMPER_ERASE_MODE(MODE) (((MODE) == RTC_TAMPER_ERASE_BACKUP_ENABLE) || \
  1167. ((MODE) == RTC_TAMPER_ERASE_BACKUP_DISABLE))
  1168. #define IS_RTC_TAMPER_MASKFLAG_STATE(STATE) (((STATE) == RTC_TAMPERMASK_FLAG_ENABLE) || \
  1169. ((STATE) == RTC_TAMPERMASK_FLAG_DISABLE))
  1170. #define IS_RTC_TAMPER_FILTER(FILTER) (((FILTER) == RTC_TAMPERFILTER_DISABLE) || \
  1171. ((FILTER) == RTC_TAMPERFILTER_2SAMPLE) || \
  1172. ((FILTER) == RTC_TAMPERFILTER_4SAMPLE) || \
  1173. ((FILTER) == RTC_TAMPERFILTER_8SAMPLE))
  1174. #define IS_RTC_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \
  1175. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \
  1176. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \
  1177. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \
  1178. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \
  1179. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \
  1180. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512) || \
  1181. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256))
  1182. #define IS_RTC_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \
  1183. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \
  1184. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \
  1185. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK))
  1186. #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \
  1187. ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE))
  1188. #define IS_RTC_TAMPER_PULLUP_STATE(STATE) (((STATE) == RTC_TAMPER_PULLUP_ENABLE) || \
  1189. ((STATE) == RTC_TAMPER_PULLUP_DISABLE))
  1190. #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16) || \
  1191. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8) || \
  1192. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4) || \
  1193. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2) || \
  1194. ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \
  1195. ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS))
  1196. #define IS_RTC_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= RTC_WUTR_WUT)
  1197. #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \
  1198. ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \
  1199. ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC))
  1200. #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \
  1201. ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET))
  1202. /** @defgroup RTCEx_Smooth_calib_Minus_pulses_Definitions RTCEx Smooth calib Minus pulses Definitions
  1203. * @{
  1204. */
  1205. #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= RTC_CALR_CALM)
  1206. /**
  1207. * @}
  1208. */
  1209. #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \
  1210. ((SEL) == RTC_SHIFTADD1S_SET))
  1211. /** @defgroup RTCEx_Substract_Fraction_Of_Second_Value RTCEx Substract Fraction Of Second Value
  1212. * @{
  1213. */
  1214. #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= RTC_SHIFTR_SUBFS)
  1215. /**
  1216. * @}
  1217. */
  1218. #define IS_RTC_CALIB_OUTPUT(OUTPUT) (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \
  1219. ((OUTPUT) == RTC_CALIBOUTPUT_1HZ))
  1220. /**
  1221. * @}
  1222. */
  1223. /**
  1224. * @}
  1225. */
  1226. /**
  1227. * @}
  1228. */
  1229. /**
  1230. * @}
  1231. */
  1232. #ifdef __cplusplus
  1233. }
  1234. #endif
  1235. #endif /* STM32WBxx_HAL_RTC_EX_H */
  1236. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/