1 /**
2   ******************************************************************************
3   * @file    stm32u5xx_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) 2021 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 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32U5xx_HAL_RTC_EX_H
21 #define STM32U5xx_HAL_RTC_EX_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32u5xx_hal_def.h"
29 
30 /** @addtogroup STM32U5xx_HAL_Driver
31   * @{
32   */
33 
34 /** @defgroup RTCEx RTCEx
35   * @{
36   */
37 
38 /* Exported types ------------------------------------------------------------*/
39 /** @defgroup RTCEx_Exported_Types RTCEx Exported Types
40   * @{
41   */
42 
43 /** @defgroup RTCEx_Tamper_structure_definition RTCEx Tamper structure definition
44   * @{
45   */
46 typedef struct
47 {
48   uint32_t Tamper;                      /*!< Specifies the Tamper Pin.
49                                              This parameter can be a value of @ref RTCEx_Tamper_Pins */
50 
51   uint32_t Trigger;                     /*!< Specifies the Tamper Trigger.
52                                              This parameter can be a value of @ref RTCEx_Tamper_Trigger */
53 
54   uint32_t NoErase;                     /*!< Specifies the Tamper no erase mode.
55                                              This parameter can be a value of @ref RTCEx_Tamper_EraseBackUp */
56 
57   uint32_t MaskFlag;                    /*!< Specifies the Tamper Flag masking.
58                                              This parameter can be a value of @ref RTCEx_Tamper_MaskFlag */
59 
60   uint32_t Filter;                      /*!< Specifies the TAMP Filter Tamper.
61                                              This parameter can be a value of @ref RTCEx_Tamper_Filter */
62 
63   uint32_t SamplingFrequency;           /*!< Specifies the sampling frequency.
64                                              This parameter can be a value of
65                                              @ref RTCEx_Tamper_Sampling_Frequencies */
66 
67   uint32_t PrechargeDuration;           /*!< Specifies the Precharge Duration .
68                                              This parameter can be a value of
69                                              @ref RTCEx_Tamper_Pin_Precharge_Duration */
70 
71   uint32_t TamperPullUp;                /*!< Specifies the Tamper PullUp .
72                                              This parameter can be a value of @ref RTCEx_Tamper_Pull_UP */
73 
74   uint32_t TimeStampOnTamperDetection;  /*!< Specifies the TimeStampOnTamperDetection.
75                                              This parameter can be a value of
76                                               @ref RTCEx_Tamper_TimeStampOnTamperDetection */
77 } RTC_TamperTypeDef;
78 /**
79   * @}
80   */
81 
82 
83 /** @defgroup RTCEx_Active_Seed_Size Seed size Definitions
84   * @{
85   */
86 #define RTC_ATAMP_SEED_NB_UINT32        4U
87 /**
88   * @}
89   */
90 
91 
92 /** @defgroup RTCEx_ActiveTamper_structures_definition RTCEx Active Tamper structures definitions
93   * @{
94   */
95 typedef struct
96 {
97   uint32_t Enable;                      /*!< Specifies the Tamper input is active.
98                                              This parameter can be a value of @ref RTCEx_ActiveTamper_Enable */
99 
100   uint32_t Interrupt;                    /*!< Specifies the interrupt mode
101                                              This parameter can be a value of @ref RTCEx_ActiveTamper_Interrupt */
102 
103   uint32_t Output;                      /*!< Specifies the TAMP output to be compared with.
104                                              The same output can be used for several tamper inputs.
105                                              This parameter can be a value of @ref RTCEx_ActiveTamper_Sel */
106 
107   uint32_t NoErase;                     /*!< Specifies the Tamper no erase mode.
108                                              This parameter can be a value of @ref RTCEx_Tamper_EraseBackUp */
109 
110   uint32_t MaskFlag;                    /*!< Specifies the Tamper Flag masking.
111                                              This parameter can be a value of @ref RTCEx_Tamper_MaskFlag */
112 
113 } RTC_ATampInputTypeDef;
114 
115 
116 typedef struct
117 {
118   uint32_t ActiveFilter;                /*!< Specifies the Active tamper filter enable.
119                                              This parameter can be a value of @ref RTCEx_ActiveTamper_Filter */
120 
121   uint32_t ActiveAsyncPrescaler;        /*!< Specifies the Active Tamper asynchronous Prescaler clock.
122                                              This parameter can be a value of
123                                              @ref RTCEx_ActiveTamper_Async_prescaler */
124 
125   uint32_t TimeStampOnTamperDetection;  /*!< Specifies the timeStamp on tamper detection.
126                                              This parameter can be a value of
127                                              @ref RTCEx_Tamper_TimeStampOnTamperDetection */
128 
129   uint32_t ActiveOutputChangePeriod;    /*!< Specifies the Active Tamper output change period .
130                                              This parameter can be a value from 0 to 7. */
131 
132   uint32_t Seed[RTC_ATAMP_SEED_NB_UINT32];
133   /*!< Specifies the RNG Seed value.
134        This parameter is an array of value from 0 to 0xFFFFFFFF */
135 
136   RTC_ATampInputTypeDef TampInput[RTC_TAMP_NB];
137   /*!< Specifies configuration of all active tampers.
138        The index of TampInput[RTC_TAMP_NB] can be a value of RTCEx_ActiveTamper_Sel */
139 } RTC_ActiveTampersTypeDef;
140 /**
141   * @}
142   */
143 
144 /** @defgroup RTCEx_Internal_Tamper_structure_definition RTCEx Internal Tamper structure definition
145   * @{
146   */
147 typedef struct
148 {
149   uint32_t IntTamper;                   /*!< Specifies the Internal Tamper Pin.
150                                              This parameter can be a value of @ref RTCEx_Internal_Tamper_Pins */
151 
152   uint32_t TimeStampOnTamperDetection;  /*!< Specifies the TimeStampOnTamperDetection.
153                                              This parameter can be a value of
154                                              @ref RTCEx_Tamper_TimeStampOnTamperDetection */
155 
156   uint32_t NoErase;                     /*!< Specifies the internal Tamper no erase mode.
157                                              This parameter can be a value of @ref RTCEx_Tamper_EraseBackUp */
158 
159 } RTC_InternalTamperTypeDef;
160 /**
161   * @}
162   */
163 
164 /** @defgroup RTCEx_Secure_State_structure_definition RTCEx Secure structure definition
165   * @{
166   */
167 typedef struct
168 {
169   uint32_t rtcSecureFull;               /*!< Specifies If the RTC is fully secure or not
170                                              This parameter can be a value of @ref RTCEx_RTC_Secure_Full */
171 
172   uint32_t rtcNonSecureFeatures;        /*!< Specifies the non-secure features.
173                                              This parameter is only relevant if RTC is not fully secure
174                                              (rtcSecureFull == RTC_SECURE_FULL_NO).
175                                              This parameter can be a combination of
176                                              @ref RTCEx_RTC_NonSecure_Features. */
177 
178   uint32_t tampSecureFull;              /*!< Specifies If the TAMP is fully secure or not execpt monotonic counters
179                                              and BackUp registers.
180                                              This parameter can be a value of @ref RTCEx_TAMP_Secure_Full */
181 
182   uint32_t backupRegisterStartZone2;    /*!< Specifies the backup register start zone 2
183                                              Zone 1 : read secure write secure.
184                                              Zone 2 : read non-secure  write secure.
185                                              This parameter can be RTC_BKP_DRx where x can be from 0 to 31 to specify
186                                               the register.
187                                              Warning : this parameter is shared with RTC_PrivilegeStateTypeDef. */
188 
189   uint32_t backupRegisterStartZone3;    /*!< Specifies the backup register start zone 3
190                                              Zone 3 : read non-secure  write non-secure
191                                              This parameter can be RTC_BKP_DRx where x can be from 0 to 31 to
192                                              specify the register.
193                                              Warning : this parameter is shared with RTC_PrivilegeStateTypeDef. */
194 
195   uint32_t MonotonicCounterSecure;      /*!< Specifies If the monotonic counter is secure or not
196                                              This parameter can be a value of
197                                              @ref RTCEx_TAMP_Monotonic_Counter_Secure */
198 } RTC_SecureStateTypeDef;
199 /**
200   * @}
201   */
202 
203 /** @defgroup RTCEx_Privilege_State_structure_definition RTCEx Privilege structure definition
204   * @{
205   */
206 typedef struct
207 {
208   uint32_t rtcPrivilegeFull;            /*!< Specifies If the RTC is fully privileged or not.
209                                              This parameter can be a value of @ref RTCEx_RTC_Privilege_Full. */
210 
211   uint32_t rtcPrivilegeFeatures;        /*!< Specifies the privileged features.
212                                              This parameter is only relevant if RTC is not fully privileged
213                                              (rtcPrivilegeFull == RTC_PRIVILEGE_FULL_NO).
214                                              This parameter can be a combination of
215                                              @ref RTCEx_RTC_Privilege_Features. */
216 
217   uint32_t tampPrivilegeFull;           /*!< Specifies If the TAMP is fully privileged or not execpt monotonic
218                                              counters and BackUp registers.
219                                              This parameter can be a value of @ref RTCEx_TAMP_Privilege_Full. */
220 
221   uint32_t backupRegisterPrivZone;      /*!< Specifies backup register zone to be privileged.
222                                              This parameter can be a combination of
223                                              @ref RTCEx_Backup_Reg_Privilege_zone.
224                                              Warning : this parameter is writable in secure mode or if trustzone is
225                                              disabled. */
226 
227   uint32_t backupRegisterStartZone2;    /*!< Specifies the backup register start zone 2.
228                                              Zone 1 granted accesses : read secure, write secure.
229                                              Zone 2 granted accesses : read non-secure, write secure.
230                                              This parameter can be RTC_BKP_DRx where x can be from 0 to 31 to specify
231                                              the register .
232                                              Warning : this parameter is writable in secure mode or if trustzone is
233                                              disabled.
234                                              Warning : this parameter is shared with RTC_SecureStateTypeDef */
235 
236   uint32_t backupRegisterStartZone3;    /*!< Specifies the backup register start zone 3.
237                                              Zone 3 granted accesses : read non-secure, write non-secure.
238                                              This parameter can be RTC_BKP_DRx where x can be from 0 to 31 to specify
239                                              the register.
240                                              Warning : this parameter is writable in secure mode or if trustzone is
241                                              disabled.
242                                              Warning : this parameter is shared with RTC_SecureStateTypeDef. */
243 
244   uint32_t MonotonicCounterPrivilege;  /*!< Specifies If the monotonic counter is privileged or not
245                                              This parameter can be a value of
246                                              @ref RTCEx_TAMP_Monotonic_Counter_Privilege */
247 } RTC_PrivilegeStateTypeDef;
248 /**
249   * @}
250   */
251 
252 /**
253   * @}
254   */
255 
256 /* Exported constants --------------------------------------------------------*/
257 /** @defgroup RTCEx_Exported_Constants RTCEx Exported Constants
258   * @{
259   */
260 
261 /** @defgroup RTCEx_Time_Stamp_Edges_definitions RTCEx Time Stamp Edges definition
262   * @{
263   */
264 #define RTC_TIMESTAMPEDGE_RISING           0U
265 #define RTC_TIMESTAMPEDGE_FALLING          RTC_CR_TSEDGE
266 /**
267   * @}
268   */
269 
270 /** @defgroup RTCEx_TimeStamp_Pin_Selections RTCEx TimeStamp Pin Selection
271   * @{
272   */
273 #define RTC_TIMESTAMPPIN_DEFAULT           0U
274 /**
275   * @}
276   */
277 
278 /** @defgroup RTCEx_Wakeup_Timer_Definitions RTCEx Wakeup Timer Definitions
279   * @{
280   */
281 #define RTC_WAKEUPCLOCK_RTCCLK_DIV16       0U
282 #define RTC_WAKEUPCLOCK_RTCCLK_DIV8        RTC_CR_WUCKSEL_0
283 #define RTC_WAKEUPCLOCK_RTCCLK_DIV4        RTC_CR_WUCKSEL_1
284 #define RTC_WAKEUPCLOCK_RTCCLK_DIV2        (RTC_CR_WUCKSEL_0 | RTC_CR_WUCKSEL_1)
285 #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS     RTC_CR_WUCKSEL_2
286 #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS     (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_2)
287 /**
288   * @}
289   */
290 
291 /** @defgroup RTCEx_Smooth_calib_period_Definitions RTCEx Smooth calib period Definitions
292   * @{
293   */
294 #define RTC_SMOOTHCALIB_PERIOD_32SEC       0U                    /*!< If RTCCLK = 32768 Hz, Smooth calibration period
295                                                                       is 32s, else 2exp20 RTCCLK pulses */
296 #define RTC_SMOOTHCALIB_PERIOD_16SEC       RTC_CALR_CALW16       /*!< If RTCCLK = 32768 Hz, Smooth calibration period
297                                                                       is 16s, else 2exp19 RTCCLK pulses */
298 #define RTC_SMOOTHCALIB_PERIOD_8SEC        RTC_CALR_CALW8        /*!< If RTCCLK = 32768 Hz, Smooth calibration period
299                                                                       is 8s, else 2exp18 RTCCLK pulses  */
300 /**
301   * @}
302   */
303 
304 /** @defgroup RTCEx_Smooth_calib_Plus_pulses_Definitions RTCEx Smooth calib Plus pulses Definitions
305   * @{
306   */
307 #define RTC_SMOOTHCALIB_PLUSPULSES_SET     RTC_CALR_CALP         /*!< The number of RTCCLK pulses added
308                                                                       during a X -second window = Y - CALM[8:0]
309                                                                       with Y = 512, 256, 128 when X = 32, 16, 8 */
310 #define RTC_SMOOTHCALIB_PLUSPULSES_RESET   0U                    /*!< The number of RTCCLK pulses subbstited
311                                                                       during a 32-second window = CALM[8:0]     */
312 /**
313   * @}
314   */
315 
316 /** @defgroup RTCEx_Smooth_calib_low_power_Definitions RTCEx Smooth calib Low Power Definitions
317   * @{
318   */
319 #define RTC_LPCAL_SET                      RTC_CALR_LPCAL        /*!< Calibration window is 2exp20 ck_apre, which is the required configuration for ultra-low consumption mode. */
320 #define RTC_LPCAL_RESET                    0U                    /*!< Calibration window is 2exp20 RTCCLK, which is a high-consumption mode.
321                                                                       This mode should be set only when less
322                                                                       than 32s calibration window is required. */
323 /**
324   * @}
325   */
326 
327 /** @defgroup RTCEx_Calib_Output_selection_Definitions RTCEx Calib Output selection Definitions
328   * @{
329   */
330 #define RTC_CALIBOUTPUT_512HZ              0U
331 #define RTC_CALIBOUTPUT_1HZ                RTC_CR_COSEL
332 /**
333   * @}
334   */
335 
336 
337 /** @defgroup RTCEx_Add_1_Second_Parameter_Definition RTCEx Add 1 Second Parameter Definitions
338   * @{
339   */
340 #define RTC_SHIFTADD1S_RESET               0U
341 #define RTC_SHIFTADD1S_SET                 RTC_SHIFTR_ADD1S
342 /**
343   * @}
344   */
345 
346 /** @defgroup RTCEx_Tamper_Pins  RTCEx Tamper Pins Definition
347   * @{
348   */
349 #define RTC_TAMPER_1                        TAMP_CR1_TAMP1E
350 #define RTC_TAMPER_2                        TAMP_CR1_TAMP2E
351 #if (RTC_TAMP_NB == 3)
352 #define RTC_TAMPER_3                         TAMP_CR1_TAMP3E
353 #define RTC_TAMPER_ALL                      (RTC_TAMPER_1 | RTC_TAMPER_2 | RTC_TAMPER_3 )
354 #elif (RTC_TAMP_NB == 8)
355 #define RTC_TAMPER_3                        TAMP_CR1_TAMP3E
356 #define RTC_TAMPER_4                        TAMP_CR1_TAMP4E
357 #define RTC_TAMPER_5                        TAMP_CR1_TAMP5E
358 #define RTC_TAMPER_6                        TAMP_CR1_TAMP6E
359 #define RTC_TAMPER_7                        TAMP_CR1_TAMP7E
360 #define RTC_TAMPER_8                        TAMP_CR1_TAMP8E
361 #define RTC_TAMPER_ALL                      (RTC_TAMPER_1 | RTC_TAMPER_2 |\
362                                              RTC_TAMPER_3 | RTC_TAMPER_4 |\
363                                              RTC_TAMPER_5 | RTC_TAMPER_6 |\
364                                              RTC_TAMPER_7 | RTC_TAMPER_8 )
365 #else
366 #define RTC_TAMPER_ALL                      (RTC_TAMPER_1 | RTC_TAMPER_2)
367 #endif /* RTC_TAMP_NB */
368 /**
369   * @}
370   */
371 
372 /** @defgroup RTCEx_Internal_Tamper_Pins  RTCEx Internal Tamper Pins Definition
373   * @{
374   */
375 #define RTC_INT_TAMPER_1                    TAMP_CR1_ITAMP1E
376 #define RTC_INT_TAMPER_2                    TAMP_CR1_ITAMP2E
377 #define RTC_INT_TAMPER_3                    TAMP_CR1_ITAMP3E
378 #define RTC_INT_TAMPER_5                    TAMP_CR1_ITAMP5E
379 #define RTC_INT_TAMPER_6                    TAMP_CR1_ITAMP6E
380 #define RTC_INT_TAMPER_7                    TAMP_CR1_ITAMP7E
381 #define RTC_INT_TAMPER_8                    TAMP_CR1_ITAMP8E
382 #define RTC_INT_TAMPER_9                    TAMP_CR1_ITAMP9E
383 #define RTC_INT_TAMPER_11                   TAMP_CR1_ITAMP11E
384 #define RTC_INT_TAMPER_12                   TAMP_CR1_ITAMP12E
385 #define RTC_INT_TAMPER_13                   TAMP_CR1_ITAMP13E
386 #define RTC_INT_TAMPER_ALL                  (RTC_INT_TAMPER_1 | RTC_INT_TAMPER_2 |\
387                                              RTC_INT_TAMPER_3 | RTC_INT_TAMPER_5 |\
388                                              RTC_INT_TAMPER_6 | RTC_INT_TAMPER_7 |\
389                                              RTC_INT_TAMPER_8 | RTC_INT_TAMPER_9 |\
390                                              RTC_INT_TAMPER_11|RTC_INT_TAMPER_12|\
391                                              RTC_INT_TAMPER_13)
392 /**
393   * @}
394   */
395 
396 /** @defgroup RTCEx_Tamper_Trigger  RTCEx Tamper Trigger
397   * @{
398   */
399 #define RTC_TAMPERTRIGGER_RISINGEDGE       0U                    /*!< Warning : Filter must be RTC_TAMPERFILTER_DISABLE */
400 #define RTC_TAMPERTRIGGER_FALLINGEDGE      1U                    /*!< Warning : Filter must be RTC_TAMPERFILTER_DISABLE */
401 #define RTC_TAMPERTRIGGER_LOWLEVEL         2U                    /*!< Warning : Filter must not be RTC_TAMPERFILTER_DISABLE */
402 #define RTC_TAMPERTRIGGER_HIGHLEVEL        3U                    /*!< Warning : Filter must not be RTC_TAMPERFILTER_DISABLE */
403 /**
404   * @}
405   */
406 
407 /** @defgroup RTCEx_Tamper_MaskFlag  RTCEx Tamper MaskFlag
408   * @{
409   */
410 #define RTC_TAMPERMASK_FLAG_DISABLE         0x00u
411 #define RTC_TAMPERMASK_FLAG_ENABLE          0x01u
412 /**
413   * @}
414   */
415 
416 /** @defgroup RTCEx_Tamper_EraseBackUp  RTCEx Tamper EraseBackUp
417   * @{
418   */
419 #define RTC_TAMPER_ERASE_BACKUP_ENABLE     0U
420 #define RTC_TAMPER_ERASE_BACKUP_DISABLE    1U
421 /**
422   * @}
423   */
424 
425 /** @defgroup RTCEx_Tamper_Filter  RTCEx Tamper Filter
426   * @{
427   */
428 #define RTC_TAMPERFILTER_DISABLE           0U                      /*!< Tamper filter is disabled */
429 #define RTC_TAMPERFILTER_2SAMPLE           TAMP_FLTCR_TAMPFLT_0    /*!< Tamper is activated after 2
430                                                                          consecutive samples at the active level */
431 #define RTC_TAMPERFILTER_4SAMPLE           TAMP_FLTCR_TAMPFLT_1    /*!< Tamper is activated after 4
432                                                                          consecutive samples at the active level */
433 #define RTC_TAMPERFILTER_8SAMPLE           TAMP_FLTCR_TAMPFLT      /*!< Tamper is activated after 8
434                                                                          consecutive samples at the active level */
435 /**
436   * @}
437   */
438 
439 /** @defgroup RTCEx_Tamper_Sampling_Frequencies  RTCEx Tamper Sampling Frequencies
440   * @{
441   */
442 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768  0U                                              /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 32768 */
443 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384  TAMP_FLTCR_TAMPFREQ_0                           /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 16384 */
444 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192   TAMP_FLTCR_TAMPFREQ_1                           /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 8192  */
445 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096   (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_1) /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 4096  */
446 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048   TAMP_FLTCR_TAMPFREQ_2                           /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 2048  */
447 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024   (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 1024  */
448 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512    (TAMP_FLTCR_TAMPFREQ_1 | TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 512   */
449 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256    (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_1 | \
450                                                  TAMP_FLTCR_TAMPFREQ_2)                         /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 256   */
451 /**
452   * @}
453   */
454 
455 /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration  RTCEx Tamper Pin Precharge Duration
456   * @{
457   */
458 #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK     0U                                                /*!< Tamper pins are pre-charged before sampling during 1 RTCCLK cycle  */
459 #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK     TAMP_FLTCR_TAMPPRCH_0                             /*!< Tamper pins are pre-charged before sampling during 2 RTCCLK cycles */
460 #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK     TAMP_FLTCR_TAMPPRCH_1                             /*!< Tamper pins are pre-charged before sampling during 4 RTCCLK cycles */
461 #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK     (TAMP_FLTCR_TAMPPRCH_0 | TAMP_FLTCR_TAMPPRCH_1)   /*!< Tamper pins are pre-charged before sampling during 8 RTCCLK cycles */
462 /**
463   * @}
464   */
465 
466 /** @defgroup RTCEx_Tamper_Pull_UP  RTCEx Tamper Pull UP
467   * @{
468   */
469 #define RTC_TAMPER_PULLUP_ENABLE           0U                    /*!< Tamper pins are pre-charged before sampling */
470 #define RTC_TAMPER_PULLUP_DISABLE          TAMP_FLTCR_TAMPPUDIS  /*!< Tamper pins pre-charge is disabled          */
471 /**
472   * @}
473   */
474 
475 /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection RTCEx Tamper TimeStamp On Tamper Detection Definitions
476   * @{
477   */
478 #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE  0U             /*!< TimeStamp on Tamper Detection event is not saved */
479 #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE   RTC_CR_TAMPTS  /*!< TimeStamp on Tamper Detection event saved        */
480 /**
481   * @}
482   */
483 
484 /** @defgroup RTCEx_Internal_Tamper_Interrupt  RTCEx Internal Tamper Interrupt
485   * @{
486   */
487 #define RTC_IT_TAMP_1                      TAMP_IER_TAMP1IE     /*!< Tamper 1 Interrupt */
488 #define RTC_IT_TAMP_2                      TAMP_IER_TAMP2IE     /*!< Tamper 2 Interrupt */
489 #define RTC_IT_TAMP_3                      TAMP_IER_TAMP3IE     /*!< Tamper 3 Interrupt */
490 #define RTC_IT_TAMP_4                      TAMP_IER_TAMP4IE     /*!< Tamper 4 Interrupt */
491 #define RTC_IT_TAMP_5                      TAMP_IER_TAMP5IE     /*!< Tamper 5 Interrupt */
492 #define RTC_IT_TAMP_6                      TAMP_IER_TAMP6IE     /*!< Tamper 6 Interrupt */
493 #define RTC_IT_TAMP_7                      TAMP_IER_TAMP7IE     /*!< Tamper 7 Interrupt */
494 #define RTC_IT_TAMP_8                      TAMP_IER_TAMP8IE     /*!< Tamper 8 Interrupt */
495 #define RTC_IT_TAMP_ALL                   (RTC_IT_TAMP_1 | RTC_IT_TAMP_2 |\
496                                            RTC_IT_TAMP_3 | RTC_IT_TAMP_4 |\
497                                            RTC_IT_TAMP_5 | RTC_IT_TAMP_6 |\
498                                            RTC_IT_TAMP_7 | RTC_IT_TAMP_8 )
499 
500 #define RTC_IT_INT_TAMP_1                   TAMP_IER_ITAMP1IE     /*!< Tamper 1 internal Interrupt */
501 #define RTC_IT_INT_TAMP_2                   TAMP_IER_ITAMP2IE     /*!< Tamper 2 internal Interrupt */
502 #define RTC_IT_INT_TAMP_3                   TAMP_IER_ITAMP3IE     /*!< Tamper 3 internal Interrupt */
503 #define RTC_IT_INT_TAMP_5                   TAMP_IER_ITAMP5IE     /*!< Tamper 5 internal Interrupt */
504 #define RTC_IT_INT_TAMP_6                   TAMP_IER_ITAMP6IE     /*!< Tamper 6 internal Interrupt */
505 #define RTC_IT_INT_TAMP_7                   TAMP_IER_ITAMP7IE     /*!< Tamper 7 internal Interrupt */
506 #define RTC_IT_INT_TAMP_8                   TAMP_IER_ITAMP8IE     /*!< Tamper 8 internal Interrupt */
507 #define RTC_IT_INT_TAMP_9                   TAMP_IER_ITAMP9IE     /*!< Tamper 9 internal Interrupt */
508 #define RTC_IT_INT_TAMP_11                  TAMP_IER_ITAMP11IE    /*!< Tamper 11 internal Interrupt */
509 #define RTC_IT_INT_TAMP_12                  TAMP_IER_ITAMP9IE     /*!< Tamper 12 internal Interrupt */
510 #define RTC_IT_INT_TAMP_13                  TAMP_IER_ITAMP11IE    /*!< Tamper 13 internal Interrupt */
511 #define RTC_IT_INT_TAMP_ALL                (RTC_IT_INT_TAMP_1 | RTC_IT_INT_TAMP_2 |\
512                                             RTC_IT_INT_TAMP_3 | RTC_IT_INT_TAMP_5 |\
513                                             RTC_IT_INT_TAMP_6 | RTC_IT_INT_TAMP_7 |\
514                                             RTC_IT_INT_TAMP_8 | RTC_IT_INT_TAMP_9 |\
515                                             RTC_IT_INT_TAMP_11| RTC_IT_INT_TAMP_12|\
516                                             RTC_IT_INT_TAMP_13)
517 /**
518   * @}
519   */
520 
521 /** @defgroup RTCEx_Flags  RTCEx Flags
522   * @{
523   */
524 #define RTC_FLAG_TAMP_1                    TAMP_SR_TAMP1F
525 #define RTC_FLAG_TAMP_2                    TAMP_SR_TAMP2F
526 #define RTC_FLAG_TAMP_3                    TAMP_SR_TAMP3F
527 #define RTC_FLAG_TAMP_4                    TAMP_SR_TAMP4F
528 #define RTC_FLAG_TAMP_5                    TAMP_SR_TAMP5F
529 #define RTC_FLAG_TAMP_6                    TAMP_SR_TAMP6F
530 #define RTC_FLAG_TAMP_7                    TAMP_SR_TAMP7F
531 #define RTC_FLAG_TAMP_8                    TAMP_SR_TAMP8F
532 #define RTC_FLAG_TAMP_ALL                  (RTC_FLAG_TAMP_1 | RTC_FLAG_TAMP_2 | RTC_FLAG_TAMP_3 |\
533                                             RTC_FLAG_TAMP_4 | RTC_FLAG_TAMP_5 | RTC_FLAG_TAMP_6 |\
534                                             RTC_FLAG_TAMP_7 | RTC_FLAG_TAMP_8)
535 
536 
537 #define RTC_FLAG_INT_TAMP_1                 TAMP_SR_ITAMP1F
538 #define RTC_FLAG_INT_TAMP_2                 TAMP_SR_ITAMP2F
539 #define RTC_FLAG_INT_TAMP_3                 TAMP_SR_ITAMP3F
540 #define RTC_FLAG_INT_TAMP_5                 TAMP_SR_ITAMP5F
541 #define RTC_FLAG_INT_TAMP_6                 TAMP_SR_ITAMP6F
542 #define RTC_FLAG_INT_TAMP_7                 TAMP_SR_ITAMP7F
543 #define RTC_FLAG_INT_TAMP_8                 TAMP_SR_ITAMP8F
544 #define RTC_FLAG_INT_TAMP_9                 TAMP_SR_ITAMP9F
545 #define RTC_FLAG_INT_TAMP_11                TAMP_SR_ITAMP11F
546 #define RTC_FLAG_INT_TAMP_12                TAMP_SR_ITAMP12F
547 #define RTC_FLAG_INT_TAMP_13                TAMP_SR_ITAMP13F
548 #define RTC_FLAG_INT_TAMP_ALL               (RTC_FLAG_INT_TAMP_1 | RTC_FLAG_INT_TAMP2 |\
549                                              RTC_FLAG_INT_TAMP_3 | RTC_FLAG_INT_TAMP5 |\
550                                              RTC_FLAG_INT_TAMP_6 | RTC_FLAG_INT_TAMP7 |\
551                                              RTC_FLAG_INT_TAMP_8 | RTC_FLAG_INT_TAMP9 |\
552                                              RTC_FLAG_INT_TAMP_11|RTC_FLAG_INT_TAMP_12|\
553                                              RTC_FLAG_INT_TAMP_13)
554 /**
555   * @}
556   */
557 
558 
559 /** @defgroup RTCEx_ActiveTamper_Enable RTCEx_ActiveTamper_Enable Definitions
560   * @{
561   */
562 #define RTC_ATAMP_ENABLE                   1U
563 #define RTC_ATAMP_DISABLE                  0U
564 /**
565   * @}
566   */
567 
568 /** @defgroup RTCEx_ActiveTamper_Interrupt RTCEx_ActiveTamper_Interrupt Definitions
569   * @{
570   */
571 #define RTC_ATAMP_INTERRUPT_ENABLE         1U
572 #define RTC_ATAMP_INTERRUPT_DISABLE        0U
573 /**
574   * @}
575   */
576 
577 /** @defgroup RTCEx_ActiveTamper_Filter RTCEx_ActiveTamper_Filter Definitions
578   * @{
579   */
580 #define RTC_ATAMP_FILTER_ENABLE           TAMP_ATCR1_FLTEN
581 #define RTC_ATAMP_FILTER_DISABLE          0U
582 /**
583   * @}
584   */
585 
586 /** @defgroup RTCEx_ActiveTamper_Async_prescaler RTCEx Active_Tamper_Asynchronous_Prescaler clock Definitions
587   * @{
588   */
589 #define RTC_ATAMP_ASYNCPRES_RTCCLK        0U                                                                      /*!< RTCCLK */
590 #define RTC_ATAMP_ASYNCPRES_RTCCLK_2      TAMP_ATCR1_ATCKSEL_0                                                    /*!< RTCCLK/2 */
591 #define RTC_ATAMP_ASYNCPRES_RTCCLK_4      TAMP_ATCR1_ATCKSEL_1                                                    /*!< RTCCLK/4 */
592 #define RTC_ATAMP_ASYNCPRES_RTCCLK_8      (TAMP_ATCR1_ATCKSEL_1 | TAMP_ATCR1_ATCKSEL_0)                           /*!< RTCCLK/8 */
593 #define RTC_ATAMP_ASYNCPRES_RTCCLK_16     TAMP_ATCR1_ATCKSEL_2                                                    /*!< RTCCLK/16 */
594 #define RTC_ATAMP_ASYNCPRES_RTCCLK_32    (TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_0)                            /*!< RTCCLK/32 */
595 #define RTC_ATAMP_ASYNCPRES_RTCCLK_64    (TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_1)                            /*!< RTCCLK/64 */
596 #define RTC_ATAMP_ASYNCPRES_RTCCLK_128   (TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_1 | TAMP_ATCR1_ATCKSEL_0)     /*!< RTCCLK/128 */
597 #define RTC_ATAMP_ASYNCPRES_RTCCLK_2048  (TAMP_ATCR1_ATCKSEL_3 | TAMP_ATCR1_ATCKSEL_1 | TAMP_ATCR1_ATCKSEL_0)     /*!< RTCCLK/2048  */
598 /**
599   * @}
600   */
601 
602 /** @defgroup RTCEx_ActiveTamper_Sel  RTCEx Active Tamper selection Definition
603   * @{
604   */
605 #define RTC_ATAMP_1                        0U                    /*!< Tamper 1 */
606 #define RTC_ATAMP_2                        1U                    /*!< Tamper 2 */
607 #define RTC_ATAMP_3                        2U                    /*!< Tamper 3 */
608 #define RTC_ATAMP_4                        3U                    /*!< Tamper 4 */
609 #define RTC_ATAMP_5                        4U                    /*!< Tamper 5 */
610 #define RTC_ATAMP_6                        5U                    /*!< Tamper 6 */
611 #define RTC_ATAMP_7                        6U                    /*!< Tamper 7 */
612 #define RTC_ATAMP_8                        7U                    /*!< Tamper 8 */
613 /**
614   * @}
615   */
616 
617 /** @defgroup RTCEx_MonotonicCounter_Instance  RTCEx Monotonic Counter Instance Definition
618   * @{
619   */
620 #define RTC_MONOTONIC_COUNTER_1            0U                    /*!< Monotonic counter 1 */
621 /**
622   * @}
623   */
624 
625 /** @defgroup RTCEx_Backup_Registers  RTCEx Backup Registers Definition
626   * @{
627   */
628 #define RTC_BKP_NUMBER                     RTC_BKP_NB
629 #define RTC_BKP_DR0                        0x00U
630 #define RTC_BKP_DR1                        0x01U
631 #define RTC_BKP_DR2                        0x02U
632 #define RTC_BKP_DR3                        0x03U
633 #define RTC_BKP_DR4                        0x04U
634 #define RTC_BKP_DR5                        0x05U
635 #define RTC_BKP_DR6                        0x06U
636 #define RTC_BKP_DR7                        0x07U
637 #define RTC_BKP_DR8                        0x08U
638 #define RTC_BKP_DR9                        0x09U
639 #define RTC_BKP_DR10                       0x0AU
640 #define RTC_BKP_DR11                       0x0BU
641 #define RTC_BKP_DR12                       0x0CU
642 #define RTC_BKP_DR13                       0x0DU
643 #define RTC_BKP_DR14                       0x0EU
644 #define RTC_BKP_DR15                       0x0FU
645 #define RTC_BKP_DR16                       0x10U
646 #define RTC_BKP_DR17                       0x11U
647 #define RTC_BKP_DR18                       0x12U
648 #define RTC_BKP_DR19                       0x13U
649 #define RTC_BKP_DR20                       0x14U
650 #define RTC_BKP_DR21                       0x15U
651 #define RTC_BKP_DR22                       0x16U
652 #define RTC_BKP_DR23                       0x17U
653 #define RTC_BKP_DR24                       0x18U
654 #define RTC_BKP_DR25                       0x19U
655 #define RTC_BKP_DR26                       0x1AU
656 #define RTC_BKP_DR27                       0x1BU
657 #define RTC_BKP_DR28                       0x1CU
658 #define RTC_BKP_DR29                       0x1DU
659 #define RTC_BKP_DR30                       0x1EU
660 #define RTC_BKP_DR31                       0x1FU
661 /**
662   * @}
663   */
664 /** @defgroup RTCEx_Binary_Mode RTC Binary Mode (32-bit free-running counter configuration).
665   *           Warning : It Should not be confused with the Binary format @ref RTC_Input_parameter_format_definitions.
666   * @{
667   */
668 #define RTC_BINARY_NONE                    0U                    /*!< Free running BCD calendar mode (Binary mode disabled) */
669 #define RTC_BINARY_ONLY                    RTC_ICSR_BIN_0        /*!< Free running Binary mode (BCD mode disabled)          */
670 #define RTC_BINARY_MIX                     RTC_ICSR_BIN_1        /*!< Free running BCD calendar and Binary modes            */
671 /**
672   * @}
673   */
674 
675 /** @defgroup RTCEx_Binary_mix_BCDU If Binary mode is RTC_BINARY_MIX, the BCD calendar second is incremented
676   *           using the SSR Least Significant Bits.
677   * @{
678   */
679 #define RTC_BINARY_MIX_BCDU_0              0U                           /*!<  The 1s BCD calendar increment is generated each time SS[7:0] = 0  */
680 #define RTC_BINARY_MIX_BCDU_1              (0x1UL << RTC_ICSR_BCDU_Pos) /*!<  The 1s BCD calendar increment is generated each time SS[8:0] = 0  */
681 #define RTC_BINARY_MIX_BCDU_2              (0x2UL << RTC_ICSR_BCDU_Pos) /*!<  The 1s BCD calendar increment is generated each time SS[9:0] = 0  */
682 #define RTC_BINARY_MIX_BCDU_3              (0x3UL << RTC_ICSR_BCDU_Pos) /*!<  The 1s BCD calendar increment is generated each time SS[10:0] = 0 */
683 #define RTC_BINARY_MIX_BCDU_4              (0x4UL << RTC_ICSR_BCDU_Pos) /*!<  The 1s BCD calendar increment is generated each time SS[11:0] = 0 */
684 #define RTC_BINARY_MIX_BCDU_5              (0x5UL << RTC_ICSR_BCDU_Pos) /*!<  The 1s BCD calendar increment is generated each time SS[12:0] = 0 */
685 #define RTC_BINARY_MIX_BCDU_6              (0x6UL << RTC_ICSR_BCDU_Pos) /*!<  The 1s BCD calendar increment is generated each time SS[13:0] = 0 */
686 #define RTC_BINARY_MIX_BCDU_7              (0x7UL << RTC_ICSR_BCDU_Pos) /*!<  The 1s BCD calendar increment is generated each time SS[14:0] = 0 */
687 /**
688   * @}
689   */
690 
691 /** @defgroup RTCEx_Alarm_Sub_Seconds_binary_Masks_Definitions RTC Alarm Sub Seconds with binary mode Masks Definitions
692   * @{
693   */
694 #define RTC_ALARMSUBSECONDBINMASK_ALL           0U                                                                      /*!< All Alarm SS fields are masked.There is no comparison on sub seconds for Alarm */
695 #define RTC_ALARMSUBSECONDBINMASK_SS31_1        (1UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:1] are don't care in Alarm comparison. Only SS[0] is compared.    */
696 #define RTC_ALARMSUBSECONDBINMASK_SS31_2        (2UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:2] are don't care in Alarm comparison. Only SS[1:0] are compared  */
697 #define RTC_ALARMSUBSECONDBINMASK_SS31_3        (3UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:3] are don't care in Alarm comparison. Only SS[2:0] are compared  */
698 #define RTC_ALARMSUBSECONDBINMASK_SS31_4        (4UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:4] are don't care in Alarm comparison. Only SS[3:0] are compared  */
699 #define RTC_ALARMSUBSECONDBINMASK_SS31_5        (5UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:5] are don't care in Alarm comparison. Only SS[4:0] are compared  */
700 #define RTC_ALARMSUBSECONDBINMASK_SS31_6        (6UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:6] are don't care in Alarm comparison. Only SS[5:0] are compared  */
701 #define RTC_ALARMSUBSECONDBINMASK_SS31_7        (7UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:7] are don't care in Alarm comparison. Only SS[6:0] are compared  */
702 #define RTC_ALARMSUBSECONDBINMASK_SS31_8        (8UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:8] are don't care in Alarm comparison. Only SS[7:0] are compared  */
703 #define RTC_ALARMSUBSECONDBINMASK_SS31_9        (9UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:9] are don't care in Alarm comparison. Only SS[8:0] are compared  */
704 #define RTC_ALARMSUBSECONDBINMASK_SS31_10      (10UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:10] are don't care in Alarm comparison. Only SS[9:0] are compared  */
705 #define RTC_ALARMSUBSECONDBINMASK_SS31_11      (11UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:11] are don't care in Alarm comparison. Only SS[10:0] are compared */
706 #define RTC_ALARMSUBSECONDBINMASK_SS31_12      (12UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:12] are don't care in Alarm comparison.Only SS[11:0] are compared  */
707 #define RTC_ALARMSUBSECONDBINMASK_SS31_13      (13UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:13] are don't care in Alarm comparison. Only SS[12:0] are compared */
708 #define RTC_ALARMSUBSECONDBINMASK_SS31_14      (14UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:14] are don't care in Alarm comparison. Only SS[13:0] are compared */
709 #define RTC_ALARMSUBSECONDBINMASK_SS31_15      (15UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:15] are don't care in Alarm comparison. Only SS[14:0] are compared */
710 #define RTC_ALARMSUBSECONDBINMASK_SS31_16      (16UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:16] are don't care in Alarm comparison. Only SS[15:0] are compared */
711 #define RTC_ALARMSUBSECONDBINMASK_SS31_17      (17UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:17] are don't care in Alarm comparison. Only SS[16:0] are compared */
712 #define RTC_ALARMSUBSECONDBINMASK_SS31_18      (18UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:18] are don't care in Alarm comparison. Only SS[17:0] are compared */
713 #define RTC_ALARMSUBSECONDBINMASK_SS31_19      (19UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:19] are don't care in Alarm comparison. Only SS[18:0] are compared */
714 #define RTC_ALARMSUBSECONDBINMASK_SS31_20      (20UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:20] are don't care in Alarm comparison. Only SS[19:0] are compared */
715 #define RTC_ALARMSUBSECONDBINMASK_SS31_21      (21UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:21] are don't care in Alarm comparison. Only SS[20:0] are compared */
716 #define RTC_ALARMSUBSECONDBINMASK_SS31_22      (22UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:22] are don't care in Alarm comparison. Only SS[21:0] are compared */
717 #define RTC_ALARMSUBSECONDBINMASK_SS31_23      (23UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:23] are don't care in Alarm comparison. Only SS[22:0] are compared */
718 #define RTC_ALARMSUBSECONDBINMASK_SS31_24      (24UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:24] are don't care in Alarm comparison. Only SS[23:0] are compared */
719 #define RTC_ALARMSUBSECONDBINMASK_SS31_25      (25UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:25] are don't care in Alarm comparison. Only SS[24:0] are compared */
720 #define RTC_ALARMSUBSECONDBINMASK_SS31_26      (26UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:26] are don't care in Alarm comparison. Only SS[25:0] are compared */
721 #define RTC_ALARMSUBSECONDBINMASK_SS31_27      (27UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:27] are don't care in Alarm comparison. Only SS[26:0] are compared */
722 #define RTC_ALARMSUBSECONDBINMASK_SS31_28      (28UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:28] are don't care in Alarm comparison. Only SS[27:0] are compared */
723 #define RTC_ALARMSUBSECONDBINMASK_SS31_29      (29UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:29] are don't care in Alarm comparison. Only SS[28:0] are compared */
724 #define RTC_ALARMSUBSECONDBINMASK_SS31_30      (30UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:30] are don't care in Alarm comparison. Only SS[29:0] are compared */
725 #define RTC_ALARMSUBSECONDBINMASK_SS31         (31UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31] is don't care in Alarm comparison. Only SS[30:0] are compared  */
726 #define RTC_ALARMSUBSECONDBINMASK_NONE         (32UL << RTC_ALRMASSR_MASKSS_Pos)                                        /*!< SS[31:0] are compared and must match to activate alarm. */
727 /**
728   * @}
729   */
730 
731 /** @defgroup RTCEx_Alarm_Sub_Seconds_binary_Clear_Definitions RTC Alarm Sub Seconds
732   *  with binary mode auto clear Definitions
733   * @{
734   */
735 #define RTC_ALARMSUBSECONDBIN_AUTOCLR_NO    0UL                  /*!<  The synchronous Binary counter (SS[31:0] in RTC_SSR) is free-running. */
736 #define RTC_ALARMSUBSECONDBIN_AUTOCLR_YES   RTC_ALRMASSR_SSCLR   /*!<  The synchronous Binary counter (SS[31:0] in RTC_SSR) is running from 0xFFFF FFFF to RTC_ALRMABINR -> SS[31:0] value and is automatically reloaded with 0xFFFF FFFF whenreaching RTC_ALRMABINR -> SS[31:0]. */
737 /**
738   * @}
739   */
740 
741 /** @defgroup RTCEx_RTC_Secure_Full  RTCEx Secure Definition
742   * @{
743   */
744 #define RTC_SECURE_FULL_YES                 RTC_SECCFGR_SEC                   /*!< RTC full secure */
745 #define RTC_SECURE_FULL_NO                  0U                                /*!< RTC is not full secure, features can be unsecure. See RTC_LL_EC_UNSECURE_RTC_FEATURE */
746 /**
747   * @}
748   */
749 
750 /** @defgroup RTCEx_RTC_NonSecure_Features  RTCEx Secure Features Definition
751   * @{
752   */
753 
754 #define RTC_NONSECURE_FEATURE_NONE            (RTC_SECCFGR_INITSEC |  RTC_SECCFGR_CALSEC | \
755                                                RTC_SECCFGR_TSSEC | RTC_SECCFGR_WUTSEC | \
756                                                RTC_SECCFGR_ALRASEC | RTC_SECCFGR_ALRBSEC)
757 #define RTC_NONSECURE_FEATURE_INIT            ~RTC_SECCFGR_INITSEC    /*!< Initialization */
758 #define RTC_NONSECURE_FEATURE_CAL             ~RTC_SECCFGR_CALSEC     /*!< Calibration */
759 #define RTC_NONSECURE_FEATURE_TS              ~RTC_SECCFGR_TSSEC      /*!< Time stamp */
760 #define RTC_NONSECURE_FEATURE_WUT             ~RTC_SECCFGR_WUTSEC     /*!< Wake up timer */
761 #define RTC_NONSECURE_FEATURE_ALRA            ~RTC_SECCFGR_ALRASEC    /*!< Alarm A */
762 #define RTC_NONSECURE_FEATURE_ALRB            ~RTC_SECCFGR_ALRBSEC    /*!< Alarm B */
763 #define RTC_NONSECURE_FEATURE_ALL             0U
764 /**
765   * @}
766   */
767 
768 /** @defgroup RTCEx_TAMP_Secure_Full  RTCEx TAMP Secure Definition
769   * @{
770   */
771 #define TAMP_SECURE_FULL_YES                 TAMP_SECCFGR_TAMPSEC      /*!< TAMPER full secure */
772 #define TAMP_SECURE_FULL_NO                  0U                        /*!< TAMPER is not secure */
773 /**
774   * @}
775   */
776 
777 /** @defgroup RTCEx_TAMP_Monotonic_Counter_Secure  RTCEx TAMP Monotonic Counter Secure Definition
778   * @{
779   */
780 #define TAMP_MONOTONIC_CNT_SECURE_YES                 TAMP_SECCFGR_CNT1SEC      /*!< TAMPER Monotonic Counter secure */
781 #define TAMP_MONOTONIC_CNT_SECURE_NO                  0U                        /*!< TAMPER Monotonic Counter is not secure */
782 /**
783   * @}
784   */
785 /** @defgroup RTCEx_RTC_Privilege_Full  RTCEx Privilege Full Definition
786   * @{
787   */
788 #define RTC_PRIVILEGE_FULL_YES               RTC_PRIVCFGR_PRIV
789 #define RTC_PRIVILEGE_FULL_NO                0U
790 /**
791   * @}
792   */
793 
794 /** @defgroup RTCEx_RTC_Privilege_Features  RTCEx Privilege Features Definition
795   * @{
796   */
797 #define RTC_PRIVILEGE_FEATURE_NONE           0U
798 #define RTC_PRIVILEGE_FEATURE_INIT           RTC_PRIVCFGR_INITPRIV  /*!< Initialization */
799 #define RTC_PRIVILEGE_FEATURE_CAL            RTC_PRIVCFGR_CALPRIV   /*!< Calibration */
800 #define RTC_PRIVILEGE_FEATURE_TS             RTC_PRIVCFGR_TSPRIV   /*!< Time stamp */
801 #define RTC_PRIVILEGE_FEATURE_WUT            RTC_PRIVCFGR_WUTPRIV   /*!< Wake up timer */
802 #define RTC_PRIVILEGE_FEATURE_ALRA           RTC_PRIVCFGR_ALRAPRIV  /*!< Alarm A */
803 #define RTC_PRIVILEGE_FEATURE_ALRB           RTC_PRIVCFGR_ALRBPRIV  /*!< Alarm B */
804 #define RTC_PRIVILEGE_FEATURE_ALL            (RTC_PRIVCFGR_INITPRIV |  RTC_PRIVCFGR_CALPRIV | \
805                                               RTC_PRIVCFGR_TSPRIV | RTC_PRIVCFGR_WUTPRIV | \
806                                               RTC_PRIVCFGR_ALRAPRIV | RTC_PRIVCFGR_ALRBPRIV)
807 /**
808   * @}
809   */
810 
811 /** @defgroup RTCEx_TAMP_Privilege_Full  RTCEx TAMP security Definition
812   * @{
813   */
814 #define TAMP_PRIVILEGE_FULL_YES              TAMP_PRIVCFGR_TAMPPRIV
815 #define TAMP_PRIVILEGE_FULL_NO               0U
816 /**
817   * @}
818   */
819 
820 /** @defgroup RTCEx_TAMP_Secret_Device_Conf_Erase  RTCEx TAMP Secret Device Conf Erase Definition
821   * @{
822   */
823 #define TAMP_SECRETDEVICE_ERASE_ENABLE                TAMP_ERCFGR0
824 #define TAMP_SECRETDEVICE_ERASE_DISABLE               0U
825 /**
826   * @}
827   */
828 
829 /** @defgroup RTCEx_TAMP_Monotonic_Counter_Privilege  RTCEx TAMP Monotonic Counter Privilege Definition
830   * @{
831   */
832 #define TAMP_MONOTONIC_CNT_PRIVILEGE_YES     TAMP_PRIVCFGR_CNT1PRIV
833 #define TAMP_MONOTONIC_CNT_PRIVILEGE_NO      0U
834 /**
835   * @}
836   */
837 
838 /** @defgroup RTCEx_Backup_Reg_Privilege_zone  RTCEx Privilege Backup register privilege zone Definition
839   * @{
840   */
841 #define RTC_PRIVILEGE_BKUP_ZONE_NONE         0U
842 #define RTC_PRIVILEGE_BKUP_ZONE_1            TAMP_PRIVCFGR_BKPRWPRIV
843 #define RTC_PRIVILEGE_BKUP_ZONE_2            TAMP_PRIVCFGR_BKPWPRIV
844 #define RTC_PRIVILEGE_BKUP_ZONE_ALL          (RTC_PRIVILEGE_BKUP_ZONE_1 |  RTC_PRIVILEGE_BKUP_ZONE_2)
845 /**
846   * @}
847   */
848 
849 /**
850   * @}
851   */
852 
853 /* Exported macros -----------------------------------------------------------*/
854 /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros
855   * @{
856   */
857 
858 /** @brief  Clear the specified RTC pending flag.
859   * @param  __HANDLE__ specifies the RTC Handle.
860   * @param  __FLAG__ specifies the flag to check.
861   *          This parameter can be any combination of the following values:
862   *            @arg @ref RTC_CLEAR_ITSF               Clear Internal Time-stamp flag
863   *            @arg @ref RTC_CLEAR_TSOVF              Clear Time-stamp overflow flag
864   *            @arg @ref RTC_CLEAR_TSF                Clear Time-stamp flag
865   *            @arg @ref RTC_CLEAR_WUTF               Clear Wakeup timer flag
866   *            @arg @ref RTC_CLEAR_ALRBF              Clear Alarm B flag
867   *            @arg @ref RTC_CLEAR_ALRAF              Clear Alarm A flag
868   * @retval None
869   */
870 #define __HAL_RTC_CLEAR_FLAG(__HANDLE__, __FLAG__)   (RTC->SCR = (__FLAG__))
871 
872 /** @brief  Check whether the specified RTC flag is set or not.
873   * @param  __HANDLE__ specifies the RTC Handle.
874   * @param  __FLAG__ specifies the flag to check.
875   *          This parameter can be any combination of the following values:
876   *            @arg @ref RTC_FLAG_RECALPF             Recalibration pending Flag
877   *            @arg @ref RTC_FLAG_INITF               Initialization flag
878   *            @arg @ref RTC_FLAG_RSF                 Registers synchronization flag
879   *            @arg @ref RTC_FLAG_INITS               Initialization status flag
880   *            @arg @ref RTC_FLAG_SHPF                Shift operation pending flag
881   *            @arg @ref RTC_FLAG_WUTWF               Wakeup timer write flag
882   *            @arg @ref RTC_FLAG_ITSF                Internal Time-stamp flag
883   *            @arg @ref RTC_FLAG_TSOVF               Time-stamp overflow flag
884   *            @arg @ref RTC_FLAG_TSF                 Time-stamp flag
885   *            @arg @ref RTC_FLAG_WUTF                Wakeup timer flag
886   *            @arg @ref RTC_FLAG_ALRBF               Alarm B flag
887   *            @arg @ref RTC_FLAG_ALRAF               Alarm A flag
888   * @retval The state of __FLAG__ (TRUE or FALSE).
889   */
890 #define __HAL_RTC_GET_FLAG(__HANDLE__, __FLAG__)( \
891                                ((__FLAG__) == RTC_FLAG_RECALPF) ? (READ_BIT(RTC->ICSR, RTC_ICSR_RECALPF) == \
892                                                                 RTC_ICSR_RECALPF) : \
893                                ((__FLAG__) == RTC_FLAG_INITF)   ? (READ_BIT(RTC->ICSR, RTC_ICSR_INITF) == \
894                                                                 RTC_ICSR_INITF) : \
895                                ((__FLAG__) == RTC_FLAG_RSF)     ? (READ_BIT(RTC->ICSR, RTC_ICSR_RSF) == \
896                                                                 RTC_ICSR_RSF) : \
897                                ((__FLAG__) == RTC_FLAG_INITS)   ? (READ_BIT(RTC->ICSR, RTC_ICSR_INITS) == \
898                                                                 RTC_ICSR_INITS) : \
899                                ((__FLAG__) == RTC_FLAG_SHPF)    ? (READ_BIT(RTC->ICSR, RTC_ICSR_SHPF) == \
900                                                                 RTC_ICSR_SHPF) : \
901                                ((__FLAG__) == RTC_FLAG_WUTWF)   ? (READ_BIT(RTC->ICSR, RTC_ICSR_WUTWF) == \
902                                                                 RTC_ICSR_WUTWF) : \
903                                ((__FLAG__) == RTC_FLAG_SSRUF)   ? (READ_BIT(RTC->SR, RTC_SR_SSRUF) == \
904                                                                 RTC_SR_SSRUF) : \
905                                ((__FLAG__) == RTC_FLAG_ITSF)    ? (READ_BIT(RTC->SR, RTC_SR_ITSF) == \
906                                                                 RTC_SR_ITSF) : \
907                                ((__FLAG__) == RTC_FLAG_TSOVF)   ? (READ_BIT(RTC->SR, RTC_SR_TSOVF) == \
908                                                                 RTC_SR_TSOVF) : \
909                                ((__FLAG__) == RTC_FLAG_TSF)     ? (READ_BIT(RTC->SR, RTC_SR_TSF) == \
910                                                                 RTC_SR_TSF): \
911                                ((__FLAG__) == RTC_FLAG_WUTF)    ? (READ_BIT(RTC->SR, RTC_SR_WUTF) == \
912                                                                 RTC_SR_WUTF): \
913                                ((__FLAG__) == RTC_FLAG_ALRBF)   ? (READ_BIT(RTC->SR, RTC_SR_ALRBF) == \
914                                                                 RTC_SR_ALRBF) : \
915                                ((__FLAG__) == RTC_FLAG_ALRAF)   ? (READ_BIT(RTC->SR, RTC_SR_ALRAF) == \
916                                                                 RTC_SR_ALRAF) : \
917                                (0U)) /* Return 0 because it is an invalid parameter value */
918 
919 /* ---------------------------------WAKEUPTIMER---------------------------------*/
920 /** @defgroup RTCEx_WakeUp_Timer RTC WakeUp Timer
921   * @{
922   */
923 
924 /**
925   * @brief  Enable the RTC WakeUp Timer peripheral.
926   * @param  __HANDLE__ specifies the RTC handle.
927   * @retval None
928   */
929 #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__)                      (RTC->CR |= (RTC_CR_WUTE))
930 
931 /**
932   * @brief  Disable the RTC WakeUp Timer peripheral.
933   * @param  __HANDLE__ specifies the RTC handle.
934   * @retval None
935   */
936 #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__)                     (RTC->CR &= ~(RTC_CR_WUTE))
937 
938 /**
939   * @brief  Enable the RTC WakeUpTimer interrupt.
940   * @param  __HANDLE__ specifies the RTC handle.
941   * @param  __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be enabled.
942   *         This parameter can be:
943   *            @arg @ref RTC_IT_WUT WakeUpTimer interrupt
944   * @retval None
945   */
946 #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__)    (RTC->CR |= (RTC_CR_WUTIE))
947 
948 /**
949   * @brief  Disable the RTC WakeUpTimer interrupt.
950   * @param  __HANDLE__ specifies the RTC handle.
951   * @param  __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be disabled.
952   *         This parameter can be:
953   *            @arg @ref RTC_IT_WUT WakeUpTimer interrupt
954   * @retval None
955   */
956 #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__)   (RTC->CR &= ~(RTC_CR_WUTIE))
957 
958 /**
959   * @brief  Check whether the specified RTC WakeUpTimer interrupt has occurred or not.
960   * @param  __HANDLE__ specifies the RTC handle.
961   * @param  __INTERRUPT__ specifies the RTC WakeUpTimer interrupt to check.
962   *         This parameter can be:
963   *            @arg @ref RTC_IT_WUT  WakeUpTimer interrupt
964   * @retval The state of __INTERRUPT__ (TRUE or FALSE).
965   */
966 #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __INTERRUPT__)       (((RTC->MISR) & (RTC_MISR_WUTMF)) != 0U)
967 
968 /**
969   * @brief  Check whether the specified RTC Wake Up timer interrupt has been enabled or not.
970   * @param  __HANDLE__ specifies the RTC handle.
971   * @param  __INTERRUPT__ specifies the RTC Wake Up timer interrupt sources to check.
972   *         This parameter can be:
973   *            @arg @ref RTC_IT_WUT  WakeUpTimer interrupt
974   * @retval The state of __INTERRUPT__ (TRUE or FALSE).
975   */
976 #define __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)   (((RTC->CR) & (RTC_CR_WUTIE)) != 0U)
977 
978 /**
979   * @brief  Get the selected RTC WakeUpTimers flag status.
980   * @param  __HANDLE__ specifies the RTC handle.
981   * @param  __FLAG__ specifies the RTC WakeUpTimer Flag is pending or not.
982   *          This parameter can be:
983   *             @arg @ref RTC_FLAG_WUTF
984   *             @arg @ref RTC_FLAG_WUTWF
985   * @retval The state of __FLAG__ (TRUE or FALSE).
986   */
987 #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__)( \
988                             ((__FLAG__) == RTC_FLAG_WUTF)  ? (READ_BIT(RTC->SR, RTC_SR_WUTF) == RTC_SR_WUTF):\
989                             ((__FLAG__) == RTC_FLAG_WUTWF) ? (READ_BIT(RTC->ICSR, RTC_ICSR_WUTWF) == RTC_ICSR_WUTWF):\
990                             (0U)) /* Return 0 because it is an invalid parameter value */
991 
992 /**
993   * @brief  Clear the RTC Wake Up timers pending flags.
994   * @param  __HANDLE__ specifies the RTC handle.
995   * @param  __FLAG__ specifies the RTC WakeUpTimer Flag to clear.
996   *         This parameter can be:
997   *            @arg @ref RTC_FLAG_WUTF
998   * @retval None
999   */
1000 #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__)  (WRITE_REG(RTC->SCR, RTC_SCR_CWUTF))
1001 
1002 /**
1003   * @}
1004   */
1005 
1006 /* ---------------------------------TIMESTAMP---------------------------------*/
1007 /** @defgroup RTCEx_Timestamp RTC Timestamp
1008   * @{
1009   */
1010 
1011 /**
1012   * @brief  Enable the RTC TimeStamp peripheral.
1013   * @param  __HANDLE__ specifies the RTC handle.
1014   * @retval None
1015   */
1016 #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__)                       (RTC->CR |= (RTC_CR_TSE))
1017 
1018 /**
1019   * @brief  Disable the RTC TimeStamp peripheral.
1020   * @param  __HANDLE__ specifies the RTC handle.
1021   * @retval None
1022   */
1023 #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__)                      (RTC->CR &= ~(RTC_CR_TSE))
1024 
1025 /**
1026   * @brief  Enable the RTC TimeStamp interrupt.
1027   * @param  __HANDLE__ specifies the RTC handle.
1028   * @param  __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be enabled.
1029   *         This parameter can be:
1030   *            @arg @ref RTC_IT_TS TimeStamp interrupt
1031   * @retval None
1032   */
1033 #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__)     (RTC->CR |= (RTC_CR_TSIE))
1034 
1035 /**
1036   * @brief  Disable the RTC TimeStamp interrupt.
1037   * @param  __HANDLE__ specifies the RTC handle.
1038   * @param  __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be disabled.
1039   *         This parameter can be:
1040   *            @arg @ref RTC_IT_TS TimeStamp interrupt
1041   * @retval None
1042   */
1043 #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__)    (RTC->CR &= ~(RTC_CR_TSIE))
1044 
1045 /**
1046   * @brief  Check whether the specified RTC TimeStamp interrupt has occurred or not.
1047   * @param  __HANDLE__ specifies the RTC handle.
1048   * @param  __INTERRUPT__ specifies the RTC TimeStamp interrupt to check.
1049   *         This parameter can be:
1050   *            @arg @ref RTC_IT_TS TimeStamp interrupt
1051   * @retval The state of __INTERRUPT__ (TRUE or FALSE).
1052   */
1053 #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__)        (((RTC->MISR) & (RTC_MISR_TSMF)) != 0U)
1054 
1055 /**
1056   * @brief  Check whether the specified RTC Time Stamp interrupt has been enabled or not.
1057   * @param  __HANDLE__ specifies the RTC handle.
1058   * @param  __INTERRUPT__ specifies the RTC Time Stamp interrupt source to check.
1059   *         This parameter can be:
1060   *            @arg @ref RTC_IT_TS TimeStamp interrupt
1061   * @retval The state of __INTERRUPT__ (TRUE or FALSE).
1062   */
1063 #define __HAL_RTC_TIMESTAMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)  (((RTC->CR) & (RTC_CR_TSIE)) != 0U)
1064 
1065 /**
1066   * @brief  Get the selected RTC TimeStamps flag status.
1067   * @param  __HANDLE__ specifies the RTC handle.
1068   * @param  __FLAG__ specifies the RTC TimeStamp Flag is pending or not.
1069   *         This parameter can be:
1070   *            @arg @ref RTC_FLAG_TSF
1071   *            @arg @ref RTC_FLAG_TSOVF
1072   * @retval The state of __FLAG__ (TRUE or FALSE) or 255 if invalid parameter.
1073   */
1074 #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__)( \
1075                                 ((__FLAG__) == RTC_FLAG_TSF)   ? (READ_BIT(RTC->SR, RTC_SR_TSF) == RTC_SR_TSF):\
1076                                 ((__FLAG__) == RTC_FLAG_TSOVF) ? (READ_BIT(RTC->SR, RTC_SR_TSOVF) == RTC_SR_TSOVF):\
1077                                 (0U)) /* Return 0 because it is an invalid parameter value */
1078 
1079 /**
1080   * @brief  Clear the RTC Time Stamps pending flags.
1081   * @param  __HANDLE__ specifies the RTC handle.
1082   * @param  __FLAG__ specifies the RTC TimeStamp Flag to clear.
1083   *          This parameter can be:
1084   *             @arg @ref RTC_FLAG_TSF
1085   *             @arg @ref RTC_FLAG_TSOVF
1086   * @retval None
1087   */
1088 #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__)( \
1089                                 ((__FLAG__) == RTC_FLAG_TSF)   ? (WRITE_REG(RTC->SCR, RTC_SCR_CTSF)):\
1090                                 ((__FLAG__) == RTC_FLAG_TSOVF) ? (WRITE_REG(RTC->SCR, RTC_SCR_CTSOVF)):\
1091                                 (0U)) /* Dummy action because is an invalid parameter value */
1092 
1093 /**
1094   * @brief  Enable the RTC internal TimeStamp peripheral.
1095   * @param  __HANDLE__ specifies the RTC handle.
1096   * @retval None
1097   */
1098 #define __HAL_RTC_INTERNAL_TIMESTAMP_ENABLE(__HANDLE__)                (RTC->CR |= (RTC_CR_ITSE))
1099 
1100 /**
1101   * @brief  Disable the RTC internal TimeStamp peripheral.
1102   * @param  __HANDLE__ specifies the RTC handle.
1103   * @retval None
1104   */
1105 #define __HAL_RTC_INTERNAL_TIMESTAMP_DISABLE(__HANDLE__)               (RTC->CR &= ~(RTC_CR_ITSE))
1106 
1107 /**
1108   * @brief  Get the selected RTC Internal Time Stamps flag status.
1109   * @param  __HANDLE__ specifies the RTC handle.
1110   * @param  __FLAG__ specifies the RTC Internal Time Stamp Flag is pending or not.
1111   *         This parameter can be:
1112   *            @arg @ref RTC_FLAG_ITSF
1113   * @retval None
1114   */
1115 #define __HAL_RTC_INTERNAL_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__)   ((READ_BIT(RTC->SR, RTC_SR_ITSF) == RTC_SR_ITSF))
1116 
1117 /**
1118   * @brief  Clear the RTC Internal Time Stamps pending flags.
1119   * @param  __HANDLE__ specifies the RTC handle.
1120   * @param  __FLAG__ specifies the RTC Internal Time Stamp Flag source to clear.
1121   * This parameter can be:
1122   *             @arg @ref RTC_FLAG_ITSF
1123   * @retval None
1124   */
1125 #define __HAL_RTC_INTERNAL_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__)   (SET_BIT(RTC->SCR, RTC_SCR_CITSF))
1126 
1127 /**
1128   * @brief  Enable the RTC TimeStamp on Tamper detection.
1129   * @param  __HANDLE__ specifies the RTC handle.
1130   * @retval None
1131   */
1132 #define __HAL_RTC_TAMPTS_ENABLE(__HANDLE__)                       (RTC->CR |= (RTC_CR_TAMPTS))
1133 
1134 /**
1135   * @brief  Disable the RTC TimeStamp on Tamper detection.
1136   * @param  __HANDLE__ specifies the RTC handle.
1137   * @retval None
1138   */
1139 #define __HAL_RTC_TAMPTS_DISABLE(__HANDLE__)                      (RTC->CR &= ~(RTC_CR_TAMPTS))
1140 
1141 /**
1142   * @brief  Enable the RTC Tamper detection output.
1143   * @param  __HANDLE__ specifies the RTC handle.
1144   * @retval None
1145   */
1146 #define __HAL_RTC_TAMPOE_ENABLE(__HANDLE__)                       (RTC->CR |= (RTC_CR_TAMPOE))
1147 
1148 /**
1149   * @brief  Disable the RTC Tamper detection output.
1150   * @param  __HANDLE__ specifies the RTC handle.
1151   * @retval None
1152   */
1153 #define __HAL_RTC_TAMPOE_DISABLE(__HANDLE__)                      (RTC->CR &= ~(RTC_CR_TAMPOE))
1154 
1155 
1156 /**
1157   * @}
1158   */
1159 
1160 /* ------------------------------Calibration----------------------------------*/
1161 /** @defgroup RTCEx_Calibration RTC Calibration
1162   * @{
1163   */
1164 
1165 /**
1166   * @brief  Enable the RTC calibration output.
1167   * @param  __HANDLE__ specifies the RTC handle.
1168   * @retval None
1169   */
1170 #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__)               (RTC->CR |= (RTC_CR_COE))
1171 
1172 /**
1173   * @brief  Disable the calibration output.
1174   * @param  __HANDLE__ specifies the RTC handle.
1175   * @retval None
1176   */
1177 #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__)              (RTC->CR &= ~(RTC_CR_COE))
1178 
1179 
1180 /**
1181   * @brief  Enable the clock reference detection.
1182   * @param  __HANDLE__ specifies the RTC handle.
1183   * @retval None
1184   */
1185 #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__)               (RTC->CR |= (RTC_CR_REFCKON))
1186 
1187 /**
1188   * @brief  Disable the clock reference detection.
1189   * @param  __HANDLE__ specifies the RTC handle.
1190   * @retval None
1191   */
1192 #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__)              (RTC->CR &= ~(RTC_CR_REFCKON))
1193 
1194 
1195 /**
1196   * @brief  Get the selected RTC shift operations flag status.
1197   * @param  __HANDLE__ specifies the RTC handle.
1198   * @param  __FLAG__ specifies the RTC shift operation Flag is pending or not.
1199   *          This parameter can be:
1200   *             @arg @ref RTC_FLAG_SHPF
1201   * @retval The state of __FLAG__ (TRUE or FALSE)
1202   */
1203 #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__)  ((READ_BIT(RTC->ICSR, RTC_ICSR_SHPF) == RTC_ICSR_SHPF))
1204 /**
1205   * @}
1206   */
1207 
1208 /* ------------------------------Tamper----------------------------------*/
1209 /** @defgroup RTCEx_Tamper RTCEx tamper
1210   * @{
1211   */
1212 
1213 /**
1214   * @brief  Enable the TAMP Tamper input detection.
1215   * @param  __HANDLE__ specifies the RTC handle.
1216   * @param  __TAMPER__ specifies the RTC Tamper source to be enabled.
1217   *         This parameter can be any combination of the following values:
1218   *            @arg  RTC_TAMPER_ALL: All tampers
1219   *            @arg  RTC_TAMPER_1: Tamper1
1220   *            @arg  RTC_TAMPER_2: Tamper2
1221   *            @arg  RTC_TAMPER_3: Tamper3
1222   *            @arg  RTC_TAMPER_4: Tamper4
1223   *            @arg  RTC_TAMPER_5: Tamper5
1224   *            @arg  RTC_TAMPER_6: Tamper6
1225   *            @arg  RTC_TAMPER_7: Tamper7
1226   *            @arg  RTC_TAMPER_8: Tamper8
1227   * @retval None
1228   */
1229 #define __HAL_RTC_TAMPER_ENABLE(__HANDLE__, __TAMPER__)           (TAMP->CR1 |= (__TAMPER__))
1230 
1231 /**
1232   * @brief  Disable the TAMP Tamper input detection.
1233   * @param  __HANDLE__ specifies the RTC handle.
1234   * @param  __TAMPER__ specifies the RTC Tamper sources to be enabled.
1235   *         This parameter can be any combination of the following values:
1236   *            @arg  RTC_TAMPER_ALL: All tampers
1237   *            @arg  RTC_TAMPER_1: Tamper1
1238   *            @arg  RTC_TAMPER_2: Tamper2
1239   *            @arg  RTC_TAMPER_3: Tamper3
1240   *            @arg  RTC_TAMPER_4: Tamper4
1241   *            @arg  RTC_TAMPER_5: Tamper5
1242   *            @arg  RTC_TAMPER_6: Tamper6
1243   *            @arg  RTC_TAMPER_7: Tamper7
1244   *            @arg  RTC_TAMPER_8: Tamper8
1245   */
1246 #define __HAL_RTC_TAMPER_DISABLE(__HANDLE__, __TAMPER__)           (TAMP->CR1 &= ~(__TAMPER__))
1247 
1248 
1249 /**************************************************************************************************/
1250 /**
1251   * @brief  Enable the TAMP Tamper interrupt.
1252   * @param  __HANDLE__ specifies the RTC handle.
1253   * @param  __INTERRUPT__ specifies the RTC Tamper interrupt sources to be enabled.
1254   *          This parameter can be any combination of the following values:
1255   *            @arg  RTC_IT_TAMP_ALL: All tampers interrupts
1256   *            @arg  RTC_IT_TAMP_1: Tamper1 interrupt
1257   *            @arg  RTC_IT_TAMP_2: Tamper2 interrupt
1258   *            @arg  RTC_IT_TAMP_3: Tamper3 interrupt
1259   *            @arg  RTC_IT_TAMP_4: Tamper4 interrupt
1260   *            @arg  RTC_IT_TAMP_5: Tamper5 interrupt
1261   *            @arg  RTC_IT_TAMP_6: Tamper6 interrupt
1262   *            @arg  RTC_IT_TAMP_7: Tamper7 interrupt
1263   *            @arg  RTC_IT_TAMP_8: Tamper8 interrupt
1264   * @retval None
1265   */
1266 #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__)        (TAMP->IER |= (__INTERRUPT__))
1267 
1268 /**
1269   * @brief  Disable the TAMP Tamper interrupt.
1270   * @param  __HANDLE__ specifies the RTC handle.
1271   * @param  __INTERRUPT__ specifies the RTC Tamper interrupt sources to be disabled.
1272   *         This parameter can be any combination of the following values:
1273   *            @arg  RTC_IT_TAMP_ALL: All tampers interrupts
1274   *            @arg  RTC_IT_TAMP_1: Tamper1 interrupt
1275   *            @arg  RTC_IT_TAMP_2: Tamper2 interrupt
1276   *            @arg  RTC_IT_TAMP_3: Tamper3 interrupt
1277   *            @arg  RTC_IT_TAMP_4: Tamper4 interrupt
1278   *            @arg  RTC_IT_TAMP_5: Tamper5 interrupt
1279   *            @arg  RTC_IT_TAMP_6: Tamper6 interrupt
1280   *            @arg  RTC_IT_TAMP_7: Tamper7 interrupt
1281   *            @arg  RTC_IT_TAMP_8: Tamper8 interrupt
1282   * @retval None
1283   */
1284 #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__)       (TAMP->IER &= ~(__INTERRUPT__))
1285 
1286 
1287 /**************************************************************************************************/
1288 /**
1289   * @brief  Check whether the specified RTC Tamper interrupt has occurred or not.
1290   * @param  __HANDLE__ specifies the RTC handle.
1291   * @param  __INTERRUPT__ specifies the RTC Tamper interrupt to check.
1292   *         This parameter can be:
1293   *            @arg  RTC_IT_TAMP_ALL: All tampers interrupts
1294   *            @arg  RTC_IT_TAMP_1: Tamper1 interrupt
1295   *            @arg  RTC_IT_TAMP_2: Tamper2 interrupt
1296   *            @arg  RTC_IT_TAMP_3: Tamper3 interrupt
1297   *            @arg  RTC_IT_TAMP_4: Tamper4 interrupt
1298   *            @arg  RTC_IT_TAMP_5: Tamper5 interrupt
1299   *            @arg  RTC_IT_TAMP_6: Tamper6 interrupt
1300   *            @arg  RTC_IT_TAMP_7: Tamper7 interrupt
1301   *            @arg  RTC_IT_TAMP_8: Tamper8 interrupt
1302   *            @arg  RTC_IT_INT_TAMP_ALL: All Internal Tamper interrupts
1303   *            @arg  RTC_IT_INT_TAMP_1: Internal Tamper1 interrupt
1304   *            @arg  RTC_IT_INT_TAMP_2: Internal Tamper2 interrupt
1305   *            @arg  RTC_IT_INT_TAMP_3: Internal Tamper3 interrupt
1306   *            @arg  RTC_IT_INT_TAMP_5: Internal Tamper5 interrupt
1307   *            @arg  RTC_IT_INT_TAMP_6: Internal Tamper6 interrupt
1308   *            @arg  RTC_IT_INT_TAMP_7: Internal Tamper7 interrupt
1309   *            @arg  RTC_IT_INT_TAMP_8: Internal Tamper8 interrupt
1310   *            @arg  RTC_IT_INT_TAMP_9: Internal Tamper9 interrupt
1311   *            @arg  RTC_IT_INT_TAMP_11: Internal Tamper11 interrupt
1312   *            @arg  RTC_IT_INT_TAMP_12: Internal Tamper12 interrupt
1313   *            @arg  RTC_IT_INT_TAMP_13: Internal Tamper13 interrupt
1314   * @retval The state of __INTERRUPT__ (TRUE or FALSE)
1315   */
1316 #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__)    ((((TAMP->MISR) & (__INTERRUPT__)) != 0U) ? 1UL : 0UL)
1317 
1318 /**
1319   * @brief  Check whether the specified RTC Tamper interrupt has been enabled or not.
1320   * @param  __HANDLE__ specifies the RTC handle.
1321   * @param  __INTERRUPT__ specifies the RTC Tamper interrupt source to check.
1322   *         This parameter can be:
1323   *            @arg  RTC_IT_TAMP_ALL: All tampers interrupts
1324   *            @arg  RTC_IT_TAMP_1: Tamper1 interrupt
1325   *            @arg  RTC_IT_TAMP_2: Tamper2 interrupt
1326   *            @arg  RTC_IT_TAMP_3: Tamper3 interrupt
1327   *            @arg  RTC_IT_TAMP_4: Tamper4 interrupt
1328   *            @arg  RTC_IT_TAMP_5: Tamper5 interrupt
1329   *            @arg  RTC_IT_TAMP_6: Tamper6 interrupt
1330   *            @arg  RTC_IT_TAMP_7: Tamper7 interrupt
1331   *            @arg  RTC_IT_TAMP_8: Tamper8 interrupt
1332   *            @arg  RTC_IT_INT_TAMP_ALL: All internal tampers interrupts
1333   *            @arg  RTC_IT_INT_TAMP_1: Internal Tamper1 interrupt
1334   *            @arg  RTC_IT_INT_TAMP_2: Internal Tamper2 interrupt
1335   *            @arg  RTC_IT_INT_TAMP_3: Internal Tamper3 interrupt
1336   *            @arg  RTC_IT_INT_TAMP_5: Internal Tamper5 interrupt
1337   *            @arg  RTC_IT_INT_TAMP_6: Internal Tamper6 interrupt
1338   *            @arg  RTC_IT_INT_TAMP_7: Internal Tamper7 interrupt
1339   *            @arg  RTC_IT_INT_TAMP_8: Internal Tamper8 interrupt
1340   *            @arg  RTC_IT_INT_TAMP_9: Internal Tamper9 interrupt
1341   *            @arg  RTC_IT_INT_TAMP_11: Internal Tamper11 interrupt
1342   *            @arg  RTC_IT_INT_TAMP_12: Internal Tamper12 interrupt
1343   *            @arg  RTC_IT_INT_TAMP_13: Internal Tamper13 interrupt
1344   * @retval The state of __INTERRUPT__ (TRUE or FALSE)
1345   */
1346 #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)   ((((TAMP->IER) & (__INTERRUPT__)) != \
1347                                                                       0U) ? 1UL : 0UL)
1348 
1349 /**
1350   * @brief  Get the selected RTC Tampers flag status.
1351   * @param  __HANDLE__ specifies the RTC handle.
1352   * @param  __FLAG__ specifies the RTC Tamper Flag is pending or not.
1353   *          This parameter can be:
1354   *             @arg RTC_FLAG_TAMP_ALL: All tampers flag
1355   *             @arg RTC_FLAG_TAMP_1: Tamper1 flag
1356   *             @arg RTC_FLAG_TAMP_2: Tamper2 flag
1357   *             @arg RTC_FLAG_TAMP_3: Tamper3 flag
1358   *             @arg RTC_FLAG_TAMP_4: Tamper4 flag
1359   *             @arg RTC_FLAG_TAMP_5: Tamper5 flag
1360   *             @arg RTC_FLAG_TAMP_6: Tamper6 flag
1361   *             @arg RTC_FLAG_TAMP_7: Tamper7 flag
1362   *             @arg RTC_FLAG_TAMP_8: Tamper8 flag
1363   *             @arg RTC_FLAG_INT_TAMP_1: Internal Tamper1 flag
1364   *             @arg RTC_FLAG_INT_TAMP_2: Internal Tamper2 flag
1365   *             @arg RTC_FLAG_INT_TAMP_3: Internal Tamper3 flag
1366   *             @arg RTC_FLAG_INT_TAMP_5: Internal Tamper5 flag
1367   *             @arg RTC_FLAG_INT_TAMP_6: Internal Tamper6 flag
1368   *             @arg RTC_FLAG_INT_TAMP_7: Internal Tamper7 flag
1369   *             @arg RTC_FLAG_INT_TAMP_8: Internal Tamper8 flag
1370   *             @arg RTC_FLAG_INT_TAMP_9: Internal Tamper9 flag
1371   *             @arg RTC_FLAG_INT_TAMP_11: Internal Tamper11 flag
1372   *             @arg RTC_FLAG_INT_TAMP_12: Internal Tamper12 flag
1373   *             @arg RTC_FLAG_INT_TAMP_13: Internal Tamper13 flag
1374   * @retval The state of __FLAG__ (TRUE or FALSE)
1375   */
1376 #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__)        (((TAMP->SR) & (__FLAG__)) != 0U)
1377 
1378 /**
1379   * @brief  Clear the RTC Tamper's pending flags.
1380   * @param  __HANDLE__ specifies the RTC handle.
1381   * @param  __FLAG__ specifies the RTC Tamper Flag to clear.
1382   *          This parameter can be:
1383   *             @arg RTC_FLAG_TAMP_ALL: All tampers flag
1384   *             @arg RTC_FLAG_TAMP_1: Tamper1 flag
1385   *             @arg RTC_FLAG_TAMP_2: Tamper2 flag
1386   *             @arg RTC_FLAG_TAMP_3: Tamper3 flag
1387   *             @arg RTC_FLAG_TAMP_4: Tamper4 flag
1388   *             @arg RTC_FLAG_TAMP_5: Tamper5 flag
1389   *             @arg RTC_FLAG_TAMP_6: Tamper6 flag
1390   *             @arg RTC_FLAG_TAMP_7: Tamper7 flag
1391   *             @arg RTC_FLAG_TAMP_8: Tamper8 flag
1392   *             @arg RTC_FLAG_INT_TAMP_ALL: All Internal Tamper flags
1393   *             @arg RTC_FLAG_INT_TAMP_1: Internal Tamper1 flag
1394   *             @arg RTC_FLAG_INT_TAMP_2: Internal Tamper2 flag
1395   *             @arg RTC_FLAG_INT_TAMP_3: Internal Tamper3 flag
1396   *             @arg RTC_FLAG_INT_TAMP_5: Internal Tamper5 flag
1397   *             @arg RTC_FLAG_INT_TAMP_6: Internal Tamper6 flag
1398   *             @arg RTC_FLAG_INT_TAMP_7: Internal Tamper7 flag
1399   *             @arg RTC_FLAG_INT_TAMP_8: Internal Tamper8 flag
1400   *             @arg RTC_FLAG_INT_TAMP_9: Internal Tamper9 flag
1401   *             @arg RTC_FLAG_INT_TAMP_11: Internal Tamper11 flag
1402   *             @arg RTC_IT_INT_TAMP_12: Internal Tamper12 interrupt
1403   *             @arg RTC_IT_INT_TAMP_13: Internal Tamper13 interrupt
1404   * @retval None
1405   */
1406 #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__)      ((TAMP->SCR) = (__FLAG__))
1407 
1408 /**
1409   * @}
1410   */
1411 
1412 /* --------------------------------- SSR Underflow ---------------------------------*/
1413 /** @defgroup RTCEx_SSR_Underflow RTC SSR Underflow
1414   * @{
1415   */
1416 
1417 /**
1418   * @brief  Enable the RTC SSRU interrupt.
1419   * @param  __HANDLE__ specifies the RTC handle.
1420   * @param  __INTERRUPT__ specifies the RTC SSRU interrupt sources to be enabled.
1421   *         This parameter can be:
1422   *            @arg @ref RTC_IT_SSRU SSRU interrupt
1423   * @retval None
1424   */
1425 #define __HAL_RTC_SSRU_ENABLE_IT(__HANDLE__, __INTERRUPT__)    (RTC->CR |= (RTC_CR_SSRUIE))
1426 
1427 /**
1428   * @brief  Disable the RTC SSRU interrupt.
1429   * @param  __HANDLE__ specifies the RTC handle.
1430   * @param  __INTERRUPT__ specifies the RTC SSRU interrupt sources to be disabled.
1431   *         This parameter can be:
1432   *            @arg @ref RTC_IT_SSRU SSRU interrupt
1433   * @retval None
1434   */
1435 #define __HAL_RTC_SSRU_DISABLE_IT(__HANDLE__, __INTERRUPT__)   (RTC->CR &= ~(RTC_CR_SSRUIE))
1436 
1437 
1438 /**
1439   * @brief  Check whether the specified RTC SSRU interrupt has occurred or not.
1440   * @param  __HANDLE__ specifies the RTC handle.
1441   * @param  __INTERRUPT__ specifies the RTC SSRU interrupt to check.
1442   *         This parameter can be:
1443   *            @arg @ref RTC_IT_SSRU  SSRU interrupt
1444   * @retval The state of __INTERRUPT__ (TRUE or FALSE)
1445   */
1446 #define __HAL_RTC_SSRU_GET_IT(__HANDLE__, __INTERRUPT__)       ((((RTC->MISR) & (RTC_MISR_SSRUMF)) != 0U) ? 1U : 0U)
1447 /**
1448   * @brief  Check whether the specified RTC SSRU interrupt has been enabled or not.
1449   * @param  __HANDLE__ specifies the RTC handle.
1450   * @param  __INTERRUPT__ specifies the RTC SSRU interrupt sources to check.
1451   *         This parameter can be:
1452   *            @arg @ref RTC_IT_SSRU  SSRU interrupt
1453   * @retval The state of __INTERRUPT__ (TRUE or FALSE)
1454   */
1455 #define __HAL_RTC_SSRU_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)   ((((RTC->CR) & (RTC_CR_SSRUIE)) != 0U) ? 1U : 0U)
1456 
1457 /**
1458   * @brief  Get the selected RTC SSRU's flag status.
1459   * @param  __HANDLE__ specifies the RTC handle.
1460   * @param  __FLAG__ specifies the RTC SSRU Flag is pending or not.
1461   *          This parameter can be:
1462   *             @arg @ref RTC_FLAG_SSRUF
1463   * @retval The state of __FLAG__ (TRUE or FALSE)
1464   */
1465 #define __HAL_RTC_SSRU_GET_FLAG(__HANDLE__, __FLAG__)       ((READ_BIT(RTC->SR, RTC_SR_SSRUF) == RTC_SR_SSRUF))
1466 
1467 /**
1468   * @brief  Clear the RTC SSRU's pending flags.
1469   * @param  __HANDLE__ specifies the RTC handle.
1470   * @param  __FLAG__ specifies the RTC SSRU Flag to clear.
1471   *         This parameter can be:
1472   *            @arg @ref RTC_FLAG_SSRUF
1473   * @retval None
1474   */
1475 #define __HAL_RTC_SSRU_CLEAR_FLAG(__HANDLE__, __FLAG__)     (WRITE_REG(RTC->SCR, RTC_SCR_CSSRUF))
1476 /**
1477   * @}
1478   */
1479 
1480 /**
1481   * @}
1482   */
1483 
1484 /* Exported functions --------------------------------------------------------*/
1485 /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions
1486   * @{
1487   */
1488 
1489 /* RTC TimeStamp functions *****************************************/
1490 /** @defgroup RTCEx_Exported_Functions_Group1 Extended RTC TimeStamp functions
1491   * @{
1492   */
1493 
1494 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge,
1495                                          uint32_t RTC_TimeStampPin);
1496 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge,
1497                                             uint32_t RTC_TimeStampPin);
1498 HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc);
1499 HAL_StatusTypeDef HAL_RTCEx_SetInternalTimeStamp(RTC_HandleTypeDef *hrtc);
1500 HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTimeStamp(RTC_HandleTypeDef *hrtc);
1501 HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp,
1502                                          RTC_DateTypeDef *sTimeStampDate, uint32_t Format);
1503 void              HAL_RTCEx_TimeStampIRQHandler(RTC_HandleTypeDef *hrtc);
1504 HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
1505 void              HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc);
1506 
1507 /**
1508   * @}
1509   */
1510 /* RTC Wake-up functions ******************************************************/
1511 /** @defgroup RTCEx_Exported_Functions_Group2 Extended RTC Wake-up functions
1512   * @{
1513   */
1514 
1515 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
1516 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock,
1517                                               uint32_t WakeUpAutoClr);
1518 HAL_StatusTypeDef HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc);
1519 uint32_t          HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc);
1520 void              HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc);
1521 void              HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc);
1522 HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
1523 /**
1524   * @}
1525   */
1526 
1527 /* Extended Control functions ************************************************/
1528 /** @defgroup RTCEx_Exported_Functions_Group3 Extended Peripheral Control functions
1529   * @{
1530   */
1531 
1532 HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod,
1533                                            uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue);
1534 HAL_StatusTypeDef HAL_RTCEx_SetLowPowerCalib(RTC_HandleTypeDef *hrtc, uint32_t LowPowerCalib);
1535 HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS);
1536 HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput);
1537 HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc);
1538 HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc);
1539 HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc);
1540 HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc);
1541 HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc);
1542 HAL_StatusTypeDef HAL_RTCEx_MonotonicCounterIncrement(RTC_HandleTypeDef *hrtc, uint32_t Instance);
1543 HAL_StatusTypeDef HAL_RTCEx_MonotonicCounterGet(RTC_HandleTypeDef *hrtc, uint32_t Instance, uint32_t *Value);
1544 HAL_StatusTypeDef HAL_RTCEx_SetSSRU_IT(RTC_HandleTypeDef *hrtc);
1545 HAL_StatusTypeDef HAL_RTCEx_DeactivateSSRU(RTC_HandleTypeDef *hrtc);
1546 void              HAL_RTCEx_SSRUIRQHandler(RTC_HandleTypeDef *hrtc);
1547 void              HAL_RTCEx_SSRUEventCallback(RTC_HandleTypeDef *hrtc);
1548 /**
1549   * @}
1550   */
1551 
1552 /* Extended RTC features functions *******************************************/
1553 /** @defgroup RTCEx_Exported_Functions_Group4 Extended features functions
1554   * @{
1555   */
1556 
1557 void              HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc);
1558 HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(const RTC_HandleTypeDef *hrtc, uint32_t Timeout);
1559 /**
1560   * @}
1561   */
1562 
1563 /** @defgroup RTCEx_Exported_Functions_Group5 Extended RTC Tamper functions
1564   * @{
1565   */
1566 HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper);
1567 HAL_StatusTypeDef HAL_RTCEx_SetActiveTampers(RTC_HandleTypeDef *hrtc, RTC_ActiveTampersTypeDef *sAllTamper);
1568 HAL_StatusTypeDef HAL_RTCEx_SetActiveSeed(RTC_HandleTypeDef *hrtc, uint32_t *pSeed);
1569 HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper);
1570 HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper);
1571 HAL_StatusTypeDef HAL_RTCEx_DeactivateActiveTampers(RTC_HandleTypeDef *hrtc);
1572 HAL_StatusTypeDef HAL_RTCEx_PollForTamperEvent(RTC_HandleTypeDef *hrtc, uint32_t Tamper, uint32_t Timeout);
1573 HAL_StatusTypeDef HAL_RTCEx_SetInternalTamper(RTC_HandleTypeDef *hrtc, RTC_InternalTamperTypeDef *sIntTamper);
1574 HAL_StatusTypeDef HAL_RTCEx_SetInternalTamper_IT(RTC_HandleTypeDef *hrtc, RTC_InternalTamperTypeDef *sIntTamper);
1575 HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTamper(RTC_HandleTypeDef *hrtc, uint32_t IntTamper);
1576 HAL_StatusTypeDef HAL_RTCEx_PollForInternalTamperEvent(RTC_HandleTypeDef *hrtc, uint32_t IntTamper, uint32_t Timeout);
1577 HAL_StatusTypeDef HAL_RTCEx_SetBoothardwareKey(RTC_HandleTypeDef *hrtc);
1578 void              HAL_RTCEx_GetActiveTampers(RTC_ActiveTampersTypeDef *sAllTamper);
1579 void              HAL_RTCEx_GetInternalTampers(RTC_InternalTamperTypeDef *sIntTamper);
1580 void              HAL_RTCEx_TamperIRQHandler(RTC_HandleTypeDef *hrtc);
1581 void              HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc);
1582 void              HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc);
1583 void              HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc);
1584 void              HAL_RTCEx_Tamper4EventCallback(RTC_HandleTypeDef *hrtc);
1585 void              HAL_RTCEx_Tamper5EventCallback(RTC_HandleTypeDef *hrtc);
1586 void              HAL_RTCEx_Tamper6EventCallback(RTC_HandleTypeDef *hrtc);
1587 void              HAL_RTCEx_Tamper7EventCallback(RTC_HandleTypeDef *hrtc);
1588 void              HAL_RTCEx_Tamper8EventCallback(RTC_HandleTypeDef *hrtc);
1589 void              HAL_RTCEx_InternalTamper1EventCallback(RTC_HandleTypeDef *hrtc);
1590 void              HAL_RTCEx_InternalTamper2EventCallback(RTC_HandleTypeDef *hrtc);
1591 void              HAL_RTCEx_InternalTamper3EventCallback(RTC_HandleTypeDef *hrtc);
1592 void              HAL_RTCEx_InternalTamper5EventCallback(RTC_HandleTypeDef *hrtc);
1593 void              HAL_RTCEx_InternalTamper6EventCallback(RTC_HandleTypeDef *hrtc);
1594 void              HAL_RTCEx_InternalTamper7EventCallback(RTC_HandleTypeDef *hrtc);
1595 void              HAL_RTCEx_InternalTamper8EventCallback(RTC_HandleTypeDef *hrtc);
1596 void              HAL_RTCEx_InternalTamper9EventCallback(RTC_HandleTypeDef *hrtc);
1597 void              HAL_RTCEx_InternalTamper11EventCallback(RTC_HandleTypeDef *hrtc);
1598 void              HAL_RTCEx_InternalTamper12EventCallback(RTC_HandleTypeDef *hrtc);
1599 void              HAL_RTCEx_InternalTamper13EventCallback(RTC_HandleTypeDef *hrtc);
1600 /**
1601   * @}
1602   */
1603 
1604 /** @defgroup RTCEx_Exported_Functions_Group6 Extended RTC Backup register functions
1605   * @{
1606   */
1607 void              HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data);
1608 uint32_t          HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister);
1609 void              HAL_RTCEx_BKUPErase(RTC_HandleTypeDef *hrtc);
1610 void              HAL_RTCEx_BKUPBlock_Enable(RTC_HandleTypeDef *hrtc);
1611 void              HAL_RTCEx_BKUPBlock_Disable(RTC_HandleTypeDef *hrtc);
1612 void              HAL_RTCEx_Erase_SecretDev_Conf(RTC_HandleTypeDef *hrtc, uint32_t SecretDeviceConf);
1613 uint32_t          HAL_RTCEx_Get_Erase_SecretDev_Conf(void);
1614 /**
1615   * @}
1616   */
1617 
1618 /** @defgroup RTCEx_Exported_Functions_Group7 Extended RTC secure functions
1619   * @{
1620   */
1621 HAL_StatusTypeDef HAL_RTCEx_SecureModeGet(RTC_HandleTypeDef *hrtc, RTC_SecureStateTypeDef  *secureState);
1622 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
1623 HAL_StatusTypeDef HAL_RTCEx_SecureModeSet(RTC_HandleTypeDef *hrtc, RTC_SecureStateTypeDef  *secureState);
1624 #endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
1625 
1626 /**
1627   * @}
1628   */
1629 
1630 /** @defgroup RTCEx_Exported_Functions_Group8 Extended RTC privilege functions
1631   * @{
1632   */
1633 HAL_StatusTypeDef HAL_RTCEx_PrivilegeModeSet(RTC_HandleTypeDef *hrtc, RTC_PrivilegeStateTypeDef *privilegeState);
1634 HAL_StatusTypeDef HAL_RTCEx_PrivilegeModeGet(RTC_HandleTypeDef *hrtc, RTC_PrivilegeStateTypeDef *privilegeState);
1635 /**
1636   * @}
1637   */
1638 
1639 /**
1640   * @}
1641   */
1642 
1643 /* Private types -------------------------------------------------------------*/
1644 /* Private variables ---------------------------------------------------------*/
1645 /* Private constants ---------------------------------------------------------*/
1646 /* Private macros ------------------------------------------------------------*/
1647 /** @defgroup RTCEx_Private_Macros RTCEx Private Macros
1648   * @{
1649   */
1650 
1651 /** @defgroup RTCEx_IS_RTC_Definitions Private macros to check input parameters
1652   * @{
1653   */
1654 #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \
1655                                  ((EDGE) == RTC_TIMESTAMPEDGE_FALLING))
1656 
1657 
1658 #define IS_RTC_TIMESTAMP_PIN(PIN)  (((PIN) == RTC_TIMESTAMPPIN_DEFAULT))
1659 
1660 
1661 #define IS_RTC_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \
1662                                                        ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE))
1663 
1664 #define IS_RTC_TAMPER_TAMPERDETECTIONOUTPUT(MODE)    (((MODE) == RTC_TAMPERDETECTIONOUTPUT_ENABLE) || \
1665                                                       ((MODE) == RTC_TAMPERDETECTIONOUTPUT_DISABLE))
1666 
1667 #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16)   || \
1668                                     ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8)    || \
1669                                     ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4)    || \
1670                                     ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2)    || \
1671                                     ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \
1672                                     ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS))
1673 
1674 #define IS_RTC_WAKEUP_COUNTER(COUNTER)  ((COUNTER) <= RTC_WUTR_WUT)
1675 
1676 #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \
1677                                             ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \
1678                                             ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC))
1679 
1680 #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \
1681                                         ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET))
1682 
1683 #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= RTC_CALR_CALM)
1684 
1685 #define IS_RTC_LOW_POWER_CALIB(LPCAL) (((LPCAL) == RTC_LPCAL_SET) || \
1686                                        ((LPCAL) == RTC_LPCAL_RESET))
1687 
1688 
1689 #define IS_RTC_TAMPER(__TAMPER__)                ((((__TAMPER__) & RTC_TAMPER_ALL) != 0U) && \
1690                                                   (((__TAMPER__) & ~RTC_TAMPER_ALL) == 0U))
1691 
1692 #define IS_RTC_INTERNAL_TAMPER(__INT_TAMPER__)   ((((__INT_TAMPER__) & RTC_INT_TAMPER_ALL) != 0U) && \
1693                                                   (((__INT_TAMPER__) & ~RTC_INT_TAMPER_ALL) == 0U))
1694 
1695 #define IS_RTC_TAMPER_TRIGGER(__TRIGGER__)       (((__TRIGGER__) == RTC_TAMPERTRIGGER_RISINGEDGE)  || \
1696                                                   ((__TRIGGER__) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \
1697                                                   ((__TRIGGER__) == RTC_TAMPERTRIGGER_LOWLEVEL)    || \
1698                                                   ((__TRIGGER__) == RTC_TAMPERTRIGGER_HIGHLEVEL))
1699 
1700 #define IS_RTC_TAMPER_ERASE_MODE(__MODE__)       (((__MODE__) == RTC_TAMPER_ERASE_BACKUP_ENABLE) || \
1701                                                   ((__MODE__) == RTC_TAMPER_ERASE_BACKUP_DISABLE))
1702 
1703 #define IS_RTC_TAMPER_MASKFLAG_STATE(__STATE__)  (((__STATE__) == RTC_TAMPERMASK_FLAG_ENABLE) || \
1704                                                   ((__STATE__) == RTC_TAMPERMASK_FLAG_DISABLE))
1705 
1706 #define IS_RTC_TAMPER_FILTER(__FILTER__)         (((__FILTER__) == RTC_TAMPERFILTER_DISABLE)  || \
1707                                                   ((__FILTER__) == RTC_TAMPERFILTER_2SAMPLE) || \
1708                                                   ((__FILTER__) == RTC_TAMPERFILTER_4SAMPLE) || \
1709                                                   ((__FILTER__) == RTC_TAMPERFILTER_8SAMPLE))
1710 
1711 #define IS_RTC_TAMPER_SAMPLING_FREQ(__FREQ__)    (((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \
1712                                                   ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \
1713                                                   ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \
1714                                                   ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \
1715                                                   ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \
1716                                                   ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \
1717                                                   ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512)  || \
1718                                                   ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256))
1719 
1720 #define IS_RTC_TAMPER_PRECHARGE_DURATION(__DURATION__) (((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \
1721                                                         ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \
1722                                                         ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \
1723                                                         ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK))
1724 
1725 #define IS_RTC_TAMPER_PULLUP_STATE(__STATE__)    (((__STATE__) == RTC_TAMPER_PULLUP_ENABLE) || \
1726                                                   ((__STATE__) == RTC_TAMPER_PULLUP_DISABLE))
1727 
1728 #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE)\
1729                                                               ||((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE))
1730 
1731 #define IS_RTC_BKP(__BKP__)   ((__BKP__) < RTC_BKP_NUMBER)
1732 
1733 #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \
1734                                  ((SEL) == RTC_SHIFTADD1S_SET))
1735 
1736 #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= RTC_SHIFTR_SUBFS)
1737 
1738 #define IS_RTC_CALIB_OUTPUT(OUTPUT)  (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \
1739                                       ((OUTPUT) == RTC_CALIBOUTPUT_1HZ))
1740 
1741 #define IS_RTC_SECURE_FULL(__STATE__) (((__STATE__) == RTC_SECURE_FULL_YES) || \
1742                                        ((__STATE__) == RTC_SECURE_FULL_NO))
1743 
1744 #define IS_RTC_NONSECURE_FEATURES(__FEATURES__) (((__FEATURES__) & ~RTC_NONSECURE_FEATURE_NONE) == 0U)
1745 
1746 #define IS_TAMP_SECURE_FULL(__STATE__) (((__STATE__) == TAMP_SECURE_FULL_YES) || \
1747                                         ((__STATE__) == TAMP_SECURE_FULL_NO))
1748 
1749 #define IS_TAMP_MONOTONIC_CNT_SECURE(__STATE__) (((__STATE__) == TAMP_MONOTONIC_CNT_SECURE_YES) || \
1750                                                  ((__STATE__) == TAMP_MONOTONIC_CNT_SECURE_NO))
1751 
1752 #define IS_RTC_PRIVILEGE_FULL(__STATE__) (((__STATE__) == RTC_PRIVILEGE_FULL_YES) || \
1753                                           ((__STATE__) == RTC_PRIVILEGE_FULL_NO))
1754 
1755 #define IS_RTC_PRIVILEGE_FEATURES(__FEATURES__) (((__FEATURES__) & ~RTC_PRIVILEGE_FEATURE_ALL) == 0U)
1756 
1757 #define IS_TAMP_PRIVILEGE_FULL(__STATE__) (((__STATE__) == TAMP_PRIVILEGE_FULL_YES) || \
1758                                            ((__STATE__) == TAMP_PRIVILEGE_FULL_NO))
1759 
1760 #define IS_TAMP_MONOTONIC_CNT_PRIVILEGE(__STATE__) (((__STATE__) == TAMP_MONOTONIC_CNT_PRIVILEGE_YES) || \
1761                                                     ((__STATE__) == TAMP_MONOTONIC_CNT_PRIVILEGE_NO))
1762 
1763 #define IS_RTC_PRIVILEGE_BKUP_ZONE(__ZONES__) (((__ZONES__) & ~RTC_PRIVILEGE_BKUP_ZONE_ALL) == 0U)
1764 
1765 #define IS_RTC_BINARY_MODE(MODE) (((MODE) == RTC_BINARY_NONE) || \
1766                                   ((MODE) == RTC_BINARY_ONLY) || \
1767                                   ((MODE) == RTC_BINARY_MIX ))
1768 
1769 #define IS_RTC_BINARY_MIX_BCDU(BDCU) (((BDCU) == RTC_BINARY_MIX_BCDU_0) || \
1770                                       ((BDCU) == RTC_BINARY_MIX_BCDU_1) || \
1771                                       ((BDCU) == RTC_BINARY_MIX_BCDU_2) || \
1772                                       ((BDCU) == RTC_BINARY_MIX_BCDU_3) || \
1773                                       ((BDCU) == RTC_BINARY_MIX_BCDU_4) || \
1774                                       ((BDCU) == RTC_BINARY_MIX_BCDU_5) || \
1775                                       ((BDCU) == RTC_BINARY_MIX_BCDU_6) || \
1776                                       ((BDCU) == RTC_BINARY_MIX_BCDU_7))
1777 
1778 #define IS_RTC_ALARM_SUB_SECOND_BINARY_MASK(MASK)   (((MASK) == 0U) || \
1779                                                      (((MASK) >= RTC_ALARMSUBSECONDBINMASK_SS31_1) &&\
1780                                                       ((MASK) <= RTC_ALARMSUBSECONDBINMASK_NONE)))
1781 
1782 #define IS_RTC_ALARMSUBSECONDBIN_AUTOCLR(SEL) (((SEL) == RTC_ALARMSUBSECONDBIN_AUTOCLR_NO) || \
1783                                                ((SEL) == RTC_ALARMSUBSECONDBIN_AUTOCLR_YES))
1784 /**
1785   * @}
1786   */
1787 
1788 /**
1789   * @}
1790   */
1791 
1792 /**
1793   * @}
1794   */
1795 
1796 /**
1797   * @}
1798   */
1799 
1800 /**
1801   * @}
1802   */
1803 
1804 /**
1805   * @}
1806   */
1807 
1808 #ifdef __cplusplus
1809 }
1810 #endif
1811 
1812 #endif /* STM32U5xx_HAL_RTC_EX_H */
1813