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.
 
 

1012 line
43 KiB

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