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.
 
 
 

1006 lines
44 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_rtc_ex.h
  4. * @author MCD Application Team
  5. * @version V1.5.2
  6. * @date 22-September-2016
  7. * @brief Header file of RTC HAL Extension module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2016 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)0x00000000U)
  88. #define RTC_BKP_DR1 ((uint32_t)0x00000001U)
  89. #define RTC_BKP_DR2 ((uint32_t)0x00000002U)
  90. #define RTC_BKP_DR3 ((uint32_t)0x00000003U)
  91. #define RTC_BKP_DR4 ((uint32_t)0x00000004U)
  92. #define RTC_BKP_DR5 ((uint32_t)0x00000005U)
  93. #define RTC_BKP_DR6 ((uint32_t)0x00000006U)
  94. #define RTC_BKP_DR7 ((uint32_t)0x00000007U)
  95. #define RTC_BKP_DR8 ((uint32_t)0x00000008U)
  96. #define RTC_BKP_DR9 ((uint32_t)0x00000009U)
  97. #define RTC_BKP_DR10 ((uint32_t)0x0000000AU)
  98. #define RTC_BKP_DR11 ((uint32_t)0x0000000BU)
  99. #define RTC_BKP_DR12 ((uint32_t)0x0000000CU)
  100. #define RTC_BKP_DR13 ((uint32_t)0x0000000DU)
  101. #define RTC_BKP_DR14 ((uint32_t)0x0000000EU)
  102. #define RTC_BKP_DR15 ((uint32_t)0x0000000FU)
  103. #define RTC_BKP_DR16 ((uint32_t)0x00000010U)
  104. #define RTC_BKP_DR17 ((uint32_t)0x00000011U)
  105. #define RTC_BKP_DR18 ((uint32_t)0x00000012U)
  106. #define RTC_BKP_DR19 ((uint32_t)0x00000013U)
  107. /**
  108. * @}
  109. */
  110. /** @defgroup RTCEx_Time_Stamp_Edges_definitions RTC TimeStamp Edges Definitions
  111. * @{
  112. */
  113. #define RTC_TIMESTAMPEDGE_RISING ((uint32_t)0x00000000U)
  114. #define RTC_TIMESTAMPEDGE_FALLING ((uint32_t)0x00000008U)
  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_DEFAULT ((uint32_t)0x00000000U)
  130. #define RTC_TAMPERPIN_POS1 ((uint32_t)0x00010000U)
  131. /**
  132. * @}
  133. */
  134. /** @defgroup RTCEx_TimeStamp_Pin_Selection RTC TimeStamp Pins Selection
  135. * @{
  136. */
  137. #define RTC_TIMESTAMPPIN_DEFAULT ((uint32_t)0x00000000U)
  138. #define RTC_TIMESTAMPPIN_POS1 ((uint32_t)0x00020000U)
  139. /**
  140. * @}
  141. */
  142. /** @defgroup RTCEx_Tamper_Trigger_Definitions RTC Tamper Triggers Definitions
  143. * @{
  144. */
  145. #define RTC_TAMPERTRIGGER_RISINGEDGE ((uint32_t)0x00000000U)
  146. #define RTC_TAMPERTRIGGER_FALLINGEDGE ((uint32_t)0x00000002U)
  147. #define RTC_TAMPERTRIGGER_LOWLEVEL RTC_TAMPERTRIGGER_RISINGEDGE
  148. #define RTC_TAMPERTRIGGER_HIGHLEVEL RTC_TAMPERTRIGGER_FALLINGEDGE
  149. /**
  150. * @}
  151. */
  152. /** @defgroup RTCEx_Tamper_Filter_Definitions RTC Tamper Filter Definitions
  153. * @{
  154. */
  155. #define RTC_TAMPERFILTER_DISABLE ((uint32_t)0x00000000U) /*!< Tamper filter is disabled */
  156. #define RTC_TAMPERFILTER_2SAMPLE ((uint32_t)0x00000800U) /*!< Tamper is activated after 2
  157. consecutive samples at the active level */
  158. #define RTC_TAMPERFILTER_4SAMPLE ((uint32_t)0x00001000U) /*!< Tamper is activated after 4
  159. consecutive samples at the active level */
  160. #define RTC_TAMPERFILTER_8SAMPLE ((uint32_t)0x00001800U) /*!< Tamper is activated after 8
  161. consecutive samples at the active level. */
  162. /**
  163. * @}
  164. */
  165. /** @defgroup RTCEx_Tamper_Sampling_Frequencies_Definitions RTC Tamper Sampling Frequencies Definitions
  166. * @{
  167. */
  168. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768 ((uint32_t)0x00000000U) /*!< Each of the tamper inputs are sampled
  169. with a frequency = RTCCLK / 32768 */
  170. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384 ((uint32_t)0x00000100U) /*!< Each of the tamper inputs are sampled
  171. with a frequency = RTCCLK / 16384 */
  172. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192 ((uint32_t)0x00000200U) /*!< Each of the tamper inputs are sampled
  173. with a frequency = RTCCLK / 8192 */
  174. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096 ((uint32_t)0x00000300U) /*!< Each of the tamper inputs are sampled
  175. with a frequency = RTCCLK / 4096 */
  176. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048 ((uint32_t)0x00000400U) /*!< Each of the tamper inputs are sampled
  177. with a frequency = RTCCLK / 2048 */
  178. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024 ((uint32_t)0x00000500U) /*!< Each of the tamper inputs are sampled
  179. with a frequency = RTCCLK / 1024 */
  180. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512 ((uint32_t)0x00000600U) /*!< Each of the tamper inputs are sampled
  181. with a frequency = RTCCLK / 512 */
  182. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256 ((uint32_t)0x00000700U) /*!< Each of the tamper inputs are sampled
  183. with a frequency = RTCCLK / 256 */
  184. /**
  185. * @}
  186. */
  187. /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration_Definitions RTC Tamper Pin Precharge Duration Definitions
  188. * @{
  189. */
  190. #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK ((uint32_t)0x00000000U) /*!< Tamper pins are pre-charged before
  191. sampling during 1 RTCCLK cycle */
  192. #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK ((uint32_t)0x00002000U) /*!< Tamper pins are pre-charged before
  193. sampling during 2 RTCCLK cycles */
  194. #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK ((uint32_t)0x00004000U) /*!< Tamper pins are pre-charged before
  195. sampling during 4 RTCCLK cycles */
  196. #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK ((uint32_t)0x00006000U) /*!< Tamper pins are pre-charged before
  197. sampling during 8 RTCCLK cycles */
  198. /**
  199. * @}
  200. */
  201. /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection_Definitions RTC Tamper TimeStamp On Tamper Detection Definitions
  202. * @{
  203. */
  204. #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE ((uint32_t)RTC_TAFCR_TAMPTS) /*!< TimeStamp on Tamper Detection event saved */
  205. #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE ((uint32_t)0x00000000U) /*!< TimeStamp on Tamper Detection event is not saved */
  206. /**
  207. * @}
  208. */
  209. /** @defgroup RTCEx_Tamper_Pull_UP_Definitions RTC Tamper Pull Up Definitions
  210. * @{
  211. */
  212. #define RTC_TAMPER_PULLUP_ENABLE ((uint32_t)0x00000000U) /*!< TimeStamp on Tamper Detection event saved */
  213. #define RTC_TAMPER_PULLUP_DISABLE ((uint32_t)RTC_TAFCR_TAMPPUDIS) /*!< TimeStamp on Tamper Detection event is not saved */
  214. /**
  215. * @}
  216. */
  217. /** @defgroup RTCEx_Wakeup_Timer_Definitions RTC Wake-up Timer Definitions
  218. * @{
  219. */
  220. #define RTC_WAKEUPCLOCK_RTCCLK_DIV16 ((uint32_t)0x00000000U)
  221. #define RTC_WAKEUPCLOCK_RTCCLK_DIV8 ((uint32_t)0x00000001U)
  222. #define RTC_WAKEUPCLOCK_RTCCLK_DIV4 ((uint32_t)0x00000002U)
  223. #define RTC_WAKEUPCLOCK_RTCCLK_DIV2 ((uint32_t)0x00000003U)
  224. #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS ((uint32_t)0x00000004U)
  225. #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS ((uint32_t)0x00000006U)
  226. /**
  227. * @}
  228. */
  229. /** @defgroup RTCEx_Digital_Calibration_Definitions RTC Digital Calib Definitions
  230. * @{
  231. */
  232. #define RTC_CALIBSIGN_POSITIVE ((uint32_t)0x00000000U)
  233. #define RTC_CALIBSIGN_NEGATIVE ((uint32_t)0x00000080U)
  234. /**
  235. * @}
  236. */
  237. /** @defgroup RTCEx_Smooth_calib_period_Definitions RTC Smooth Calib Period Definitions
  238. * @{
  239. */
  240. #define RTC_SMOOTHCALIB_PERIOD_32SEC ((uint32_t)0x00000000U) /*!< If RTCCLK = 32768 Hz, Smooth calibration
  241. period is 32s, else 2exp20 RTCCLK seconds */
  242. #define RTC_SMOOTHCALIB_PERIOD_16SEC ((uint32_t)0x00002000U) /*!< If RTCCLK = 32768 Hz, Smooth calibration
  243. period is 16s, else 2exp19 RTCCLK seconds */
  244. #define RTC_SMOOTHCALIB_PERIOD_8SEC ((uint32_t)0x00004000U) /*!< If RTCCLK = 32768 Hz, Smooth calibration
  245. period is 8s, else 2exp18 RTCCLK seconds */
  246. /**
  247. * @}
  248. */
  249. /** @defgroup RTCEx_Smooth_calib_Plus_pulses_Definitions RTC Smooth Calib Plus Pulses Definitions
  250. * @{
  251. */
  252. #define RTC_SMOOTHCALIB_PLUSPULSES_SET ((uint32_t)0x00008000U) /*!< The number of RTCCLK pulses added
  253. during a X -second window = Y - CALM[8:0]
  254. with Y = 512, 256, 128 when X = 32, 16, 8 */
  255. #define RTC_SMOOTHCALIB_PLUSPULSES_RESET ((uint32_t)0x00000000U) /*!< The number of RTCCLK pulses subbstited
  256. during a 32-second window = CALM[8:0] */
  257. /**
  258. * @}
  259. */
  260. /** @defgroup RTCEx_Add_1_Second_Parameter_Definitions RTC Add 1 Second Parameter Definitions
  261. * @{
  262. */
  263. #define RTC_SHIFTADD1S_RESET ((uint32_t)0x00000000U)
  264. #define RTC_SHIFTADD1S_SET ((uint32_t)0x80000000U)
  265. /**
  266. * @}
  267. */
  268. /** @defgroup RTCEx_Calib_Output_selection_Definitions RTC Calib Output Selection Definitions
  269. * @{
  270. */
  271. #define RTC_CALIBOUTPUT_512HZ ((uint32_t)0x00000000U)
  272. #define RTC_CALIBOUTPUT_1HZ ((uint32_t)0x00080000U)
  273. /**
  274. * @}
  275. */
  276. /**
  277. * @}
  278. */
  279. /* Exported macro ------------------------------------------------------------*/
  280. /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros
  281. * @{
  282. */
  283. /* ---------------------------------WAKEUPTIMER---------------------------------*/
  284. /** @defgroup RTCEx_WakeUp_Timer RTC WakeUp Timer
  285. * @{
  286. */
  287. /**
  288. * @brief Enable the RTC WakeUp Timer peripheral.
  289. * @param __HANDLE__: specifies the RTC handle.
  290. * @retval None
  291. */
  292. #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_WUTE))
  293. /**
  294. * @brief Disable the RTC Wake-up Timer peripheral.
  295. * @param __HANDLE__: specifies the RTC handle.
  296. * @retval None
  297. */
  298. #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_WUTE))
  299. /**
  300. * @brief Enable the RTC WakeUpTimer interrupt.
  301. * @param __HANDLE__: specifies the RTC handle.
  302. * @param __INTERRUPT__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled.
  303. * This parameter can be:
  304. * @arg RTC_IT_WUT: WakeUpTimer A interrupt
  305. * @retval None
  306. */
  307. #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  308. /**
  309. * @brief Disable the RTC WakeUpTimer interrupt.
  310. * @param __HANDLE__: specifies the RTC handle.
  311. * @param __INTERRUPT__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled.
  312. * This parameter can be:
  313. * @arg RTC_IT_WUT: WakeUpTimer A interrupt
  314. * @retval None
  315. */
  316. #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  317. /**
  318. * @brief Check whether the specified RTC WakeUpTimer interrupt has occurred or not.
  319. * @param __HANDLE__: specifies the RTC handle.
  320. * @param __INTERRUPT__: specifies the RTC WakeUpTimer interrupt to check.
  321. * This parameter can be:
  322. * @arg RTC_IT_WUT: WakeUpTimer A interrupt
  323. * @retval None
  324. */
  325. #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 4U)) != RESET)? SET : RESET)
  326. /**
  327. * @brief Check whether the specified RTC Wake Up timer interrupt has been enabled or not.
  328. * @param __HANDLE__: specifies the RTC handle.
  329. * @param __INTERRUPT__: specifies the RTC Wake Up timer interrupt sources to check.
  330. * This parameter can be:
  331. * @arg RTC_IT_WUT: WakeUpTimer interrupt
  332. * @retval None
  333. */
  334. #define __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
  335. /**
  336. * @brief Get the selected RTC WakeUpTimer's flag status.
  337. * @param __HANDLE__: specifies the RTC handle.
  338. * @param __FLAG__: specifies the RTC WakeUpTimer Flag to check.
  339. * This parameter can be:
  340. * @arg RTC_FLAG_WUTF
  341. * @arg RTC_FLAG_WUTWF
  342. * @retval None
  343. */
  344. #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
  345. /**
  346. * @brief Clear the RTC Wake Up timer's pending flags.
  347. * @param __HANDLE__: specifies the RTC handle.
  348. * @param __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled.
  349. * This parameter can be:
  350. * @arg RTC_FLAG_WUTF
  351. * @retval None
  352. */
  353. #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  354. /**
  355. * @brief Enable interrupt on the RTC Wake-up Timer associated Exti line.
  356. * @retval None
  357. */
  358. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  359. /**
  360. * @brief Disable interrupt on the RTC Wake-up Timer associated Exti line.
  361. * @retval None
  362. */
  363. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  364. /**
  365. * @brief Enable event on the RTC Wake-up Timer associated Exti line.
  366. * @retval None.
  367. */
  368. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  369. /**
  370. * @brief Disable event on the RTC Wake-up Timer associated Exti line.
  371. * @retval None.
  372. */
  373. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  374. /**
  375. * @brief Enable falling edge trigger on the RTC Wake-up Timer associated Exti line.
  376. * @retval None.
  377. */
  378. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  379. /**
  380. * @brief Disable falling edge trigger on the RTC Wake-up Timer associated Exti line.
  381. * @retval None.
  382. */
  383. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  384. /**
  385. * @brief Enable rising edge trigger on the RTC Wake-up Timer associated Exti line.
  386. * @retval None.
  387. */
  388. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  389. /**
  390. * @brief Disable rising edge trigger on the RTC Wake-up Timer associated Exti line.
  391. * @retval None.
  392. */
  393. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  394. /**
  395. * @brief Enable rising & falling edge trigger on the RTC Wake-up Timer associated Exti line.
  396. * @retval None.
  397. */
  398. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_FALLING_EDGE() do { __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE();\
  399. __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE();\
  400. } while(0)
  401. /**
  402. * @brief Disable rising & falling edge trigger on the RTC Wake-up Timer associated Exti line.
  403. * This parameter can be:
  404. * @retval None.
  405. */
  406. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_FALLING_EDGE() do { __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE();\
  407. __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE();\
  408. } while(0)
  409. /**
  410. * @brief Check whether the RTC Wake-up Timer associated Exti line interrupt flag is set or not.
  411. * @retval Line Status.
  412. */
  413. #define __HAL_RTC_WAKEUPTIMER_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  414. /**
  415. * @brief Clear the RTC Wake-up Timer associated Exti line flag.
  416. * @retval None.
  417. */
  418. #define __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  419. /**
  420. * @brief Generate a Software interrupt on the RTC Wake-up Timer associated Exti line.
  421. * @retval None.
  422. */
  423. #define __HAL_RTC_WAKEUPTIMER_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  424. /**
  425. * @}
  426. */
  427. /* ---------------------------------TIMESTAMP---------------------------------*/
  428. /** @defgroup RTCEx_Timestamp RTC Timestamp
  429. * @{
  430. */
  431. /**
  432. * @brief Enable the RTC TimeStamp peripheral.
  433. * @param __HANDLE__: specifies the RTC handle.
  434. * @retval None
  435. */
  436. #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TSE))
  437. /**
  438. * @brief Disable the RTC TimeStamp peripheral.
  439. * @param __HANDLE__: specifies the RTC handle.
  440. * @retval None
  441. */
  442. #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TSE))
  443. /**
  444. * @brief Enable the RTC TimeStamp interrupt.
  445. * @param __HANDLE__: specifies the RTC handle.
  446. * @param __INTERRUPT__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled.
  447. * This parameter can be:
  448. * @arg RTC_IT_TS: TimeStamp interrupt
  449. * @retval None
  450. */
  451. #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  452. /**
  453. * @brief Disable the RTC TimeStamp interrupt.
  454. * @param __HANDLE__: specifies the RTC handle.
  455. * @param __INTERRUPT__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled.
  456. * This parameter can be:
  457. * @arg RTC_IT_TS: TimeStamp interrupt
  458. * @retval None
  459. */
  460. #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  461. /**
  462. * @brief Check whether the specified RTC TimeStamp interrupt has occurred or not.
  463. * @param __HANDLE__: specifies the RTC handle.
  464. * @param __INTERRUPT__: specifies the RTC TimeStamp interrupt to check.
  465. * This parameter can be:
  466. * @arg RTC_IT_TS: TimeStamp interrupt
  467. * @retval None
  468. */
  469. #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 4U)) != RESET)? SET : RESET)
  470. /**
  471. * @brief Check whether the specified RTC Time Stamp interrupt has been enabled or not.
  472. * @param __HANDLE__: specifies the RTC handle.
  473. * @param __INTERRUPT__: specifies the RTC Time Stamp interrupt source to check.
  474. * This parameter can be:
  475. * @arg RTC_IT_TS: TimeStamp interrupt
  476. * @retval None
  477. */
  478. #define __HAL_RTC_TIMESTAMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
  479. /**
  480. * @brief Get the selected RTC TimeStamp's flag status.
  481. * @param __HANDLE__: specifies the RTC handle.
  482. * @param __FLAG__: specifies the RTC TimeStamp flag to check.
  483. * This parameter can be:
  484. * @arg RTC_FLAG_TSF
  485. * @arg RTC_FLAG_TSOVF
  486. * @retval None
  487. */
  488. #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
  489. /**
  490. * @brief Clear the RTC Time Stamp's pending flags.
  491. * @param __HANDLE__: specifies the RTC handle.
  492. * @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled.
  493. * This parameter can be:
  494. * @arg RTC_FLAG_TSF
  495. * @retval None
  496. */
  497. #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  498. /**
  499. * @}
  500. */
  501. /* ---------------------------------TAMPER------------------------------------*/
  502. /** @defgroup RTCEx_Tamper RTC Tamper
  503. * @{
  504. */
  505. /**
  506. * @brief Enable the RTC Tamper1 input detection.
  507. * @param __HANDLE__: specifies the RTC handle.
  508. * @retval None
  509. */
  510. #define __HAL_RTC_TAMPER1_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAFCR |= (RTC_TAFCR_TAMP1E))
  511. /**
  512. * @brief Disable the RTC Tamper1 input detection.
  513. * @param __HANDLE__: specifies the RTC handle.
  514. * @retval None
  515. */
  516. #define __HAL_RTC_TAMPER1_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAFCR &= ~(RTC_TAFCR_TAMP1E))
  517. /**
  518. * @brief Enable the RTC Tamper2 input detection.
  519. * @param __HANDLE__: specifies the RTC handle.
  520. * @retval None
  521. */
  522. #define __HAL_RTC_TAMPER2_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAFCR |= (RTC_TAFCR_TAMP2E))
  523. /**
  524. * @brief Disable the RTC Tamper2 input detection.
  525. * @param __HANDLE__: specifies the RTC handle.
  526. * @retval None
  527. */
  528. #define __HAL_RTC_TAMPER2_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAFCR &= ~(RTC_TAFCR_TAMP2E))
  529. /**
  530. * @brief Check whether the specified RTC Tamper interrupt has occurred or not.
  531. * @param __HANDLE__: specifies the RTC handle.
  532. * @param __INTERRUPT__: specifies the RTC Tamper interrupt to check.
  533. * This parameter can be:
  534. * @arg RTC_IT_TAMP1
  535. * @arg RTC_IT_TAMP2
  536. * @retval None
  537. */
  538. #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 4U)) != RESET)? SET : RESET)
  539. /**
  540. * @brief Check whether the specified RTC Tamper interrupt has been enabled or not.
  541. * @param __HANDLE__: specifies the RTC handle.
  542. * @param __INTERRUPT__: specifies the RTC Tamper interrupt source to check.
  543. * This parameter can be:
  544. * @arg RTC_IT_TAMP: Tamper interrupt
  545. * @retval None
  546. */
  547. #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->TAFCR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
  548. /**
  549. * @brief Get the selected RTC Tamper's flag status.
  550. * @param __HANDLE__: specifies the RTC handle.
  551. * @param __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled.
  552. * This parameter can be:
  553. * @arg RTC_FLAG_TAMP1F
  554. * @arg RTC_FLAG_TAMP2F
  555. * @retval None
  556. */
  557. #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
  558. /**
  559. * @brief Clear the RTC Tamper's pending flags.
  560. * @param __HANDLE__: specifies the RTC handle.
  561. * @param __FLAG__: specifies the RTC Tamper Flag to clear.
  562. * This parameter can be:
  563. * @arg RTC_FLAG_TAMP1F
  564. * @arg RTC_FLAG_TAMP2F
  565. * @retval None
  566. */
  567. #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  568. /**
  569. * @}
  570. */
  571. /* --------------------------TAMPER/TIMESTAMP---------------------------------*/
  572. /** @defgroup RTCEx_Tamper_Timestamp EXTI RTC Tamper Timestamp EXTI
  573. * @{
  574. */
  575. /**
  576. * @brief Enable interrupt on the RTC Tamper and Timestamp associated Exti line.
  577. * @retval None
  578. */
  579. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  580. /**
  581. * @brief Disable interrupt on the RTC Tamper and Timestamp associated Exti line.
  582. * @retval None
  583. */
  584. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_IT() (EXTI->IMR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  585. /**
  586. * @brief Enable event on the RTC Tamper and Timestamp associated Exti line.
  587. * @retval None.
  588. */
  589. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  590. /**
  591. * @brief Disable event on the RTC Tamper and Timestamp associated Exti line.
  592. * @retval None.
  593. */
  594. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  595. /**
  596. * @brief Enable falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  597. * @retval None.
  598. */
  599. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  600. /**
  601. * @brief Disable falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  602. * @retval None.
  603. */
  604. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  605. /**
  606. * @brief Enable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
  607. * @retval None.
  608. */
  609. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  610. /**
  611. * @brief Disable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
  612. * @retval None.
  613. */
  614. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  615. /**
  616. * @brief Enable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  617. * @retval None.
  618. */
  619. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_FALLING_EDGE() do { __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE();\
  620. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE(); \
  621. } while(0)
  622. /**
  623. * @brief Disable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  624. * This parameter can be:
  625. * @retval None.
  626. */
  627. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_FALLING_EDGE() do { __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE();\
  628. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE();\
  629. } while(0)
  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_TAMPER_TIMESTAMP_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)!(RTC_TAFCR_TAMP1E | RTC_TAFCR_TAMP2E))) == 0x00U) && ((TAMPER) != (uint32_t)RESET))
  814. #define IS_RTC_TAMPER_PIN(PIN) (((PIN) == RTC_TAMPERPIN_DEFAULT) || \
  815. ((PIN) == RTC_TAMPERPIN_POS1))
  816. #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TIMESTAMPPIN_DEFAULT) || \
  817. ((PIN) == RTC_TIMESTAMPPIN_POS1))
  818. #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) || \
  819. ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \
  820. ((TRIGGER) == RTC_TAMPERTRIGGER_LOWLEVEL) || \
  821. ((TRIGGER) == RTC_TAMPERTRIGGER_HIGHLEVEL))
  822. #define IS_RTC_TAMPER_FILTER(FILTER) (((FILTER) == RTC_TAMPERFILTER_DISABLE) || \
  823. ((FILTER) == RTC_TAMPERFILTER_2SAMPLE) || \
  824. ((FILTER) == RTC_TAMPERFILTER_4SAMPLE) || \
  825. ((FILTER) == RTC_TAMPERFILTER_8SAMPLE))
  826. #define IS_RTC_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \
  827. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \
  828. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \
  829. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \
  830. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \
  831. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \
  832. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512) || \
  833. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256))
  834. #define IS_RTC_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \
  835. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \
  836. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \
  837. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK))
  838. #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \
  839. ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE))
  840. #define IS_RTC_TAMPER_PULLUP_STATE(STATE) (((STATE) == RTC_TAMPER_PULLUP_ENABLE) || \
  841. ((STATE) == RTC_TAMPER_PULLUP_DISABLE))
  842. #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16) || \
  843. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8) || \
  844. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4) || \
  845. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2) || \
  846. ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \
  847. ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS))
  848. #define IS_RTC_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= 0xFFFFU)
  849. #define IS_RTC_CALIB_SIGN(SIGN) (((SIGN) == RTC_CALIBSIGN_POSITIVE) || \
  850. ((SIGN) == RTC_CALIBSIGN_NEGATIVE))
  851. #define IS_RTC_CALIB_VALUE(VALUE) ((VALUE) < 0x20U)
  852. #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \
  853. ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \
  854. ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC))
  855. #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \
  856. ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET))
  857. #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= 0x000001FFU)
  858. #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \
  859. ((SEL) == RTC_SHIFTADD1S_SET))
  860. #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= 0x00007FFFU)
  861. #define IS_RTC_CALIB_OUTPUT(OUTPUT) (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \
  862. ((OUTPUT) == RTC_CALIBOUTPUT_1HZ))
  863. /**
  864. * @}
  865. */
  866. /**
  867. * @}
  868. */
  869. /**
  870. * @}
  871. */
  872. /**
  873. * @}
  874. */
  875. #ifdef __cplusplus
  876. }
  877. #endif
  878. #endif /* __STM32F4xx_HAL_RTC_EX_H */
  879. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/