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.
 
 
 

1030 lines
44 KiB

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