1 /**
2   ******************************************************************************
3   * @file    stm32mp1xx_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) 2019 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 STM32MP1xx_HAL_RTC_EX_H
21 #define STM32MP1xx_HAL_RTC_EX_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32mp1xx_hal_def.h"
29 
30 /** @addtogroup STM32MP1xx_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 @ref RTCEx_Tamper_Sampling_Frequencies */
65 
66   uint32_t PrechargeDuration;           /*!< Specifies the Precharge Duration .
67                                              This parameter can be a value of @ref RTCEx_Tamper_Pin_Precharge_Duration */
68 
69   uint32_t TamperPullUp;                /*!< Specifies the Tamper PullUp .
70                                              This parameter can be a value of @ref RTCEx_Tamper_Pull_UP */
71 
72   uint32_t TimeStampOnTamperDetection;  /*!< Specifies the TimeStampOnTamperDetection.
73                                              This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection */
74 } RTC_TamperTypeDef;
75 /**
76   * @}
77   */
78 
79 
80 /** @defgroup RTCEx_Active_Seed_Size Seed size Definitions
81   * @{
82   */
83 #define RTC_ATAMP_SEED_NB_UINT32        4U
84 /**
85   * @}
86   */
87 
88 
89 /** @defgroup RTCEx_ActiveTamper_structures_definition RTCEx Active Tamper structures definitions
90   * @{
91   */
92 typedef struct
93 {
94   uint32_t Enable;                      /*!< Specifies the Tamper input is active.
95                                              This parameter can be a value of @ref RTCEx_ActiveTamper_Enable */
96 
97   uint32_t Interrupt;                    /*!< Specifies the interrupt mode
98                                              This parameter can be a value of @ref RTCEx_ActiveTamper_Interrupt */
99 
100   uint32_t Output;                      /*!< Specifies the TAMP output to be compared with.
101                                              The same output can be used for several tamper inputs.
102                                              This parameter can be a value of @ref RTCEx_ActiveTamper_Sel */
103 
104   uint32_t NoErase;                     /*!< Specifies the Tamper no erase mode.
105                                              This parameter can be a value of @ref RTCEx_Tamper_EraseBackUp */
106 
107   uint32_t MaskFlag;                    /*!< Specifies the Tamper Flag masking.
108                                              This parameter can be a value of @ref RTCEx_Tamper_MaskFlag */
109 
110 } RTC_ATampInputTypeDef;
111 
112 
113 typedef struct
114 {
115   uint32_t ActiveFilter;                /*!< Specifies the Active tamper filter enable.
116                                              This parameter can be a value of @ref RTCEx_ActiveTamper_Filter */
117 
118   uint32_t ActiveAsyncPrescaler;        /*!< Specifies the Active Tamper asynchronous Prescaler clock.
119                                              This parameter can be a value of @ref RTCEx_ActiveTamper_Async_prescaler */
120 
121   uint32_t TimeStampOnTamperDetection;  /*!< Specifies the timeStamp on tamper detection.
122                                              This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection */
123 
124   uint32_t ActiveOutputChangePeriod;    /*!< Specifies the Active Tamper output change period.
125                                              This parameter can be a value from 0 to 7. */
126 
127   uint32_t Seed[RTC_ATAMP_SEED_NB_UINT32];
128   /*!< Specifies the RNG Seed value.
129        This parameter is an array of value from 0 to 0xFFFFFFFF. */
130 
131   RTC_ATampInputTypeDef TampInput[RTC_TAMP_NB];
132   /*!< Specifies configuration of all active tampers.
133        The index of TampInput[RTC_TAMP_NB] can be a value of RTCEx_ActiveTamper_Sel */
134 } RTC_ActiveTampersTypeDef;
135 /**
136   * @}
137   */
138 
139 /** @defgroup RTCEx_Internal_Tamper_structure_definition RTCEx Internal Tamper structure definition
140   * @{
141   */
142 typedef struct
143 {
144   uint32_t IntTamper;                   /*!< Specifies the Internal Tamper Pin.
145                                              This parameter can be a value of @ref RTCEx_Internal_Tamper_Pins */
146 
147   uint32_t TimeStampOnTamperDetection;  /*!< Specifies the TimeStampOnTamperDetection.
148                                              This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection */
149 
150   uint32_t NoErase;                     /*!< Specifies the internal Tamper no erase mode.
151                                              This parameter can be a value of @ref RTCEx_Tamper_EraseBackUp */
152 
153 } RTC_InternalTamperTypeDef;
154 /**
155   * @}
156   */
157 
158 /** @defgroup RTCEx_Secure_State_structure_definition RTCEx Secure structure definition
159   * @{
160   */
161 typedef struct
162 {
163   uint32_t rtcSecureFull;               /*!< Specifies If the RTC is fully secure or not
164                                              This parameter can be a value of @ref RTCEx_RTC_Secure_Full */
165   uint32_t rtcNonSecureFeatures;        /*!< Specifies the non-secure features.
166                                              This parameter is only relevant if RTC is not fully secure (rtcSecureFull == RTC_SECURE_FULL_NO).
167                                              This parameter can be a combination of @ref RTCEx_RTC_NonSecure_Features. */
168 
169   uint32_t tampSecureFull;              /*!< Specifies If the TAMP is fully secure or not
170                                              This parameter can be a value of @ref RTCEx_TAMP_Secure_Full */
171 
172   uint32_t backupRegisterStartZone2;    /*!< Specifies the backup register start zone 2
173                                              Zone 1 : read secure write secure.
174                                              Zone 2 : read non-secure  write secure.
175                                              This parameter can be RTC_BKP_DRx where x can be from 0 to 31 to specify the register.
176                                              Warning : this parameter is shared with RTC_PrivilegeStateTypeDef. */
177 
178   uint32_t backupRegisterStartZone3;    /*!< Specifies the backup register start zone 3
179                                              Zone 3 : read non-secure  write non-secure
180                                              This parameter can be RTC_BKP_DRx where x can be from 0 to 31 to specify the register.
181                                              Warning : this parameter is shared with RTC_PrivilegeStateTypeDef. */
182 
183 } RTC_SecureStateTypeDef ;
184 /**
185   * @}
186   */
187 
188 /** @defgroup RTCEx_Privilege_State_structure_definition RTCEx Privilege structure definition
189   * @{
190   */
191 typedef struct
192 {
193   uint32_t rtcPrivilegeFull;            /*!< Specifies If the RTC is fully privileged or not.
194                                              This parameter can be a value of @ref RTCEx_RTC_Privilege_Full. */
195 
196   uint32_t rtcPrivilegeFeatures;        /*!< Specifies the privileged features.
197                                              This parameter is only relevant if RTC is not fully privileged (rtcPrivilegeFull == RTC_PRIVILEGE_FULL_NO).
198                                              This parameter can be a combination of @ref RTCEx_RTC_Privilege_Features. */
199 
200   uint32_t tampPrivilegeFull;           /*!< Specifies If the TAMP is fully privileged or not.
201                                              This parameter can be a value of @ref RTCEx_TAMP_Privilege_Full. */
202 
203   uint32_t backupRegisterPrivZone;      /*!< Specifies backup register zone to be privileged.
204                                              This parameter can be a combination of @ref RTCEx_Backup_Reg_Privilege_zone.
205                                              Warning : this parameter is writable in secure mode or if trustzone is disabled. */
206 
207 
208   uint32_t backupRegisterStartZone2;    /*!< Specifies the backup register start zone 2.
209                                              Zone 1 : read secure write secure.
210                                              Zone 2 : read non-secure  write secure.
211                                              This parameter can be RTC_BKP_DRx where x can be from 0 to 31 to specify the register .
212                                              Warning : this parameter is writable in secure mode or if trustzone is disabled.
213                                              Warning : this parameter is shared with RTC_SecureStateTypeDef */
214 
215   uint32_t backupRegisterStartZone3;    /*!< Specifies the backup register start zone 3.
216                                              Zone 3 : read non-secure  write non-secure.
217                                              This parameter can be RTC_BKP_DRx where x can be from 0 to 31 to specify the register.
218                                              Warning : this parameter is writable in secure mode or if trustzone is disabled.
219                                              Warning : this parameter is shared with RTC_SecureStateTypeDef. */
220 
221 } RTC_PrivilegeStateTypeDef;
222 /**
223   * @}
224   */
225 
226 /**
227   * @}
228   */
229 
230 /* Exported constants --------------------------------------------------------*/
231 /** @defgroup RTCEx_Exported_Constants RTCEx Exported Constants
232   * @{
233   */
234 
235 /** @defgroup RTCEx_Time_Stamp_Edges_definitions RTCEx Time Stamp Edges definition
236   * @{
237   */
238 #define RTC_TIMESTAMPEDGE_RISING        0x00000000u
239 #define RTC_TIMESTAMPEDGE_FALLING       RTC_CR_TSEDGE
240 /**
241   * @}
242   */
243 
244 /** @defgroup RTCEx_TimeStamp_Pin_Selections RTCEx TimeStamp Pin Selection
245   * @{
246   */
247 #define RTC_TIMESTAMPPIN_DEFAULT              0x00000000u
248 /**
249   * @}
250   */
251 
252 /** @defgroup RTCEx_Wakeup_Timer_Definitions RTCEx Wakeup Timer Definitions
253   * @{
254   */
255 #define RTC_WAKEUPCLOCK_RTCCLK_DIV16        0x00000000u
256 #define RTC_WAKEUPCLOCK_RTCCLK_DIV8         RTC_CR_WUCKSEL_0
257 #define RTC_WAKEUPCLOCK_RTCCLK_DIV4         RTC_CR_WUCKSEL_1
258 #define RTC_WAKEUPCLOCK_RTCCLK_DIV2         (RTC_CR_WUCKSEL_0 | RTC_CR_WUCKSEL_1)
259 #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS      RTC_CR_WUCKSEL_2
260 #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS      (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_2)
261 /**
262   * @}
263   */
264 
265 /** @defgroup RTCEx_Smooth_calib_period_Definitions RTCEx Smooth calib period Definitions
266   * @{
267   */
268 #define RTC_SMOOTHCALIB_PERIOD_32SEC   0x00000000u              /*!< If RTCCLK = 32768 Hz, Smooth calibration
269                                                                      period is 32s,  else 2exp20 RTCCLK pulses */
270 #define RTC_SMOOTHCALIB_PERIOD_16SEC   RTC_CALR_CALW16          /*!< If RTCCLK = 32768 Hz, Smooth calibration
271                                                                      period is 16s, else 2exp19 RTCCLK pulses */
272 #define RTC_SMOOTHCALIB_PERIOD_8SEC    RTC_CALR_CALW8           /*!< If RTCCLK = 32768 Hz, Smooth calibration
273                                                                      period is 8s, else 2exp18 RTCCLK pulses */
274 /**
275   * @}
276   */
277 
278 /** @defgroup RTCEx_Smooth_calib_Plus_pulses_Definitions RTCEx Smooth calib Plus pulses Definitions
279   * @{
280   */
281 #define RTC_SMOOTHCALIB_PLUSPULSES_SET    RTC_CALR_CALP         /*!< The number of RTCCLK pulses added
282                                                                      during a X -second window = Y - CALM[8:0]
283                                                                      with Y = 512, 256, 128 when X = 32, 16, 8 */
284 #define RTC_SMOOTHCALIB_PLUSPULSES_RESET  0x00000000u           /*!< The number of RTCCLK pulses subbstited
285                                                                      during a 32-second window = CALM[8:0] */
286 /**
287   * @}
288   */
289 
290 /** @defgroup RTCEx_Calib_Output_selection_Definitions RTCEx Calib Output selection Definitions
291  * @{
292  */
293 #define RTC_CALIBOUTPUT_512HZ            0x00000000u
294 #define RTC_CALIBOUTPUT_1HZ              RTC_CR_COSEL
295 
296 /**
297   * @}
298   */
299 
300 
301 /** @defgroup RTCEx_Add_1_Second_Parameter_Definition RTCEx Add 1 Second Parameter Definitions
302   * @{
303   */
304 #define RTC_SHIFTADD1S_RESET      0x00000000u
305 #define RTC_SHIFTADD1S_SET        RTC_SHIFTR_ADD1S
306 /**
307   * @}
308   */
309 
310 /** @defgroup RTCEx_Tamper_Pins  RTCEx Tamper Pins Definition
311   * @{
312   */
313 #define RTC_TAMPER_1                        TAMP_CR1_TAMP1E
314 #define RTC_TAMPER_2                        TAMP_CR1_TAMP2E
315 #define RTC_TAMPER_3                        TAMP_CR1_TAMP3E
316 #define RTC_TAMPER_ALL                      (RTC_TAMPER_1 | RTC_TAMPER_2 | RTC_TAMPER_3 )
317 
318 /**
319   * @}
320   */
321 
322 /** @defgroup RTCEx_Internal_Tamper_Pins  RTCEx Internal Tamper Pins Definition
323   * @{
324   */
325 #define RTC_INT_TAMPER_1                    TAMP_CR1_ITAMP1E
326 #define RTC_INT_TAMPER_2                    TAMP_CR1_ITAMP2E
327 #define RTC_INT_TAMPER_3                    TAMP_CR1_ITAMP3E
328 #define RTC_INT_TAMPER_4                    TAMP_CR1_ITAMP4E
329 #define RTC_INT_TAMPER_5                    TAMP_CR1_ITAMP5E
330 #define RTC_INT_TAMPER_8                    TAMP_CR1_ITAMP8E
331 #define RTC_INT_TAMPER_ALL                  (RTC_INT_TAMPER_1 | RTC_INT_TAMPER_2 |\
332                                              RTC_INT_TAMPER_3 | RTC_INT_TAMPER_5 |\
333                                              RTC_INT_TAMPER_4 | RTC_INT_TAMPER_8)
334 /**
335   * @}
336   */
337 
338 /** @defgroup RTCEx_Tamper_Trigger  RTCEx Tamper Trigger
339   * @{
340   */
341 #define RTC_TAMPERTRIGGER_RISINGEDGE        0x00u  /*!< Warning : Filter must be RTC_TAMPERFILTER_DISABLE */
342 #define RTC_TAMPERTRIGGER_FALLINGEDGE       0x01u  /*!< Warning : Filter must be RTC_TAMPERFILTER_DISABLE */
343 #define RTC_TAMPERTRIGGER_LOWLEVEL          0x02u  /*!< Warning : Filter must not be RTC_TAMPERFILTER_DISABLE */
344 #define RTC_TAMPERTRIGGER_HIGHLEVEL         0x03u  /*!< Warning : Filter must not be RTC_TAMPERFILTER_DISABLE */
345 /**
346   * @}
347   */
348 
349 /** @defgroup RTCEx_Tamper_MaskFlag  RTCEx Tamper MaskFlag
350   * @{
351   */
352 #define RTC_TAMPERMASK_FLAG_DISABLE         0x00u
353 #define RTC_TAMPERMASK_FLAG_ENABLE          0x01u
354 /**
355   * @}
356   */
357 
358 /** @defgroup RTCEx_Tamper_EraseBackUp  RTCEx Tamper EraseBackUp
359 * @{
360 */
361 #define RTC_TAMPER_ERASE_BACKUP_ENABLE      0x00u
362 #define RTC_TAMPER_ERASE_BACKUP_DISABLE     0x01u
363 /**
364   * @}
365   */
366 
367 /** @defgroup RTCEx_Tamper_Filter  RTCEx Tamper Filter
368   * @{
369   */
370 #define RTC_TAMPERFILTER_DISABLE           0x00000000U             /*!< Tamper filter is disabled */
371 #define RTC_TAMPERFILTER_2SAMPLE           TAMP_FLTCR_TAMPFLT_0    /*!< Tamper is activated after 2
372                                                                          consecutive samples at the active level */
373 #define RTC_TAMPERFILTER_4SAMPLE           TAMP_FLTCR_TAMPFLT_1    /*!< Tamper is activated after 4
374                                                                          consecutive samples at the active level */
375 #define RTC_TAMPERFILTER_8SAMPLE           TAMP_FLTCR_TAMPFLT      /*!< Tamper is activated after 8
376                                                                          consecutive samples at the active level */
377 /**
378   * @}
379   */
380 
381 /** @defgroup RTCEx_Tamper_Sampling_Frequencies  RTCEx Tamper Sampling Frequencies
382   * @{
383   */
384 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768  0x00000000U                                     /*!< Each of the tamper inputs are sampled
385                                                                                                       with a frequency =  RTCCLK / 32768 */
386 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384  TAMP_FLTCR_TAMPFREQ_0                           /*!< Each of the tamper inputs are sampled
387                                                                                                       with a frequency =  RTCCLK / 16384 */
388 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192   TAMP_FLTCR_TAMPFREQ_1                           /*!< Each of the tamper inputs are sampled
389                                                                                                       with a frequency =  RTCCLK / 8192  */
390 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096   (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_1) /*!< Each of the tamper inputs are sampled
391                                                                                                       with a frequency =  RTCCLK / 4096  */
392 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048   TAMP_FLTCR_TAMPFREQ_2                           /*!< Each of the tamper inputs are sampled
393                                                                                                       with a frequency =  RTCCLK / 2048  */
394 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024   (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled
395                                                                                                       with a frequency =  RTCCLK / 1024  */
396 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512    (TAMP_FLTCR_TAMPFREQ_1 | TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled
397                                                                                                       with a frequency =  RTCCLK / 512   */
398 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256    (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_1 | \
399                                                   TAMP_FLTCR_TAMPFREQ_2)                         /*!< Each of the tamper inputs are sampled
400                                                                                                       with a frequency =  RTCCLK / 256   */
401 /**
402   * @}
403   */
404 
405 /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration  RTCEx Tamper Pin Precharge Duration
406   * @{
407   */
408 #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK     0x00000000U                                       /*!< Tamper pins are pre-charged before
409                                                                                                         sampling during 1 RTCCLK cycle  */
410 #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK     TAMP_FLTCR_TAMPPRCH_0                             /*!< Tamper pins are pre-charged before
411                                                                                                         sampling during 2 RTCCLK cycles */
412 #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK     TAMP_FLTCR_TAMPPRCH_1                             /*!< Tamper pins are pre-charged before
413                                                                                                         sampling during 4 RTCCLK cycles */
414 #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK     (TAMP_FLTCR_TAMPPRCH_0 | TAMP_FLTCR_TAMPPRCH_1)   /*!< Tamper pins are pre-charged before
415                                                                                                         sampling during 8 RTCCLK cycles */
416 /**
417   * @}
418   */
419 
420 /** @defgroup RTCEx_Tamper_Pull_UP  RTCEx Tamper Pull UP
421   * @{
422   */
423 #define RTC_TAMPER_PULLUP_ENABLE           0x00000000u           /*!< Tamper pins are pre-charged before sampling */
424 #define RTC_TAMPER_PULLUP_DISABLE          TAMP_FLTCR_TAMPPUDIS  /*!< Tamper pins pre-charge is disabled          */
425 /**
426   * @}
427   */
428 
429 /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection RTCEx Tamper TimeStamp On Tamper Detection Definitions
430   * @{
431   */
432 #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE  0x00000000u    /*!< TimeStamp on Tamper Detection event is not saved */
433 #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE   RTC_CR_TAMPTS  /*!< TimeStamp on Tamper Detection event saved        */
434 /**
435   * @}
436   */
437 
438 /** @defgroup RTCEx_Internal_Tamper_Interrupt  RTCEx Internal Tamper Interrupt
439   * @{
440   */
441 #define RTC_IT_TAMP_1                      TAMP_IER_TAMP1IE     /*!< Tamper 1 Interrupt */
442 #define RTC_IT_TAMP_2                      TAMP_IER_TAMP2IE     /*!< Tamper 2 Interrupt */
443 #define RTC_IT_TAMP_3                      TAMP_IER_TAMP3IE     /*!< Tamper 3 Interrupt */
444 
445 #define RTC_IT_TAMP_ALL                   (RTC_IT_TAMP_1 | RTC_IT_TAMP_2 | RTC_IT_TAMP_3)
446 
447 #define RTC_IT_INT_TAMP_1                   TAMP_IER_ITAMP1IE    /*!< Tamper 1 internal Interrupt */
448 #define RTC_IT_INT_TAMP_2                   TAMP_IER_ITAMP2IE    /*!< Tamper 2 internal Interrupt */
449 #define RTC_IT_INT_TAMP_3                   TAMP_IER_ITAMP3IE    /*!< Tamper 3 internal Interrupt */
450 #define RTC_IT_INT_TAMP_4                   TAMP_IER_ITAMP4IE    /*!< Tamper 4 internal Interrupt */
451 #define RTC_IT_INT_TAMP_5                   TAMP_IER_ITAMP5IE    /*!< Tamper 5 internal Interrupt */
452 #define RTC_IT_INT_TAMP_8                   TAMP_IER_ITAMP8IE    /*!< Tamper 8 internal Interrupt */
453 
454 #define RTC_IT_INT_TAMP_ALL                (RTC_IT_INT_TAMP_1 | RTC_IT_INT_TAMP_2 |\
455                                             RTC_IT_INT_TAMP_3 | RTC_IT_INT_TAMP_4 |\
456                                             RTC_IT_INT_TAMP_5 | RTC_IT_INT_TAMP_8 )
457 /**
458   * @}
459   */
460 
461 /** @defgroup RTCEx_Flags  RTCEx Flags
462   * @{
463   */
464 #define RTC_FLAG_TAMP_1                    TAMP_SR_TAMP1F
465 #define RTC_FLAG_TAMP_2                    TAMP_SR_TAMP2F
466 #define RTC_FLAG_TAMP_3                    TAMP_SR_TAMP3F
467 #define RTC_FLAG_TAMP_ALL                 (RTC_FLAG_TAMP_1 | RTC_FLAG_TAMP_2 | RTC_FLAG_TAMP_3)
468 
469 
470 #define RTC_FLAG_INT_TAMP_1                 TAMP_SR_ITAMP1F
471 #define RTC_FLAG_INT_TAMP_2                 TAMP_SR_ITAMP2F
472 #define RTC_FLAG_INT_TAMP_3                 TAMP_SR_ITAMP3F
473 #define RTC_FLAG_INT_TAMP_4                 TAMP_SR_ITAMP4F
474 #define RTC_FLAG_INT_TAMP_5                 TAMP_SR_ITAMP5F
475 #define RTC_FLAG_INT_TAMP_8                 TAMP_SR_ITAMP8F
476 #define RTC_FLAG_INT_TAMP_ALL               (RTC_FLAG_INT_TAMP_1 | RTC_FLAG_INT_TAMP_2 |\
477                                              RTC_FLAG_INT_TAMP_3 | RTC_FLAG_INT_TAMP_4 |\
478                                              RTC_FLAG_INT_TAMP_5 | RTC_FLAG_INT_TAMP_8)
479 /**
480   * @}
481   */
482 
483 
484 /** @defgroup RTCEx_ActiveTamper_Enable RTCEx_ActiveTamper_Enable Definitions
485   * @{
486   */
487 #define RTC_ATAMP_ENABLE                   1u
488 #define RTC_ATAMP_DISABLE                  0u
489 /**
490   * @}
491   */
492 
493 /** @defgroup RTCEx_ActiveTamper_Interrupt RTCEx_ActiveTamper_Interrupt Definitions
494   * @{
495   */
496 #define RTC_ATAMP_INTERRUPT_ENABLE        1u
497 #define RTC_ATAMP_INTERRUPT_DISABLE       0u
498 /**
499   * @}
500   */
501 
502 /** @defgroup RTCEx_ActiveTamper_Filter RTCEx_ActiveTamper_Filter Definitions
503   * @{
504   */
505 #define RTC_ATAMP_FILTER_ENABLE           TAMP_ATCR1_FLTEN
506 #define RTC_ATAMP_FILTER_DISABLE          0u
507 /**
508   * @}
509   */
510 
511 /** @defgroup RTCEx_ActiveTamper_Async_prescaler RTCEx Active_Tamper_Asynchronous_Prescaler clock Definitions
512   * @{
513   */
514 #define RTC_ATAMP_ASYNCPRES_RTCCLK        0u                                                                      /*!< RTCCLK */
515 #define RTC_ATAMP_ASYNCPRES_RTCCLK_2      TAMP_ATCR1_ATCKSEL_0                                                    /*!< RTCCLK/2 */
516 #define RTC_ATAMP_ASYNCPRES_RTCCLK_4      TAMP_ATCR1_ATCKSEL_1                                                    /*!< RTCCLK/4 */
517 #define RTC_ATAMP_ASYNCPRES_RTCCLK_8     (TAMP_ATCR1_ATCKSEL_1 | TAMP_ATCR1_ATCKSEL_0)                            /*!< RTCCLK/8 */
518 #define RTC_ATAMP_ASYNCPRES_RTCCLK_16     TAMP_ATCR1_ATCKSEL_2                                                    /*!< RTCCLK/16 */
519 #define RTC_ATAMP_ASYNCPRES_RTCCLK_32    (TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_0)                            /*!< RTCCLK/32 */
520 #define RTC_ATAMP_ASYNCPRES_RTCCLK_64    (TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_1)                            /*!< RTCCLK/64 */
521 #define RTC_ATAMP_ASYNCPRES_RTCCLK_128   (TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_1 | TAMP_ATCR1_ATCKSEL_0)     /*!< RTCCLK/128 */
522 /**
523   * @}
524   */
525 
526 /** @defgroup RTCEx_ActiveTamper_Sel  RTCEx Active Tamper selection Definition
527   * @{
528   */
529 #define RTC_ATAMP_1                       0u   /*!< Tamper 1 */
530 #define RTC_ATAMP_2                       1u   /*!< Tamper 2 */
531 #define RTC_ATAMP_3                       2u   /*!< Tamper 3 */
532 /**
533   * @}
534   */
535 
536 
537 /** @defgroup RTCEx_MonotonicCounter_Instance  RTCEx Monotonic Counter Instance Definition
538   * @{
539   */
540 #define RTC_MONOTONIC_COUNTER_1           0u   /*!< Monotonic counter 1 */
541 /**
542   * @}
543   */
544 
545 
546 /** @defgroup RTCEx_Backup_Registers  RTCEx Backup Registers Definition
547   * @{
548   */
549 #define RTC_BKP_NUMBER                    RTC_BACKUP_NB
550 #define RTC_BKP_DR0                       0x00u
551 #define RTC_BKP_DR1                       0x01u
552 #define RTC_BKP_DR2                       0x02u
553 #define RTC_BKP_DR3                       0x03u
554 #define RTC_BKP_DR4                       0x04u
555 #define RTC_BKP_DR5                       0x05u
556 #define RTC_BKP_DR6                       0x06u
557 #define RTC_BKP_DR7                       0x07u
558 #define RTC_BKP_DR8                       0x08u
559 #define RTC_BKP_DR9                       0x09u
560 #define RTC_BKP_DR10                      0x0Au
561 #define RTC_BKP_DR11                      0x0Bu
562 #define RTC_BKP_DR12                      0x0Cu
563 #define RTC_BKP_DR13                      0x0Du
564 #define RTC_BKP_DR14                      0x0Eu
565 #define RTC_BKP_DR15                      0x0Fu
566 #define RTC_BKP_DR16                      0x10u
567 #define RTC_BKP_DR17                      0x11u
568 #define RTC_BKP_DR18                      0x12u
569 #define RTC_BKP_DR19                      0x13u
570 #define RTC_BKP_DR20                      0x14u
571 #define RTC_BKP_DR21                      0x15u
572 #define RTC_BKP_DR22                      0x16u
573 #define RTC_BKP_DR23                      0x17u
574 #define RTC_BKP_DR24                      0x18u
575 #define RTC_BKP_DR25                      0x19u
576 #define RTC_BKP_DR26                      0x1Au
577 #define RTC_BKP_DR27                      0x1Bu
578 #define RTC_BKP_DR28                      0x1Cu
579 #define RTC_BKP_DR29                      0x1Du
580 #define RTC_BKP_DR30                      0x1Eu
581 #define RTC_BKP_DR31                      0x1Fu
582 /**
583   * @}
584   */
585 
586 
587 /** @defgroup RTCEx_RTC_Secure_Full  RTCEx Secure Definition
588   * @{
589   */
590 #define RTC_SECURE_FULL_YES                  0u                  /*!< RTC full secure */
591 #define RTC_SECURE_FULL_NO                   RTC_SMCR_DECPROT    /*!< RTC is not full secure, features can be non-secure. See RTC_LL_EC_NONSECURE_RTC_FEATURE */
592 /**
593   * @}
594   */
595 
596 /** @defgroup RTCEx_RTC_NonSecure_Features  RTCEx Secure Features Definition
597   * @{
598   */
599 #define RTC_NONSECURE_FEATURE_NONE            0u
600 #define RTC_NONSECURE_FEATURE_INIT            RTC_SMCR_INITDPROT  /*!< Initialization */
601 #define RTC_NONSECURE_FEATURE_CAL             RTC_SMCR_CALDPROT   /*!< Calibration */
602 #define RTC_NONSECURE_FEATURE_TS              RTC_SMCR_TSDPROT    /*!< Time stamp */
603 #define RTC_NONSECURE_FEATURE_WUT             RTC_SMCR_WUTDPROT   /*!< Wake up timer */
604 #define RTC_NONSECURE_FEATURE_ALRA            RTC_SMCR_ALRADPROT  /*!< Alarm A */
605 #define RTC_NONSECURE_FEATURE_ALRB            RTC_SMCR_ALRBDPROT  /*!< Alarm B */
606 #define RTC_NONSECURE_FEATURE_ALL             (RTC_SMCR_INITDPROT |  RTC_SMCR_CALDPROT | \
607                                               RTC_SMCR_TSDPROT | RTC_SMCR_WUTDPROT | \
608                                               RTC_SMCR_ALRADPROT | RTC_SMCR_ALRBDPROT)
609 /**
610   * @}
611   */
612 
613 /** @defgroup RTCEx_TAMP_Secure_Full  RTCEx TAMP Secure
614   * @{
615   */
616 #define TAMP_SECURE_FULL_YES                 0u                  /*!< TAMPER full secure */
617 #define TAMP_SECURE_FULL_NO                  TAMP_SMCR_TAMPDPROT /*!< TAMPER is not secure */
618 /**
619   * @}
620   */
621 
622 
623 /** @defgroup RTCEx_RTC_Privilege_Full  RTCEx Privilege Features
624   * @{
625   */
626 #define RTC_PRIVILEGE_FULL_YES               RTC_PRIVCR_PRIV
627 #define RTC_PRIVILEGE_FULL_NO                0u
628 /**
629   * @}
630   */
631 
632 /** @defgroup RTCEx_RTC_Privilege_Features  RTCEx Privilege Features Definition
633   * @{
634   */
635 #define RTC_PRIVILEGE_FEATURE_NONE           0u
636 #define RTC_PRIVILEGE_FEATURE_INIT           RTC_PRIVCR_INITPRIV  /*!< Initialization */
637 #define RTC_PRIVILEGE_FEATURE_CAL            RTC_PRIVCR_CALPRIV   /*!< Calibration */
638 #define RTC_PRIVILEGE_FEATURE_TS             RTC_PRIVCR_TSPRIV    /*!< Time stamp */
639 #define RTC_PRIVILEGE_FEATURE_WUT            RTC_PRIVCR_WUTPRIV   /*!< Wake up timer */
640 #define RTC_PRIVILEGE_FEATURE_ALRA           RTC_PRIVCR_ALRAPRIV  /*!< Alarm A */
641 #define RTC_PRIVILEGE_FEATURE_ALRB           RTC_PRIVCR_ALRBPRIV  /*!< Alarm B */
642 #define RTC_PRIVILEGE_FEATURE_ALL            (RTC_PRIVCR_INITPRIV |  RTC_PRIVCR_CALPRIV | \
643                                              RTC_PRIVCR_TSPRIV | RTC_PRIVCR_WUTPRIV | \
644                                              RTC_PRIVCR_ALRAPRIV | RTC_PRIVCR_ALRBPRIV)
645 /**
646   * @}
647   */
648 
649 /** @defgroup RTCEx_TAMP_Privilege_Full  RTCEx TAMP security Definition
650   * @{
651   */
652 #define TAMP_PRIVILEGE_FULL_YES              TAMP_PRIVCR_TAMPPRIV
653 #define TAMP_PRIVILEGE_FULL_NO               0u
654 /**
655   * @}
656   */
657 
658 /** @defgroup RTCEx_Backup_Reg_Privilege_zone  RTCEx Privilege Backup register privilege zone Definition
659   * @{
660   */
661 #define RTC_PRIVILEGE_BKUP_ZONE_NONE         0u
662 #define RTC_PRIVILEGE_BKUP_ZONE_1            TAMP_PRIVCR_BKPRWPRIV
663 #define RTC_PRIVILEGE_BKUP_ZONE_2            TAMP_PRIVCR_BKPWPRIV
664 #define RTC_PRIVILEGE_BKUP_ZONE_ALL          (RTC_PRIVILEGE_BKUP_ZONE_1 |  RTC_PRIVILEGE_BKUP_ZONE_2)
665 /**
666   * @}
667   */
668 
669 /**
670   * @}
671   */
672 
673 /* Exported macros -----------------------------------------------------------*/
674 /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros
675   * @{
676   */
677 
678 /** @brief  Clear the specified RTC pending flag.
679   * @param  __HANDLE__ specifies the RTC Handle.
680   * @param  __FLAG__ specifies the flag to check.
681   *          This parameter can be any combination of the following values:
682   *            @arg @ref RTC_CLEAR_ITSF               Clear Internal Time-stamp flag
683   *            @arg @ref RTC_CLEAR_TSOVF              Clear Time-stamp overflow flag
684   *            @arg @ref RTC_CLEAR_TSF                Clear Time-stamp flag
685   *            @arg @ref RTC_CLEAR_WUTF               Clear Wakeup timer flag
686   *            @arg @ref RTC_CLEAR_ALRBF              Clear Alarm B flag
687   *            @arg @ref RTC_CLEAR_ALRAF              Clear Alarm A flag
688   * @retval None
689   */
690 #define __HAL_RTC_CLEAR_FLAG(__HANDLE__, __FLAG__)   (RTC->SCR = (__FLAG__))
691 
692 /** @brief  Check whether the specified RTC flag is set or not.
693   * @param  __HANDLE__ specifies the RTC Handle.
694   * @param  __FLAG__ specifies the flag to check.
695   *          This parameter can be any combination of the following values:
696   *            @arg @ref RTC_FLAG_RECALPF             Recalibration pending Flag
697   *            @arg @ref RTC_FLAG_INITF               Initialization flag
698   *            @arg @ref RTC_FLAG_RSF                 Registers synchronization flag
699   *            @arg @ref RTC_FLAG_INITS               Initialization status flag
700   *            @arg @ref RTC_FLAG_SHPF                Shift operation pending flag
701   *            @arg @ref RTC_FLAG_WUTWF               Wakeup timer write flag
702   *            @arg @ref RTC_FLAG_ITSF                Internal Time-stamp flag
703   *            @arg @ref RTC_FLAG_TSOVF               Time-stamp overflow flag
704   *            @arg @ref RTC_FLAG_TSF                 Time-stamp flag
705   *            @arg @ref RTC_FLAG_WUTF                Wakeup timer flag
706   *            @arg @ref RTC_FLAG_ALRBF               Alarm B flag
707   *            @arg @ref RTC_FLAG_ALRAF               Alarm A flag
708   * @retval None
709   */
710 #define __HAL_RTC_GET_FLAG(__HANDLE__, __FLAG__)    (((((__FLAG__)) >> 8U) == 1U) ? (RTC->ICSR & (1U << (((uint16_t)(__FLAG__)) & RTC_FLAG_MASK))) : \
711                                                      (RTC->SR & (1U << (((uint16_t)(__FLAG__)) & RTC_FLAG_MASK))))
712 
713 /* ---------------------------------WAKEUPTIMER---------------------------------*/
714 /** @defgroup RTCEx_WakeUp_Timer RTC WakeUp Timer
715   * @{
716   */
717 /**
718   * @brief  Enable the RTC WakeUp Timer peripheral.
719   * @param  __HANDLE__ specifies the RTC handle.
720   * @retval None
721   */
722 #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__)                      (RTC->CR |= (RTC_CR_WUTE))
723 
724 /**
725   * @brief  Disable the RTC WakeUp Timer peripheral.
726   * @param  __HANDLE__ specifies the RTC handle.
727   * @retval None
728   */
729 #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__)                     (RTC->CR &= ~(RTC_CR_WUTE))
730 
731 /**
732   * @brief  Enable the RTC WakeUpTimer interrupt.
733   * @param  __HANDLE__ specifies the RTC handle.
734   * @param  __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be enabled.
735   *         This parameter can be:
736   *            @arg @ref RTC_IT_WUT WakeUpTimer interrupt
737   * @retval None
738   */
739 #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__)    (RTC->CR |= (__INTERRUPT__))
740 
741 /**
742   * @brief  Disable the RTC WakeUpTimer interrupt.
743   * @param  __HANDLE__ specifies the RTC handle.
744   * @param  __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be disabled.
745   *         This parameter can be:
746   *            @arg @ref RTC_IT_WUT WakeUpTimer interrupt
747   * @retval None
748   */
749 #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__)   (RTC->CR &= ~(__INTERRUPT__))
750 
751 
752 /**
753   * @brief  Check whether the specified RTC WakeUpTimer interrupt has occurred or not.
754   * @param  __HANDLE__ specifies the RTC handle.
755   * @param  __INTERRUPT__ specifies the RTC WakeUpTimer interrupt to check.
756   *         This parameter can be:
757   *            @arg @ref RTC_IT_WUT  WakeUpTimer interrupt
758   * @retval None
759   */
760 #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __INTERRUPT__)       ((((RTC->MISR) & ((__INTERRUPT__)>> 12U)) != 0UL) ? 1UL : 0UL)
761 /**
762   * @brief  Check whether the specified RTC Wake Up timer interrupt has been enabled or not.
763   * @param  __HANDLE__ specifies the RTC handle.
764   * @param  __INTERRUPT__ specifies the RTC Wake Up timer interrupt sources to check.
765   *         This parameter can be:
766   *            @arg @ref RTC_IT_WUT  WakeUpTimer interrupt
767   * @retval None
768   */
769 #define __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)   ((((RTC->CR) & (__INTERRUPT__)) != 0UL) ? 1UL : 0UL)
770 
771 /**
772   * @brief  Get the selected RTC WakeUpTimers flag status.
773   * @param  __HANDLE__ specifies the RTC handle.
774   * @param  __FLAG__ specifies the RTC WakeUpTimer Flag is pending or not.
775   *          This parameter can be:
776   *             @arg @ref RTC_FLAG_WUTF
777   *             @arg @ref RTC_FLAG_WUTWF
778   * @retval None
779   */
780 #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__)   (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__)))
781 
782 /**
783   * @brief  Clear the RTC Wake Up timers pending flags.
784   * @param  __HANDLE__ specifies the RTC handle.
785   * @param  __FLAG__ specifies the RTC WakeUpTimer Flag to clear.
786   *         This parameter can be:
787   *            @arg @ref RTC_FLAG_WUTF
788   * @retval None
789   */
790 #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__)     (__HAL_RTC_CLEAR_FLAG((__HANDLE__), RTC_CLEAR_WUTF))
791 
792 
793 #if defined(CORE_CM4)
794 
795 /* WAKE-UP TIMER EXTI */
796 /* ------------------ */
797 /**
798   * @brief  Enable interrupt on the RTC WakeUp Timer associated Exti line.
799   * @retval None
800   */
801 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT()       (EXTI_C2->IMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
802 
803 /**
804   * @brief  Disable interrupt on the RTC WakeUp Timer associated Exti line.
805   * @retval None
806   */
807 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT()      (EXTI_C2->IMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
808 
809 /**
810   * @brief  Enable event on the RTC WakeUp Timer associated Exti line.
811   * @retval None
812   */
813 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT()    (EXTI_C2->EMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
814 
815 /**
816   * @brief  Disable event on the RTC WakeUp Timer associated Exti line.
817   * @retval None
818   */
819 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT()   (EXTI_C2->EMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
820 
821 /**
822   * @}
823   */
824 #elif defined(CORE_CA7)
825 /* WAKE-UP TIMER EXTI */
826 /* ------------------ */
827 /**
828   * @brief  Enable interrupt on the RTC WakeUp Timer associated Exti line.
829   * @retval None
830   */
831 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT()       (EXTI_C1->IMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
832 
833 /**
834   * @brief  Disable interrupt on the RTC WakeUp Timer associated Exti line.
835   * @retval None
836   */
837 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT()      (EXTI_C1->IMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
838 
839 /**
840   * @brief  Enable event on the RTC WakeUp Timer associated Exti line.
841   * @retval None
842   */
843 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT()    (EXTI_C1->EMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
844 
845 /**
846   * @brief  Disable event on the RTC WakeUp Timer associated Exti line.
847   * @retval None
848   */
849 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT()   (EXTI_C1->EMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
850 
851 /**
852   * @}
853   */
854 #else /* !CORE_CA7 */
855 
856 #error Please #define CORE_CM4 or CORE_CA7
857 
858 #endif
859 
860 
861 
862 /* ---------------------------------TIMESTAMP---------------------------------*/
863 /** @defgroup RTCEx_Timestamp RTC Timestamp
864   * @{
865   */
866 /**
867   * @brief  Enable the RTC TimeStamp peripheral.
868   * @param  __HANDLE__ specifies the RTC handle.
869   * @retval None
870   */
871 #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__)                       (RTC->CR |= (RTC_CR_TSE))
872 
873 /**
874   * @brief  Disable the RTC TimeStamp peripheral.
875   * @param  __HANDLE__ specifies the RTC handle.
876   * @retval None
877   */
878 #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__)                      (RTC->CR &= ~(RTC_CR_TSE))
879 
880 /**
881   * @brief  Enable the RTC TimeStamp interrupt.
882   * @param  __HANDLE__ specifies the RTC handle.
883   * @param  __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be enabled.
884   *         This parameter can be:
885   *            @arg @ref RTC_IT_TS TimeStamp interrupt
886   * @retval None
887   */
888 #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__)     (RTC->CR |= (__INTERRUPT__))
889 
890 /**
891   * @brief  Disable the RTC TimeStamp interrupt.
892   * @param  __HANDLE__ specifies the RTC handle.
893   * @param  __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be disabled.
894   *         This parameter can be:
895   *            @arg @ref RTC_IT_TS TimeStamp interrupt
896   * @retval None
897   */
898 #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__)    (RTC->CR &= ~(__INTERRUPT__))
899 
900 /**
901   * @brief  Check whether the specified RTC TimeStamp interrupt has occurred or not.
902   * @param  __HANDLE__ specifies the RTC handle.
903   * @param  __INTERRUPT__ specifies the RTC TimeStamp interrupt to check.
904   *         This parameter can be:
905   *            @arg @ref RTC_IT_TS TimeStamp interrupt
906   * @retval None
907   */
908 #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__)        ((((RTC->MISR) & ((__INTERRUPT__)>> 12U)) != 0U) ? 1UL : 0UL)
909 /**
910   * @brief  Check whether the specified RTC Time Stamp interrupt has been enabled or not.
911   * @param  __HANDLE__ specifies the RTC handle.
912   * @param  __INTERRUPT__ specifies the RTC Time Stamp interrupt source to check.
913   *         This parameter can be:
914   *            @arg @ref RTC_IT_TS TimeStamp interrupt
915   * @retval None
916   */
917 #define __HAL_RTC_TIMESTAMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)     ((((RTC->CR) & (__INTERRUPT__)) != 0U) ? 1UL : 0UL)
918 
919 /**
920   * @brief  Get the selected RTC TimeStamps flag status.
921   * @param  __HANDLE__ specifies the RTC handle.
922   * @param  __FLAG__ specifies the RTC TimeStamp Flag is pending or not.
923   *         This parameter can be:
924   *            @arg @ref RTC_FLAG_TSF
925   *            @arg @ref RTC_FLAG_TSOVF
926   * @retval None
927   */
928 #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__)     (__HAL_RTC_GET_FLAG((__HANDLE__),(__FLAG__)))
929 
930 /**
931   * @brief  Clear the RTC Time Stamps pending flags.
932   * @param  __HANDLE__ specifies the RTC handle.
933   * @param  __FLAG__ specifies the RTC TimeStamp Flag to clear.
934   *          This parameter can be:
935   *             @arg @ref RTC_FLAG_TSF
936   *             @arg @ref RTC_FLAG_TSOVF
937   * @retval None
938   */
939 #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__)   (__HAL_RTC_CLEAR_FLAG((__HANDLE__), (__FLAG__)))
940 
941 #if defined(CORE_CM4)
942 /**
943   * @brief  Enable interrupt on the RTC Timestamp associated Exti line.
944   * @retval None
945   */
946 #define __HAL_RTC_TIMESTAMP_EXTI_ENABLE_IT()        (EXTI_C2->IMR1 |= RTC_EXTI_LINE_TIMESTAMP_EVENT)
947 
948 /**
949   * @brief  Disable interrupt on the RTC Timestamp associated Exti line.
950   * @retval None
951   */
952 #define __HAL_RTC_TIMESTAMP_EXTI_DISABLE_IT()       (EXTI_C2->IMR1 &= ~(RTC_EXTI_LINE_TIMESTAMP_EVENT))
953 
954 /**
955   * @brief  Enable event on the RTC Timestamp associated Exti line.
956   * @retval None
957   */
958 #define __HAL_RTC_TIMESTAMP_EXTI_ENABLE_EVENT()    (EXTI_C2->EMR1 |= RTC_EXTI_LINE_TIMESTAMP_EVENT)
959 
960 /**
961   * @brief  Disable event on the RTC Timestamp associated Exti line.
962   * @retval None
963   */
964 #define __HAL_RTC_TIMESTAMP_EXTI_DISABLE_EVENT()   (EXTI_C2->EMR1 &= ~(RTC_EXTI_LINE_TIMESTAMP_EVENT))
965 
966 #elif defined(CORE_CA7)
967 /**
968   * @brief  Enable interrupt on the RTC Timestamp associated Exti line.
969   * @retval None
970   */
971 #define __HAL_RTC_TIMESTAMP_EXTI_ENABLE_IT()        (EXTI_C1->IMR1 |= RTC_EXTI_LINE_TIMESTAMP_EVENT)
972 
973 /**
974   * @brief  Disable interrupt on the RTC Timestamp associated Exti line.
975   * @retval None
976   */
977 #define __HAL_RTC_TIMESTAMP_EXTI_DISABLE_IT()       (EXTI_C1->IMR1 &= ~(RTC_EXTI_LINE_TIMESTAMP_EVENT))
978 
979 /**
980   * @brief  Enable event on the RTC Timestamp associated Exti line.
981   * @retval None
982   */
983 #define __HAL_RTC_TIMESTAMP_EXTI_ENABLE_EVENT()    (EXTI_C1->EMR1 |= RTC_EXTI_LINE_TIMESTAMP_EVENT)
984 
985 /**
986   * @brief  Disable event on the RTC Timestamp associated Exti line.
987   * @retval None
988   */
989 #define __HAL_RTC_TIMESTAMP_EXTI_DISABLE_EVENT()   (EXTI_C1->EMR1 &= ~(RTC_EXTI_LINE_TIMESTAMP_EVENT))
990 
991 #else /* !CORE_CA7 */
992 
993 #error Please #define CORE_CM4 or CORE_CA7
994 
995 #endif
996 
997 /**
998   * @brief  Enable the RTC internal TimeStamp peripheral.
999   * @param  __HANDLE__ specifies the RTC handle.
1000   * @retval None
1001   */
1002 #define __HAL_RTC_INTERNAL_TIMESTAMP_ENABLE(__HANDLE__)                (RTC->CR |= (RTC_CR_ITSE))
1003 
1004 /**
1005   * @brief  Disable the RTC internal TimeStamp peripheral.
1006   * @param  __HANDLE__ specifies the RTC handle.
1007   * @retval None
1008   */
1009 #define __HAL_RTC_INTERNAL_TIMESTAMP_DISABLE(__HANDLE__)               (RTC->CR &= ~(RTC_CR_ITSE))
1010 
1011 /**
1012   * @brief  Get the selected RTC Internal Time Stamps flag status.
1013   * @param  __HANDLE__ specifies the RTC handle.
1014   * @param  __FLAG__ specifies the RTC Internal Time Stamp Flag is pending or not.
1015   *         This parameter can be:
1016   *            @arg @ref RTC_FLAG_ITSF
1017   * @retval None
1018   */
1019 #define __HAL_RTC_INTERNAL_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__)     (__HAL_RTC_GET_FLAG((__HANDLE__),(__FLAG__)))
1020 
1021 /**
1022   * @brief  Clear the RTC Internal Time Stamps pending flags.
1023   * @param  __HANDLE__ specifies the RTC handle.
1024   * @param  __FLAG__ specifies the RTC Internal Time Stamp Flag source to clear.
1025   * This parameter can be:
1026   *             @arg @ref RTC_FLAG_ITSF
1027   * @retval None
1028   */
1029 #define __HAL_RTC_INTERNAL_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__)     (__HAL_RTC_CLEAR_FLAG((__HANDLE__), RTC_CLEAR_ITSF))
1030 
1031 /**
1032   * @brief  Enable the RTC TimeStamp on Tamper detection.
1033   * @param  __HANDLE__ specifies the RTC handle.
1034   * @retval None
1035   */
1036 #define __HAL_RTC_TAMPTS_ENABLE(__HANDLE__)                       (RTC->CR |= (RTC_CR_TAMPTS))
1037 
1038 /**
1039   * @brief  Disable the RTC TimeStamp on Tamper detection.
1040   * @param  __HANDLE__ specifies the RTC handle.
1041   * @retval None
1042   */
1043 #define __HAL_RTC_TAMPTS_DISABLE(__HANDLE__)                      (RTC->CR &= ~(RTC_CR_TAMPTS))
1044 
1045 /**
1046   * @brief  Enable the RTC Tamper detection output.
1047   * @param  __HANDLE__ specifies the RTC handle.
1048   * @retval None
1049   */
1050 #define __HAL_RTC_TAMPOE_ENABLE(__HANDLE__)                       (RTC->CR |= (RTC_CR_TAMPOE))
1051 
1052 /**
1053   * @brief  Disable the RTC Tamper detection output.
1054   * @param  __HANDLE__ specifies the RTC handle.
1055   * @retval None
1056   */
1057 #define __HAL_RTC_TAMPOE_DISABLE(__HANDLE__)                      (RTC->CR &= ~(RTC_CR_TAMPOE))
1058 
1059 
1060 /**
1061   * @}
1062   */
1063 
1064 
1065 /* ------------------------------Calibration----------------------------------*/
1066 /** @defgroup RTCEx_Calibration RTC Calibration
1067   * @{
1068   */
1069 
1070 /**
1071   * @brief  Enable the RTC calibration output.
1072   * @param  __HANDLE__ specifies the RTC handle.
1073   * @retval None
1074   */
1075 #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__)               (RTC->CR |= (RTC_CR_COE))
1076 
1077 /**
1078   * @brief  Disable the calibration output.
1079   * @param  __HANDLE__ specifies the RTC handle.
1080   * @retval None
1081   */
1082 #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__)              (RTC->CR &= ~(RTC_CR_COE))
1083 
1084 
1085 /**
1086   * @brief  Enable the clock reference detection.
1087   * @param  __HANDLE__ specifies the RTC handle.
1088   * @retval None
1089   */
1090 #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__)               (RTC->CR |= (RTC_CR_REFCKON))
1091 
1092 /**
1093   * @brief  Disable the clock reference detection.
1094   * @param  __HANDLE__ specifies the RTC handle.
1095   * @retval None
1096   */
1097 #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__)              (RTC->CR &= ~(RTC_CR_REFCKON))
1098 
1099 
1100 /**
1101   * @brief  Get the selected RTC shift operations flag status.
1102   * @param  __HANDLE__ specifies the RTC handle.
1103   * @param  __FLAG__ specifies the RTC shift operation Flag is pending or not.
1104   *          This parameter can be:
1105   *             @arg @ref RTC_FLAG_SHPF
1106   * @retval None
1107   */
1108 #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__)                (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__)))
1109 /**
1110   * @}
1111   */
1112 
1113 
1114 /* ------------------------------Tamper----------------------------------*/
1115 /** @defgroup RTCEx_Tamper RTCEx tamper
1116   * @{
1117   */
1118 /**
1119   * @brief  Enable the TAMP Tamper input detection.
1120   * @param  __HANDLE__ specifies the RTC handle.
1121   * @param  __TAMPER__ specifies the RTC Tamper source to be enabled.
1122   *         This parameter can be any combination of the following values:
1123   *            @arg  RTC_TAMPER_ALL: All tampers
1124   *            @arg  RTC_TAMPER_1: Tamper1
1125   *            @arg  RTC_TAMPER_2: Tamper2
1126   *            @arg  RTC_TAMPER_3: Tamper3
1127   * @retval None
1128   */
1129 #define __HAL_RTC_TAMPER_ENABLE(__HANDLE__, __TAMPER__)           (TAMP->CR1 |= (__TAMPER__))
1130 
1131 /**
1132   * @brief  Disable the TAMP Tamper input detection.
1133   * @param  __HANDLE__ specifies the RTC handle.
1134   * @param  __TAMPER__ specifies the RTC Tamper sources to be enabled.
1135   *         This parameter can be any combination of the following values:
1136   *            @arg  RTC_TAMPER_ALL: All tampers
1137   *            @arg  RTC_TAMPER_1: Tamper1
1138   *            @arg  RTC_TAMPER_2: Tamper2
1139   *            @arg  RTC_TAMPER_3: Tamper3
1140   */
1141 #define __HAL_RTC_TAMPER_DISABLE(__HANDLE__, __TAMPER__)           (TAMP->CR1 &= ~(__TAMPER__))
1142 
1143 
1144 /**************************************************************************************************/
1145 /**
1146   * @brief  Enable the TAMP Tamper interrupt.
1147   * @param  __HANDLE__ specifies the RTC handle.
1148   * @param  __INTERRUPT__ specifies the RTC Tamper interrupt sources to be enabled.
1149   *          This parameter can be any combination of the following values:
1150   *            @arg  RTC_IT_TAMP_ALL: All tampers interrupts
1151   *            @arg  RTC_IT_TAMP_1: Tamper1 interrupt
1152   *            @arg  RTC_IT_TAMP_2: Tamper2 interrupt
1153   *            @arg  RTC_IT_TAMP_3: Tamper3 interrupt
1154   * @retval None
1155   */
1156 #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__)        (TAMP->IER |= (__INTERRUPT__))
1157 
1158 /**
1159   * @brief  Disable the TAMP Tamper interrupt.
1160   * @param  __HANDLE__ specifies the RTC handle.
1161   * @param  __INTERRUPT__ specifies the RTC Tamper interrupt sources to be disabled.
1162   *         This parameter can be any combination of the following values:
1163   *            @arg  RTC_IT_TAMP_ALL: All tampers interrupts
1164   *            @arg  RTC_IT_TAMP_1: Tamper1 interrupt
1165   *            @arg  RTC_IT_TAMP_2: Tamper2 interrupt
1166   *            @arg  RTC_IT_TAMP_3: Tamper3 interrupt
1167   * @retval None
1168   */
1169 #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__)       (TAMP->IER &= ~(__INTERRUPT__))
1170 
1171 
1172 /**************************************************************************************************/
1173 /**
1174   * @brief  Check whether the specified RTC Tamper interrupt has occurred or not.
1175   * @param  __HANDLE__ specifies the RTC handle.
1176   * @param  __INTERRUPT__ specifies the RTC Tamper interrupt to check.
1177   *         This parameter can be:
1178   *            @arg  RTC_IT_TAMP_ALL: All tampers interrupts
1179   *            @arg  RTC_IT_TAMP_1: Tamper1 interrupt
1180   *            @arg  RTC_IT_TAMP_2: Tamper2 interrupt
1181   *            @arg  RTC_IT_TAMP_3: Tamper3 interrupt
1182   *            @arg  RTC_IT_INT_TAMP_ALL: All Internal Tamper interrupts
1183   *            @arg  RTC_IT_INT_TAMP_1: Internal Tamper1 interrupt
1184   *            @arg  RTC_IT_INT_TAMP_2: Internal Tamper2 interrupt
1185   *            @arg  RTC_IT_INT_TAMP_3: Internal Tamper3 interrupt
1186   *            @arg  RTC_IT_INT_TAMP_4: Internal Tamper4 interrupt
1187   *            @arg  RTC_IT_INT_TAMP_5: Internal Tamper5 interrupt
1188   *            @arg  RTC_IT_INT_TAMP_8: Internal Tamper8 interrupt
1189   * @retval None
1190   */
1191 #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__)     ((((TAMP->MISR) & (__INTERRUPT__)) != 0U) ? 1UL : 0UL)
1192 
1193 
1194 /**
1195   * @brief  Check whether the specified RTC Tamper interrupt has been enabled or not.
1196   * @param  __HANDLE__ specifies the RTC handle.
1197   * @param  __INTERRUPT__ specifies the RTC Tamper interrupt source to check.
1198   *         This parameter can be:
1199   *            @arg  RTC_IT_TAMP_ALL: All tampers interrupts
1200   *            @arg  RTC_IT_TAMP_1: Tamper1 interrupt
1201   *            @arg  RTC_IT_TAMP_2: Tamper2 interrupt
1202   *            @arg  RTC_IT_TAMP_3: Tamper3 interrupt
1203   *            @arg  RTC_IT_INT_TAMP_ALL: All internal tampers interrupts
1204   *            @arg  RTC_IT_INT_TAMP_1: Internal Tamper1 interrupt
1205   *            @arg  RTC_IT_INT_TAMP_2: Internal Tamper2 interrupt
1206   *            @arg  RTC_IT_INT_TAMP_3: Internal Tamper3 interrupt
1207   *            @arg  RTC_IT_INT_TAMP_5: Internal Tamper5 interrupt
1208   *            @arg  RTC_IT_INT_TAMP_8: Internal Tamper8 interrupt
1209   * @retval None
1210   */
1211 #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)    ((((TAMP->IER) & (__INTERRUPT__)) != 0U) ? 1UL : 0UL)
1212 
1213 
1214 /**
1215   * @brief  Get the selected RTC Tampers flag status.
1216   * @param  __HANDLE__ specifies the RTC handle.
1217   * @param  __FLAG__ specifies the RTC Tamper Flag is pending or not.
1218   *          This parameter can be:
1219   *             @arg RTC_FLAG_TAMP_ALL: All tampers flag
1220   *             @arg RTC_FLAG_TAMP_1: Tamper1 flag
1221   *             @arg RTC_FLAG_TAMP_2: Tamper2 flag
1222   *             @arg RTC_FLAG_TAMP_3: Tamper3 flag
1223   *             @arg RTC_FLAG_INT_TAMP_1: Internal Tamper1 flag
1224   *             @arg RTC_FLAG_INT_TAMP_2: Internal Tamper2 flag
1225   *             @arg RTC_FLAG_INT_TAMP_3: Internal Tamper3 flag
1226   *             @arg RTC_FLAG_INT_TAMP_4: Internal Tamper4 flag
1227   *             @arg RTC_FLAG_INT_TAMP_5: Internal Tamper5 flag
1228   *             @arg RTC_FLAG_INT_TAMP_8: Internal Tamper8 flag
1229   * @retval None
1230   */
1231 #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__)        (((TAMP->SR) & (__FLAG__)) != 0U)
1232 
1233 /**
1234   * @brief  Clear the RTC Tamper's pending flags.
1235   * @param  __HANDLE__ specifies the RTC handle.
1236   * @param  __FLAG__ specifies the RTC Tamper Flag to clear.
1237   *          This parameter can be:
1238   *             @arg RTC_FLAG_TAMP_ALL: All tampers flag
1239   *             @arg RTC_FLAG_TAMP_1: Tamper1 flag
1240   *             @arg RTC_FLAG_TAMP_2: Tamper2 flag
1241   *             @arg RTC_FLAG_TAMP_3: Tamper3 flag
1242   *             @arg RTC_FLAG_INT_TAMP_ALL: All Internal Tamper flags
1243   *             @arg RTC_FLAG_INT_TAMP_1: Internal Tamper1 flag
1244   *             @arg RTC_FLAG_INT_TAMP_2: Internal Tamper2 flag
1245   *             @arg RTC_FLAG_INT_TAMP_3: Internal Tamper3 flag
1246   *             @arg RTC_FLAG_INT_TAMP_4: Internal Tamper4 flag
1247   *             @arg RTC_FLAG_INT_TAMP_5: Internal Tamper5 flag
1248   *             @arg RTC_FLAG_INT_TAMP_8: Internal Tamper8 flag
1249   * @retval None
1250   */
1251 #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__)      ((TAMP->SCR) = (__FLAG__))
1252 
1253 
1254 #if defined(CORE_CM4)
1255 /**
1256   * @brief  Enable interrupt on the RTC tamper associated Exti line.
1257   * @retval None
1258   */
1259 #define __HAL_RTC_TAMPER_EXTI_ENABLE_IT()        (EXTI_C2->IMR1 |= RTC_EXTI_LINE_TAMPER_EVENT)
1260 
1261 /**
1262   * @brief  Disable interrupt on the RTC tamper associated Exti line.
1263   * @retval None
1264   */
1265 #define __HAL_RTC_TAMPER_EXTI_DISABLE_IT()       (EXTI_C2->IMR1 &= ~(RTC_EXTI_LINE_TAMPER_EVENT))
1266 
1267 /**
1268   * @brief  Enable event on the RTC tamper associated Exti line.
1269   * @retval None
1270   */
1271 #define __HAL_RTC_TAMPER_EXTI_ENABLE_EVENT()    (EXTI_C2->EMR1 |= RTC_EXTI_LINE_TAMPER_EVENT)
1272 
1273 /**
1274   * @brief  Disable event on the RTC tamper associated Exti line.
1275   * @retval None
1276   */
1277 #define __HAL_RTC_TAMPER_EXTI_DISABLE_EVENT()   (EXTI_C2->EMR1 &= ~(RTC_EXTI_LINE_TAMPER_EVENT))
1278 
1279 #elif defined(CORE_CA7)
1280 /**
1281   * @brief  Enable interrupt on the RTC tamper associated Exti line.
1282   * @retval None
1283   */
1284 #define __HAL_RTC_TAMPER_EXTI_ENABLE_IT()        (EXTI_C1->IMR1 |= RTC_EXTI_LINE_TAMPER_EVENT)
1285 
1286 /**
1287   * @brief  Disable interrupt on the RTC tamper associated Exti line.
1288   * @retval None
1289   */
1290 #define __HAL_RTC_TAMPER_EXTI_DISABLE_IT()       (EXTI_C1->IMR1 &= ~(RTC_EXTI_LINE_TAMPER_EVENT))
1291 
1292 /**
1293   * @brief  Enable event on the RTC tamper associated Exti line.
1294   * @retval None
1295   */
1296 #define __HAL_RTC_TAMPER_EXTI_ENABLE_EVENT()    (EXTI_C1->EMR1 |= RTC_EXTI_LINE_TAMPER_EVENT)
1297 
1298 /**
1299   * @brief  Disable event on the RTC tamper associated Exti line.
1300   * @retval None
1301   */
1302 #define __HAL_RTC_TAMPER_EXTI_DISABLE_EVENT()   (EXTI_C1->EMR1 &= ~(RTC_EXTI_LINE_TAMPER_EVENT))
1303 
1304 #else /* !CORE_CA7 */
1305 
1306 #error Please #define CORE_CM4 or CORE_CA7
1307 
1308 #endif
1309 
1310 /**
1311   * @}
1312   */
1313 
1314 /**
1315   * @}
1316   */
1317 
1318 /* Exported functions --------------------------------------------------------*/
1319 /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions
1320   * @{
1321   */
1322 
1323 /* RTC TimeStamp functions *****************************************/
1324 /** @defgroup RTCEx_Exported_Functions_Group1 Extended RTC TimeStamp functions
1325   * @{
1326   */
1327 
1328 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
1329 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
1330 HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc);
1331 HAL_StatusTypeDef HAL_RTCEx_SetInternalTimeStamp(RTC_HandleTypeDef *hrtc);
1332 HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTimeStamp(RTC_HandleTypeDef *hrtc);
1333 HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format);
1334 void              HAL_RTCEx_TimeStampIRQHandler(RTC_HandleTypeDef *hrtc);
1335 HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
1336 void              HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc);
1337 /**
1338   * @}
1339   */
1340 
1341 
1342 /* RTC Wake-up functions ******************************************************/
1343 /** @defgroup RTCEx_Exported_Functions_Group2 Extended RTC Wake-up functions
1344  * @{
1345  */
1346 
1347 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
1348 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock, uint32_t WakeUpAutoClr);
1349 HAL_StatusTypeDef HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc);
1350 uint32_t          HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc);
1351 void              HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc);
1352 void              HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc);
1353 HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
1354 /**
1355   * @}
1356   */
1357 
1358 /* Extended Control functions ************************************************/
1359 /** @defgroup RTCEx_Exported_Functions_Group3 Extended Peripheral Control functions
1360  * @{
1361  */
1362 
1363 HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue);
1364 HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS);
1365 HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput);
1366 HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc);
1367 HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc);
1368 HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc);
1369 HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc);
1370 HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc);
1371 HAL_StatusTypeDef HAL_RTCEx_MonotonicCounterIncrement(RTC_HandleTypeDef *hrtc, uint32_t Instance);
1372 HAL_StatusTypeDef HAL_RTCEx_MonotonicCounterGet(RTC_HandleTypeDef *hrtc, uint32_t Instance, uint32_t *Value);
1373 /**
1374   * @}
1375   */
1376 
1377 /* Extended RTC features functions *******************************************/
1378 /** @defgroup RTCEx_Exported_Functions_Group4 Extended features functions
1379   * @{
1380   */
1381 
1382 void              HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc);
1383 HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
1384 /**
1385   * @}
1386   */
1387 
1388 /** @defgroup RTCEx_Exported_Functions_Group5 Extended RTC Tamper functions
1389   * @{
1390   */
1391 HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper);
1392 HAL_StatusTypeDef HAL_RTCEx_SetActiveTampers(RTC_HandleTypeDef *hrtc, RTC_ActiveTampersTypeDef *sAllTamper);
1393 HAL_StatusTypeDef HAL_RTCEx_SetActiveSeed(RTC_HandleTypeDef *hrtc, uint32_t *pSeed);
1394 HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper);
1395 HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper);
1396 HAL_StatusTypeDef HAL_RTCEx_DeactivateActiveTampers(RTC_HandleTypeDef *hrtc);
1397 HAL_StatusTypeDef HAL_RTCEx_PollForTamperEvent(RTC_HandleTypeDef *hrtc, uint32_t Tamper, uint32_t Timeout);
1398 HAL_StatusTypeDef HAL_RTCEx_SetInternalTamper(RTC_HandleTypeDef *hrtc, RTC_InternalTamperTypeDef *sIntTamper);
1399 HAL_StatusTypeDef HAL_RTCEx_SetInternalTamper_IT(RTC_HandleTypeDef *hrtc, RTC_InternalTamperTypeDef *sIntTamper);
1400 HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTamper(RTC_HandleTypeDef *hrtc, uint32_t IntTamper);
1401 HAL_StatusTypeDef HAL_RTCEx_PollForInternalTamperEvent(RTC_HandleTypeDef *hrtc, uint32_t IntTamper, uint32_t Timeout);
1402 void              HAL_RTCEx_TamperIRQHandler(RTC_HandleTypeDef *hrtc);
1403 void              HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc);
1404 void              HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc);
1405 void              HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc);
1406 void              HAL_RTCEx_InternalTamper1EventCallback(RTC_HandleTypeDef *hrtc);
1407 void              HAL_RTCEx_InternalTamper2EventCallback(RTC_HandleTypeDef *hrtc);
1408 void              HAL_RTCEx_InternalTamper3EventCallback(RTC_HandleTypeDef *hrtc);
1409 void              HAL_RTCEx_InternalTamper4EventCallback(RTC_HandleTypeDef *hrtc);
1410 void              HAL_RTCEx_InternalTamper5EventCallback(RTC_HandleTypeDef *hrtc);
1411 void              HAL_RTCEx_InternalTamper8EventCallback(RTC_HandleTypeDef *hrtc);
1412 /**
1413   * @}
1414   */
1415 
1416 /** @defgroup RTCEx_Exported_Functions_Group6 Extended RTC Backup register functions
1417  * @{
1418  */
1419 void              HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data);
1420 uint32_t          HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister);
1421 /**
1422   * @}
1423   */
1424 
1425 /** @defgroup RTCEx_Exported_Functions_Group7 Extended RTC secure functions
1426  * @{
1427  */
1428 HAL_StatusTypeDef HAL_RTCEx_SecureModeGet(RTC_HandleTypeDef *hrtc, RTC_SecureStateTypeDef  *secureState);
1429 #if defined (CORTEX_IN_SECURE_STATE)
1430 HAL_StatusTypeDef HAL_RTCEx_SecureModeSet(RTC_HandleTypeDef *hrtc, RTC_SecureStateTypeDef  *secureState);
1431 #endif /* #if defined (CORTEX_IN_SECURE_STATE) */
1432 /**
1433   * @}
1434   */
1435 
1436 /**
1437   * @}
1438   */
1439 
1440 /* Private types -------------------------------------------------------------*/
1441 /* Private variables ---------------------------------------------------------*/
1442 /* Private constants ---------------------------------------------------------*/
1443 /** @defgroup RTCEx_Private_Constants RTCEx Private Constants
1444   * @{
1445   */
1446 #if defined (CORTEX_IN_SECURE_STATE)
1447 #define RTC_EXTI_LINE_ALARM_EVENT             EXTI_IMR1_IM18 /*!< External interrupt line 18 Connected to the RTC Alarm event */
1448 #define RTC_EXTI_LINE_TIMESTAMP_EVENT         EXTI_IMR1_IM18 /*!< External interrupt line 18 Connected to the RTC Time Stamp events */
1449 #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT       EXTI_IMR1_IM18 /*!< External interrupt line 18 Connected to the RTC Wakeup event */
1450 #define RTC_EXTI_LINE_TAMPER_EVENT            EXTI_IMR1_IM20 /*!< External interrupt line 20 Connected to the RTC tamper events */
1451 #else /* #if defined (CORTEX_IN_SECURE_STATE) */
1452 #define RTC_EXTI_LINE_ALARM_EVENT             EXTI_IMR1_IM17 /*!< External interrupt line 17 Connected to the RTC Alarm event */
1453 #define RTC_EXTI_LINE_TIMESTAMP_EVENT         EXTI_IMR1_IM17 /*!< External interrupt line 17 Connected to the RTC Time Stamp events */
1454 #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT       EXTI_IMR1_IM17 /*!< External interrupt line 17 Connected to the RTC Wakeup event */
1455 #define RTC_EXTI_LINE_TAMPER_EVENT            EXTI_IMR1_IM19 /*!< External interrupt line 19 Connected to the RTC tamper events */
1456 #endif /* #if defined (CORTEX_IN_SECURE_STATE) */
1457 /**
1458   * @}
1459   */
1460 
1461 /* Private macros ------------------------------------------------------------*/
1462 /** @defgroup RTCEx_Private_Macros RTCEx Private Macros
1463   * @{
1464   */
1465 
1466 /** @defgroup RTCEx_IS_RTC_Definitions Private macros to check input parameters
1467   * @{
1468   */
1469 #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \
1470                                  ((EDGE) == RTC_TIMESTAMPEDGE_FALLING))
1471 
1472 
1473 #define IS_RTC_TIMESTAMP_PIN(PIN)  (((PIN) == RTC_TIMESTAMPPIN_DEFAULT))
1474 
1475 
1476 
1477 #define IS_RTC_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \
1478                                                        ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE))
1479 
1480 #define IS_RTC_TAMPER_TAMPERDETECTIONOUTPUT(MODE)    (((MODE) == RTC_TAMPERDETECTIONOUTPUT_ENABLE) || \
1481                                                       ((MODE) == RTC_TAMPERDETECTIONOUTPUT_DISABLE))
1482 
1483 #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16)   || \
1484                                     ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8)    || \
1485                                     ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4)    || \
1486                                     ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2)    || \
1487                                     ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \
1488                                     ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS))
1489 
1490 #define IS_RTC_WAKEUP_COUNTER(COUNTER)  ((COUNTER) <= RTC_WUTR_WUT)
1491 
1492 #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \
1493                                             ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \
1494                                             ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC))
1495 
1496 #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \
1497                                         ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET))
1498 
1499 #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= RTC_CALR_CALM)
1500 
1501 #define IS_RTC_LOW_POWER_CALIB(LPCAL) (((LPCAL) == RTC_LPCAL_SET) || \
1502                                        ((LPCAL) == RTC_LPCAL_RESET))
1503 
1504 
1505 #define IS_RTC_TAMPER(__TAMPER__)                ((((__TAMPER__) & RTC_TAMPER_ALL) != 0x00U) && \
1506                                                   (((__TAMPER__) & ~RTC_TAMPER_ALL) == 0x00U))
1507 
1508 #define IS_RTC_INTERNAL_TAMPER(__INT_TAMPER__)   ((((__INT_TAMPER__) & RTC_INT_TAMPER_ALL) != 0x00U) && \
1509                                                   (((__INT_TAMPER__) & ~RTC_INT_TAMPER_ALL) == 0x00U))
1510 
1511 #define IS_RTC_TAMPER_TRIGGER(__TRIGGER__)       (((__TRIGGER__) == RTC_TAMPERTRIGGER_RISINGEDGE)  || \
1512                                                   ((__TRIGGER__) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \
1513                                                   ((__TRIGGER__) == RTC_TAMPERTRIGGER_LOWLEVEL)    || \
1514                                                   ((__TRIGGER__) == RTC_TAMPERTRIGGER_HIGHLEVEL))
1515 
1516 #define IS_RTC_TAMPER_ERASE_MODE(__MODE__)       (((__MODE__) == RTC_TAMPER_ERASE_BACKUP_ENABLE) || \
1517                                                   ((__MODE__) == RTC_TAMPER_ERASE_BACKUP_DISABLE))
1518 
1519 #define IS_RTC_TAMPER_MASKFLAG_STATE(__STATE__)  (((__STATE__) == RTC_TAMPERMASK_FLAG_ENABLE) || \
1520                                                   ((__STATE__) == RTC_TAMPERMASK_FLAG_DISABLE))
1521 
1522 #define IS_RTC_TAMPER_FILTER(__FILTER__)         (((__FILTER__) == RTC_TAMPERFILTER_DISABLE)  || \
1523                                                   ((__FILTER__) == RTC_TAMPERFILTER_2SAMPLE) || \
1524                                                   ((__FILTER__) == RTC_TAMPERFILTER_4SAMPLE) || \
1525                                                   ((__FILTER__) == RTC_TAMPERFILTER_8SAMPLE))
1526 
1527 #define IS_RTC_TAMPER_SAMPLING_FREQ(__FREQ__)    (((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \
1528                                                   ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \
1529                                                   ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \
1530                                                   ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \
1531                                                   ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \
1532                                                   ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \
1533                                                   ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512)  || \
1534                                                   ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256))
1535 
1536 #define IS_RTC_TAMPER_PRECHARGE_DURATION(__DURATION__)   (((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \
1537                                                           ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \
1538                                                           ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \
1539                                                           ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK))
1540 
1541 #define IS_RTC_TAMPER_PULLUP_STATE(__STATE__)    (((__STATE__) == RTC_TAMPER_PULLUP_ENABLE) || \
1542                                                   ((__STATE__) == RTC_TAMPER_PULLUP_DISABLE))
1543 
1544 #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \
1545                                                               ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE))
1546 
1547 #define IS_RTC_BKP(__BKP__)   ((__BKP__) < RTC_BKP_NUMBER)
1548 
1549 #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \
1550                                  ((SEL) == RTC_SHIFTADD1S_SET))
1551 
1552 #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= RTC_SHIFTR_SUBFS)
1553 
1554 #define IS_RTC_CALIB_OUTPUT(OUTPUT)  (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \
1555                                       ((OUTPUT) == RTC_CALIBOUTPUT_1HZ))
1556 
1557 #define IS_RTC_SECURE_FULL(__STATE__) (((__STATE__) == RTC_SECURE_FULL_YES) || \
1558                                        ((__STATE__) == RTC_SECURE_FULL_NO))
1559 
1560 #define IS_RTC_NONSECURE_FEATURES(__FEATURES__) (((__FEATURES__) & ~RTC_NONSECURE_FEATURE_ALL) == 0u)
1561 
1562 #define IS_TAMP_SECURE_FULL(__STATE__) (((__STATE__) == TAMP_SECURE_FULL_YES) || \
1563                                         ((__STATE__) == TAMP_SECURE_FULL_NO))
1564 
1565 #define IS_RTC_PRIVILEGE_FULL(__STATE__) (((__STATE__) == RTC_PRIVILEGE_FULL_YES) || \
1566                                           ((__STATE__) == RTC_PRIVILEGE_FULL_NO))
1567 
1568 #define IS_RTC_PRIVILEGE_FEATURES(__FEATURES__) (((__FEATURES__) & ~RTC_PRIVILEGE_FEATURE_ALL) == 0u)
1569 
1570 #define IS_TAMP_PRIVILEGE_FULL(__STATE__) (((__STATE__) == TAMP_PRIVILEGE_FULL_YES) || \
1571                                            ((__STATE__) == TAMP_PRIVILEGE_FULL_NO))
1572 
1573 #define IS_RTC_PRIVILEGE_BKUP_ZONE(__ZONES__) (((__ZONES__) & ~RTC_PRIVILEGE_BKUP_ZONE_ALL) == 0u)
1574 
1575 /**
1576   * @}
1577   */
1578 
1579 /**
1580   * @}
1581   */
1582 
1583 /**
1584   * @}
1585   */
1586 
1587 /**
1588   * @}
1589   */
1590 
1591 #ifdef __cplusplus
1592 }
1593 #endif
1594 
1595 #endif /* STM32MP1xx_HAL_RTC_EX_H */
1596