stm32f3xx_hal_rtc_ex.h 45 KB

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