stm32l4xx_hal_rtc_ex.h 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741
  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. * Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32L4xx_HAL_RTC_EX_H
  20. #define STM32L4xx_HAL_RTC_EX_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32l4xx_hal_def.h"
  26. /** @addtogroup STM32L4xx_HAL_Driver
  27. * @{
  28. */
  29. /** @defgroup RTCEx RTCEx
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /** @defgroup RTCEx_Exported_Types RTCEx Exported Types
  34. * @{
  35. */
  36. /** @defgroup RTCEx_Tamper_structure_definition RTCEx Tamper structure definition
  37. * @{
  38. */
  39. typedef struct
  40. {
  41. uint32_t Tamper; /*!< Specifies the Tamper Pin.
  42. This parameter can be a value of @ref RTCEx_Tamper_Pins_Definitions */
  43. uint32_t Interrupt; /*!< Specifies the Tamper Interrupt.
  44. This parameter can be a value of @ref RTCEx_Tamper_Interrupt_Definitions */
  45. uint32_t Trigger; /*!< Specifies the Tamper Trigger.
  46. This parameter can be a value of @ref RTCEx_Tamper_Trigger_Definitions */
  47. uint32_t NoErase; /*!< Specifies the Tamper no erase mode.
  48. This parameter can be a value of @ref RTCEx_Tamper_EraseBackUp_Definitions */
  49. uint32_t MaskFlag; /*!< Specifies the Tamper Flag masking.
  50. This parameter can be a value of @ref RTCEx_Tamper_MaskFlag_Definitions */
  51. uint32_t Filter; /*!< Specifies the TAMP Filter Tamper.
  52. This parameter can be a value of @ref RTCEx_Tamper_Filter_Definitions */
  53. uint32_t SamplingFrequency; /*!< Specifies the sampling frequency.
  54. This parameter can be a value of @ref RTCEx_Tamper_Sampling_Frequencies_Definitions */
  55. uint32_t PrechargeDuration; /*!< Specifies the Precharge Duration .
  56. This parameter can be a value of @ref RTCEx_Tamper_Pin_Precharge_Duration_Definitions */
  57. uint32_t TamperPullUp; /*!< Specifies the Tamper PullUp .
  58. This parameter can be a value of @ref RTCEx_Tamper_Pull_UP_Definitions */
  59. uint32_t TimeStampOnTamperDetection; /*!< Specifies the TimeStampOnTamperDetection.
  60. This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection_Definitions */
  61. } RTC_TamperTypeDef;
  62. /**
  63. * @}
  64. */
  65. /**
  66. * @}
  67. */
  68. /* Exported constants --------------------------------------------------------*/
  69. /** @defgroup RTCEx_Exported_Constants RTCEx Exported Constants
  70. * @{
  71. */
  72. /* ========================================================================== */
  73. /* ##### RTC TimeStamp exported constants ##### */
  74. /* ========================================================================== */
  75. /** @defgroup RTCEx_Time_Stamp_Edges_definitions RTCEx Time Stamp Edges Definitions
  76. *
  77. * @{
  78. */
  79. #define RTC_TIMESTAMPEDGE_RISING 0x00000000u
  80. #define RTC_TIMESTAMPEDGE_FALLING RTC_CR_TSEDGE
  81. /**
  82. * @}
  83. */
  84. /** @defgroup RTCEx_TimeStamp_Pin_Selection RTCEx TimeStamp Pin Selection
  85. * @{
  86. */
  87. #define RTC_TIMESTAMPPIN_DEFAULT 0x00000000u
  88. /**
  89. * @}
  90. */
  91. /* ========================================================================== */
  92. /* ##### RTC Wake-up exported constants ##### */
  93. /* ========================================================================== */
  94. /** @defgroup RTCEx_Wakeup_Timer_Definitions RTCEx Wakeup Timer Definitions
  95. * @{
  96. */
  97. #define RTC_WAKEUPCLOCK_RTCCLK_DIV16 0x00000000u
  98. #define RTC_WAKEUPCLOCK_RTCCLK_DIV8 RTC_CR_WUCKSEL_0
  99. #define RTC_WAKEUPCLOCK_RTCCLK_DIV4 RTC_CR_WUCKSEL_1
  100. #define RTC_WAKEUPCLOCK_RTCCLK_DIV2 (RTC_CR_WUCKSEL_0 | RTC_CR_WUCKSEL_1)
  101. #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS RTC_CR_WUCKSEL_2
  102. #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_2)
  103. /**
  104. * @}
  105. */
  106. /* ========================================================================== */
  107. /* ##### Extended RTC Peripheral Control exported constants ##### */
  108. /* ========================================================================== */
  109. /** @defgroup RTCEx_Smooth_calib_period_Definitions RTCEx Smooth Calib Period Definitions
  110. * @{
  111. */
  112. #define RTC_SMOOTHCALIB_PERIOD_32SEC 0x00000000u /*!< If RTCCLK = 32768 Hz, Smooth calibration
  113. period is 32s, else 2exp20 RTCCLK pulses */
  114. #define RTC_SMOOTHCALIB_PERIOD_16SEC RTC_CALR_CALW16 /*!< If RTCCLK = 32768 Hz, Smooth calibration
  115. period is 16s, else 2exp19 RTCCLK pulses */
  116. #define RTC_SMOOTHCALIB_PERIOD_8SEC RTC_CALR_CALW8 /*!< If RTCCLK = 32768 Hz, Smooth calibration
  117. period is 8s, else 2exp18 RTCCLK pulses */
  118. /**
  119. * @}
  120. */
  121. /** @defgroup RTCEx_Smooth_calib_Plus_pulses_Definitions RTCEx Smooth calib Plus pulses Definitions
  122. * @{
  123. */
  124. #define RTC_SMOOTHCALIB_PLUSPULSES_SET RTC_CALR_CALP /*!< The number of RTCCLK pulses added
  125. during a X -second window = Y - CALM[8:0]
  126. with Y = 512, 256, 128 when X = 32, 16, 8 */
  127. #define RTC_SMOOTHCALIB_PLUSPULSES_RESET 0x00000000u /*!< The number of RTCCLK pulses subbstited
  128. during a 32-second window = CALM[8:0] */
  129. /**
  130. * @}
  131. */
  132. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  133. /** @defgroup RTCEx_Smooth_Calib_Low_Power_Definitions RTCEx Smooth Calib Low Power Definitions
  134. * @{
  135. */
  136. #define RTC_LPCAL_SET RTC_CALR_LPCAL /*!< Calibration window is 220 ck_apre,
  137. which is the required configuration for
  138. ultra-low consumption mode. */
  139. #define RTC_LPCAL_RESET 0x00000000u /*!< Calibration window is 220 RTCCLK,
  140. which is a high-consumption mode.
  141. This mode should be set only when less
  142. than 32s calibration window is required. */
  143. /**
  144. * @}
  145. */
  146. #endif /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  147. /** @defgroup RTCEx_Calib_Output_selection_Definitions RTCEx Calib Output Selection Definitions
  148. * @{
  149. */
  150. #define RTC_CALIBOUTPUT_512HZ 0x00000000u
  151. #define RTC_CALIBOUTPUT_1HZ RTC_CR_COSEL
  152. /**
  153. * @}
  154. */
  155. /** @defgroup RTCEx_Add_1_Second_Parameter_Definitions RTC Add 1 Second Parameter Definitions
  156. * @{
  157. */
  158. #define RTC_SHIFTADD1S_RESET 0x00000000u
  159. #define RTC_SHIFTADD1S_SET RTC_SHIFTR_ADD1S
  160. /**
  161. * @}
  162. */
  163. /* ========================================================================== */
  164. /* ##### RTC Tamper exported constants ##### */
  165. /* ========================================================================== */
  166. /** @defgroup RTCEx_Tamper_Pins_Definitions RTCEx Tamper Pins Definitions
  167. * @{
  168. */
  169. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  170. #if defined(RTC_TAMPER1_SUPPORT)
  171. #define RTC_TAMPER_1 TAMP_CR1_TAMP1E
  172. #endif /* RTC_TAMPER1_SUPPORT */
  173. #define RTC_TAMPER_2 TAMP_CR1_TAMP2E
  174. #if defined(RTC_TAMPER3_SUPPORT)
  175. #define RTC_TAMPER_3 TAMP_CR1_TAMP3E
  176. #endif /* RTC_TAMPER3_SUPPORT */
  177. #if defined(RTC_TAMPER3_SUPPORT)
  178. #define RTC_TAMPER_ALL (TAMP_CR1_TAMP1E | TAMP_CR1_TAMP2E | TAMP_CR1_TAMP3E)
  179. #else
  180. #define RTC_TAMPER_ALL (TAMP_CR1_TAMP1E | TAMP_CR1_TAMP2E)
  181. #endif
  182. #else /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  183. #if defined(RTC_TAMPER1_SUPPORT)
  184. #define RTC_TAMPER_1 RTC_TAMPCR_TAMP1E
  185. #endif /* RTC_TAMPER1_SUPPORT */
  186. #define RTC_TAMPER_2 RTC_TAMPCR_TAMP2E
  187. #if defined(RTC_TAMPER3_SUPPORT)
  188. #define RTC_TAMPER_3 RTC_TAMPCR_TAMP3E
  189. #endif /* RTC_TAMPER3_SUPPORT */
  190. #endif /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  191. /**
  192. * @}
  193. */
  194. /** @defgroup RTCEx_Tamper_Trigger_Definitions RTCEx Tamper Triggers Definitions
  195. * @{
  196. */
  197. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  198. #define RTC_TAMPERTRIGGER_RISINGEDGE 0x00u /*!< Warning : Filter must be RTC_TAMPERFILTER_DISABLE */
  199. #define RTC_TAMPERTRIGGER_FALLINGEDGE 0x01u /*!< Warning : Filter must be RTC_TAMPERFILTER_DISABLE */
  200. #define RTC_TAMPERTRIGGER_LOWLEVEL 0x02u /*!< Warning : Filter must not be RTC_TAMPERFILTER_DISABLE */
  201. #define RTC_TAMPERTRIGGER_HIGHLEVEL 0x03u /*!< Warning : Filter must not be RTC_TAMPERFILTER_DISABLE */
  202. #else
  203. #define RTC_TAMPERTRIGGER_RISINGEDGE ((uint32_t)0x00000000)
  204. #define RTC_TAMPERTRIGGER_FALLINGEDGE ((uint32_t)0x00000002)
  205. #define RTC_TAMPERTRIGGER_LOWLEVEL RTC_TAMPERTRIGGER_RISINGEDGE
  206. #define RTC_TAMPERTRIGGER_HIGHLEVEL RTC_TAMPERTRIGGER_FALLINGEDGE
  207. #endif
  208. /**
  209. * @}
  210. */
  211. /** @defgroup RTCEx_Tamper_MaskFlag_Definitions RTCEx Tamper Mask Flag Definitions
  212. * @{
  213. */
  214. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  215. #define RTC_TAMPERMASK_FLAG_DISABLE 0x00u
  216. #define RTC_TAMPERMASK_FLAG_ENABLE 0x01u
  217. #else
  218. #define RTC_TAMPERMASK_FLAG_DISABLE 0x00000000u
  219. #define RTC_TAMPERMASK_FLAG_ENABLE 0x00040000u
  220. #endif
  221. /**
  222. * @}
  223. */
  224. /** @defgroup RTCEx_Tamper_EraseBackUp_Definitions RTCEx Tamper EraseBackUp Definitions
  225. * @{
  226. */
  227. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  228. #define RTC_TAMPER_ERASE_BACKUP_ENABLE 0x00u
  229. #define RTC_TAMPER_ERASE_BACKUP_DISABLE 0x01u
  230. #else
  231. #define RTC_TAMPER_ERASE_BACKUP_ENABLE 0x00000000u
  232. #define RTC_TAMPER_ERASE_BACKUP_DISABLE 0x00020000u
  233. #endif
  234. /**
  235. * @}
  236. */
  237. /** @defgroup RTCEx_Tamper_Filter_Definitions RTCEx Tamper Filter Definitions
  238. * @{
  239. */
  240. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  241. #define RTC_TAMPERFILTER_DISABLE 0x00000000U /*!< Tamper filter is disabled */
  242. #define RTC_TAMPERFILTER_2SAMPLE TAMP_FLTCR_TAMPFLT_0 /*!< Tamper is activated after 2
  243. consecutive samples at the active level */
  244. #define RTC_TAMPERFILTER_4SAMPLE TAMP_FLTCR_TAMPFLT_1 /*!< Tamper is activated after 4
  245. consecutive samples at the active level */
  246. #define RTC_TAMPERFILTER_8SAMPLE TAMP_FLTCR_TAMPFLT /*!< Tamper is activated after 8
  247. consecutive samples at the active level */
  248. #else /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  249. #define RTC_TAMPERFILTER_DISABLE 0x00000000u /*!< Tamper filter is disabled */
  250. #define RTC_TAMPERFILTER_2SAMPLE RTC_TAMPCR_TAMPFLT_0 /*!< Tamper is activated after 2
  251. consecutive samples at the active level */
  252. #define RTC_TAMPERFILTER_4SAMPLE RTC_TAMPCR_TAMPFLT_1 /*!< Tamper is activated after 4
  253. consecutive samples at the active level */
  254. #define RTC_TAMPERFILTER_8SAMPLE RTC_TAMPCR_TAMPFLT /*!< Tamper is activated after 8
  255. consecutive samples at the active level. */
  256. #endif /*#if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  257. /**
  258. * @}
  259. */
  260. /** @defgroup RTCEx_Tamper_Sampling_Frequencies_Definitions RTCEx Tamper Sampling Frequencies Definitions
  261. * @{
  262. */
  263. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  264. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768 0x00000000U /*!< Each of the tamper inputs are sampled
  265. with a frequency = RTCCLK / 32768 */
  266. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384 TAMP_FLTCR_TAMPFREQ_0 /*!< Each of the tamper inputs are sampled
  267. with a frequency = RTCCLK / 16384 */
  268. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192 TAMP_FLTCR_TAMPFREQ_1 /*!< Each of the tamper inputs are sampled
  269. with a frequency = RTCCLK / 8192 */
  270. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096 (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_1) /*!< Each of the tamper inputs are sampled
  271. with a frequency = RTCCLK / 4096 */
  272. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048 TAMP_FLTCR_TAMPFREQ_2 /*!< Each of the tamper inputs are sampled
  273. with a frequency = RTCCLK / 2048 */
  274. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024 (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled
  275. with a frequency = RTCCLK / 1024 */
  276. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512 (TAMP_FLTCR_TAMPFREQ_1 | TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled
  277. with a frequency = RTCCLK / 512 */
  278. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256 TAMP_FLTCR_TAMPFREQ /*!< Each of the tamper inputs are sampled
  279. with a frequency = RTCCLK / 256 */
  280. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_MASK TAMP_FLTCR_TAMPFREQ /*!< Masking all bits except those of
  281. field TAMPFREQ[2:0]*/
  282. #else /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  283. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768 0x00000000u /*!< Each of the tamper inputs are sampled
  284. with a frequency = RTCCLK / 32768 */
  285. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384 RTC_TAMPCR_TAMPFREQ_0 /*!< Each of the tamper inputs are sampled
  286. with a frequency = RTCCLK / 16384 */
  287. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192 RTC_TAMPCR_TAMPFREQ_1 /*!< Each of the tamper inputs are sampled
  288. with a frequency = RTCCLK / 8192 */
  289. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096 (RTC_TAMPCR_TAMPFREQ_0 | RTC_TAMPCR_TAMPFREQ_1) /*!< Each of the tamper inputs are sampled
  290. with a frequency = RTCCLK / 4096 */
  291. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048 RTC_TAMPCR_TAMPFREQ_2 /*!< Each of the tamper inputs are sampled
  292. with a frequency = RTCCLK / 2048 */
  293. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024 (RTC_TAMPCR_TAMPFREQ_0 | RTC_TAMPCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled
  294. with a frequency = RTCCLK / 1024 */
  295. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512 (RTC_TAMPCR_TAMPFREQ_1 | RTC_TAMPCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled
  296. with a frequency = RTCCLK / 512 */
  297. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256 RTC_TAMPCR_TAMPFREQ /*!< Each of the tamper inputs are sampled
  298. with a frequency = RTCCLK / 256 */
  299. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_MASK RTC_TAMPCR_TAMPFREQ /*!< Masking all bits except those of
  300. field TAMPFREQ[2:0]*/
  301. #endif /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  302. /**
  303. * @}
  304. */
  305. /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration_Definitions RTCEx Tamper Pin Precharge Duration Definitions
  306. * @{
  307. */
  308. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  309. #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK 0x00000000U /*!< Tamper pins are pre-charged before
  310. sampling during 1 RTCCLK cycle */
  311. #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK TAMP_FLTCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before
  312. sampling during 2 RTCCLK cycles */
  313. #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK TAMP_FLTCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before
  314. sampling during 4 RTCCLK cycles */
  315. #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK TAMP_FLTCR_TAMPPRCH /*!< Tamper pins are pre-charged before
  316. sampling during 8 RTCCLK cycles */
  317. #else /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  318. #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK 0x00000000u /*!< Tamper pins are pre-charged before
  319. sampling during 1 RTCCLK cycle */
  320. #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK RTC_TAMPCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before
  321. sampling during 2 RTCCLK cycles */
  322. #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK RTC_TAMPCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before
  323. sampling during 4 RTCCLK cycles */
  324. #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK RTC_TAMPCR_TAMPPRCH /*!< Tamper pins are pre-charged before
  325. sampling during 8 RTCCLK cycles */
  326. #define RTC_TAMPERPRECHARGEDURATION_MASK RTC_TAMPCR_TAMPPRCH /*!< Masking all bits except those of
  327. field TAMPPRCH[1:0] */
  328. #endif /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  329. /**
  330. * @}
  331. */
  332. /** @defgroup RTCEx_Tamper_Pull_UP_Definitions RTCEx Tamper Pull Up Definitions
  333. * @{
  334. */
  335. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  336. #define RTC_TAMPER_PULLUP_ENABLE 0x00000000u /*!< Tamper pins are pre-charged before sampling */
  337. #define RTC_TAMPER_PULLUP_DISABLE TAMP_FLTCR_TAMPPUDIS /*!< Tamper pins pre-charge is disabled */
  338. #else
  339. #define RTC_TAMPER_PULLUP_ENABLE 0x00000000u /*!< TimeStamp on Tamper Detection event saved */
  340. #define RTC_TAMPER_PULLUP_DISABLE RTC_TAMPCR_TAMPPUDIS /*!< TimeStamp on Tamper Detection event is not saved */
  341. #endif
  342. /**
  343. * @}
  344. */
  345. /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection_Definitions RTCEx Tamper TimeStamp On Tamper Detection Definitions
  346. * @{
  347. */
  348. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  349. #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE 0x00000000u /*!< TimeStamp on Tamper Detection event is not saved */
  350. #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE RTC_CR_TAMPTS /*!< TimeStamp on Tamper Detection event saved */
  351. #else
  352. #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE 0x00000000u /*!< TimeStamp on Tamper Detection event is not saved */
  353. #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE RTC_TAMPCR_TAMPTS /*!< TimeStamp on Tamper Detection event saved */
  354. #endif
  355. /**
  356. * @}
  357. */
  358. /** @defgroup RTCEx_Tamper_Interrupt_Definitions RTC Tamper Interrupts Definitions
  359. * @{
  360. */
  361. #if defined(STM32L412xx) || defined(STM32L422xx)
  362. #define RTC_IT_TAMP1 TAMP_IER_TAMP1IE /*!< Tamper 1 Interrupt */
  363. #define RTC_IT_TAMP2 TAMP_IER_TAMP2IE /*!< Tamper 2 Interrupt */
  364. #define RTC_IT_TAMP (TAMP_IER_TAMP1IE | TAMP_IER_TAMP2IE) /*!< Enable all Tamper Interrupt */
  365. #elif defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  366. #define RTC_IT_TAMP1 TAMP_IER_TAMP1IE /*!< Tamper 1 Interrupt */
  367. #define RTC_IT_TAMP2 TAMP_IER_TAMP2IE /*!< Tamper 2 Interrupt */
  368. #define RTC_IT_TAMP3 TAMP_IER_TAMP3IE /*!< Tamper 3 Interrupt */
  369. #define RTC_IT_TAMP (TAMP_IER_TAMP1IE | TAMP_IER_TAMP2IE | TAMP_IER_TAMP3IE) /*!< Enable all Tamper Interrupt */
  370. #else
  371. #define RTC_IT_TAMP RTC_TAMPCR_TAMPIE /*!< Enable all Tamper Interrupt */
  372. #define RTC_IT_TAMP1 RTC_TAMPCR_TAMP1IE /*!< Enable Tamper 1 Interrupt */
  373. #define RTC_IT_TAMP2 RTC_TAMPCR_TAMP2IE /*!< Enable Tamper 2 Interrupt */
  374. #define RTC_IT_TAMP3 RTC_TAMPCR_TAMP3IE /*!< Enable Tamper 3 Interrupt */
  375. #endif
  376. #define RTC_IT_TAMPALL RTC_IT_TAMP
  377. /**
  378. * @}
  379. */
  380. /** @defgroup RTCEx_Flags RTCEx Flags
  381. * @{
  382. */
  383. #if defined(STM32L412xx) || defined(STM32L422xx)
  384. #define RTC_FLAG_TAMP1F TAMP_SR_TAMP1F
  385. #define RTC_FLAG_TAMP2F TAMP_SR_TAMP2F
  386. #define RTC_FLAG_TAMPALL (RTC_FLAG_TAMP1F | RTC_FLAG_TAMP2F)
  387. #elif defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  388. #define RTC_FLAG_TAMP1F TAMP_SR_TAMP1F
  389. #define RTC_FLAG_TAMP2F TAMP_SR_TAMP2F
  390. #define RTC_FLAG_TAMP3F TAMP_SR_TAMP3F
  391. #define RTC_FLAG_TAMPALL (RTC_FLAG_TAMP1F | RTC_FLAG_TAMP2F | RTC_FLAG_TAMP3F)
  392. #else
  393. #define RTC_FLAG_TAMP1F RTC_ISR_TAMP1F
  394. #define RTC_FLAG_TAMP2F RTC_ISR_TAMP2F
  395. #define RTC_FLAG_TAMP3F RTC_ISR_TAMP3F
  396. #endif
  397. /**
  398. * @}
  399. */
  400. /* ========================================================================== */
  401. /* ##### Extended RTC Backup registers exported constants ##### */
  402. /* ========================================================================== */
  403. /** @defgroup RTCEx_Backup_Data_Registers_Number_Definitions RTC Backup Data Registers Number Definitions
  404. * @{
  405. */
  406. #if defined(RTC_BKP_NUMBER)
  407. #define BKP_REG_NUMBER RTC_BKP_NUMBER
  408. #endif /* RTC_BKP_NUMBER */
  409. #if defined(TAMP_BKP_NUMBER)
  410. #define BKP_REG_NUMBER TAMP_BKP_NUMBER
  411. #endif /* TAMP_BKP_NUMBER */
  412. /**
  413. * @}
  414. */
  415. /** @defgroup RTCEx_Backup_Data_Registers_Definitions RTCEx Backup Data Registers Definitions
  416. * @{
  417. */
  418. #define RTC_BKP_DR0 0x00u
  419. #define RTC_BKP_DR1 0x01u
  420. #define RTC_BKP_DR2 0x02u
  421. #define RTC_BKP_DR3 0x03u
  422. #define RTC_BKP_DR4 0x04u
  423. #define RTC_BKP_DR5 0x05u
  424. #define RTC_BKP_DR6 0x06u
  425. #define RTC_BKP_DR7 0x07u
  426. #define RTC_BKP_DR8 0x08u
  427. #define RTC_BKP_DR9 0x09u
  428. #define RTC_BKP_DR10 0x0Au
  429. #define RTC_BKP_DR11 0x0Bu
  430. #define RTC_BKP_DR12 0x0Cu
  431. #define RTC_BKP_DR13 0x0Du
  432. #define RTC_BKP_DR14 0x0Eu
  433. #define RTC_BKP_DR15 0x0Fu
  434. #define RTC_BKP_DR16 0x10u
  435. #define RTC_BKP_DR17 0x11u
  436. #define RTC_BKP_DR18 0x12u
  437. #define RTC_BKP_DR19 0x13u
  438. #define RTC_BKP_DR20 0x14u
  439. #define RTC_BKP_DR21 0x15u
  440. #define RTC_BKP_DR22 0x16u
  441. #define RTC_BKP_DR23 0x17u
  442. #define RTC_BKP_DR24 0x18u
  443. #define RTC_BKP_DR25 0x19u
  444. #define RTC_BKP_DR26 0x1Au
  445. #define RTC_BKP_DR27 0x1Bu
  446. #define RTC_BKP_DR28 0x1Cu
  447. #define RTC_BKP_DR29 0x1Du
  448. #define RTC_BKP_DR30 0x1Eu
  449. #define RTC_BKP_DR31 0x1Fu
  450. /**
  451. * @}
  452. */
  453. /** @defgroup RTCEx_Tamper_Interrupt_Definitions RTC Tamper Interrupts Definitions
  454. * @{
  455. */
  456. #if defined(STM32L412xx) || defined(STM32L422xx)
  457. #define RTC_TAMPER1_INTERRUPT TAMP_IER_TAMP1IE
  458. #define RTC_TAMPER2_INTERRUPT TAMP_IER_TAMP2IE
  459. #define RTC_ALL_TAMPER_INTERRUPT (TAMP_IER_TAMP1IE | TAMP_IER_TAMP2IE)
  460. #elif defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  461. #define RTC_TAMPER1_INTERRUPT TAMP_IER_TAMP1IE
  462. #define RTC_TAMPER2_INTERRUPT TAMP_IER_TAMP2IE
  463. #define RTC_TAMPER3_INTERRUPT TAMP_IER_TAMP3IE
  464. #define RTC_ALL_TAMPER_INTERRUPT (TAMP_IER_TAMP1IE | TAMP_IER_TAMP2IE | TAMP_IER_TAMP3IE)
  465. #else /* #if defined(STM32L412xx) || defined(STM32L422xx) */
  466. #if defined(RTC_TAMPER1_SUPPORT)
  467. #define RTC_TAMPER1_INTERRUPT RTC_TAMPCR_TAMP1IE
  468. #endif /* RTC_TAMPER1_SUPPORT */
  469. #define RTC_TAMPER2_INTERRUPT RTC_TAMPCR_TAMP2IE
  470. #if defined(RTC_TAMPER3_SUPPORT)
  471. #define RTC_TAMPER3_INTERRUPT RTC_TAMPCR_TAMP3IE
  472. #endif /* RTC_TAMPER3_SUPPORT */
  473. #define RTC_ALL_TAMPER_INTERRUPT RTC_TAMPCR_TAMPIE
  474. #endif /* #if defined(STM32L412xx) || defined(STM32L422xx) */
  475. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  476. /** @defgroup RTCEx_Binary_Mode RTC Binary Mode (32-bit free-running counter configuration).
  477. * Warning : It Should not be confused with the Binary format @ref RTC_Input_parameter_format_definitions.
  478. * @{
  479. */
  480. #define RTC_BINARY_NONE 0x00000000u /*!< Free running BCD calendar mode (Binary mode disabled). */
  481. #define RTC_BINARY_ONLY RTC_ICSR_BIN_0 /*!< Free running Binary mode (BCD mode disabled) */
  482. #define RTC_BINARY_MIX RTC_ICSR_BIN_1 /*!< Free running BCD calendar and Binary modes */
  483. /**
  484. * @}
  485. */
  486. /** @defgroup RTCEx_Binary_mix_BCDU If Binary mode is RTC_BINARY_MIX, the BCD calendar second is incremented using the SSR Least Significant Bits.
  487. * @{
  488. */
  489. #define RTC_BINARY_MIX_BCDU_0 0x00000000u /*!< The 1s BCD calendar increment is generated each time SS[7:0] = 0 */
  490. #define RTC_BINARY_MIX_BCDU_1 (0x1UL << RTC_ICSR_BCDU_Pos) /*!< The 1s BCD calendar increment is generated each time SS[8:0] = 0 */
  491. #define RTC_BINARY_MIX_BCDU_2 (0x2UL << RTC_ICSR_BCDU_Pos) /*!< The 1s BCD calendar increment is generated each time SS[9:0] = 0 */
  492. #define RTC_BINARY_MIX_BCDU_3 (0x3UL << RTC_ICSR_BCDU_Pos) /*!< The 1s BCD calendar increment is generated each time SS[10:0] = 0 */
  493. #define RTC_BINARY_MIX_BCDU_4 (0x4UL << RTC_ICSR_BCDU_Pos) /*!< The 1s BCD calendar increment is generated each time SS[11:0] = 0 */
  494. #define RTC_BINARY_MIX_BCDU_5 (0x5UL << RTC_ICSR_BCDU_Pos) /*!< The 1s BCD calendar increment is generated each time SS[12:0] = 0 */
  495. #define RTC_BINARY_MIX_BCDU_6 (0x6UL << RTC_ICSR_BCDU_Pos) /*!< The 1s BCD calendar increment is generated each time SS[13:0] = 0 */
  496. #define RTC_BINARY_MIX_BCDU_7 (0x7UL << RTC_ICSR_BCDU_Pos) /*!< The 1s BCD calendar increment is generated each time SS[14:0] = 0 */
  497. /**
  498. * @}
  499. */
  500. /** @defgroup RTCEx_Alarm_Sub_Seconds_binary_Masks_Definitions RTC Alarm Sub Seconds with binary mode Masks Definitions
  501. * @{
  502. */
  503. #define RTC_ALARMSUBSECONDBINMASK_ALL 0x00000000u /*!< All Alarm SS fields are masked.
  504. There is no comparison on sub seconds for Alarm */
  505. #define RTC_ALARMSUBSECONDBINMASK_SS31_1 (1UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:1] are don't care in Alarm
  506. comparison. Only SS[0] is compared. */
  507. #define RTC_ALARMSUBSECONDBINMASK_SS31_2 (2UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:2] are don't care in Alarm
  508. comparison. Only SS[1:0] are compared */
  509. #define RTC_ALARMSUBSECONDBINMASK_SS31_3 (3UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:3] are don't care in Alarm
  510. comparison. Only SS[2:0] are compared */
  511. #define RTC_ALARMSUBSECONDBINMASK_SS31_4 (4UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:4] are don't care in Alarm
  512. comparison. Only SS[3:0] are compared */
  513. #define RTC_ALARMSUBSECONDBINMASK_SS31_5 (5UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:5] are don't care in Alarm
  514. comparison. Only SS[4:0] are compared */
  515. #define RTC_ALARMSUBSECONDBINMASK_SS31_6 (6UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:6] are don't care in Alarm
  516. comparison. Only SS[5:0] are compared */
  517. #define RTC_ALARMSUBSECONDBINMASK_SS31_7 (7UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:7] are don't care in Alarm
  518. comparison. Only SS[6:0] are compared */
  519. #define RTC_ALARMSUBSECONDBINMASK_SS31_8 (8UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:8] are don't care in Alarm
  520. comparison. Only SS[7:0] are compared */
  521. #define RTC_ALARMSUBSECONDBINMASK_SS31_9 (9UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:9] are don't care in Alarm
  522. comparison. Only SS[8:0] are compared */
  523. #define RTC_ALARMSUBSECONDBINMASK_SS31_10 (10UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:10] are don't care in Alarm
  524. comparison. Only SS[9:0] are compared */
  525. #define RTC_ALARMSUBSECONDBINMASK_SS31_11 (11UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:11] are don't care in Alarm
  526. comparison. Only SS[10:0] are compared */
  527. #define RTC_ALARMSUBSECONDBINMASK_SS31_12 (12UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:12] are don't care in Alarm
  528. comparison.Only SS[11:0] are compared */
  529. #define RTC_ALARMSUBSECONDBINMASK_SS31_13 (13UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:13] are don't care in Alarm
  530. comparison. Only SS[12:0] are compared */
  531. #define RTC_ALARMSUBSECONDBINMASK_SS31_14 (14UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:14] are don't care in Alarm
  532. comparison. Only SS[13:0] are compared */
  533. #define RTC_ALARMSUBSECONDBINMASK_SS31_15 (15UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:15] are don't care in Alarm
  534. comparison. Only SS[14:0] are compared */
  535. #define RTC_ALARMSUBSECONDBINMASK_SS31_16 (16UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:16] are don't care in Alarm
  536. comparison. Only SS[15:0] are compared */
  537. #define RTC_ALARMSUBSECONDBINMASK_SS31_17 (17UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:17] are don't care in Alarm
  538. comparison. Only SS[16:0] are compared */
  539. #define RTC_ALARMSUBSECONDBINMASK_SS31_18 (18UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:18] are don't care in Alarm
  540. comparison. Only SS[17:0] are compared */
  541. #define RTC_ALARMSUBSECONDBINMASK_SS31_19 (19UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:19] are don't care in Alarm
  542. comparison. Only SS[18:0] are compared */
  543. #define RTC_ALARMSUBSECONDBINMASK_SS31_20 (20UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:20] are don't care in Alarm
  544. comparison. Only SS[19:0] are compared */
  545. #define RTC_ALARMSUBSECONDBINMASK_SS31_21 (21UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:21] are don't care in Alarm
  546. comparison. Only SS[20:0] are compared */
  547. #define RTC_ALARMSUBSECONDBINMASK_SS31_22 (22UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:22] are don't care in Alarm
  548. comparison. Only SS[21:0] are compared */
  549. #define RTC_ALARMSUBSECONDBINMASK_SS31_23 (23UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:23] are don't care in Alarm
  550. comparison. Only SS[22:0] are compared */
  551. #define RTC_ALARMSUBSECONDBINMASK_SS31_24 (24UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:24] are don't care in Alarm
  552. comparison. Only SS[23:0] are compared */
  553. #define RTC_ALARMSUBSECONDBINMASK_SS31_25 (25UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:25] are don't care in Alarm
  554. comparison. Only SS[24:0] are compared */
  555. #define RTC_ALARMSUBSECONDBINMASK_SS31_26 (26UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:26] are don't care in Alarm
  556. comparison. Only SS[25:0] are compared */
  557. #define RTC_ALARMSUBSECONDBINMASK_SS31_27 (27UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:27] are don't care in Alarm
  558. comparison. Only SS[26:0] are compared */
  559. #define RTC_ALARMSUBSECONDBINMASK_SS31_28 (28UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:28] are don't care in Alarm
  560. comparison. Only SS[27:0] are compared */
  561. #define RTC_ALARMSUBSECONDBINMASK_SS31_29 (29UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:29] are don't care in Alarm
  562. comparison. Only SS[28:0] are compared */
  563. #define RTC_ALARMSUBSECONDBINMASK_SS31_30 (30UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:30] are don't care in Alarm
  564. comparison. Only SS[29:0] are compared */
  565. #define RTC_ALARMSUBSECONDBINMASK_SS31 (31UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31] is don't care in Alarm
  566. comparison. Only SS[30:0] are compared */
  567. #define RTC_ALARMSUBSECONDBINMASK_NONE (32UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:0] are compared and must match to activate alarm. */
  568. /**
  569. * @}
  570. */
  571. /** @defgroup RTCEx_Alarm_Sub_Seconds_binary_Clear_Definitions RTC Alarm Sub Seconds with binary mode auto clear Definitions
  572. * @{
  573. */
  574. #define RTC_ALARMSUBSECONDBIN_AUTOCLR_NO 0UL /*!< The synchronous Binary counter (SS[31:0] in RTC_SSR) is free-running. */
  575. #define RTC_ALARMSUBSECONDBIN_AUTOCLR_YES RTC_ALRMASSR_SSCLR /*!< The synchronous Binary counter (SS[31:0] in RTC_SSR) is running from 0xFFFF FFFF to
  576. RTC_ALRMABINR -> SS[31:0] value and is automatically reloaded with 0xFFFF FFFF
  577. whenreaching RTC_ALRMABINR -> SS[31:0]. */
  578. /**
  579. * @}
  580. */
  581. #endif /* #if defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  582. /**
  583. * @}
  584. */
  585. /* Exported macros -----------------------------------------------------------*/
  586. /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros
  587. * @{
  588. */
  589. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  590. /** @brief Clear the specified RTC pending flag.
  591. * @param __HANDLE__ specifies the RTC Handle.
  592. * @param __FLAG__ specifies the flag to check.
  593. * This parameter can be any combination of the following values:
  594. * @arg @ref RTC_CLEAR_ITSF Clear Internal Time-stamp flag
  595. * @arg @ref RTC_CLEAR_TSOVF Clear Time-stamp overflow flag
  596. * @arg @ref RTC_CLEAR_TSF Clear Time-stamp flag
  597. * @arg @ref RTC_CLEAR_WUTF Clear Wakeup timer flag
  598. * @arg @ref RTC_CLEAR_ALRBF Clear Alarm B flag
  599. * @arg @ref RTC_CLEAR_ALRAF Clear Alarm A flag
  600. * @retval None
  601. */
  602. #define __HAL_RTC_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SCR = (__FLAG__))
  603. /** @brief Check whether the specified RTC flag is set or not.
  604. * @param __HANDLE__ specifies the RTC Handle.
  605. * @param __FLAG__ specifies the flag to check.
  606. * This parameter can be any combination of the following values:
  607. * @arg @ref RTC_FLAG_RECALPF Recalibration pending Flag
  608. * @arg @ref RTC_FLAG_INITF Initialization flag
  609. * @arg @ref RTC_FLAG_RSF Registers synchronization flag
  610. * @arg @ref RTC_FLAG_INITS Initialization status flag
  611. * @arg @ref RTC_FLAG_SHPF Shift operation pending flag
  612. * @arg @ref RTC_FLAG_WUTWF Wakeup timer write flag
  613. * @arg @ref RTC_FLAG_ALRBWF Alarm B write flag
  614. * @arg @ref RTC_FLAG_ALRAWF Alarm A write flag
  615. * @arg @ref RTC_FLAG_ITSF Internal Time-stamp flag
  616. * @arg @ref RTC_FLAG_TSOVF Time-stamp overflow flag
  617. * @arg @ref RTC_FLAG_TSF Time-stamp flag
  618. * @arg @ref RTC_FLAG_WUTF Wakeup timer flag
  619. * @arg @ref RTC_FLAG_ALRBF Alarm B flag
  620. * @arg @ref RTC_FLAG_ALRAF Alarm A flag
  621. * @retval None
  622. */
  623. #define __HAL_RTC_GET_FLAG(__HANDLE__, __FLAG__) (((((__FLAG__)) >> 8U) == 1U) ? ((__HANDLE__)->Instance->ICSR & (1U << (((uint16_t)(__FLAG__)) & RTC_FLAG_MASK))) : \
  624. ((__HANDLE__)->Instance->SR & (1U << (((uint16_t)(__FLAG__)) & RTC_FLAG_MASK))))
  625. #endif /*#if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  626. /* ---------------------------------WAKEUPTIMER---------------------------------*/
  627. /** @defgroup RTCEx_WakeUp_Timer RTC WakeUp Timer
  628. * @{
  629. */
  630. /**
  631. * @brief Enable the RTC WakeUp Timer peripheral.
  632. * @param __HANDLE__ specifies the RTC handle.
  633. * @retval None
  634. */
  635. #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_WUTE))
  636. /**
  637. * @brief Disable the RTC WakeUp Timer peripheral.
  638. * @param __HANDLE__ specifies the RTC handle.
  639. * @retval None
  640. */
  641. #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_WUTE))
  642. /**
  643. * @brief Enable the RTC WakeUpTimer interrupt.
  644. * @param __HANDLE__ specifies the RTC handle.
  645. * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be enabled.
  646. * This parameter can be:
  647. * @arg @ref RTC_IT_WUT WakeUpTimer interrupt
  648. * @retval None
  649. */
  650. #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  651. /**
  652. * @brief Disable the RTC WakeUpTimer interrupt.
  653. * @param __HANDLE__ specifies the RTC handle.
  654. * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be disabled.
  655. * This parameter can be:
  656. * @arg @ref RTC_IT_WUT WakeUpTimer interrupt
  657. * @retval None
  658. */
  659. #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  660. /**
  661. * @brief Check whether the specified RTC WakeUpTimer interrupt has occurred or not.
  662. * @param __HANDLE__ specifies the RTC handle.
  663. * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to check.
  664. * This parameter can be:
  665. * @arg @ref RTC_IT_WUT WakeUpTimer interrupt
  666. * @retval None
  667. */
  668. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  669. #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->MISR) & ((__INTERRUPT__) >> 12)) != 0U) ? 1U : 0U)
  670. #else
  671. #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__) >> 4)) != 0U) ? 1U : 0U)
  672. #endif
  673. /**
  674. * @brief Check whether the specified RTC Wake Up timer interrupt has been enabled or not.
  675. * @param __HANDLE__ specifies the RTC handle.
  676. * @param __INTERRUPT__ specifies the RTC Wake Up timer interrupt sources to check.
  677. * This parameter can be:
  678. * @arg @ref RTC_IT_WUT WakeUpTimer interrupt
  679. * @retval None
  680. */
  681. #define __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
  682. /**
  683. * @brief Get the selected RTC WakeUpTimer's flag status.
  684. * @param __HANDLE__ specifies the RTC handle.
  685. * @param __FLAG__ specifies the RTC WakeUpTimer Flag is pending or not.
  686. * This parameter can be:
  687. * @arg @ref RTC_FLAG_WUTF
  688. * @arg @ref RTC_FLAG_WUTWF
  689. * @retval Flag status
  690. */
  691. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  692. #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__)))
  693. #else
  694. #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
  695. #endif
  696. /**
  697. * @brief Clear the RTC Wake Up timers pending flags.
  698. * @param __HANDLE__ specifies the RTC handle.
  699. * @param __FLAG__ specifies the RTC WakeUpTimer Flag to clear.
  700. * This parameter can be:
  701. * @arg @ref RTC_FLAG_WUTF
  702. * @retval None
  703. */
  704. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  705. #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_CLEAR_FLAG((__HANDLE__), RTC_CLEAR_WUTF))
  706. #else
  707. #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  708. #endif
  709. /* WAKE-UP TIMER EXTI */
  710. /* ------------------ */
  711. /**
  712. * @brief Enable interrupt on the RTC WakeUp Timer associated Exti line.
  713. * @retval None
  714. */
  715. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  716. /**
  717. * @brief Disable interrupt on the RTC WakeUp Timer associated Exti line.
  718. * @retval None
  719. */
  720. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  721. /**
  722. * @brief Enable event on the RTC WakeUp Timer associated Exti line.
  723. * @retval None
  724. */
  725. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  726. /**
  727. * @brief Disable event on the RTC WakeUp Timer associated Exti line.
  728. * @retval None
  729. */
  730. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  731. /**
  732. * @brief Enable falling edge trigger on the RTC WakeUp Timer associated Exti line.
  733. * @retval None
  734. */
  735. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  736. /**
  737. * @brief Disable falling edge trigger on the RTC WakeUp Timer associated Exti line.
  738. * @retval None
  739. */
  740. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  741. /**
  742. * @brief Enable rising edge trigger on the RTC WakeUp Timer associated Exti line.
  743. * @retval None
  744. */
  745. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  746. /**
  747. * @brief Disable rising edge trigger on the RTC WakeUp Timer associated Exti line.
  748. * @retval None
  749. */
  750. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  751. /**
  752. * @brief Enable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line.
  753. * @retval None
  754. */
  755. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  756. __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE(); \
  757. __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE(); \
  758. } while(0)
  759. /**
  760. * @brief Disable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line.
  761. * This parameter can be:
  762. * @retval None
  763. */
  764. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  765. __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE(); \
  766. __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE(); \
  767. } while(0)
  768. /**
  769. * @brief Check whether the RTC WakeUp Timer associated Exti line interrupt flag is set or not.
  770. * @retval Line Status.
  771. */
  772. #define __HAL_RTC_WAKEUPTIMER_EXTI_GET_FLAG() (EXTI->PR1 & RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  773. /**
  774. * @brief Clear the RTC WakeUp Timer associated Exti line flag.
  775. * @retval None
  776. */
  777. #define __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG() (EXTI->PR1 = RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  778. /**
  779. * @brief Generate a Software interrupt on the RTC WakeUp Timer associated Exti line.
  780. * @retval None
  781. */
  782. #define __HAL_RTC_WAKEUPTIMER_EXTI_GENERATE_SWIT() (EXTI->SWIER1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  783. /**
  784. * @}
  785. */
  786. /* ---------------------------------TIMESTAMP---------------------------------*/
  787. /** @defgroup RTCEx_Timestamp RTC Timestamp
  788. * @{
  789. */
  790. /**
  791. * @brief Enable the RTC TimeStamp peripheral.
  792. * @param __HANDLE__ specifies the RTC handle.
  793. * @retval None
  794. */
  795. #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TSE))
  796. /**
  797. * @brief Disable the RTC TimeStamp peripheral.
  798. * @param __HANDLE__ specifies the RTC handle.
  799. * @retval None
  800. */
  801. #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TSE))
  802. /**
  803. * @brief Enable the RTC TimeStamp interrupt.
  804. * @param __HANDLE__ specifies the RTC handle.
  805. * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be enabled.
  806. * This parameter can be:
  807. * @arg @ref RTC_IT_TS TimeStamp interrupt
  808. * @retval None
  809. */
  810. #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  811. /**
  812. * @brief Disable the RTC TimeStamp interrupt.
  813. * @param __HANDLE__ specifies the RTC handle.
  814. * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be disabled.
  815. * This parameter can be:
  816. * @arg @ref RTC_IT_TS TimeStamp interrupt
  817. * @retval None
  818. */
  819. #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  820. /**
  821. * @brief Check whether the specified RTC TimeStamp interrupt has occurred or not.
  822. * @param __HANDLE__ specifies the RTC handle.
  823. * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt source to check.
  824. * This parameter can be:
  825. * @arg @ref RTC_IT_TS TimeStamp interrupt
  826. * @retval None
  827. */
  828. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  829. #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->MISR) & ((__INTERRUPT__) >> 12)) != 0U) ? 1U : 0U)
  830. #else
  831. #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__) >> 4)) != 0U) ? 1U : 0U)
  832. #endif
  833. /**
  834. * @brief Check whether the specified RTC Time Stamp interrupt has been enabled or not.
  835. * @param __HANDLE__ specifies the RTC handle.
  836. * @param __INTERRUPT__ specifies the RTC Time Stamp interrupt source to check.
  837. * This parameter can be:
  838. * @arg @ref RTC_IT_TS TimeStamp interrupt
  839. * @retval None
  840. */
  841. #define __HAL_RTC_TIMESTAMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
  842. /**
  843. * @brief Get the selected RTC TimeStamp's flag status.
  844. * @param __HANDLE__ specifies the RTC handle.
  845. * @param __FLAG__ specifies the RTC TimeStamp Flag is pending or not.
  846. * This parameter can be:
  847. * @arg @ref RTC_FLAG_TSF
  848. * @arg @ref RTC_FLAG_TSOVF
  849. * @retval Flag status
  850. */
  851. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  852. #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__),(__FLAG__)))
  853. #else
  854. #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
  855. #endif
  856. /**
  857. * @brief Clear the RTC Time Stamps pending flags.
  858. * @param __HANDLE__ specifies the RTC handle.
  859. * @param __FLAG__ specifies the RTC TimeStamp Flag to clear.
  860. * This parameter can be:
  861. * @arg @ref RTC_FLAG_TSF
  862. * @arg @ref RTC_FLAG_TSOVF
  863. * @retval None
  864. */
  865. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  866. #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_CLEAR_FLAG((__HANDLE__), (__FLAG__)))
  867. #else
  868. #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  869. #endif
  870. /**
  871. * @brief Enable the RTC internal TimeStamp peripheral.
  872. * @param __HANDLE__ specifies the RTC handle.
  873. * @retval None
  874. */
  875. #define __HAL_RTC_INTERNAL_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ITSE))
  876. /**
  877. * @brief Disable the RTC internal TimeStamp peripheral.
  878. * @param __HANDLE__ specifies the RTC handle.
  879. * @retval None
  880. */
  881. #define __HAL_RTC_INTERNAL_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ITSE))
  882. /**
  883. * @brief Get the selected RTC Internal Time Stamps flag status.
  884. * @param __HANDLE__ specifies the RTC handle.
  885. * @param __FLAG__ specifies the RTC Internal Time Stamp Flag is pending or not.
  886. * This parameter can be:
  887. * @arg @ref RTC_FLAG_ITSF
  888. * @retval None
  889. */
  890. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  891. #define __HAL_RTC_INTERNAL_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__),(__FLAG__)))
  892. #else
  893. #define __HAL_RTC_INTERNAL_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
  894. #endif
  895. /**
  896. * @brief Clear the RTC Internal Time Stamps pending flags.
  897. * @param __HANDLE__ specifies the RTC handle.
  898. * @param __FLAG__ specifies the RTC Internal Time Stamp Flag source to clear.
  899. * This parameter can be:
  900. * @arg @ref RTC_FLAG_ITSF
  901. * @retval None
  902. */
  903. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  904. #define __HAL_RTC_INTERNAL_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_CLEAR_FLAG((__HANDLE__), RTC_CLEAR_ITSF))
  905. #else
  906. #define __HAL_RTC_INTERNAL_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  907. #endif
  908. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  909. /**
  910. * @brief Enable the RTC TimeStamp on Tamper detection.
  911. * @param __HANDLE__ specifies the RTC handle.
  912. * @retval None
  913. */
  914. #define __HAL_RTC_TAMPTS_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TAMPTS))
  915. /**
  916. * @brief Disable the RTC TimeStamp on Tamper detection.
  917. * @param __HANDLE__ specifies the RTC handle.
  918. * @retval None
  919. */
  920. #define __HAL_RTC_TAMPTS_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TAMPTS))
  921. /**
  922. * @brief Enable the RTC Tamper detection output.
  923. * @param __HANDLE__ specifies the RTC handle.
  924. * @retval None
  925. */
  926. #define __HAL_RTC_TAMPOE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TAMPOE))
  927. /**
  928. * @brief Disable the RTC Tamper detection output.
  929. * @param __HANDLE__ specifies the RTC handle.
  930. * @retval None
  931. */
  932. #define __HAL_RTC_TAMPOE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TAMPOE))
  933. /**
  934. * @}
  935. */
  936. #endif /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  937. /* ------------------------------Calibration----------------------------------*/
  938. /** @defgroup RTCEx_Calibration RTC Calibration
  939. * @{
  940. */
  941. /**
  942. * @brief Enable the RTC calibration output.
  943. * @param __HANDLE__ specifies the RTC handle.
  944. * @retval None
  945. */
  946. #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_COE))
  947. /**
  948. * @brief Disable the calibration output.
  949. * @param __HANDLE__ specifies the RTC handle.
  950. * @retval None
  951. */
  952. #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_COE))
  953. /**
  954. * @brief Enable the clock reference detection.
  955. * @param __HANDLE__ specifies the RTC handle.
  956. * @retval None
  957. */
  958. #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_REFCKON))
  959. /**
  960. * @brief Disable the clock reference detection.
  961. * @param __HANDLE__ specifies the RTC handle.
  962. * @retval None
  963. */
  964. #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_REFCKON))
  965. /**
  966. * @brief Get the selected RTC shift operation's flag status.
  967. * @param __HANDLE__ specifies the RTC handle.
  968. * @param __FLAG__ specifies the RTC shift operation Flag is pending or not.
  969. * This parameter can be:
  970. * @arg @ref RTC_FLAG_SHPF
  971. * @retval None
  972. */
  973. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  974. #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__)))
  975. #else
  976. #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
  977. #endif
  978. /**
  979. * @}
  980. */
  981. /* ------------------------------Tamper----------------------------------*/
  982. /** @defgroup RTCEx_Tamper RTCEx tamper
  983. * @{
  984. */
  985. #if defined(RTC_TAMPER1_SUPPORT)
  986. /**
  987. * @brief Enable the RTC Tamper1 input detection.
  988. * @param __HANDLE__ specifies the RTC handle.
  989. * @retval None
  990. */
  991. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  992. #define __HAL_RTC_TAMPER1_ENABLE(__HANDLE__) (((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->CR1 |= (TAMP_CR1_TAMP1E))
  993. #else
  994. #define __HAL_RTC_TAMPER1_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR |= (RTC_TAMPCR_TAMP1E))
  995. #endif
  996. /**
  997. * @brief Disable the RTC Tamper1 input detection.
  998. * @param __HANDLE__ specifies the RTC handle.
  999. * @retval None
  1000. */
  1001. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1002. #define __HAL_RTC_TAMPER1_DISABLE(__HANDLE__) (((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->CR1 &= ~(RTC_TAMPCR_TAMP1E))
  1003. #else
  1004. #define __HAL_RTC_TAMPER1_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR &= ~(RTC_TAMPCR_TAMP1E))
  1005. #endif
  1006. #endif /* RTC_TAMPER1_SUPPORT */
  1007. /**
  1008. * @brief Enable the RTC Tamper2 input detection.
  1009. * @param __HANDLE__ specifies the RTC handle.
  1010. * @retval None
  1011. */
  1012. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1013. #define __HAL_RTC_TAMPER2_ENABLE(__HANDLE__) (((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->CR1 |= (TAMP_CR1_TAMP2E))
  1014. #else
  1015. #define __HAL_RTC_TAMPER2_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR |= (RTC_TAMPCR_TAMP2E))
  1016. #endif
  1017. /**
  1018. * @brief Disable the RTC Tamper2 input detection.
  1019. * @param __HANDLE__ specifies the RTC handle.
  1020. * @retval None
  1021. */
  1022. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1023. #define __HAL_RTC_TAMPER2_DISABLE(__HANDLE__) (((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->CR1 &= ~(RTC_TAMPCR_TAMP2E))
  1024. #else
  1025. #define __HAL_RTC_TAMPER2_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR &= ~(RTC_TAMPCR_TAMP2E))
  1026. #endif
  1027. #if defined(RTC_TAMPER3_SUPPORT)
  1028. /**
  1029. * @brief Enable the RTC Tamper3 input detection.
  1030. * @param __HANDLE__ specifies the RTC handle.
  1031. * @retval None
  1032. */
  1033. #define __HAL_RTC_TAMPER3_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR |= (RTC_TAMPCR_TAMP3E))
  1034. /**
  1035. * @brief Disable the RTC Tamper3 input detection.
  1036. * @param __HANDLE__ specifies the RTC handle.
  1037. * @retval None
  1038. */
  1039. #define __HAL_RTC_TAMPER3_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAMPCR &= ~(RTC_TAMPCR_TAMP3E))
  1040. #endif /* RTC_TAMPER3_SUPPORT */
  1041. /**************************************************************************************************/
  1042. /**
  1043. * @brief Enable the TAMP Tamper interrupt.
  1044. * @param __HANDLE__ specifies the RTC handle.
  1045. * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be enabled.
  1046. * This parameter can be any combination of the following values:
  1047. * @arg RTC_IT_TAMPALL: All tampers interrupts
  1048. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  1049. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  1050. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  1051. * @retval None
  1052. */
  1053. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1054. #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->IER |= (__INTERRUPT__))
  1055. #else
  1056. #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->TAMPCR |= (__INTERRUPT__))
  1057. #endif
  1058. /**
  1059. * @brief Disable the TAMP Tamper interrupt.
  1060. * @param __HANDLE__ specifies the RTC handle.
  1061. * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be disabled.
  1062. * This parameter can be any combination of the following values:
  1063. * @arg RTC_IT_TAMPALL: All tampers interrupts
  1064. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  1065. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  1066. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  1067. * @retval None
  1068. */
  1069. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1070. #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->IER &= ~(__INTERRUPT__))
  1071. #else
  1072. #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->TAMPCR &= ~(__INTERRUPT__))
  1073. #endif
  1074. /**************************************************************************************************/
  1075. /**
  1076. * @brief Check whether the specified RTC Tamper interrupt has occurred or not.
  1077. * @param __HANDLE__ specifies the RTC handle.
  1078. * @param __INTERRUPT__ specifies the RTC Tamper interrupt to check.
  1079. * This parameter can be:
  1080. * @arg RTC_IT_TAMPALL: All tampers interrupts
  1081. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  1082. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  1083. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  1084. * @retval None
  1085. */
  1086. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1087. #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) ((((((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->MISR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
  1088. #else /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  1089. #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
  1090. #endif /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  1091. /**
  1092. * @brief Check whether the specified RTC Tamper interrupt has been enabled or not.
  1093. * @param __HANDLE__ specifies the RTC handle.
  1094. * @param __INTERRUPT__ specifies the RTC Tamper interrupt source to check.
  1095. * This parameter can be:
  1096. * @arg RTC_IT_TAMPALL: All tampers interrupts
  1097. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  1098. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  1099. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  1100. * @retval None
  1101. */
  1102. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1103. #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->IER) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
  1104. #else
  1105. #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->TAMPCR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
  1106. #endif
  1107. /**
  1108. * @brief Get the selected RTC Tamper's flag status.
  1109. * @param __HANDLE__ specifies the RTC handle.
  1110. * @param __FLAG__ specifies the RTC Tamper Flag is pending or not.
  1111. * This parameter can be:
  1112. * @arg RTC_FLAG_TAMP1F: Tamper1 flag
  1113. * @arg RTC_FLAG_TAMP2F: Tamper2 flag
  1114. * @arg RTC_FLAG_TAMP3F: Tamper3 flag
  1115. * @retval None
  1116. */
  1117. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1118. #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->SR) & (__FLAG__)) != 0U)
  1119. #else
  1120. #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
  1121. #endif
  1122. /**
  1123. * @brief Clear the RTC Tamper's pending flags.
  1124. * @param __HANDLE__ specifies the RTC handle.
  1125. * @param __FLAG__ specifies the RTC Tamper Flag to clear.
  1126. * This parameter can be:
  1127. * @arg RTC_FLAG_TAMP1F: Tamper1 flag
  1128. * @arg RTC_FLAG_TAMP2F: Tamper2 flag
  1129. * @arg RTC_FLAG_TAMP3F: Tamper3 flag
  1130. * @retval None
  1131. */
  1132. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1133. #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->SCR) = (__FLAG__))
  1134. #else
  1135. #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  1136. #endif
  1137. /**
  1138. * @brief Enable interrupt on the RTC Tamper and Timestamp associated Exti line.
  1139. * @retval None
  1140. */
  1141. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  1142. /**
  1143. * @brief Disable interrupt on the RTC Tamper and Timestamp associated Exti line.
  1144. * @retval None
  1145. */
  1146. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  1147. /**
  1148. * @brief Enable event on the RTC Tamper and Timestamp associated Exti line.
  1149. * @retval None
  1150. */
  1151. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  1152. /**
  1153. * @brief Disable event on the RTC Tamper and Timestamp associated Exti line.
  1154. * @retval None
  1155. */
  1156. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  1157. /**
  1158. * @brief Enable falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  1159. * @retval None
  1160. */
  1161. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  1162. /**
  1163. * @brief Disable falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  1164. * @retval None
  1165. */
  1166. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  1167. /**
  1168. * @brief Enable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
  1169. * @retval None
  1170. */
  1171. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  1172. /**
  1173. * @brief Disable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
  1174. * @retval None
  1175. */
  1176. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR1 &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  1177. /**
  1178. * @brief Enable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  1179. * @retval None
  1180. */
  1181. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  1182. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE(); \
  1183. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE(); \
  1184. } while(0)
  1185. /**
  1186. * @brief Disable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  1187. * @retval None
  1188. */
  1189. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  1190. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE(); \
  1191. __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE(); \
  1192. } while(0)
  1193. /**
  1194. * @brief Check whether the RTC Tamper and Timestamp associated Exti line interrupt flag is set or not.
  1195. * @retval Line Status.
  1196. */
  1197. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GET_FLAG() (EXTI->PR1 & RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  1198. /**
  1199. * @brief Clear the RTC Tamper and Timestamp associated Exti line flag.
  1200. * @retval None
  1201. */
  1202. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_CLEAR_FLAG() (EXTI->PR1 = RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  1203. /**
  1204. * @brief Generate a Software interrupt on the RTC Tamper and Timestamp associated Exti line
  1205. * @retval None
  1206. */
  1207. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GENERATE_SWIT() (EXTI->SWIER1 |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  1208. /**
  1209. * @}
  1210. */
  1211. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1212. /* --------------------------------- SSR Underflow ---------------------------------*/
  1213. /** @defgroup RTCEx_SSR_Underflow RTC SSR Underflow
  1214. * @{
  1215. */
  1216. /**
  1217. * @brief Enable the RTC SSRU interrupt.
  1218. * @param __HANDLE__ specifies the RTC handle.
  1219. * @param __INTERRUPT__ specifies the RTC SSRU interrupt sources to be enabled.
  1220. * This parameter can be:
  1221. * @arg @ref RTC_IT_SSRU SSRU interrupt
  1222. * @retval None
  1223. */
  1224. #define __HAL_RTC_SSRU_ENABLE_IT(__HANDLE__, __INTERRUPT__) (RTC->CR |= (__INTERRUPT__))
  1225. /**
  1226. * @brief Disable the RTC SSRU interrupt.
  1227. * @param __HANDLE__ specifies the RTC handle.
  1228. * @param __INTERRUPT__ specifies the RTC SSRU interrupt sources to be disabled.
  1229. * This parameter can be:
  1230. * @arg @ref RTC_IT_SSRU SSRU interrupt
  1231. * @retval None
  1232. */
  1233. #define __HAL_RTC_SSRU_DISABLE_IT(__HANDLE__, __INTERRUPT__) (RTC->CR &= ~(__INTERRUPT__))
  1234. /**
  1235. * @brief Check whether the specified RTC SSRU interrupt has occurred or not.
  1236. * @param __HANDLE__ specifies the RTC handle.
  1237. * @param __INTERRUPT__ specifies the RTC SSRU interrupt to check.
  1238. * This parameter can be:
  1239. * @arg @ref RTC_IT_SSRU SSRU interrupt
  1240. * @retval None
  1241. */
  1242. #define __HAL_RTC_SSRU_GET_IT(__HANDLE__, __INTERRUPT__) ((((RTC->MISR) & ((__INTERRUPT__) >> 1) != 0U) ? 1U : 0U)
  1243. /**
  1244. * @brief Check whether the specified RTC Wake Up timer interrupt has been enabled or not.
  1245. * @param __HANDLE__ specifies the RTC handle.
  1246. * @param __INTERRUPT__ specifies the RTC Wake Up timer interrupt sources to check.
  1247. * This parameter can be:
  1248. * @arg @ref RTC_IT_SSRU SSRU interrupt
  1249. * @retval None
  1250. */
  1251. #define __HAL_RTC_SSRU_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((RTC->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
  1252. /**
  1253. * @brief Get the selected RTC SSRU's flag status.
  1254. * @param __HANDLE__ specifies the RTC handle.
  1255. * @param __FLAG__ specifies the RTC SSRU Flag is pending or not.
  1256. * This parameter can be:
  1257. * @arg @ref RTC_FLAG_SSRUF
  1258. * @arg @ref RTC_FLAG_SSRUWF
  1259. * @retval None
  1260. */
  1261. #define __HAL_RTC_SSRU_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__)))
  1262. /**
  1263. * @brief Clear the RTC Wake Up timer's pending flags.
  1264. * @param __HANDLE__ specifies the RTC handle.
  1265. * @param __FLAG__ specifies the RTC SSRU Flag to clear.
  1266. * This parameter can be:
  1267. * @arg @ref RTC_FLAG_SSRUF
  1268. * @retval None
  1269. */
  1270. #define __HAL_RTC_SSRU_CLEAR_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_CLEAR_FLAG((__HANDLE__), RTC_CLEAR_SSRUF))
  1271. /* WAKE-UP TIMER EXTI */
  1272. /* ------------------ */
  1273. /**
  1274. * @brief Enable interrupt on the RTC SSR Underflow associated Exti line.
  1275. * @retval None
  1276. */
  1277. #define __HAL_RTC_SSRU_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_SSRU_EVENT)
  1278. /**
  1279. * @brief Disable interrupt on the RTC SSR Underflow associated Exti line.
  1280. * @retval None
  1281. */
  1282. #define __HAL_RTC_SSRU_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_SSRU_EVENT))
  1283. /**
  1284. * @brief Enable event on the RTC SSR Underflow associated Exti line.
  1285. * @retval None
  1286. */
  1287. #define __HAL_RTC_SSRU_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_SSRU_EVENT)
  1288. /**
  1289. * @brief Disable event on the RTC SSR Underflow associated Exti line.
  1290. * @retval None
  1291. */
  1292. #define __HAL_RTC_SSRU_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_SSRU_EVENT))
  1293. /**
  1294. * @}
  1295. */
  1296. #endif /* #if defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  1297. /**
  1298. * @}
  1299. */
  1300. /* Exported functions --------------------------------------------------------*/
  1301. /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions
  1302. * @{
  1303. */
  1304. /* ========================================================================== */
  1305. /* ##### RTC TimeStamp exported functions ##### */
  1306. /* ========================================================================== */
  1307. /* RTC TimeStamp functions ****************************************************/
  1308. /** @defgroup RTCEx_Exported_Functions_Group1 Extended RTC TimeStamp functions
  1309. * @{
  1310. */
  1311. HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
  1312. HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
  1313. HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc);
  1314. HAL_StatusTypeDef HAL_RTCEx_SetInternalTimeStamp(RTC_HandleTypeDef *hrtc);
  1315. HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTimeStamp(RTC_HandleTypeDef *hrtc);
  1316. HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format);
  1317. void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc);
  1318. void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc);
  1319. HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  1320. /**
  1321. * @}
  1322. */
  1323. /* ========================================================================== */
  1324. /* ##### RTC Wake-up exported functions ##### */
  1325. /* ========================================================================== */
  1326. /* RTC Wake-up functions ******************************************************/
  1327. /** @defgroup RTCEx_Exported_Functions_Group2 Extended RTC Wake-up functions
  1328. * @{
  1329. */
  1330. HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
  1331. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1332. HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock, uint32_t WakeUpAutoClr);
  1333. #else
  1334. HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
  1335. #endif
  1336. HAL_StatusTypeDef HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc);
  1337. uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc);
  1338. void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc);
  1339. void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc);
  1340. HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  1341. /**
  1342. * @}
  1343. */
  1344. /* ========================================================================== */
  1345. /* ##### Extended RTC Peripheral Control exported functions ##### */
  1346. /* ========================================================================== */
  1347. /* Extended RTC Peripheral Control functions **********************************/
  1348. /** @defgroup RTCEx_Exported_Functions_Group3 Extended Peripheral Control functions
  1349. * @{
  1350. */
  1351. HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue);
  1352. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1353. HAL_StatusTypeDef HAL_RTCEx_SetLowPowerCalib(RTC_HandleTypeDef *hrtc, uint32_t LowPowerCalib);
  1354. #endif
  1355. HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS);
  1356. HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput);
  1357. HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc);
  1358. HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc);
  1359. HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc);
  1360. HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc);
  1361. HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc);
  1362. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1363. HAL_StatusTypeDef HAL_RTCEx_SetSSRU_IT(RTC_HandleTypeDef *hrtc);
  1364. HAL_StatusTypeDef HAL_RTCEx_DeactivateSSRU(RTC_HandleTypeDef *hrtc);
  1365. void HAL_RTCEx_SSRUIRQHandler(RTC_HandleTypeDef *hrtc);
  1366. void HAL_RTCEx_SSRUEventCallback(RTC_HandleTypeDef *hrtc);
  1367. #endif
  1368. /**
  1369. * @}
  1370. */
  1371. /* Extended RTC features functions *******************************************/
  1372. /** @defgroup RTCEx_Exported_Functions_Group4 Extended features functions
  1373. * @{
  1374. */
  1375. void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc);
  1376. HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  1377. /**
  1378. * @}
  1379. */
  1380. /** @defgroup RTCEx_Exported_Functions_Group5 Extended RTC Tamper functions
  1381. * @{
  1382. */
  1383. HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper);
  1384. HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper);
  1385. HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper);
  1386. #if defined(RTC_TAMPER1_SUPPORT)
  1387. HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  1388. #endif /* RTC_TAMPER1_SUPPORT */
  1389. HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  1390. #if defined(RTC_TAMPER3_SUPPORT)
  1391. HAL_StatusTypeDef HAL_RTCEx_PollForTamper3Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  1392. #endif /* RTC_TAMPER3_SUPPORT */
  1393. #if defined(RTC_TAMPER1_SUPPORT)
  1394. void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc);
  1395. #endif /* RTC_TAMPER1_SUPPORT */
  1396. void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc);
  1397. #if defined(RTC_TAMPER3_SUPPORT)
  1398. void HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc);
  1399. #endif /* RTC_TAMPER3_SUPPORT */
  1400. /**
  1401. * @}
  1402. */
  1403. /** @defgroup RTCEx_Exported_Functions_Group6 Extended RTC Backup register functions
  1404. * @{
  1405. */
  1406. void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data);
  1407. uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister);
  1408. /**
  1409. * @}
  1410. */
  1411. /**
  1412. * @}
  1413. */
  1414. /* Private types -------------------------------------------------------------*/
  1415. /* Private variables ---------------------------------------------------------*/
  1416. /* Private constants ---------------------------------------------------------*/
  1417. /** @defgroup RTCEx_Private_Constants RTCEx Private Constants
  1418. * @{
  1419. */
  1420. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1421. #define RTC_EXTI_LINE_SSRU_EVENT EXTI_IMR1_IM18 /*!< External interrupt line 18 Connected to the RTC SSR Underflow event */
  1422. #endif
  1423. #define RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT EXTI_IMR1_IM19 /*!< External interrupt line 19 Connected to the RTC Tamper and Time Stamp events */
  1424. #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT EXTI_IMR1_IM20 /*!< External interrupt line 20 Connected to the RTC Wakeup event */
  1425. /**
  1426. * @}
  1427. */
  1428. /* Private macros ------------------------------------------------------------*/
  1429. /** @defgroup RTCEx_Private_Macros RTCEx Private Macros
  1430. * @{
  1431. */
  1432. /** @defgroup RTCEx_IS_RTC_Definitions Private macros to check input parameters
  1433. * @{
  1434. */
  1435. #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \
  1436. ((EDGE) == RTC_TIMESTAMPEDGE_FALLING))
  1437. #define IS_RTC_TAMPER_INTERRUPT(INTERRUPT) ((((INTERRUPT) & (uint32_t)0xFFB6FFFB) == 0x00) && ((INTERRUPT) != 0U))
  1438. #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TIMESTAMPPIN_DEFAULT))
  1439. #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16) || \
  1440. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8) || \
  1441. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4) || \
  1442. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2) || \
  1443. ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \
  1444. ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS))
  1445. #define IS_RTC_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= RTC_WUTR_WUT)
  1446. #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \
  1447. ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \
  1448. ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC))
  1449. #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \
  1450. ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET))
  1451. #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= RTC_CALR_CALM)
  1452. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1453. #define IS_RTC_LOW_POWER_CALIB(LPCAL) (((LPCAL) == RTC_LPCAL_SET) || \
  1454. ((LPCAL) == RTC_LPCAL_RESET))
  1455. #endif
  1456. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1457. #define IS_RTC_TAMPER(__TAMPER__) ((((__TAMPER__) & RTC_TAMPER_ALL) != 0x00U) && \
  1458. (((__TAMPER__) & ~RTC_TAMPER_ALL) == 0x00U))
  1459. #else
  1460. #define IS_RTC_TAMPER(TAMPER) ((((TAMPER) & (uint32_t)0xFFFFFFD6) == 0x00) && ((TAMPER) != 0U))
  1461. #endif
  1462. #define IS_RTC_TAMPER_TRIGGER(__TRIGGER__) (((__TRIGGER__) == RTC_TAMPERTRIGGER_RISINGEDGE) || \
  1463. ((__TRIGGER__) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \
  1464. ((__TRIGGER__) == RTC_TAMPERTRIGGER_LOWLEVEL) || \
  1465. ((__TRIGGER__) == RTC_TAMPERTRIGGER_HIGHLEVEL))
  1466. #define IS_RTC_TAMPER_ERASE_MODE(__MODE__) (((__MODE__) == RTC_TAMPER_ERASE_BACKUP_ENABLE) || \
  1467. ((__MODE__) == RTC_TAMPER_ERASE_BACKUP_DISABLE))
  1468. #define IS_RTC_TAMPER_MASKFLAG_STATE(__STATE__) (((__STATE__) == RTC_TAMPERMASK_FLAG_ENABLE) || \
  1469. ((__STATE__) == RTC_TAMPERMASK_FLAG_DISABLE))
  1470. #define IS_RTC_TAMPER_FILTER(__FILTER__) (((__FILTER__) == RTC_TAMPERFILTER_DISABLE) || \
  1471. ((__FILTER__) == RTC_TAMPERFILTER_2SAMPLE) || \
  1472. ((__FILTER__) == RTC_TAMPERFILTER_4SAMPLE) || \
  1473. ((__FILTER__) == RTC_TAMPERFILTER_8SAMPLE))
  1474. #define IS_RTC_TAMPER_SAMPLING_FREQ(__FREQ__) (((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \
  1475. ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \
  1476. ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \
  1477. ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \
  1478. ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \
  1479. ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \
  1480. ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512) || \
  1481. ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256))
  1482. #define IS_RTC_TAMPER_PRECHARGE_DURATION(__DURATION__) (((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \
  1483. ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \
  1484. ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \
  1485. ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK))
  1486. #define IS_RTC_TAMPER_PULLUP_STATE(__STATE__) (((__STATE__) == RTC_TAMPER_PULLUP_ENABLE) || \
  1487. ((__STATE__) == RTC_TAMPER_PULLUP_DISABLE))
  1488. #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \
  1489. ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE))
  1490. #define IS_RTC_BKP(__BKP__) ((__BKP__) < RTC_BKP_NUMBER)
  1491. #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \
  1492. ((SEL) == RTC_SHIFTADD1S_SET))
  1493. #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= RTC_SHIFTR_SUBFS)
  1494. #define IS_RTC_CALIB_OUTPUT(OUTPUT) (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \
  1495. ((OUTPUT) == RTC_CALIBOUTPUT_1HZ))
  1496. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1497. #define IS_RTC_BINARY_MODE(MODE) (((MODE) == RTC_BINARY_NONE) || \
  1498. ((MODE) == RTC_BINARY_ONLY) || \
  1499. ((MODE) == RTC_BINARY_MIX ))
  1500. #define IS_RTC_BINARY_MIX_BCDU(BDCU) (((BDCU) == RTC_BINARY_MIX_BCDU_0) || \
  1501. ((BDCU) == RTC_BINARY_MIX_BCDU_1) || \
  1502. ((BDCU) == RTC_BINARY_MIX_BCDU_2) || \
  1503. ((BDCU) == RTC_BINARY_MIX_BCDU_3) || \
  1504. ((BDCU) == RTC_BINARY_MIX_BCDU_4) || \
  1505. ((BDCU) == RTC_BINARY_MIX_BCDU_5) || \
  1506. ((BDCU) == RTC_BINARY_MIX_BCDU_6) || \
  1507. ((BDCU) == RTC_BINARY_MIX_BCDU_7))
  1508. #define IS_RTC_ALARM_SUB_SECOND_BINARY_MASK(MASK) (((MASK) == 0u) || \
  1509. (((MASK) >= RTC_ALARMSUBSECONDBINMASK_SS31_1) && ((MASK) <= RTC_ALARMSUBSECONDBINMASK_NONE)))
  1510. #define IS_RTC_ALARMSUBSECONDBIN_AUTOCLR(SEL) (((SEL) == RTC_ALARMSUBSECONDBIN_AUTOCLR_NO) || \
  1511. ((SEL) == RTC_ALARMSUBSECONDBIN_AUTOCLR_YES))
  1512. #endif /* #if defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  1513. /**
  1514. * @}
  1515. */
  1516. /**
  1517. * @}
  1518. */
  1519. /**
  1520. * @}
  1521. */
  1522. /**
  1523. * @}
  1524. */
  1525. #ifdef __cplusplus
  1526. }
  1527. #endif /* __cplusplus */
  1528. #endif /* STM32L4xx_HAL_RTC_EX_H */