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