You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1036 lines
47 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f7xx_hal_rtc_ex.h
  4. * @author MCD Application Team
  5. * @version V1.0.1
  6. * @date 25-June-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 __STM32F7xx_HAL_RTC_EX_H
  39. #define __STM32F7xx_HAL_RTC_EX_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32f7xx_hal_def.h"
  45. /** @addtogroup STM32F7xx_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 Interrupt; /*!< Specifies the Tamper Interrupt.
  63. This parameter can be a value of @ref RTCEx_Tamper_Interrupt_Definitions */
  64. uint32_t Trigger; /*!< Specifies the Tamper Trigger.
  65. This parameter can be a value of @ref RTCEx_Tamper_Trigger_Definitions */
  66. uint32_t NoErase; /*!< Specifies the Tamper no erase mode.
  67. This parameter can be a value of @ref RTCEx_Tamper_EraseBackUp_Definitions */
  68. uint32_t MaskFlag; /*!< Specifies the Tamper Flag masking.
  69. This parameter can be a value of @ref RTCEx_Tamper_MaskFlag_Definitions */
  70. uint32_t Filter; /*!< Specifies the RTC Filter Tamper.
  71. This parameter can be a value of @ref RTCEx_Tamper_Filter_Definitions */
  72. uint32_t SamplingFrequency; /*!< Specifies the sampling frequency.
  73. This parameter can be a value of @ref RTCEx_Tamper_Sampling_Frequencies_Definitions */
  74. uint32_t PrechargeDuration; /*!< Specifies the Precharge Duration .
  75. This parameter can be a value of @ref RTCEx_Tamper_Pin_Precharge_Duration_Definitions */
  76. uint32_t TamperPullUp; /*!< Specifies the Tamper PullUp .
  77. This parameter can be a value of @ref RTCEx_Tamper_Pull_UP_Definitions */
  78. uint32_t TimeStampOnTamperDetection; /*!< Specifies the TimeStampOnTamperDetection.
  79. This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection_Definitions */
  80. }RTC_TamperTypeDef;
  81. /**
  82. * @}
  83. */
  84. /* Exported constants --------------------------------------------------------*/
  85. /** @defgroup RTCEx_Exported_Constants RTCEx Exported Constants
  86. * @{
  87. */
  88. /** @defgroup RTCEx_Output_selection_Definitions RTCEx Output selection Definitions
  89. * @{
  90. */
  91. #define RTC_OUTPUT_DISABLE ((uint32_t)0x00000000)
  92. #define RTC_OUTPUT_ALARMA ((uint32_t)0x00200000)
  93. #define RTC_OUTPUT_ALARMB ((uint32_t)0x00400000)
  94. #define RTC_OUTPUT_WAKEUP ((uint32_t)0x00600000)
  95. /**
  96. * @}
  97. */
  98. /** @defgroup RTCEx_Backup_Registers_Definitions RTC Backup Registers Definitions
  99. * @{
  100. */
  101. #define RTC_BKP_DR0 ((uint32_t)0x00000000)
  102. #define RTC_BKP_DR1 ((uint32_t)0x00000001)
  103. #define RTC_BKP_DR2 ((uint32_t)0x00000002)
  104. #define RTC_BKP_DR3 ((uint32_t)0x00000003)
  105. #define RTC_BKP_DR4 ((uint32_t)0x00000004)
  106. #define RTC_BKP_DR5 ((uint32_t)0x00000005)
  107. #define RTC_BKP_DR6 ((uint32_t)0x00000006)
  108. #define RTC_BKP_DR7 ((uint32_t)0x00000007)
  109. #define RTC_BKP_DR8 ((uint32_t)0x00000008)
  110. #define RTC_BKP_DR9 ((uint32_t)0x00000009)
  111. #define RTC_BKP_DR10 ((uint32_t)0x0000000A)
  112. #define RTC_BKP_DR11 ((uint32_t)0x0000000B)
  113. #define RTC_BKP_DR12 ((uint32_t)0x0000000C)
  114. #define RTC_BKP_DR13 ((uint32_t)0x0000000D)
  115. #define RTC_BKP_DR14 ((uint32_t)0x0000000E)
  116. #define RTC_BKP_DR15 ((uint32_t)0x0000000F)
  117. #define RTC_BKP_DR16 ((uint32_t)0x00000010)
  118. #define RTC_BKP_DR17 ((uint32_t)0x00000011)
  119. #define RTC_BKP_DR18 ((uint32_t)0x00000012)
  120. #define RTC_BKP_DR19 ((uint32_t)0x00000013)
  121. #define RTC_BKP_DR20 ((uint32_t)0x00000014)
  122. #define RTC_BKP_DR21 ((uint32_t)0x00000015)
  123. #define RTC_BKP_DR22 ((uint32_t)0x00000016)
  124. #define RTC_BKP_DR23 ((uint32_t)0x00000017)
  125. #define RTC_BKP_DR24 ((uint32_t)0x00000018)
  126. #define RTC_BKP_DR25 ((uint32_t)0x00000019)
  127. #define RTC_BKP_DR26 ((uint32_t)0x0000001A)
  128. #define RTC_BKP_DR27 ((uint32_t)0x0000001B)
  129. #define RTC_BKP_DR28 ((uint32_t)0x0000001C)
  130. #define RTC_BKP_DR29 ((uint32_t)0x0000001D)
  131. #define RTC_BKP_DR30 ((uint32_t)0x0000001E)
  132. #define RTC_BKP_DR31 ((uint32_t)0x0000001F)
  133. /**
  134. * @}
  135. */
  136. /** @defgroup RTCEx_Time_Stamp_Edges_definitions RTCEx Time Stamp Edges definitions
  137. * @{
  138. */
  139. #define RTC_TIMESTAMPEDGE_RISING ((uint32_t)0x00000000)
  140. #define RTC_TIMESTAMPEDGE_FALLING ((uint32_t)0x00000008)
  141. /**
  142. * @}
  143. */
  144. /** @defgroup RTCEx_Tamper_Pins_Definitions RTCEx Tamper Pins Definitions
  145. * @{
  146. */
  147. #define RTC_TAMPER_1 RTC_TAMPCR_TAMP1E
  148. #define RTC_TAMPER_2 RTC_TAMPCR_TAMP2E
  149. #define RTC_TAMPER_3 RTC_TAMPCR_TAMP3E
  150. /**
  151. * @}
  152. */
  153. /** @defgroup RTCEx_Tamper_Interrupt_Definitions RTCEx Tamper Interrupt Definitions
  154. * @{
  155. */
  156. #define RTC_TAMPER1_INTERRUPT RTC_TAMPCR_TAMP1IE
  157. #define RTC_TAMPER2_INTERRUPT RTC_TAMPCR_TAMP2IE
  158. #define RTC_TAMPER3_INTERRUPT RTC_TAMPCR_TAMP3IE
  159. #define RTC_ALL_TAMPER_INTERRUPT RTC_TAMPCR_TAMPIE
  160. /**
  161. * @}
  162. */
  163. /** @defgroup RTCEx_TimeStamp_Pin_Selection RTCEx TimeStamp Pin Selection
  164. * @{
  165. */
  166. #define RTC_TIMESTAMPPIN_DEFAULT ((uint32_t)0x00000000)
  167. #define RTC_TIMESTAMPPIN_POS1 ((uint32_t)0x00000002)
  168. #define RTC_TIMESTAMPPIN_POS2 ((uint32_t)0x00000004)
  169. /**
  170. * @}
  171. */
  172. /** @defgroup RTCEx_Tamper_Trigger_Definitions RTCEx Tamper Trigger Definitions
  173. * @{
  174. */
  175. #define RTC_TAMPERTRIGGER_RISINGEDGE ((uint32_t)0x00000000)
  176. #define RTC_TAMPERTRIGGER_FALLINGEDGE ((uint32_t)0x00000002)
  177. #define RTC_TAMPERTRIGGER_LOWLEVEL RTC_TAMPERTRIGGER_RISINGEDGE
  178. #define RTC_TAMPERTRIGGER_HIGHLEVEL RTC_TAMPERTRIGGER_FALLINGEDGE
  179. /**
  180. * @}
  181. */
  182. /** @defgroup RTCEx_Tamper_EraseBackUp_Definitions RTCEx Tamper EraseBackUp Definitions
  183. * @{
  184. */
  185. #define RTC_TAMPER_ERASE_BACKUP_ENABLE ((uint32_t)0x00000000)
  186. #define RTC_TAMPER_ERASE_BACKUP_DISABLE ((uint32_t)0x00020000)
  187. /**
  188. * @}
  189. */
  190. /** @defgroup RTCEx_Tamper_MaskFlag_Definitions RTCEx Tamper MaskFlag Definitions
  191. * @{
  192. */
  193. #define RTC_TAMPERMASK_FLAG_DISABLE ((uint32_t)0x00000000)
  194. #define RTC_TAMPERMASK_FLAG_ENABLE ((uint32_t)0x00040000)
  195. /**
  196. * @}
  197. */
  198. /** @defgroup RTCEx_Tamper_Filter_Definitions RTCEx Tamper Filter Definitions
  199. * @{
  200. */
  201. #define RTC_TAMPERFILTER_DISABLE ((uint32_t)0x00000000) /*!< Tamper filter is disabled */
  202. #define RTC_TAMPERFILTER_2SAMPLE ((uint32_t)0x00000800) /*!< Tamper is activated after 2
  203. consecutive samples at the active level */
  204. #define RTC_TAMPERFILTER_4SAMPLE ((uint32_t)0x00001000) /*!< Tamper is activated after 4
  205. consecutive samples at the active level */
  206. #define RTC_TAMPERFILTER_8SAMPLE ((uint32_t)0x00001800) /*!< Tamper is activated after 8
  207. consecutive samples at the active leve. */
  208. /**
  209. * @}
  210. */
  211. /** @defgroup RTCEx_Tamper_Sampling_Frequencies_Definitions RTCEx Tamper Sampling Frequencies Definitions
  212. * @{
  213. */
  214. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768 ((uint32_t)0x00000000) /*!< Each of the tamper inputs are sampled
  215. with a frequency = RTCCLK / 32768 */
  216. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384 ((uint32_t)0x00000100) /*!< Each of the tamper inputs are sampled
  217. with a frequency = RTCCLK / 16384 */
  218. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192 ((uint32_t)0x00000200) /*!< Each of the tamper inputs are sampled
  219. with a frequency = RTCCLK / 8192 */
  220. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096 ((uint32_t)0x00000300) /*!< Each of the tamper inputs are sampled
  221. with a frequency = RTCCLK / 4096 */
  222. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048 ((uint32_t)0x00000400) /*!< Each of the tamper inputs are sampled
  223. with a frequency = RTCCLK / 2048 */
  224. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024 ((uint32_t)0x00000500) /*!< Each of the tamper inputs are sampled
  225. with a frequency = RTCCLK / 1024 */
  226. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512 ((uint32_t)0x00000600) /*!< Each of the tamper inputs are sampled
  227. with a frequency = RTCCLK / 512 */
  228. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256 ((uint32_t)0x00000700) /*!< Each of the tamper inputs are sampled
  229. with a frequency = RTCCLK / 256 */
  230. /**
  231. * @}
  232. */
  233. /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration_Definitions RTCEx Tamper Pin Precharge Duration Definitions
  234. * @{
  235. */
  236. #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK ((uint32_t)0x00000000) /*!< Tamper pins are pre-charged before
  237. sampling during 1 RTCCLK cycle */
  238. #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK ((uint32_t)0x00002000) /*!< Tamper pins are pre-charged before
  239. sampling during 2 RTCCLK cycles */
  240. #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK ((uint32_t)0x00004000) /*!< Tamper pins are pre-charged before
  241. sampling during 4 RTCCLK cycles */
  242. #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK ((uint32_t)0x00006000) /*!< Tamper pins are pre-charged before
  243. sampling during 8 RTCCLK cycles */
  244. /**
  245. * @}
  246. */
  247. /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection_Definitions RTCEx Tamper TimeStampOnTamperDetection Definitions
  248. * @{
  249. */
  250. #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE ((uint32_t)RTC_TAMPCR_TAMPTS) /*!< TimeStamp on Tamper Detection event saved */
  251. #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE ((uint32_t)0x00000000) /*!< TimeStamp on Tamper Detection event is not saved */
  252. /**
  253. * @}
  254. */
  255. /** @defgroup RTCEx_Tamper_Pull_UP_Definitions RTCEx Tamper Pull UP Definitions
  256. * @{
  257. */
  258. #define RTC_TAMPER_PULLUP_ENABLE ((uint32_t)0x00000000) /*!< TimeStamp on Tamper Detection event saved */
  259. #define RTC_TAMPER_PULLUP_DISABLE ((uint32_t)RTC_TAMPCR_TAMPPUDIS) /*!< TimeStamp on Tamper Detection event is not saved */
  260. /**
  261. * @}
  262. */
  263. /** @defgroup RTCEx_Wakeup_Timer_Definitions RTCEx Wakeup Timer Definitions
  264. * @{
  265. */
  266. #define RTC_WAKEUPCLOCK_RTCCLK_DIV16 ((uint32_t)0x00000000)
  267. #define RTC_WAKEUPCLOCK_RTCCLK_DIV8 ((uint32_t)0x00000001)
  268. #define RTC_WAKEUPCLOCK_RTCCLK_DIV4 ((uint32_t)0x00000002)
  269. #define RTC_WAKEUPCLOCK_RTCCLK_DIV2 ((uint32_t)0x00000003)
  270. #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS ((uint32_t)0x00000004)
  271. #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS ((uint32_t)0x00000006)
  272. /**
  273. * @}
  274. */
  275. /** @defgroup RTCEx_Smooth_calib_period_Definitions RTCEx Smooth calib period Definitions
  276. * @{
  277. */
  278. #define RTC_SMOOTHCALIB_PERIOD_32SEC ((uint32_t)0x00000000) /*!< If RTCCLK = 32768 Hz, Smooth calibration
  279. period is 32s, else 2exp20 RTCCLK seconds */
  280. #define RTC_SMOOTHCALIB_PERIOD_16SEC ((uint32_t)0x00002000) /*!< If RTCCLK = 32768 Hz, Smooth calibration
  281. period is 16s, else 2exp19 RTCCLK seconds */
  282. #define RTC_SMOOTHCALIB_PERIOD_8SEC ((uint32_t)0x00004000) /*!< If RTCCLK = 32768 Hz, Smooth calibration
  283. period is 8s, else 2exp18 RTCCLK seconds */
  284. /**
  285. * @}
  286. */
  287. /** @defgroup RTCEx_Smooth_calib_Plus_pulses_Definitions RTCEx Smooth calib Plus pulses Definitions
  288. * @{
  289. */
  290. #define RTC_SMOOTHCALIB_PLUSPULSES_SET ((uint32_t)0x00008000) /*!< The number of RTCCLK pulses added
  291. during a X -second window = Y - CALM[8:0]
  292. with Y = 512, 256, 128 when X = 32, 16, 8 */
  293. #define RTC_SMOOTHCALIB_PLUSPULSES_RESET ((uint32_t)0x00000000) /*!< The number of RTCCLK pulses subbstited
  294. during a 32-second window = CALM[8:0] */
  295. /**
  296. * @}
  297. */
  298. /** @defgroup RTCEx_Add_1_Second_Parameter_Definitions RTCEx Add 1 Second Parameter Definitions
  299. * @{
  300. */
  301. #define RTC_SHIFTADD1S_RESET ((uint32_t)0x00000000)
  302. #define RTC_SHIFTADD1S_SET ((uint32_t)0x80000000)
  303. /**
  304. * @}
  305. */
  306. /** @defgroup RTCEx_Calib_Output_selection_Definitions RTCEx Calib Output selection Definitions
  307. * @{
  308. */
  309. #define RTC_CALIBOUTPUT_512HZ ((uint32_t)0x00000000)
  310. #define RTC_CALIBOUTPUT_1HZ ((uint32_t)0x00080000)
  311. /**
  312. * @}
  313. */
  314. /**
  315. * @}
  316. */
  317. /* Exported macros -----------------------------------------------------------*/
  318. /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros
  319. * @{
  320. */
  321. /**
  322. * @brief Enable the RTC WakeUp Timer peripheral.
  323. * @param __HANDLE__: specifies the RTC handle.
  324. * @retval None
  325. */
  326. #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_WUTE))
  327. /**
  328. * @brief Disable the RTC WakeUp Timer peripheral.
  329. * @param __HANDLE__: specifies the RTC handle.
  330. * @retval None
  331. */
  332. #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_WUTE))
  333. /**
  334. * @brief Enable the RTC WakeUpTimer interrupt.
  335. * @param __HANDLE__: specifies the RTC handle.
  336. * @param __INTERRUPT__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled.
  337. * This parameter can be:
  338. * @arg RTC_IT_WUT: WakeUpTimer interrupt
  339. * @retval None
  340. */
  341. #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  342. /**
  343. * @brief Disable the RTC WakeUpTimer interrupt.
  344. * @param __HANDLE__: specifies the RTC handle.
  345. * @param __INTERRUPT__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled.
  346. * This parameter can be:
  347. * @arg RTC_IT_WUT: WakeUpTimer interrupt
  348. * @retval None
  349. */
  350. #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  351. /**
  352. * @brief Check whether the specified RTC WakeUpTimer interrupt has occurred or not.
  353. * @param __HANDLE__: specifies the RTC handle.
  354. * @param __INTERRUPT__: specifies the RTC WakeUpTimer interrupt sources to check.
  355. * This parameter can be:
  356. * @arg RTC_IT_WUT: WakeUpTimer interrupt
  357. * @retval None
  358. */
  359. #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 4)) != RESET) ? SET : RESET)
  360. /**
  361. * @brief Check whether the specified RTC Wake Up timer interrupt has been enabled or not.
  362. * @param __HANDLE__: specifies the RTC handle.
  363. * @param __INTERRUPT__: specifies the RTC Wake Up timer interrupt sources to check.
  364. * This parameter can be:
  365. * @arg RTC_IT_WUT: WakeUpTimer interrupt
  366. * @retval None
  367. */
  368. #define __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
  369. /**
  370. * @brief Get the selected RTC WakeUpTimer's flag status.
  371. * @param __HANDLE__: specifies the RTC handle.
  372. * @param __FLAG__: specifies the RTC WakeUpTimer Flag is pending or not.
  373. * This parameter can be:
  374. * @arg RTC_FLAG_WUTF
  375. * @arg RTC_FLAG_WUTWF
  376. * @retval None
  377. */
  378. #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET) ? SET : RESET)
  379. /**
  380. * @brief Clear the RTC Wake Up timer's pending flags.
  381. * @param __HANDLE__: specifies the RTC handle.
  382. * @param __FLAG__: specifies the RTC WakeUpTimer Flag to clear.
  383. * This parameter can be:
  384. * @arg RTC_FLAG_WUTF
  385. * @retval None
  386. */
  387. #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  388. /**
  389. * @brief Enable the RTC Tamper1 input detection.
  390. * @param __HANDLE__: specifies the RTC handle.
  391. * @retval None
  392. */
  393. #define __HAL_RTC_TAMPER1_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR |= (RTC_TAMPCR_TAMP1E))
  394. /**
  395. * @brief Disable the RTC Tamper1 input detection.
  396. * @param __HANDLE__: specifies the RTC handle.
  397. * @retval None
  398. */
  399. #define __HAL_RTC_TAMPER1_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR &= ~(RTC_TAMPCR_TAMP1E))
  400. /**
  401. * @brief Enable the RTC Tamper2 input detection.
  402. * @param __HANDLE__: specifies the RTC handle.
  403. * @retval None
  404. */
  405. #define __HAL_RTC_TAMPER2_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR |= (RTC_TAMPCR_TAMP2E))
  406. /**
  407. * @brief Disable the RTC Tamper2 input detection.
  408. * @param __HANDLE__: specifies the RTC handle.
  409. * @retval None
  410. */
  411. #define __HAL_RTC_TAMPER2_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR &= ~(RTC_TAMPCR_TAMP2E))
  412. /**
  413. * @brief Enable the RTC Tamper3 input detection.
  414. * @param __HANDLE__: specifies the RTC handle.
  415. * @retval None
  416. */
  417. #define __HAL_RTC_TAMPER3_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR |= (RTC_TAMPCR_TAMP3E))
  418. /**
  419. * @brief Disable the RTC Tamper3 input detection.
  420. * @param __HANDLE__: specifies the RTC handle.
  421. * @retval None
  422. */
  423. #define __HAL_RTC_TAMPER3_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR &= ~(RTC_TAMPCR_TAMP3E))
  424. /**
  425. * @brief Check whether the specified RTC Tamper interrupt has occurred or not.
  426. * @param __HANDLE__: specifies the RTC handle.
  427. * @param __INTERRUPT__: specifies the RTC Tamper interrupt to check.
  428. * This parameter can be:
  429. * @arg RTC_IT_TAMP: All tampers interrupts
  430. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  431. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  432. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  433. * @retval None
  434. */
  435. #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) == RTC_IT_TAMP1) ? (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 3)) != RESET) ? SET : RESET) : \
  436. ((__INTERRUPT__) == RTC_IT_TAMP2) ? (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 5)) != RESET) ? SET : RESET) : \
  437. (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 7)) != RESET) ? SET : RESET))
  438. /**
  439. * @brief Check whether the specified RTC Tamper interrupt has been enabled or not.
  440. * @param __HANDLE__: specifies the RTC handle.
  441. * @param __INTERRUPT__: specifies the RTC Tamper interrupt source to check.
  442. * This parameter can be:
  443. * @arg RTC_IT_TAMP: All tampers interrupts
  444. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  445. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  446. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  447. * @retval None
  448. */
  449. #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->TAMPCR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
  450. /**
  451. * @brief Get the selected RTC Tamper's flag status.
  452. * @param __HANDLE__: specifies the RTC handle.
  453. * @param __FLAG__: specifies the RTC Tamper Flag is pending or not.
  454. * This parameter can be:
  455. * @arg RTC_FLAG_TAMP1F: Tamper1 flag
  456. * @arg RTC_FLAG_TAMP2F: Tamper2 flag
  457. * @arg RTC_FLAG_TAMP3F: Tamper3 flag
  458. * @retval None
  459. */
  460. #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET) ? SET : RESET)
  461. /**
  462. * @brief Clear the RTC Tamper's pending flags.
  463. * @param __HANDLE__: specifies the RTC handle.
  464. * @param __FLAG__: specifies the RTC Tamper Flag sources to clear.
  465. * This parameter can be:
  466. * @arg RTC_FLAG_TAMP1F: Tamper1 flag
  467. * @arg RTC_FLAG_TAMP2F: Tamper2 flag
  468. * @arg RTC_FLAG_TAMP3F: Tamper3 flag
  469. * @retval None
  470. */
  471. #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  472. /**
  473. * @brief Enable the RTC TimeStamp peripheral.
  474. * @param __HANDLE__: specifies the RTC handle.
  475. * @retval None
  476. */
  477. #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TSE))
  478. /**
  479. * @brief Disable the RTC TimeStamp peripheral.
  480. * @param __HANDLE__: specifies the RTC handle.
  481. * @retval None
  482. */
  483. #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TSE))
  484. /**
  485. * @brief Enable the RTC TimeStamp interrupt.
  486. * @param __HANDLE__: specifies the RTC handle.
  487. * @param __INTERRUPT__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled.
  488. * This parameter can be:
  489. * @arg RTC_IT_TS: TimeStamp interrupt
  490. * @retval None
  491. */
  492. #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  493. /**
  494. * @brief Disable the RTC TimeStamp interrupt.
  495. * @param __HANDLE__: specifies the RTC handle.
  496. * @param __INTERRUPT__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled.
  497. * This parameter can be:
  498. * @arg RTC_IT_TS: TimeStamp interrupt
  499. * @retval None
  500. */
  501. #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  502. /**
  503. * @brief Check whether the specified RTC TimeStamp interrupt has occurred or not.
  504. * @param __HANDLE__: specifies the RTC handle.
  505. * @param __INTERRUPT__: specifies the RTC TimeStamp interrupt sources to check.
  506. * This parameter can be:
  507. * @arg RTC_IT_TS: TimeStamp interrupt
  508. * @retval None
  509. */
  510. #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 4)) != RESET) ? SET : RESET)
  511. /**
  512. * @brief Check whether the specified RTC Time Stamp interrupt has been enabled or not.
  513. * @param __HANDLE__: specifies the RTC handle.
  514. * @param __INTERRUPT__: specifies the RTC Time Stamp interrupt source to check.
  515. * This parameter can be:
  516. * @arg RTC_IT_TS: TimeStamp interrupt
  517. * @retval None
  518. */
  519. #define __HAL_RTC_TIMESTAMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
  520. /**
  521. * @brief Get the selected RTC TimeStamp's flag status.
  522. * @param __HANDLE__: specifies the RTC handle.
  523. * @param __FLAG__: specifies the RTC TimeStamp Flag is pending or not.
  524. * This parameter can be:
  525. * @arg RTC_FLAG_TSF
  526. * @arg RTC_FLAG_TSOVF
  527. * @retval None
  528. */
  529. #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET) ? SET : RESET)
  530. /**
  531. * @brief Clear the RTC Time Stamp's pending flags.
  532. * @param __HANDLE__: specifies the RTC handle.
  533. * @param __FLAG__: specifies the RTC Alarm Flag sources to clear.
  534. * This parameter can be:
  535. * @arg RTC_FLAG_TSF
  536. * @arg RTC_FLAG_TSOVF
  537. * @retval None
  538. */
  539. #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  540. /**
  541. * @brief Enable the RTC internal TimeStamp peripheral.
  542. * @param __HANDLE__: specifies the RTC handle.
  543. * @retval None
  544. */
  545. #define __HAL_RTC_INTERNAL_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ITSE))
  546. /**
  547. * @brief Disable the RTC internal TimeStamp peripheral.
  548. * @param __HANDLE__: specifies the RTC handle.
  549. * @retval None
  550. */
  551. #define __HAL_RTC_INTERNAL_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ITSE))
  552. /**
  553. * @brief Get the selected RTC Internal Time Stamp's flag status.
  554. * @param __HANDLE__: specifies the RTC handle.
  555. * @param __FLAG__: specifies the RTC Internal Time Stamp Flag is pending or not.
  556. * This parameter can be:
  557. * @arg RTC_FLAG_ITSF
  558. * @retval None
  559. */
  560. #define __HAL_RTC_INTERNAL_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET) ? SET : RESET)
  561. /**
  562. * @brief Clear the RTC Internal Time Stamp's pending flags.
  563. * @param __HANDLE__: specifies the RTC handle.
  564. * @param __FLAG__: specifies the RTC Internal Time Stamp Flag source to clear.
  565. * This parameter can be:
  566. * @arg RTC_FLAG_ITSF
  567. * @retval None
  568. */
  569. #define __HAL_RTC_INTERNAL_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& 0x0003FFFF)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  570. /**
  571. * @brief Enable the RTC calibration output.
  572. * @param __HANDLE__: specifies the RTC handle.
  573. * @retval None
  574. */
  575. #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_COE))
  576. /**
  577. * @brief Disable the calibration output.
  578. * @param __HANDLE__: specifies the RTC handle.
  579. * @retval None
  580. */
  581. #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_COE))
  582. /**
  583. * @brief Enable the clock reference detection.
  584. * @param __HANDLE__: specifies the RTC handle.
  585. * @retval None
  586. */
  587. #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_REFCKON))
  588. /**
  589. * @brief Disable the clock reference detection.
  590. * @param __HANDLE__: specifies the RTC handle.
  591. * @retval None
  592. */
  593. #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_REFCKON))
  594. /**
  595. * @brief Get the selected RTC shift operation's flag status.
  596. * @param __HANDLE__: specifies the RTC handle.
  597. * @param __FLAG__: specifies the RTC shift operation Flag is pending or not.
  598. * This parameter can be:
  599. * @arg RTC_FLAG_SHPF
  600. * @retval None
  601. */
  602. #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET) ? SET : RESET)
  603. /**
  604. * @brief Enable interrupt on the RTC WakeUp Timer associated Exti line.
  605. * @retval None
  606. */
  607. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  608. /**
  609. * @brief Disable interrupt on the RTC WakeUp Timer associated Exti line.
  610. * @retval None
  611. */
  612. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  613. /**
  614. * @brief Enable event on the RTC WakeUp Timer associated Exti line.
  615. * @retval None.
  616. */
  617. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  618. /**
  619. * @brief Disable event on the RTC WakeUp Timer associated Exti line.
  620. * @retval None.
  621. */
  622. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  623. /**
  624. * @brief Enable falling edge trigger on the RTC WakeUp Timer associated Exti line.
  625. * @retval None.
  626. */
  627. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  628. /**
  629. * @brief Disable falling edge trigger on the RTC WakeUp Timer associated Exti line.
  630. * @retval None.
  631. */
  632. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  633. /**
  634. * @brief Enable rising edge trigger on the RTC WakeUp Timer associated Exti line.
  635. * @retval None.
  636. */
  637. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  638. /**
  639. * @brief Disable rising edge trigger on the RTC WakeUp Timer associated Exti line.
  640. * @retval None.
  641. */
  642. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  643. /**
  644. * @brief Enable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line.
  645. * @retval None.
  646. */
  647. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_FALLING_EDGE() __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE();__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE();
  648. /**
  649. * @brief Disable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line.
  650. * This parameter can be:
  651. * @retval None.
  652. */
  653. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_FALLING_EDGE() __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE();__HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE();
  654. /**
  655. * @brief Check whether the RTC WakeUp Timer associated Exti line interrupt flag is set or not.
  656. * @retval Line Status.
  657. */
  658. #define __HAL_RTC_WAKEUPTIMER_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  659. /**
  660. * @brief Clear the RTC WakeUp Timer associated Exti line flag.
  661. * @retval None.
  662. */
  663. #define __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  664. /**
  665. * @brief Generate a Software interrupt on the RTC WakeUp Timer associated Exti line.
  666. * @retval None.
  667. */
  668. #define __HAL_RTC_WAKEUPTIMER_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  669. /**
  670. * @brief Enable interrupt on the RTC Tamper and Timestamp associated Exti line.
  671. * @retval None
  672. */
  673. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  674. /**
  675. * @brief Disable interrupt on the RTC Tamper and Timestamp associated Exti line.
  676. * @retval None
  677. */
  678. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_IT() (EXTI->IMR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  679. /**
  680. * @brief Enable event on the RTC Tamper and Timestamp associated Exti line.
  681. * @retval None.
  682. */
  683. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  684. /**
  685. * @brief Disable event on the RTC Tamper and Timestamp associated Exti line.
  686. * @retval None.
  687. */
  688. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  689. /**
  690. * @brief Enable falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  691. * @retval None.
  692. */
  693. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  694. /**
  695. * @brief Disable falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  696. * @retval None.
  697. */
  698. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  699. /**
  700. * @brief Enable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
  701. * @retval None.
  702. */
  703. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  704. /**
  705. * @brief Disable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
  706. * @retval None.
  707. */
  708. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  709. /**
  710. * @brief Enable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  711. * @retval None.
  712. */
  713. #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();
  714. /**
  715. * @brief Disable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  716. * This parameter can be:
  717. * @retval None.
  718. */
  719. #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();
  720. /**
  721. * @brief Check whether the RTC Tamper and Timestamp associated Exti line interrupt flag is set or not.
  722. * @retval Line Status.
  723. */
  724. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  725. /**
  726. * @brief Clear the RTC Tamper and Timestamp associated Exti line flag.
  727. * @retval None.
  728. */
  729. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  730. /**
  731. * @brief Generate a Software interrupt on the RTC Tamper and Timestamp associated Exti line
  732. * @retval None.
  733. */
  734. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  735. /**
  736. * @}
  737. */
  738. /* Exported functions --------------------------------------------------------*/
  739. /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions
  740. * @{
  741. */
  742. /** @addtogroup RTCEx_Exported_Functions_Group1
  743. * @{
  744. */
  745. /* RTC TimeStamp and Tamper functions *****************************************/
  746. HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
  747. HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
  748. HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc);
  749. HAL_StatusTypeDef HAL_RTCEx_SetInternalTimeStamp(RTC_HandleTypeDef *hrtc);
  750. HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTimeStamp(RTC_HandleTypeDef *hrtc);
  751. HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format);
  752. HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper);
  753. HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper);
  754. HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper);
  755. void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc);
  756. void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc);
  757. void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc);
  758. void HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc);
  759. void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc);
  760. HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  761. HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  762. HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  763. HAL_StatusTypeDef HAL_RTCEx_PollForTamper3Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  764. /**
  765. * @}
  766. */
  767. /** @addtogroup RTCEx_Exported_Functions_Group2
  768. * @{
  769. */
  770. /* RTC Wake-up functions ******************************************************/
  771. HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
  772. HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
  773. uint32_t HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc);
  774. uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc);
  775. void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc);
  776. void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc);
  777. HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  778. /**
  779. * @}
  780. */
  781. /** @addtogroup RTCEx_Exported_Functions_Group3
  782. * @{
  783. */
  784. /* Extension Control functions ************************************************/
  785. void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data);
  786. uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister);
  787. HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmouthCalibMinusPulsesValue);
  788. HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS);
  789. HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput);
  790. HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc);
  791. HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc);
  792. HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc);
  793. HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc);
  794. HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc);
  795. /**
  796. * @}
  797. */
  798. /** @addtogroup RTCEx_Exported_Functions_Group4
  799. * @{
  800. */
  801. /* Extension RTC features functions *******************************************/
  802. void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc);
  803. HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  804. /**
  805. * @}
  806. */
  807. /**
  808. * @}
  809. */
  810. /* Private types -------------------------------------------------------------*/
  811. /* Private variables ---------------------------------------------------------*/
  812. /* Private constants ---------------------------------------------------------*/
  813. /** @defgroup RTCEx_Private_Constants RTCEx Private Constants
  814. * @{
  815. */
  816. #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 */
  817. #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT ((uint32_t)EXTI_IMR_MR22) /*!< External interrupt line 22 Connected to the RTC Wake-up event */
  818. /**
  819. * @}
  820. */
  821. /* Private constants ---------------------------------------------------------*/
  822. /** @defgroup RTCEx_Private_Constants RTCEx Private Constants
  823. * @{
  824. */
  825. /* Masks Definition */
  826. #define RTC_TAMPCR_TAMPXE ((uint32_t) (RTC_TAMPCR_TAMP3E | RTC_TAMPCR_TAMP2E | RTC_TAMPCR_TAMP1E))
  827. #define RTC_TAMPCR_TAMPXIE ((uint32_t) (RTC_TAMPER1_INTERRUPT | RTC_TAMPER2_INTERRUPT | RTC_TAMPER3_INTERRUPT))
  828. /**
  829. * @}
  830. */
  831. /* Private macros ------------------------------------------------------------*/
  832. /** @defgroup RTCEx_Private_Macros RTCEx Private Macros
  833. * @{
  834. */
  835. /** @defgroup RTCEx_IS_RTC_Definitions Private macros to check input parameters
  836. * @{
  837. */
  838. #define IS_RTC_OUTPUT(__OUTPUT__) (((__OUTPUT__) == RTC_OUTPUT_DISABLE) || \
  839. ((__OUTPUT__) == RTC_OUTPUT_ALARMA) || \
  840. ((__OUTPUT__) == RTC_OUTPUT_ALARMB) || \
  841. ((__OUTPUT__) == RTC_OUTPUT_WAKEUP))
  842. #define IS_RTC_BKP(__BKP__) ((__BKP__) < (uint32_t) RTC_BKP_NUMBER)
  843. #define IS_TIMESTAMP_EDGE(__EDGE__) (((__EDGE__) == RTC_TIMESTAMPEDGE_RISING) || \
  844. ((__EDGE__) == RTC_TIMESTAMPEDGE_FALLING))
  845. #define IS_RTC_TAMPER(__TAMPER__) ((((__TAMPER__) & ((uint32_t)(0xFFFFFFFF ^ RTC_TAMPCR_TAMPXE))) == 0x00) && ((__TAMPER__) != (uint32_t)RESET))
  846. #define IS_RTC_TAMPER_INTERRUPT(__INTERRUPT__) ((((__INTERRUPT__) & (uint32_t)(0xFFFFFFFF ^ RTC_TAMPCR_TAMPXIE)) == 0x00) && ((__INTERRUPT__) != (uint32_t)RESET))
  847. #define IS_RTC_TIMESTAMP_PIN(__PIN__) (((__PIN__) == RTC_TIMESTAMPPIN_DEFAULT) || \
  848. ((__PIN__) == RTC_TIMESTAMPPIN_POS1) || \
  849. ((__PIN__) == RTC_TIMESTAMPPIN_POS2))
  850. #define IS_RTC_TAMPER_TRIGGER(__TRIGGER__) (((__TRIGGER__) == RTC_TAMPERTRIGGER_RISINGEDGE) || \
  851. ((__TRIGGER__) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \
  852. ((__TRIGGER__) == RTC_TAMPERTRIGGER_LOWLEVEL) || \
  853. ((__TRIGGER__) == RTC_TAMPERTRIGGER_HIGHLEVEL))
  854. #define IS_RTC_TAMPER_ERASE_MODE(__MODE__) (((__MODE__) == RTC_TAMPER_ERASE_BACKUP_ENABLE) || \
  855. ((__MODE__) == RTC_TAMPER_ERASE_BACKUP_DISABLE))
  856. #define IS_RTC_TAMPER_MASKFLAG_STATE(__STATE__) (((__STATE__) == RTC_TAMPERMASK_FLAG_ENABLE) || \
  857. ((__STATE__) == RTC_TAMPERMASK_FLAG_DISABLE))
  858. #define IS_RTC_TAMPER_FILTER(__FILTER__) (((__FILTER__) == RTC_TAMPERFILTER_DISABLE) || \
  859. ((__FILTER__) == RTC_TAMPERFILTER_2SAMPLE) || \
  860. ((__FILTER__) == RTC_TAMPERFILTER_4SAMPLE) || \
  861. ((__FILTER__) == RTC_TAMPERFILTER_8SAMPLE))
  862. #define IS_RTC_TAMPER_SAMPLING_FREQ(__FREQ__) (((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \
  863. ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \
  864. ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \
  865. ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \
  866. ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \
  867. ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \
  868. ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512) || \
  869. ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256))
  870. #define IS_RTC_TAMPER_PRECHARGE_DURATION(__DURATION__) (((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \
  871. ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \
  872. ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \
  873. ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK))
  874. #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(__DETECTION__) (((__DETECTION__) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \
  875. ((__DETECTION__) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE))
  876. #define IS_RTC_TAMPER_PULLUP_STATE(__STATE__) (((__STATE__) == RTC_TAMPER_PULLUP_ENABLE) || \
  877. ((__STATE__) == RTC_TAMPER_PULLUP_DISABLE))
  878. #define IS_RTC_WAKEUP_CLOCK(__CLOCK__) (((__CLOCK__) == RTC_WAKEUPCLOCK_RTCCLK_DIV16) || \
  879. ((__CLOCK__) == RTC_WAKEUPCLOCK_RTCCLK_DIV8) || \
  880. ((__CLOCK__) == RTC_WAKEUPCLOCK_RTCCLK_DIV4) || \
  881. ((__CLOCK__) == RTC_WAKEUPCLOCK_RTCCLK_DIV2) || \
  882. ((__CLOCK__) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \
  883. ((__CLOCK__) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS))
  884. #define IS_RTC_WAKEUP_COUNTER(__COUNTER__) ((__COUNTER__) <= 0xFFFF)
  885. #define IS_RTC_SMOOTH_CALIB_PERIOD(__PERIOD__) (((__PERIOD__) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \
  886. ((__PERIOD__) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \
  887. ((__PERIOD__) == RTC_SMOOTHCALIB_PERIOD_8SEC))
  888. #define IS_RTC_SMOOTH_CALIB_PLUS(__PLUS__) (((__PLUS__) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \
  889. ((__PLUS__) == RTC_SMOOTHCALIB_PLUSPULSES_RESET))
  890. #define IS_RTC_SMOOTH_CALIB_MINUS(__VALUE__) ((__VALUE__) <= 0x000001FF)
  891. #define IS_RTC_SHIFT_ADD1S(__SEL__) (((__SEL__) == RTC_SHIFTADD1S_RESET) || \
  892. ((__SEL__) == RTC_SHIFTADD1S_SET))
  893. #define IS_RTC_SHIFT_SUBFS(__FS__) ((__FS__) <= 0x00007FFF)
  894. #define IS_RTC_CALIB_OUTPUT(__OUTPUT__) (((__OUTPUT__) == RTC_CALIBOUTPUT_512HZ) || \
  895. ((__OUTPUT__) == RTC_CALIBOUTPUT_1HZ))
  896. /**
  897. * @}
  898. */
  899. /**
  900. * @}
  901. */
  902. /**
  903. * @}
  904. */
  905. /**
  906. * @}
  907. */
  908. #ifdef __cplusplus
  909. }
  910. #endif
  911. #endif /* __STM32F7xx_HAL_RTC_EX_H */
  912. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/