stm32f4xx_hal_rtc_ex.h 44 KB

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