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.
 
 
 

1095 lines
48 KiB

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