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