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.
 
 
 

1065 lines
45 KiB

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