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.
 
 
 

1103 lines
48 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_hal_rtc_ex.h
  4. * @author MCD Application Team
  5. * @version V1.7.2
  6. * @date 16-June-2017
  7. * @brief Header file of RTC HAL Extended module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __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. #if defined(RTC_TAMPER1_SUPPORT)
  395. /**
  396. * @brief Enable the RTC Tamper1 input detection.
  397. * @param __HANDLE__: specifies the RTC handle.
  398. * @retval None
  399. */
  400. #define __HAL_RTC_TAMPER1_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR |= (RTC_TAMPCR_TAMP1E))
  401. /**
  402. * @brief Disable the RTC Tamper1 input detection.
  403. * @param __HANDLE__: specifies the RTC handle.
  404. * @retval None
  405. */
  406. #define __HAL_RTC_TAMPER1_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR &= ~(RTC_TAMPCR_TAMP1E))
  407. #endif /* RTC_TAMPER1_SUPPORT */
  408. /**
  409. * @brief Enable the RTC Tamper2 input detection.
  410. * @param __HANDLE__: specifies the RTC handle.
  411. * @retval None
  412. */
  413. #define __HAL_RTC_TAMPER2_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR |= (RTC_TAMPCR_TAMP2E))
  414. /**
  415. * @brief Disable the RTC Tamper2 input detection.
  416. * @param __HANDLE__: specifies the RTC handle.
  417. * @retval None
  418. */
  419. #define __HAL_RTC_TAMPER2_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR &= ~(RTC_TAMPCR_TAMP2E))
  420. #if defined(RTC_TAMPER3_SUPPORT)
  421. /**
  422. * @brief Enable the RTC Tamper3 input detection.
  423. * @param __HANDLE__: specifies the RTC handle.
  424. * @retval None
  425. */
  426. #define __HAL_RTC_TAMPER3_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR |= (RTC_TAMPCR_TAMP3E))
  427. /**
  428. * @brief Disable the RTC Tamper3 input detection.
  429. * @param __HANDLE__: specifies the RTC handle.
  430. * @retval None
  431. */
  432. #define __HAL_RTC_TAMPER3_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR &= ~(RTC_TAMPCR_TAMP3E))
  433. #endif /* RTC_TAMPER3_SUPPORT */
  434. /**
  435. * @brief Enable the RTC Tamper interrupt.
  436. * @param __HANDLE__: specifies the RTC handle.
  437. * @param __INTERRUPT__: specifies the RTC Tamper interrupt sources to be enabled.
  438. * This parameter can be any combination of the following values:
  439. * @arg RTC_IT_TAMP: All tampers interrupts
  440. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  441. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  442. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  443. * @retval None
  444. */
  445. #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->TAMPCR |= (__INTERRUPT__))
  446. /**
  447. * @brief Disable the RTC Tamper interrupt.
  448. * @param __HANDLE__: specifies the RTC handle.
  449. * @param __INTERRUPT__: specifies the RTC Tamper interrupt sources to be disabled.
  450. * This parameter can be any combination of the following values:
  451. * @arg RTC_IT_TAMP: All tampers interrupts
  452. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  453. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  454. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  455. * @retval None
  456. */
  457. #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->TAMPCR &= ~(__INTERRUPT__))
  458. /**
  459. * @brief Check whether the specified RTC Tamper interrupt has occurred or not.
  460. * @param __HANDLE__: specifies the RTC handle.
  461. * @param __INTERRUPT__: specifies the RTC Tamper interrupt to check.
  462. * This parameter can be:
  463. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  464. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  465. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  466. * @retval None
  467. */
  468. #if defined(RTC_TAMPER1_SUPPORT) && defined(RTC_TAMPER3_SUPPORT)
  469. #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) == RTC_IT_TAMP1) ? (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 3)) != RESET) ? SET : RESET) : \
  470. ((__INTERRUPT__) == RTC_IT_TAMP2) ? (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 5)) != RESET) ? SET : RESET) : \
  471. (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 7)) != RESET) ? SET : RESET))
  472. #else
  473. #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 5)) != RESET) ? SET : RESET)
  474. #endif /* RTC_TAMPER1_SUPPORT && RTC_TAMPER3_SUPPORT */
  475. /**
  476. * @brief Check whether the specified RTC Tamper interrupt is enabled or not.
  477. * @param __HANDLE__: specifies the RTC handle.
  478. * @param __INTERRUPT__: specifies the RTC Tamper interrupt source to check.
  479. * This parameter can be:
  480. * @arg RTC_IT_TAMP: All tampers interrupts
  481. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  482. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  483. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  484. * @retval None
  485. */
  486. #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->TAMPCR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
  487. /**
  488. * @brief Get the selected RTC Tamper's flag status.
  489. * @param __HANDLE__: specifies the RTC handle.
  490. * @param __FLAG__: specifies the RTC Tamper Flag is pending or not.
  491. * This parameter can be:
  492. * @arg RTC_FLAG_TAMP1F: Tamper1 flag
  493. * @arg RTC_FLAG_TAMP2F: Tamper2 flag
  494. * @arg RTC_FLAG_TAMP3F: Tamper3 flag
  495. * @retval None
  496. */
  497. #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET) ? SET : RESET)
  498. /**
  499. * @brief Clear the RTC Tamper's pending flags.
  500. * @param __HANDLE__: specifies the RTC handle.
  501. * @param __FLAG__: specifies the RTC Tamper Flag sources to clear.
  502. * This parameter can be:
  503. * @arg RTC_FLAG_TAMP1F: Tamper1 flag
  504. * @arg RTC_FLAG_TAMP2F: Tamper2 flag
  505. * @arg RTC_FLAG_TAMP3F: Tamper3 flag
  506. * @retval None
  507. */
  508. #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  509. /**
  510. * @brief Enable the RTC TimeStamp peripheral.
  511. * @param __HANDLE__: specifies the RTC handle.
  512. * @retval None
  513. */
  514. #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TSE))
  515. /**
  516. * @brief Disable the RTC TimeStamp peripheral.
  517. * @param __HANDLE__: specifies the RTC handle.
  518. * @retval None
  519. */
  520. #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TSE))
  521. /**
  522. * @brief Enable the RTC TimeStamp interrupt.
  523. * @param __HANDLE__: specifies the RTC handle.
  524. * @param __INTERRUPT__: specifies the RTC TimeStamp interrupt source to be enabled.
  525. * This parameter can be:
  526. * @arg RTC_IT_TS: TimeStamp interrupt
  527. * @retval None
  528. */
  529. #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  530. /**
  531. * @brief Disable the RTC TimeStamp interrupt.
  532. * @param __HANDLE__: specifies the RTC handle.
  533. * @param __INTERRUPT__: specifies the RTC TimeStamp interrupt source to be disabled.
  534. * This parameter can be:
  535. * @arg RTC_IT_TS: TimeStamp interrupt
  536. * @retval None
  537. */
  538. #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  539. /**
  540. * @brief Check whether the specified RTC TimeStamp interrupt has occurred or not.
  541. * @param __HANDLE__: specifies the RTC handle.
  542. * @param __INTERRUPT__: specifies the RTC TimeStamp interrupt source to check.
  543. * This parameter can be:
  544. * @arg RTC_IT_TS: TimeStamp interrupt
  545. * @retval None
  546. */
  547. #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 4)) != RESET) ? SET : RESET)
  548. /**
  549. * @brief Check whether the specified RTC Time Stamp interrupt is enabled or not.
  550. * @param __HANDLE__: specifies the RTC handle.
  551. * @param __INTERRUPT__: specifies the RTC Time Stamp interrupt source to check.
  552. * This parameter can be:
  553. * @arg RTC_IT_TS: TimeStamp interrupt
  554. * @retval None
  555. */
  556. #define __HAL_RTC_TIMESTAMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
  557. /**
  558. * @brief Get the selected RTC TimeStamp's flag status.
  559. * @param __HANDLE__: specifies the RTC handle.
  560. * @param __FLAG__: specifies the RTC TimeStamp Flag is pending or not.
  561. * This parameter can be:
  562. * @arg RTC_FLAG_TSF
  563. * @arg RTC_FLAG_TSOVF
  564. * @retval None
  565. */
  566. #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET) ? SET : RESET)
  567. /**
  568. * @brief Clear the RTC Time Stamp's pending flags.
  569. * @param __HANDLE__: specifies the RTC handle.
  570. * @param __FLAG__: specifies the RTC Alarm Flag sources to clear.
  571. * This parameter can be:
  572. * @arg RTC_FLAG_TSF
  573. * @arg RTC_FLAG_TSOVF
  574. * @retval None
  575. */
  576. #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  577. /**
  578. * @brief Enable the RTC internal TimeStamp peripheral.
  579. * @param __HANDLE__: specifies the RTC handle.
  580. * @retval None
  581. */
  582. #define __HAL_RTC_INTERNAL_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ITSE))
  583. /**
  584. * @brief Disable the RTC internal TimeStamp peripheral.
  585. * @param __HANDLE__: specifies the RTC handle.
  586. * @retval None
  587. */
  588. #define __HAL_RTC_INTERNAL_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ITSE))
  589. /**
  590. * @brief Get the selected RTC Internal Time Stamp's flag status.
  591. * @param __HANDLE__: specifies the RTC handle.
  592. * @param __FLAG__: specifies the RTC Internal Time Stamp Flag is pending or not.
  593. * This parameter can be:
  594. * @arg RTC_FLAG_ITSF
  595. * @retval None
  596. */
  597. #define __HAL_RTC_INTERNAL_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET) ? SET : RESET)
  598. /**
  599. * @brief Clear the RTC Internal Time Stamp's pending flags.
  600. * @param __HANDLE__: specifies the RTC handle.
  601. * @param __FLAG__: specifies the RTC Internal Time Stamp Flag source to clear.
  602. * This parameter can be:
  603. * @arg RTC_FLAG_ITSF
  604. * @retval None
  605. */
  606. #define __HAL_RTC_INTERNAL_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  607. /**
  608. * @brief Enable the RTC calibration output.
  609. * @param __HANDLE__: specifies the RTC handle.
  610. * @retval None
  611. */
  612. #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_COE))
  613. /**
  614. * @brief Disable the calibration output.
  615. * @param __HANDLE__: specifies the RTC handle.
  616. * @retval None
  617. */
  618. #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_COE))
  619. /**
  620. * @brief Enable the clock reference detection.
  621. * @param __HANDLE__: specifies the RTC handle.
  622. * @retval None
  623. */
  624. #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_REFCKON))
  625. /**
  626. * @brief Disable the clock reference detection.
  627. * @param __HANDLE__: specifies the RTC handle.
  628. * @retval None
  629. */
  630. #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_REFCKON))
  631. /**
  632. * @brief Get the selected RTC shift operation's flag status.
  633. * @param __HANDLE__: specifies the RTC handle.
  634. * @param __FLAG__: specifies the RTC shift operation Flag is pending or not.
  635. * This parameter can be:
  636. * @arg RTC_FLAG_SHPF
  637. * @retval None
  638. */
  639. #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET) ? SET : RESET)
  640. /**
  641. * @brief Enable interrupt on the RTC WakeUp Timer associated Exti line.
  642. * @retval None
  643. */
  644. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  645. /**
  646. * @brief Disable interrupt on the RTC WakeUp Timer associated Exti line.
  647. * @retval None
  648. */
  649. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  650. /**
  651. * @brief Enable event on the RTC WakeUp Timer associated Exti line.
  652. * @retval None
  653. */
  654. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  655. /**
  656. * @brief Disable event on the RTC WakeUp Timer associated Exti line.
  657. * @retval None
  658. */
  659. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  660. /**
  661. * @brief Enable falling edge trigger on the RTC WakeUp Timer associated Exti line.
  662. * @retval None
  663. */
  664. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  665. /**
  666. * @brief Disable falling edge trigger on the RTC WakeUp Timer associated Exti line.
  667. * @retval None
  668. */
  669. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  670. /**
  671. * @brief Enable rising edge trigger on the RTC WakeUp Timer associated Exti line.
  672. * @retval None
  673. */
  674. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  675. /**
  676. * @brief Disable rising edge trigger on the RTC WakeUp Timer associated Exti line.
  677. * @retval None
  678. */
  679. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  680. /**
  681. * @brief Enable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line.
  682. * @retval None
  683. */
  684. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  685. __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE(); \
  686. __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE(); \
  687. } while(0)
  688. /**
  689. * @brief Disable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line.
  690. * This parameter can be:
  691. * @retval None
  692. */
  693. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  694. __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE(); \
  695. __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE(); \
  696. } while(0)
  697. /**
  698. * @brief Check whether the RTC WakeUp Timer associated Exti line interrupt flag is set or not.
  699. * @retval Line Status.
  700. */
  701. #define __HAL_RTC_WAKEUPTIMER_EXTI_GET_FLAG() (EXTI->PR1 & RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  702. /**
  703. * @brief Clear the RTC WakeUp Timer associated Exti line flag.
  704. * @retval None
  705. */
  706. #define __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG() (EXTI->PR1 = RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  707. /**
  708. * @brief Generate a Software interrupt on the RTC WakeUp Timer associated Exti line.
  709. * @retval None
  710. */
  711. #define __HAL_RTC_WAKEUPTIMER_EXTI_GENERATE_SWIT() (EXTI->SWIER1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  712. /**
  713. * @brief Enable interrupt on the RTC Tamper and Timestamp associated Exti line.
  714. * @retval None
  715. */
  716. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  717. /**
  718. * @brief Disable interrupt on the RTC Tamper and Timestamp associated Exti line.
  719. * @retval None
  720. */
  721. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  722. /**
  723. * @brief Enable event on the RTC Tamper and Timestamp associated Exti line.
  724. * @retval None
  725. */
  726. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  727. /**
  728. * @brief Disable event on the RTC Tamper and Timestamp associated Exti line.
  729. * @retval None
  730. */
  731. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  732. /**
  733. * @brief Enable falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  734. * @retval None
  735. */
  736. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  737. /**
  738. * @brief Disable falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  739. * @retval None
  740. */
  741. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  742. /**
  743. * @brief Enable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
  744. * @retval None
  745. */
  746. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  747. /**
  748. * @brief Disable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
  749. * @retval None
  750. */
  751. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  752. /**
  753. * @brief Enable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  754. * @retval None
  755. */
  756. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  757. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE(); \
  758. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE(); \
  759. } while(0)
  760. /**
  761. * @brief Disable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  762. * This parameter can be:
  763. * @retval None
  764. */
  765. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  766. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE(); \
  767. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE(); \
  768. } while(0)
  769. /**
  770. * @brief Check whether the RTC Tamper and Timestamp associated Exti line interrupt flag is set or not.
  771. * @retval Line Status.
  772. */
  773. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GET_FLAG() (EXTI->PR1 & RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  774. /**
  775. * @brief Clear the RTC Tamper and Timestamp associated Exti line flag.
  776. * @retval None
  777. */
  778. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_CLEAR_FLAG() (EXTI->PR1 = RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  779. /**
  780. * @brief Generate a Software interrupt on the RTC Tamper and Timestamp associated Exti line
  781. * @retval None
  782. */
  783. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GENERATE_SWIT() (EXTI->SWIER1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  784. /**
  785. * @}
  786. */
  787. /* Exported functions --------------------------------------------------------*/
  788. /** @addtogroup RTCEx_Exported_Functions
  789. * @{
  790. */
  791. /* RTC TimeStamp and Tamper functions *****************************************/
  792. /** @addtogroup RTCEx_Exported_Functions_Group1
  793. * @{
  794. */
  795. HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
  796. HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
  797. HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc);
  798. HAL_StatusTypeDef HAL_RTCEx_SetInternalTimeStamp(RTC_HandleTypeDef *hrtc);
  799. HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTimeStamp(RTC_HandleTypeDef *hrtc);
  800. HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format);
  801. HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper);
  802. HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper);
  803. HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper);
  804. void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc);
  805. #if defined(RTC_TAMPER1_SUPPORT)
  806. void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc);
  807. #endif /* RTC_TAMPER1_SUPPORT */
  808. void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc);
  809. #if defined(RTC_TAMPER3_SUPPORT)
  810. void HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc);
  811. #endif /* RTC_TAMPER3_SUPPORT */
  812. void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc);
  813. HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  814. #if defined(RTC_TAMPER1_SUPPORT)
  815. HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  816. #endif /* RTC_TAMPER1_SUPPORT */
  817. HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  818. #if defined(RTC_TAMPER3_SUPPORT)
  819. HAL_StatusTypeDef HAL_RTCEx_PollForTamper3Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  820. #endif /* RTC_TAMPER3_SUPPORT */
  821. /**
  822. * @}
  823. */
  824. /* RTC Wake-up functions ******************************************************/
  825. /** @addtogroup RTCEx_Exported_Functions_Group2
  826. * @{
  827. */
  828. HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
  829. HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
  830. uint32_t HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc);
  831. uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc);
  832. void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc);
  833. void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc);
  834. HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  835. /**
  836. * @}
  837. */
  838. /* Extended Control functions ************************************************/
  839. /** @addtogroup RTCEx_Exported_Functions_Group3
  840. * @{
  841. */
  842. void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data);
  843. uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister);
  844. HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue);
  845. HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS);
  846. HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput);
  847. HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc);
  848. HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc);
  849. HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc);
  850. HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc);
  851. HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc);
  852. /**
  853. * @}
  854. */
  855. /* Extended RTC features functions *******************************************/
  856. /** @addtogroup RTCEx_Exported_Functions_Group4
  857. * @{
  858. */
  859. void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc);
  860. HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  861. /**
  862. * @}
  863. */
  864. /**
  865. * @}
  866. */
  867. /* Private types -------------------------------------------------------------*/
  868. /* Private variables ---------------------------------------------------------*/
  869. /* Private constants ---------------------------------------------------------*/
  870. /** @defgroup RTCEx_Private_Constants RTCEx Private Constants
  871. * @{
  872. */
  873. #define RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT ((uint32_t)0x00080000) /*!< External interrupt line 19 Connected to the RTC Tamper and Time Stamp events */
  874. #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT ((uint32_t)0x00100000) /*!< External interrupt line 20 Connected to the RTC Wakeup event */
  875. /**
  876. * @}
  877. */
  878. /* Private macros ------------------------------------------------------------*/
  879. /** @defgroup RTCEx_Private_Macros RTCEx Private Macros
  880. * @{
  881. */
  882. /** @defgroup RTCEx_IS_RTC_Definitions Private macros to check input parameters
  883. * @{
  884. */
  885. #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
  886. ((OUTPUT) == RTC_OUTPUT_ALARMA) || \
  887. ((OUTPUT) == RTC_OUTPUT_ALARMB) || \
  888. ((OUTPUT) == RTC_OUTPUT_WAKEUP))
  889. #define IS_RTC_BKP(BKP) ((BKP) < (uint32_t) RTC_BKP_NUMBER)
  890. #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \
  891. ((EDGE) == RTC_TIMESTAMPEDGE_FALLING))
  892. #define IS_RTC_TAMPER(TAMPER) ((((TAMPER) & (uint32_t)0xFFFFFFD6) == 0x00) && ((TAMPER) != (uint32_t)RESET))
  893. #define IS_RTC_TAMPER_INTERRUPT(INTERRUPT) ((((INTERRUPT) & (uint32_t)0xFFB6FFFB) == 0x00) && ((INTERRUPT) != (uint32_t)RESET))
  894. #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TIMESTAMPPIN_DEFAULT))
  895. #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) || \
  896. ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \
  897. ((TRIGGER) == RTC_TAMPERTRIGGER_LOWLEVEL) || \
  898. ((TRIGGER) == RTC_TAMPERTRIGGER_HIGHLEVEL))
  899. #define IS_RTC_TAMPER_ERASE_MODE(MODE) (((MODE) == RTC_TAMPER_ERASE_BACKUP_ENABLE) || \
  900. ((MODE) == RTC_TAMPER_ERASE_BACKUP_DISABLE))
  901. #define IS_RTC_TAMPER_MASKFLAG_STATE(STATE) (((STATE) == RTC_TAMPERMASK_FLAG_ENABLE) || \
  902. ((STATE) == RTC_TAMPERMASK_FLAG_DISABLE))
  903. #define IS_RTC_TAMPER_FILTER(FILTER) (((FILTER) == RTC_TAMPERFILTER_DISABLE) || \
  904. ((FILTER) == RTC_TAMPERFILTER_2SAMPLE) || \
  905. ((FILTER) == RTC_TAMPERFILTER_4SAMPLE) || \
  906. ((FILTER) == RTC_TAMPERFILTER_8SAMPLE))
  907. #define IS_RTC_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \
  908. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \
  909. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \
  910. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \
  911. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \
  912. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \
  913. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512) || \
  914. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256))
  915. #define IS_RTC_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \
  916. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \
  917. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \
  918. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK))
  919. #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \
  920. ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE))
  921. #define IS_RTC_TAMPER_PULLUP_STATE(STATE) (((STATE) == RTC_TAMPER_PULLUP_ENABLE) || \
  922. ((STATE) == RTC_TAMPER_PULLUP_DISABLE))
  923. #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16) || \
  924. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8) || \
  925. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4) || \
  926. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2) || \
  927. ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \
  928. ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS))
  929. #define IS_RTC_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= 0xFFFF)
  930. #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \
  931. ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \
  932. ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC))
  933. #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \
  934. ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET))
  935. #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= 0x000001FF)
  936. #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \
  937. ((SEL) == RTC_SHIFTADD1S_SET))
  938. #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= 0x00007FFF)
  939. #define IS_RTC_CALIB_OUTPUT(OUTPUT) (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \
  940. ((OUTPUT) == RTC_CALIBOUTPUT_1HZ))
  941. /**
  942. * @}
  943. */
  944. /**
  945. * @}
  946. */
  947. /**
  948. * @}
  949. */
  950. /**
  951. * @}
  952. */
  953. #ifdef __cplusplus
  954. }
  955. #endif
  956. #endif /* __STM32L4xx_HAL_RTC_EX_H */
  957. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/