stm32f0xx_hal_rtc_ex.h 43 KB

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