stm32l4xx_hal_rtc_ex.h 49 KB

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