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.
 
 
 

1349 lines
56 KiB

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