stm32f7xx_hal_rtc_ex.h 50 KB

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