stm32f4xx_hal_rtc_ex.h 45 KB

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