xref: /btstack/port/stm32-f4discovery-usb/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rtc_ex.h (revision a8f7f3fcbcd51f8d2e92aca076b6a9f812db358c)
1 /**
2   ******************************************************************************
3   * @file    stm32f4xx_hal_rtc_ex.h
4   * @author  MCD Application Team
5   * @brief   Header file of RTC HAL Extension module.
6   ******************************************************************************
7   * @attention
8   *
9   * <h2><center>&copy; Copyright (c) 2017 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 __STM32F4xx_HAL_RTC_EX_H
22 #define __STM32F4xx_HAL_RTC_EX_H
23 
24 #ifdef __cplusplus
25  extern "C" {
26 #endif
27 
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32f4xx_hal_def.h"
30 
31 /** @addtogroup STM32F4xx_HAL_Driver
32   * @{
33   */
34 
35 /** @addtogroup RTCEx
36   * @{
37   */
38 
39 /* Exported types ------------------------------------------------------------*/
40 /** @defgroup RTCEx_Exported_Types RTCEx Exported Types
41   * @{
42   */
43 
44 /**
45   * @brief  RTC Tamper structure definition
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_Definitions */
51 
52   uint32_t PinSelection;                /*!< Specifies the Tamper Pin.
53                                              This parameter can be a value of @ref  RTCEx_Tamper_Pins_Selection */
54 
55   uint32_t Trigger;                     /*!< Specifies the Tamper Trigger.
56                                              This parameter can be a value of @ref  RTCEx_Tamper_Trigger_Definitions */
57 
58   uint32_t Filter;                      /*!< Specifies the RTC Filter Tamper.
59                                              This parameter can be a value of @ref RTCEx_Tamper_Filter_Definitions */
60 
61   uint32_t SamplingFrequency;           /*!< Specifies the sampling frequency.
62                                              This parameter can be a value of @ref RTCEx_Tamper_Sampling_Frequencies_Definitions */
63 
64   uint32_t PrechargeDuration;           /*!< Specifies the Precharge Duration .
65                                              This parameter can be a value of @ref RTCEx_Tamper_Pin_Precharge_Duration_Definitions */
66 
67   uint32_t TamperPullUp;                /*!< Specifies the Tamper PullUp .
68                                              This parameter can be a value of @ref RTCEx_Tamper_Pull_UP_Definitions */
69 
70   uint32_t TimeStampOnTamperDetection;  /*!< Specifies the TimeStampOnTamperDetection.
71                                              This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection_Definitions */
72 }RTC_TamperTypeDef;
73 /**
74   * @}
75   */
76 
77 /* Exported constants --------------------------------------------------------*/
78 /** @defgroup RTCEx_Exported_Constants RTCEx Exported Constants
79   * @{
80   */
81 
82 /** @defgroup RTCEx_Backup_Registers_Definitions RTC Backup Registers Definitions
83   * @{
84   */
85 #define RTC_BKP_DR0                       0x00000000U
86 #define RTC_BKP_DR1                       0x00000001U
87 #define RTC_BKP_DR2                       0x00000002U
88 #define RTC_BKP_DR3                       0x00000003U
89 #define RTC_BKP_DR4                       0x00000004U
90 #define RTC_BKP_DR5                       0x00000005U
91 #define RTC_BKP_DR6                       0x00000006U
92 #define RTC_BKP_DR7                       0x00000007U
93 #define RTC_BKP_DR8                       0x00000008U
94 #define RTC_BKP_DR9                       0x00000009U
95 #define RTC_BKP_DR10                      0x0000000AU
96 #define RTC_BKP_DR11                      0x0000000BU
97 #define RTC_BKP_DR12                      0x0000000CU
98 #define RTC_BKP_DR13                      0x0000000DU
99 #define RTC_BKP_DR14                      0x0000000EU
100 #define RTC_BKP_DR15                      0x0000000FU
101 #define RTC_BKP_DR16                      0x00000010U
102 #define RTC_BKP_DR17                      0x00000011U
103 #define RTC_BKP_DR18                      0x00000012U
104 #define RTC_BKP_DR19                      0x00000013U
105 /**
106   * @}
107   */
108 
109 /** @defgroup RTCEx_Time_Stamp_Edges_definitions RTC TimeStamp Edges Definitions
110   * @{
111   */
112 #define RTC_TIMESTAMPEDGE_RISING          0x00000000U
113 #define RTC_TIMESTAMPEDGE_FALLING         0x00000008U
114 /**
115   * @}
116   */
117 
118 /** @defgroup RTCEx_Tamper_Pins_Definitions RTC Tamper Pins Definitions
119   * @{
120   */
121 #define RTC_TAMPER_1                    RTC_TAFCR_TAMP1E
122 
123 #if !defined(STM32F412Zx) && !defined(STM32F412Vx) && !defined(STM32F412Rx) && !defined(STM32F412Cx) && !defined(STM32F413xx) && !defined(STM32F423xx)
124 #define RTC_TAMPER_2                    RTC_TAFCR_TAMP2E
125 #endif
126 /**
127   * @}
128   */
129 
130 /** @defgroup RTCEx_Tamper_Pins_Selection RTC tamper Pins Selection
131   * @{
132   */
133 
134 #define RTC_TAMPERPIN_DEFAULT               0x00000000U
135 
136 #if !defined(STM32F412Zx) && !defined(STM32F412Vx) && !defined(STM32F412Rx) && !defined(STM32F412Cx) && !defined(STM32F413xx) && !defined(STM32F423xx)
137 #define RTC_TAMPERPIN_POS1                  0x00010000U
138 #endif
139 /**
140   * @}
141   */
142 
143 /** @defgroup RTCEx_TimeStamp_Pin_Selection RTC TimeStamp Pins Selection
144   * @{
145   */
146 #define RTC_TIMESTAMPPIN_DEFAULT            0x00000000U
147 
148 #if !defined(STM32F412Zx) && !defined(STM32F412Vx) && !defined(STM32F412Rx) && !defined(STM32F412Cx) && !defined(STM32F413xx) && !defined(STM32F423xx)
149 #define RTC_TIMESTAMPPIN_POS1               0x00020000U
150 #endif
151 /**
152   * @}
153   */
154 
155 /** @defgroup RTCEx_Tamper_Trigger_Definitions RTC Tamper Triggers Definitions
156   * @{
157   */
158 #define RTC_TAMPERTRIGGER_RISINGEDGE       0x00000000U
159 #define RTC_TAMPERTRIGGER_FALLINGEDGE      0x00000002U
160 #define RTC_TAMPERTRIGGER_LOWLEVEL         RTC_TAMPERTRIGGER_RISINGEDGE
161 #define RTC_TAMPERTRIGGER_HIGHLEVEL        RTC_TAMPERTRIGGER_FALLINGEDGE
162 /**
163   * @}
164   */
165 
166 /** @defgroup RTCEx_Tamper_Filter_Definitions RTC Tamper Filter Definitions
167   * @{
168   */
169 #define RTC_TAMPERFILTER_DISABLE   0x00000000U  /*!< Tamper filter is disabled */
170 
171 #define RTC_TAMPERFILTER_2SAMPLE   0x00000800U  /*!< Tamper is activated after 2
172                                                                 consecutive samples at the active level */
173 #define RTC_TAMPERFILTER_4SAMPLE   0x00001000U  /*!< Tamper is activated after 4
174                                                                 consecutive samples at the active level */
175 #define RTC_TAMPERFILTER_8SAMPLE   0x00001800U  /*!< Tamper is activated after 8
176                                                                 consecutive samples at the active level. */
177 /**
178   * @}
179   */
180 
181 /** @defgroup RTCEx_Tamper_Sampling_Frequencies_Definitions RTC Tamper Sampling Frequencies Definitions
182   * @{
183   */
184 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768  0x00000000U  /*!< Each of the tamper inputs are sampled
185                                                                              with a frequency =  RTCCLK / 32768 */
186 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384  0x00000100U  /*!< Each of the tamper inputs are sampled
187                                                                              with a frequency =  RTCCLK / 16384 */
188 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192   0x00000200U  /*!< Each of the tamper inputs are sampled
189                                                                              with a frequency =  RTCCLK / 8192  */
190 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096   0x00000300U  /*!< Each of the tamper inputs are sampled
191                                                                              with a frequency =  RTCCLK / 4096  */
192 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048   0x00000400U  /*!< Each of the tamper inputs are sampled
193                                                                              with a frequency =  RTCCLK / 2048  */
194 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024   0x00000500U  /*!< Each of the tamper inputs are sampled
195                                                                              with a frequency =  RTCCLK / 1024  */
196 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512    0x00000600U  /*!< Each of the tamper inputs are sampled
197                                                                              with a frequency =  RTCCLK / 512   */
198 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256    0x00000700U  /*!< Each of the tamper inputs are sampled
199                                                                              with a frequency =  RTCCLK / 256   */
200 /**
201   * @}
202   */
203 
204 /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration_Definitions RTC Tamper Pin Precharge Duration Definitions
205   * @{
206   */
207 #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK 0x00000000U  /*!< Tamper pins are pre-charged before
208                                                                          sampling during 1 RTCCLK cycle */
209 #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK 0x00002000U  /*!< Tamper pins are pre-charged before
210                                                                          sampling during 2 RTCCLK cycles */
211 #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK 0x00004000U  /*!< Tamper pins are pre-charged before
212                                                                          sampling during 4 RTCCLK cycles */
213 #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK 0x00006000U  /*!< Tamper pins are pre-charged before
214                                                                          sampling during 8 RTCCLK cycles */
215 /**
216   * @}
217   */
218 
219 /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection_Definitions RTC Tamper TimeStamp On Tamper Detection Definitions
220   * @{
221   */
222 #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE  ((uint32_t)RTC_TAFCR_TAMPTS)  /*!< TimeStamp on Tamper Detection event saved        */
223 #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE 0x00000000U        /*!< TimeStamp on Tamper Detection event is not saved */
224 /**
225   * @}
226   */
227 
228 /** @defgroup  RTCEx_Tamper_Pull_UP_Definitions RTC Tamper Pull Up Definitions
229   * @{
230   */
231 #define RTC_TAMPER_PULLUP_ENABLE  0x00000000U            /*!< TimeStamp on Tamper Detection event saved        */
232 #define RTC_TAMPER_PULLUP_DISABLE ((uint32_t)RTC_TAFCR_TAMPPUDIS)   /*!< TimeStamp on Tamper Detection event is not saved */
233 /**
234   * @}
235   */
236 
237 /** @defgroup RTCEx_Wakeup_Timer_Definitions RTC Wake-up Timer Definitions
238   * @{
239   */
240 #define RTC_WAKEUPCLOCK_RTCCLK_DIV16        0x00000000U
241 #define RTC_WAKEUPCLOCK_RTCCLK_DIV8         0x00000001U
242 #define RTC_WAKEUPCLOCK_RTCCLK_DIV4         0x00000002U
243 #define RTC_WAKEUPCLOCK_RTCCLK_DIV2         0x00000003U
244 #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS      0x00000004U
245 #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS      0x00000006U
246 /**
247   * @}
248   */
249 
250 /** @defgroup RTCEx_Digital_Calibration_Definitions RTC Digital Calib Definitions
251   * @{
252   */
253 #define RTC_CALIBSIGN_POSITIVE            0x00000000U
254 #define RTC_CALIBSIGN_NEGATIVE            0x00000080U
255 /**
256   * @}
257   */
258 
259 /** @defgroup RTCEx_Smooth_calib_period_Definitions RTC Smooth Calib Period Definitions
260   * @{
261   */
262 #define RTC_SMOOTHCALIB_PERIOD_32SEC   0x00000000U  /*!< If RTCCLK = 32768 Hz, Smooth calibration
263                                                                     period is 32s,  else 2exp20 RTCCLK seconds */
264 #define RTC_SMOOTHCALIB_PERIOD_16SEC   0x00002000U  /*!< If RTCCLK = 32768 Hz, Smooth calibration
265                                                                     period is 16s, else 2exp19 RTCCLK seconds */
266 #define RTC_SMOOTHCALIB_PERIOD_8SEC    0x00004000U  /*!< If RTCCLK = 32768 Hz, Smooth calibration
267                                                                     period is 8s, else 2exp18 RTCCLK seconds */
268 /**
269   * @}
270   */
271 
272 /** @defgroup RTCEx_Smooth_calib_Plus_pulses_Definitions RTC Smooth Calib Plus Pulses Definitions
273   * @{
274   */
275 #define RTC_SMOOTHCALIB_PLUSPULSES_SET    0x00008000U  /*!< The number of RTCCLK pulses added
276                                                                        during a X -second window = Y - CALM[8:0]
277                                                                        with Y = 512, 256, 128 when X = 32, 16, 8 */
278 #define RTC_SMOOTHCALIB_PLUSPULSES_RESET  0x00000000U  /*!< The number of RTCCLK pulses subbstited
279                                                                        during a 32-second window = CALM[8:0] */
280 /**
281   * @}
282   */
283 
284 /** @defgroup RTCEx_Add_1_Second_Parameter_Definitions RTC Add 1 Second Parameter Definitions
285   * @{
286   */
287 #define RTC_SHIFTADD1S_RESET      0x00000000U
288 #define RTC_SHIFTADD1S_SET        0x80000000U
289 /**
290   * @}
291   */
292 
293 
294  /** @defgroup RTCEx_Calib_Output_selection_Definitions RTC Calib Output Selection Definitions
295   * @{
296   */
297 #define RTC_CALIBOUTPUT_512HZ            0x00000000U
298 #define RTC_CALIBOUTPUT_1HZ              0x00080000U
299 /**
300   * @}
301   */
302 
303 /**
304   * @}
305   */
306 
307 /* Exported macro ------------------------------------------------------------*/
308 /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros
309   * @{
310   */
311 
312 /* ---------------------------------WAKEUPTIMER---------------------------------*/
313 /** @defgroup RTCEx_WakeUp_Timer RTC WakeUp Timer
314   * @{
315   */
316 
317 /**
318   * @brief  Enable the RTC WakeUp Timer peripheral.
319   * @param  __HANDLE__ specifies the RTC handle.
320   * @retval None
321   */
322 #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__)                      ((__HANDLE__)->Instance->CR |= (RTC_CR_WUTE))
323 
324 /**
325   * @brief  Disable the RTC Wake-up Timer peripheral.
326   * @param  __HANDLE__ specifies the RTC handle.
327   * @retval None
328   */
329 #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__)                     ((__HANDLE__)->Instance->CR &= ~(RTC_CR_WUTE))
330 
331 /**
332   * @brief  Enable the RTC WakeUpTimer interrupt.
333   * @param  __HANDLE__ specifies the RTC handle.
334   * @param  __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled.
335   *         This parameter can be:
336   *            @arg RTC_IT_WUT: WakeUpTimer A interrupt
337   * @retval None
338   */
339 #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__)    ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
340 
341 /**
342   * @brief  Disable the RTC WakeUpTimer interrupt.
343   * @param  __HANDLE__ specifies the RTC handle.
344   * @param  __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled.
345   *         This parameter can be:
346   *            @arg RTC_IT_WUT: WakeUpTimer A interrupt
347   * @retval None
348   */
349 #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__)   ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
350 
351 /**
352   * @brief  Check whether the specified RTC WakeUpTimer interrupt has occurred or not.
353   * @param  __HANDLE__ specifies the RTC handle.
354   * @param  __INTERRUPT__ specifies the RTC WakeUpTimer interrupt to check.
355   *         This parameter can be:
356   *            @arg RTC_IT_WUT:  WakeUpTimer A interrupt
357   * @retval None
358   */
359 #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __INTERRUPT__)            (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 4U)) != RESET)? SET : RESET)
360 
361 /**
362   * @brief  Check whether the specified RTC Wake Up timer interrupt has been enabled or not.
363   * @param  __HANDLE__ specifies the RTC handle.
364   * @param  __INTERRUPT__ specifies the RTC Wake Up timer interrupt sources to check.
365   *         This parameter can be:
366   *            @arg RTC_IT_WUT:  WakeUpTimer interrupt
367   * @retval None
368   */
369 #define __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)   (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
370 
371 /**
372   * @brief  Get the selected RTC WakeUpTimer's flag status.
373   * @param  __HANDLE__ specifies the RTC handle.
374   * @param  __FLAG__ specifies the RTC WakeUpTimer Flag to check.
375   *          This parameter can be:
376   *             @arg RTC_FLAG_WUTF
377   *             @arg RTC_FLAG_WUTWF
378   * @retval None
379   */
380 #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__)          (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
381 
382 /**
383   * @brief  Clear the RTC Wake Up timer's pending flags.
384   * @param  __HANDLE__ specifies the RTC handle.
385   * @param  __FLAG__ specifies the RTC Tamper Flag sources to be enabled or disabled.
386   *         This parameter can be:
387   *            @arg RTC_FLAG_WUTF
388   * @retval None
389   */
390 #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__)            ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
391 
392 /**
393   * @brief  Enable interrupt on the RTC Wake-up Timer associated Exti line.
394   * @retval None
395   */
396 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT()       (EXTI->IMR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
397 
398 /**
399   * @brief  Disable interrupt on the RTC Wake-up Timer associated Exti line.
400   * @retval None
401   */
402 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT()      (EXTI->IMR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
403 
404 /**
405   * @brief  Enable event on the RTC Wake-up Timer associated Exti line.
406   * @retval None.
407   */
408 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT()    (EXTI->EMR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
409 
410 /**
411   * @brief  Disable event on the RTC Wake-up Timer associated Exti line.
412   * @retval None.
413   */
414 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT()   (EXTI->EMR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
415 
416 /**
417   * @brief  Enable falling edge trigger on the RTC Wake-up Timer associated Exti line.
418   * @retval None.
419   */
420 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE()   (EXTI->FTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
421 
422 /**
423   * @brief  Disable falling edge trigger on the RTC Wake-up Timer associated Exti line.
424   * @retval None.
425   */
426 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE()  (EXTI->FTSR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
427 
428 /**
429   * @brief  Enable rising edge trigger on the RTC Wake-up Timer associated Exti line.
430   * @retval None.
431   */
432 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE()    (EXTI->RTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
433 
434 /**
435   * @brief  Disable rising edge trigger on the RTC Wake-up Timer associated Exti line.
436   * @retval None.
437   */
438 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE()   (EXTI->RTSR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
439 
440 /**
441   * @brief  Enable rising & falling edge trigger on the RTC Wake-up Timer associated Exti line.
442   * @retval None.
443   */
444 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_FALLING_EDGE() do { __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE();\
445                                                                      __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE();\
446                                                                    } while(0U)
447 
448 /**
449   * @brief  Disable rising & falling edge trigger on the RTC Wake-up Timer associated Exti line.
450   * This parameter can be:
451   * @retval None.
452   */
453 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_FALLING_EDGE() do { __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE();\
454                                                                       __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE();\
455                                                                     } while(0U)
456 
457 /**
458   * @brief Check whether the RTC Wake-up Timer associated Exti line interrupt flag is set or not.
459   * @retval Line Status.
460   */
461 #define __HAL_RTC_WAKEUPTIMER_EXTI_GET_FLAG()              (EXTI->PR & RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
462 
463 /**
464   * @brief Clear the RTC Wake-up Timer associated Exti line flag.
465   * @retval None.
466   */
467 #define __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG()            (EXTI->PR = RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
468 
469 /**
470   * @brief Generate a Software interrupt on the RTC Wake-up Timer associated Exti line.
471   * @retval None.
472   */
473 #define __HAL_RTC_WAKEUPTIMER_EXTI_GENERATE_SWIT()         (EXTI->SWIER |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
474 
475 /**
476   * @}
477   */
478 
479 /* ---------------------------------TIMESTAMP---------------------------------*/
480 /** @defgroup RTCEx_Timestamp RTC Timestamp
481   * @{
482   */
483 
484 /**
485   * @brief  Enable the RTC TimeStamp peripheral.
486   * @param  __HANDLE__ specifies the RTC handle.
487   * @retval None
488   */
489 #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__)                        ((__HANDLE__)->Instance->CR |= (RTC_CR_TSE))
490 
491 /**
492   * @brief  Disable the RTC TimeStamp peripheral.
493   * @param  __HANDLE__ specifies the RTC handle.
494   * @retval None
495   */
496 #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__)                       ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TSE))
497 
498 /**
499   * @brief  Enable the RTC TimeStamp interrupt.
500   * @param  __HANDLE__ specifies the RTC handle.
501   * @param  __INTERRUPT__ specifies the RTC TimeStamp interrupt sources to be enabled or disabled.
502   *         This parameter can be:
503   *            @arg RTC_IT_TS: TimeStamp interrupt
504   * @retval None
505   */
506 #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__)      ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
507 
508 /**
509   * @brief  Disable the RTC TimeStamp interrupt.
510   * @param  __HANDLE__ specifies the RTC handle.
511   * @param  __INTERRUPT__ specifies the RTC TimeStamp interrupt sources to be enabled or disabled.
512   *         This parameter can be:
513   *            @arg RTC_IT_TS: TimeStamp interrupt
514   * @retval None
515   */
516 #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__)     ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
517 
518 /**
519   * @brief  Check whether the specified RTC TimeStamp interrupt has occurred or not.
520   * @param  __HANDLE__ specifies the RTC handle.
521   * @param  __INTERRUPT__ specifies the RTC TimeStamp interrupt to check.
522   *         This parameter can be:
523   *            @arg RTC_IT_TS: TimeStamp interrupt
524   * @retval None
525   */
526 #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__)         (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 4U)) != RESET)? SET : RESET)
527 
528 /**
529   * @brief  Check whether the specified RTC Time Stamp interrupt has been enabled or not.
530   * @param  __HANDLE__ specifies the RTC handle.
531   * @param  __INTERRUPT__ specifies the RTC Time Stamp interrupt source to check.
532   *         This parameter can be:
533   *            @arg RTC_IT_TS: TimeStamp interrupt
534   * @retval None
535   */
536 #define __HAL_RTC_TIMESTAMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)     (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
537 
538 /**
539   * @brief  Get the selected RTC TimeStamp's flag status.
540   * @param  __HANDLE__ specifies the RTC handle.
541   * @param  __FLAG__ specifies the RTC TimeStamp flag to check.
542   *         This parameter can be:
543   *            @arg RTC_FLAG_TSF
544   *            @arg RTC_FLAG_TSOVF
545   * @retval None
546   */
547 #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__)            (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
548 
549 /**
550   * @brief  Clear the RTC Time Stamp's pending flags.
551   * @param  __HANDLE__ specifies the RTC handle.
552   * @param  __FLAG__ specifies the RTC Alarm Flag sources to be enabled or disabled.
553   *          This parameter can be:
554   *             @arg RTC_FLAG_TSF
555   * @retval None
556   */
557 #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__)          ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
558 
559 /**
560   * @}
561   */
562 
563 /* ---------------------------------TAMPER------------------------------------*/
564 /** @defgroup RTCEx_Tamper RTC Tamper
565   * @{
566   */
567 
568 /**
569   * @brief  Enable the RTC Tamper1 input detection.
570   * @param  __HANDLE__ specifies the RTC handle.
571   * @retval None
572   */
573 #define __HAL_RTC_TAMPER1_ENABLE(__HANDLE__)                         ((__HANDLE__)->Instance->TAFCR |= (RTC_TAFCR_TAMP1E))
574 
575 /**
576   * @brief  Disable the RTC Tamper1 input detection.
577   * @param  __HANDLE__ specifies the RTC handle.
578   * @retval None
579   */
580 #define __HAL_RTC_TAMPER1_DISABLE(__HANDLE__)                        ((__HANDLE__)->Instance->TAFCR &= ~(RTC_TAFCR_TAMP1E))
581 
582 #if !defined(STM32F412Zx) && !defined(STM32F412Vx) && !defined(STM32F412Rx) && !defined(STM32F412Cx) && !defined(STM32F413xx) && !defined(STM32F423xx)
583 /**
584   * @brief  Enable the RTC Tamper2 input detection.
585   * @param  __HANDLE__ specifies the RTC handle.
586   * @retval None
587   */
588 #define __HAL_RTC_TAMPER2_ENABLE(__HANDLE__)                         ((__HANDLE__)->Instance->TAFCR |= (RTC_TAFCR_TAMP2E))
589 
590 /**
591   * @brief  Disable the RTC Tamper2 input detection.
592   * @param  __HANDLE__ specifies the RTC handle.
593   * @retval None
594   */
595 #define __HAL_RTC_TAMPER2_DISABLE(__HANDLE__)                        ((__HANDLE__)->Instance->TAFCR &= ~(RTC_TAFCR_TAMP2E))
596 #endif
597 
598 /**
599   * @brief  Check whether the specified RTC Tamper interrupt has occurred or not.
600   * @param  __HANDLE__ specifies the RTC handle.
601   * @param  __INTERRUPT__ specifies the RTC Tamper interrupt to check.
602   *         This parameter can be:
603   *            @arg  RTC_IT_TAMP1
604   *            @arg  RTC_IT_TAMP2
605   * @retval None
606   */
607 #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__)       (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 4U)) != RESET)? SET : RESET)
608 
609 /**
610   * @brief  Check whether the specified RTC Tamper interrupt has been enabled or not.
611   * @param  __HANDLE__ specifies the RTC handle.
612   * @param  __INTERRUPT__ specifies the RTC Tamper interrupt source to check.
613   *         This parameter can be:
614   *            @arg RTC_IT_TAMP: Tamper interrupt
615   * @retval None
616   */
617 #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)     (((((__HANDLE__)->Instance->TAFCR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
618 
619 /**
620   * @brief  Get the selected RTC Tamper's flag status.
621   * @param  __HANDLE__ specifies the RTC handle.
622   * @param  __FLAG__ specifies the RTC Tamper Flag sources to be enabled or disabled.
623   *          This parameter can be:
624   *             @arg RTC_FLAG_TAMP1F
625   *             @arg RTC_FLAG_TAMP2F
626   * @retval None
627   */
628 #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__)               (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
629 
630 /**
631   * @brief  Clear the RTC Tamper's pending flags.
632   * @param  __HANDLE__ specifies the RTC handle.
633   * @param  __FLAG__ specifies the RTC Tamper Flag to clear.
634   *          This parameter can be:
635   *             @arg RTC_FLAG_TAMP1F
636   *             @arg RTC_FLAG_TAMP2F
637   * @retval None
638   */
639 #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__)         ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
640 /**
641   * @}
642   */
643 
644 /* --------------------------TAMPER/TIMESTAMP---------------------------------*/
645 /** @defgroup RTCEx_Tamper_Timestamp EXTI RTC Tamper Timestamp EXTI
646   * @{
647   */
648 
649 /**
650   * @brief  Enable interrupt on the RTC Tamper and Timestamp associated Exti line.
651   * @retval None
652   */
653 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT()        (EXTI->IMR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
654 
655 /**
656   * @brief  Disable interrupt on the RTC Tamper and Timestamp associated Exti line.
657   * @retval None
658   */
659 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_IT()       (EXTI->IMR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
660 
661 /**
662   * @brief  Enable event on the RTC Tamper and Timestamp associated Exti line.
663   * @retval None.
664   */
665 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_EVENT()    (EXTI->EMR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
666 
667 /**
668   * @brief  Disable event on the RTC Tamper and Timestamp associated Exti line.
669   * @retval None.
670   */
671 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_EVENT()   (EXTI->EMR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
672 
673 /**
674   * @brief  Enable falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
675   * @retval None.
676   */
677 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE()   (EXTI->FTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
678 
679 /**
680   * @brief  Disable falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
681   * @retval None.
682   */
683 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE()  (EXTI->FTSR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
684 
685 /**
686   * @brief  Enable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
687   * @retval None.
688   */
689 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE()    (EXTI->RTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
690 
691 /**
692   * @brief  Disable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
693   * @retval None.
694   */
695 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE()   (EXTI->RTSR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
696 
697 /**
698   * @brief  Enable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
699   * @retval None.
700   */
701 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_FALLING_EDGE() do { __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE();\
702                                                                           __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE(); \
703                                                                         } while(0U)
704 
705 /**
706   * @brief  Disable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
707   * This parameter can be:
708   * @retval None.
709   */
710 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_FALLING_EDGE() do { __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE();\
711                                                                            __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE();\
712                                                                          } while(0U)
713 
714 /**
715   * @brief Check whether the RTC Tamper and Timestamp associated Exti line interrupt flag is set or not.
716   * @retval Line Status.
717   */
718 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GET_FLAG()         (EXTI->PR & RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
719 
720 /**
721   * @brief Clear the RTC Tamper and Timestamp associated Exti line flag.
722   * @retval None.
723   */
724 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_CLEAR_FLAG()       (EXTI->PR = RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
725 
726 /**
727   * @brief Generate a Software interrupt on the RTC Tamper and Timestamp associated Exti line
728   * @retval None.
729   */
730 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GENERATE_SWIT()    (EXTI->SWIER |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
731 /**
732   * @}
733   */
734 
735 /* ------------------------------Calibration----------------------------------*/
736 /** @defgroup RTCEx_Calibration RTC Calibration
737   * @{
738   */
739 
740 /**
741   * @brief  Enable the Coarse calibration process.
742   * @param  __HANDLE__ specifies the RTC handle.
743   * @retval None
744   */
745 #define __HAL_RTC_COARSE_CALIB_ENABLE(__HANDLE__)                       ((__HANDLE__)->Instance->CR |= (RTC_CR_DCE))
746 
747 /**
748   * @brief  Disable the Coarse calibration process.
749   * @param  __HANDLE__ specifies the RTC handle.
750   * @retval None
751   */
752 #define __HAL_RTC_COARSE_CALIB_DISABLE(__HANDLE__)                      ((__HANDLE__)->Instance->CR &= ~(RTC_CR_DCE))
753 
754 /**
755   * @brief  Enable the RTC calibration output.
756   * @param  __HANDLE__ specifies the RTC handle.
757   * @retval None
758   */
759 #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__)                 ((__HANDLE__)->Instance->CR |= (RTC_CR_COE))
760 
761 /**
762   * @brief  Disable the calibration output.
763   * @param  __HANDLE__ specifies the RTC handle.
764   * @retval None
765   */
766 #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__)                ((__HANDLE__)->Instance->CR &= ~(RTC_CR_COE))
767 
768 /**
769   * @brief  Enable the clock reference detection.
770   * @param  __HANDLE__ specifies the RTC handle.
771   * @retval None
772   */
773 #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__)                 ((__HANDLE__)->Instance->CR |= (RTC_CR_REFCKON))
774 
775 /**
776   * @brief  Disable the clock reference detection.
777   * @param  __HANDLE__ specifies the RTC handle.
778   * @retval None
779   */
780 #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__)                ((__HANDLE__)->Instance->CR &= ~(RTC_CR_REFCKON))
781 
782 /**
783   * @brief  Get the selected RTC shift operation's flag status.
784   * @param  __HANDLE__ specifies the RTC handle.
785   * @param  __FLAG__ specifies the RTC shift operation Flag is pending or not.
786   *          This parameter can be:
787   *             @arg RTC_FLAG_SHPF
788   * @retval None
789   */
790 #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__)                (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
791 /**
792   * @}
793   */
794 
795 /**
796   * @}
797   */
798 
799 /* Exported functions --------------------------------------------------------*/
800 /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions
801   * @{
802   */
803 
804 /** @addtogroup RTCEx_Exported_Functions_Group1
805   * @{
806   */
807 /* RTC TimeStamp and Tamper functions *****************************************/
808 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
809 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
810 HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc);
811 HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format);
812 
813 HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper);
814 HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper);
815 HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper);
816 void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc);
817 
818 void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc);
819 void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc);
820 void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc);
821 HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
822 HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
823 HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
824 /**
825   * @}
826   */
827 
828 /** @addtogroup RTCEx_Exported_Functions_Group2
829   * @{
830   */
831 /* RTC Wake-up functions ******************************************************/
832 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
833 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
834 uint32_t HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc);
835 uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc);
836 void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc);
837 void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc);
838 HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
839 /**
840   * @}
841   */
842 
843 /** @addtogroup RTCEx_Exported_Functions_Group3
844   * @{
845   */
846 /* Extension Control functions ************************************************/
847 void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data);
848 uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister);
849 
850 HAL_StatusTypeDef HAL_RTCEx_SetCoarseCalib(RTC_HandleTypeDef *hrtc, uint32_t CalibSign, uint32_t Value);
851 HAL_StatusTypeDef HAL_RTCEx_DeactivateCoarseCalib(RTC_HandleTypeDef *hrtc);
852 HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmouthCalibMinusPulsesValue);
853 HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS);
854 HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput);
855 HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc);
856 HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc);
857 HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc);
858 HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc);
859 HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc);
860 /**
861   * @}
862   */
863 
864 /** @addtogroup RTCEx_Exported_Functions_Group4
865   * @{
866   */
867 /* Extension RTC features functions *******************************************/
868 void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc);
869 HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
870 /**
871   * @}
872   */
873 
874 /**
875   * @}
876   */
877 
878 /* Private types -------------------------------------------------------------*/
879 /* Private variables ---------------------------------------------------------*/
880 /* Private constants ---------------------------------------------------------*/
881 /** @defgroup RTCEx_Private_Constants RTCEx Private Constants
882   * @{
883   */
884 #define RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT  ((uint32_t)EXTI_IMR_MR21)  /*!< External interrupt line 21 Connected to the RTC Tamper and Time Stamp events */
885 #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT       ((uint32_t)EXTI_IMR_MR22)  /*!< External interrupt line 22 Connected to the RTC Wake-up event */
886 /**
887   * @}
888   */
889 
890 /* Private macros ------------------------------------------------------------*/
891 /** @defgroup RTCEx_Private_Macros RTCEx Private Macros
892   * @{
893   */
894 
895 /** @defgroup RTCEx_IS_RTC_Definitions Private macros to check input parameters
896   * @{
897   */
898 #define IS_RTC_BKP(BKP)                   (((BKP) == RTC_BKP_DR0)  || \
899                                            ((BKP) == RTC_BKP_DR1)  || \
900                                            ((BKP) == RTC_BKP_DR2)  || \
901                                            ((BKP) == RTC_BKP_DR3)  || \
902                                            ((BKP) == RTC_BKP_DR4)  || \
903                                            ((BKP) == RTC_BKP_DR5)  || \
904                                            ((BKP) == RTC_BKP_DR6)  || \
905                                            ((BKP) == RTC_BKP_DR7)  || \
906                                            ((BKP) == RTC_BKP_DR8)  || \
907                                            ((BKP) == RTC_BKP_DR9)  || \
908                                            ((BKP) == RTC_BKP_DR10) || \
909                                            ((BKP) == RTC_BKP_DR11) || \
910                                            ((BKP) == RTC_BKP_DR12) || \
911                                            ((BKP) == RTC_BKP_DR13) || \
912                                            ((BKP) == RTC_BKP_DR14) || \
913                                            ((BKP) == RTC_BKP_DR15) || \
914                                            ((BKP) == RTC_BKP_DR16) || \
915                                            ((BKP) == RTC_BKP_DR17) || \
916                                            ((BKP) == RTC_BKP_DR18) || \
917                                            ((BKP) == RTC_BKP_DR19))
918 #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \
919                                  ((EDGE) == RTC_TIMESTAMPEDGE_FALLING))
920 
921 #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
922 #define IS_RTC_TAMPER(TAMPER) ((((TAMPER) & ((uint32_t)!(RTC_TAFCR_TAMP1E ))) == 0x00U) && ((TAMPER) != (uint32_t)RESET))
923 #else
924 #define IS_RTC_TAMPER(TAMPER) ((((TAMPER) & ((uint32_t)!(RTC_TAFCR_TAMP1E | RTC_TAFCR_TAMP2E))) == 0x00U) && ((TAMPER) != (uint32_t)RESET))
925 #endif
926 
927 #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
928 #define IS_RTC_TAMPER_PIN(PIN) ((PIN) == RTC_TAMPERPIN_DEFAULT)
929 #else
930 #define IS_RTC_TAMPER_PIN(PIN) (((PIN) == RTC_TAMPERPIN_DEFAULT) || \
931                                 ((PIN) == RTC_TAMPERPIN_POS1))
932 #endif
933 
934 #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
935 #define IS_RTC_TIMESTAMP_PIN(PIN) ((PIN) == RTC_TIMESTAMPPIN_DEFAULT)
936 #else
937 #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TIMESTAMPPIN_DEFAULT) || \
938                                    ((PIN) == RTC_TIMESTAMPPIN_POS1))
939 #endif
940 #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) || \
941                                         ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \
942                                         ((TRIGGER) == RTC_TAMPERTRIGGER_LOWLEVEL) || \
943                                         ((TRIGGER) == RTC_TAMPERTRIGGER_HIGHLEVEL))
944 #define IS_RTC_TAMPER_FILTER(FILTER)  (((FILTER) == RTC_TAMPERFILTER_DISABLE) || \
945                                        ((FILTER) == RTC_TAMPERFILTER_2SAMPLE) || \
946                                        ((FILTER) == RTC_TAMPERFILTER_4SAMPLE) || \
947                                        ((FILTER) == RTC_TAMPERFILTER_8SAMPLE))
948 #define IS_RTC_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \
949                                            ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \
950                                            ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \
951                                            ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \
952                                            ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \
953                                            ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \
954                                            ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512)  || \
955                                            ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256))
956 #define IS_RTC_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \
957                                                     ((DURATION) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \
958                                                     ((DURATION) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \
959                                                     ((DURATION) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK))
960 #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \
961                                                               ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE))
962 #define IS_RTC_TAMPER_PULLUP_STATE(STATE) (((STATE) == RTC_TAMPER_PULLUP_ENABLE) || \
963                                            ((STATE) == RTC_TAMPER_PULLUP_DISABLE))
964 #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16)   || \
965                                     ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8)    || \
966                                     ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4)    || \
967                                     ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2)    || \
968                                     ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \
969                                     ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS))
970 
971 #define IS_RTC_WAKEUP_COUNTER(COUNTER)  ((COUNTER) <= 0xFFFFU)
972 #define IS_RTC_CALIB_SIGN(SIGN) (((SIGN) == RTC_CALIBSIGN_POSITIVE) || \
973                                  ((SIGN) == RTC_CALIBSIGN_NEGATIVE))
974 
975 #define IS_RTC_CALIB_VALUE(VALUE) ((VALUE) < 0x20U)
976 
977 #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \
978                                             ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \
979                                             ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC))
980 #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \
981                                         ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET))
982 
983 #define  IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= 0x000001FFU)
984 #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \
985                                  ((SEL) == RTC_SHIFTADD1S_SET))
986 #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= 0x00007FFFU)
987 #define IS_RTC_CALIB_OUTPUT(OUTPUT)  (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \
988                                       ((OUTPUT) == RTC_CALIBOUTPUT_1HZ))
989 /**
990   * @}
991   */
992 
993 /**
994   * @}
995   */
996 
997 /**
998   * @}
999   */
1000 
1001 /**
1002   * @}
1003   */
1004 
1005 #ifdef __cplusplus
1006 }
1007 #endif
1008 
1009 #endif /* __STM32F4xx_HAL_RTC_EX_H */
1010 
1011 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
1012