1 /**
2   ******************************************************************************
3   * @file    stm32h5xx_hal_rtc.h
4   * @author  MCD Application Team
5   * @brief   Header file of RTC HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2023 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32H5xx_HAL_RTC_H
21 #define STM32H5xx_HAL_RTC_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32h5xx_hal_def.h"
29 
30 /** @addtogroup STM32H5xx_HAL_Driver
31   * @{
32   */
33 
34 /** @defgroup RTC RTC
35   * @{
36   */
37 
38 /* Exported types ------------------------------------------------------------*/
39 /** @defgroup RTC_Exported_Types RTC Exported Types
40   * @{
41   */
42 
43 /**
44   * @brief  HAL State structures definition
45   */
46 typedef enum
47 {
48   HAL_RTC_STATE_RESET             = 0x00U,  /*!< RTC not yet initialized or disabled */
49   HAL_RTC_STATE_READY             = 0x01U,  /*!< RTC initialized and ready for use   */
50   HAL_RTC_STATE_BUSY              = 0x02U,  /*!< RTC process is ongoing              */
51   HAL_RTC_STATE_TIMEOUT           = 0x03U,  /*!< RTC timeout state                   */
52   HAL_RTC_STATE_ERROR             = 0x04U   /*!< RTC error state                     */
53 
54 } HAL_RTCStateTypeDef;
55 
56 /**
57   * @brief  RTC Configuration Structure definition
58   */
59 typedef struct
60 {
61   uint32_t HourFormat;        /*!< Specifies the RTC Hour Format.
62                                  This parameter can be a value of @ref RTC_Hour_Formats */
63 
64   uint32_t AsynchPrediv;      /*!< Specifies the RTC Asynchronous Predivider value.
65                                  This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */
66 
67   uint32_t SynchPrediv;       /*!< Specifies the RTC Synchronous Predivider value.
68                                  This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF */
69 
70   uint32_t OutPut;            /*!< Specifies which signal will be routed to the RTC output.
71                                  This parameter can be a value of @ref RTCEx_Output_selection_Definitions */
72 
73   uint32_t OutPutRemap;       /*!< Specifies the remap for RTC output.
74                                  This parameter can be a value of @ref  RTC_Output_ALARM_OUT_Remap */
75 
76   uint32_t OutPutPolarity;    /*!< Specifies the polarity of the output signal.
77                                  This parameter can be a value of @ref RTC_Output_Polarity_Definitions */
78 
79   uint32_t OutPutType;        /*!< Specifies the RTC Output Pin mode.
80                                  This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */
81 
82   uint32_t OutPutPullUp;      /*!< Specifies the RTC Output Pull-Up mode.
83                                  This parameter can be a value of @ref RTC_Output_PullUp_ALARM_OUT */
84 
85   uint32_t BinMode;           /*!< Specifies the RTC binary mode.
86                                  This parameter can be a value of @ref RTCEx_Binary_Mode */
87 
88   uint32_t BinMixBcdU;        /*!< Specifies the BCD calendar update if and only if BinMode = RTC_BINARY_MIX.
89                                  This parameter can be a value of @ref RTCEx_Binary_mix_BCDU */
90 } RTC_InitTypeDef;
91 
92 /**
93   * @brief  RTC Time structure definition
94   */
95 typedef struct
96 {
97   uint8_t Hours;            /*!< Specifies the RTC Time Hour.
98                                  This parameter must be a number between:
99                                  Min_Data = 0 and Max_Data = 12 if the RTC_HOURFORMAT_12 is selected.
100                                  This parameter must be a number between:
101                                  Min_Data = 0 and Max_Data = 23 if the RTC_HOURFORMAT_24 is selected */
102 
103   uint8_t Minutes;          /*!< Specifies the RTC Time Minutes.
104                                  This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
105 
106   uint8_t Seconds;          /*!< Specifies the RTC Time Seconds.
107                                  This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
108 
109   uint8_t TimeFormat;       /*!< Specifies the RTC AM/PM Time.
110                                  This parameter can be a value of @ref RTC_AM_PM_Definitions */
111 
112   uint32_t SubSeconds;      /*!< Specifies the RTC_SSR RTC Sub Second register content.
113                                  This field is not used by HAL_RTC_SetTime.
114                                  If the free running 32 bit counter is not activated (mode binary none)
115                                     - This parameter corresponds to a time unit range
116                                  between [0-1] Second with [1 Sec / SecondFraction +1] granularity
117                                  else
118                                     - This parameter corresponds to the free running 32 bit counter. */
119 
120   uint32_t SecondFraction;  /*!< Specifies the range or granularity of Sub Second register content
121                                  corresponding to Synchronous pre-scaler factor value (PREDIV_S)
122                                  This parameter corresponds to a time unit range between [0-1] Second
123                                  with [1 Sec / SecondFraction +1] granularity.
124                                  This field will be used only by HAL_RTC_GetTime function */
125 
126   uint32_t DayLightSaving;  /*!< This interface is deprecated.
127                                  To manage Daylight Saving Time, please use HAL_RTC_DST_xxx functions */
128 
129   uint32_t StoreOperation;  /*!< This interface is deprecated.
130                                  To manage Daylight Saving Time, please use HAL_RTC_DST_xxx functions */
131 } RTC_TimeTypeDef;
132 
133 /**
134   * @brief  RTC Date structure definition
135   */
136 typedef struct
137 {
138   uint8_t WeekDay;  /*!< Specifies the RTC Date WeekDay.
139                          This parameter can be a value of @ref RTC_WeekDay_Definitions */
140 
141   uint8_t Month;    /*!< Specifies the RTC Date Month (in BCD format).
142                          This parameter can be a value of @ref RTC_Month_Date_Definitions */
143 
144   uint8_t Date;     /*!< Specifies the RTC Date.
145                          This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
146 
147   uint8_t Year;     /*!< Specifies the RTC Date Year.
148                          This parameter must be a number between Min_Data = 0 and Max_Data = 99 */
149 } RTC_DateTypeDef;
150 
151 /**
152   * @brief  RTC Alarm structure definition
153   */
154 typedef struct
155 {
156   RTC_TimeTypeDef AlarmTime;     /*!< Specifies the RTC Alarm Time members */
157 
158   uint32_t AlarmMask;            /*!< Specifies the RTC Alarm Masks.
159                                       This parameter can be a value of @ref RTC_AlarmMask_Definitions */
160 
161   uint32_t AlarmSubSecondMask;   /*!< Specifies the RTC Alarm SubSeconds Masks.
162                                       if Binary mode is RTC_BINARY_ONLY or is RTC_BINARY_MIX
163                                         This parameter can be a value of
164                                         @ref RTCEx_Alarm_Sub_Seconds_binary_Masks_Definitions
165                                       else if Binary mode is RTC_BINARY_NONE
166                                         This parameter can be a value of
167                                         @ref RTC_Alarm_Sub_Seconds_BCD_Masks_Definitions */
168 
169   uint32_t BinaryAutoClr;        /*!< Clear synchronously counter (RTC_SSR) on binary alarm.
170                                       RTC_ALARMSUBSECONDBIN_AUTOCLR_YES must only be used if Binary mode
171                                        is RTC_BINARY_ONLY
172                                       This parameter can be a value of
173                                       @ref RTCEx_Alarm_Sub_Seconds_binary_Clear_Definitions */
174 
175   uint32_t AlarmDateWeekDaySel;  /*!< Specifies the RTC Alarm is on Date or WeekDay.
176                                      This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */
177 
178   uint8_t AlarmDateWeekDay;      /*!< Specifies the RTC Alarm Date/WeekDay.
179                                       If the Alarm Date is selected, this parameter must be set to a value
180                                        in the 1-31 range.
181                                       If the Alarm WeekDay is selected, this parameter can be a value of
182                                       @ref RTC_WeekDay_Definitions */
183 
184   uint32_t FlagAutoClr;          /*!< Specifies the alarm trigger generation. This feature is meaningful
185                                       to avoid any RTC software execution after configuration.
186                                       This parameter can be a value of @ref RTC_ALARM_Flag_AutoClear_Definitions */
187 
188   uint32_t Alarm;                /*!< Specifies the alarm.
189                                       This parameter can be a value of @ref RTC_Alarms_Definitions */
190 } RTC_AlarmTypeDef;
191 
192 /**
193   * @brief  RTC Handle Structure definition
194   */
195 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
196 typedef struct __RTC_HandleTypeDef
197 #else
198 typedef struct
199 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
200 {
201   RTC_TypeDef               *Instance;  /*!< Legacy register base address. Not used anymore, the driver directly uses cmsis base address */
202 
203   RTC_InitTypeDef           Init;       /*!< RTC required parameters  */
204 
205   HAL_LockTypeDef           Lock;       /*!< RTC locking object       */
206 
207   __IO HAL_RTCStateTypeDef  State;      /*!< Time communication state */
208 
209 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
210   void (* AlarmAEventCallback)(struct __RTC_HandleTypeDef *hrtc);            /*!< RTC Alarm A Event callback            */
211   void (* AlarmBEventCallback)(struct __RTC_HandleTypeDef *hrtc);            /*!< RTC Alarm B Event callback            */
212   void (* TimeStampEventCallback)(struct __RTC_HandleTypeDef *hrtc);         /*!< RTC TimeStamp Event callback          */
213   void (* WakeUpTimerEventCallback)(struct __RTC_HandleTypeDef *hrtc);       /*!< RTC WakeUpTimer Event callback        */
214   void (* SSRUEventCallback)(struct __RTC_HandleTypeDef *hrtc);              /*!< RTC SSRU Event callback               */
215   void (* Tamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Tamper 1 Event callback           */
216   void (* Tamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Tamper 2 Event callback           */
217   void (* Tamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Tamper 3 Event callback           */
218   void (* Tamper4EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Tamper 4 Event callback           */
219   void (* Tamper5EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Tamper 5 Event callback           */
220   void (* Tamper6EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Tamper 6 Event callback           */
221   void (* Tamper7EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Tamper 7 Event callback           */
222   void (* Tamper8EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Tamper 8 Event callback           */
223   void (* InternalTamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc);   /*!< RTC Internal Tamper 1 Event callback  */
224   void (* InternalTamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc);   /*!< RTC Internal Tamper 2 Event callback  */
225   void (* InternalTamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc);   /*!< RTC Internal Tamper 3 Event callback  */
226   void (* InternalTamper4EventCallback)(struct __RTC_HandleTypeDef *hrtc);   /*!< RTC Internal Tamper 4 Event callback  */
227   void (* InternalTamper5EventCallback)(struct __RTC_HandleTypeDef *hrtc);   /*!< RTC Internal Tamper 5 Event callback  */
228   void (* InternalTamper6EventCallback)(struct __RTC_HandleTypeDef *hrtc);   /*!< RTC Internal Tamper 6 Event callback  */
229   void (* InternalTamper7EventCallback)(struct __RTC_HandleTypeDef *hrtc);   /*!< RTC Internal Tamper 7 Event callback  */
230   void (* InternalTamper8EventCallback)(struct __RTC_HandleTypeDef *hrtc);   /*!< RTC Internal Tamper 8 Event callback  */
231   void (* InternalTamper9EventCallback)(struct __RTC_HandleTypeDef *hrtc);   /*!< RTC Internal Tamper 9 Event callback  */
232   void (* InternalTamper11EventCallback)(struct __RTC_HandleTypeDef *hrtc);  /*!< RTC Internal Tamper 11 Event callback */
233   void (* InternalTamper12EventCallback)(struct __RTC_HandleTypeDef *hrtc);  /*!< RTC Internal Tamper 12 Event callback */
234   void (* InternalTamper13EventCallback)(struct __RTC_HandleTypeDef *hrtc);  /*!< RTC Internal Tamper 13 Event callback */
235   void (* InternalTamper15EventCallback)(struct __RTC_HandleTypeDef *hrtc);  /*!< RTC Internal Tamper 15 Event callback */
236   void (* MspInitCallback)(struct __RTC_HandleTypeDef *hrtc);                /*!< RTC Msp Init callback                 */
237   void (* MspDeInitCallback)(struct __RTC_HandleTypeDef *hrtc);              /*!< RTC Msp DeInit callback               */
238 
239 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
240 
241 } RTC_HandleTypeDef;
242 
243 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
244 /**
245   * @brief  HAL RTC Callback ID enumeration definition
246   */
247 typedef enum
248 {
249   HAL_RTC_ALARM_A_EVENT_CB_ID           = 0U,   /*!< RTC Alarm A Event Callback ID      */
250   HAL_RTC_ALARM_B_EVENT_CB_ID           = 1U,   /*!< RTC Alarm B Event Callback ID      */
251   HAL_RTC_TIMESTAMP_EVENT_CB_ID         = 2U,   /*!< RTC TimeStamp Event Callback ID    */
252   HAL_RTC_WAKEUPTIMER_EVENT_CB_ID       = 3U,   /*!< RTC WakeUp Timer Event Callback ID */
253   HAL_RTC_SSRU_EVENT_CB_ID              = 4U,   /*!< RTC SSRU Event Callback ID         */
254   HAL_RTC_TAMPER1_EVENT_CB_ID           = 5U,   /*!< RTC Tamper 1 Callback ID           */
255   HAL_RTC_TAMPER2_EVENT_CB_ID           = 6U,   /*!< RTC Tamper 2 Callback ID           */
256   HAL_RTC_TAMPER3_EVENT_CB_ID           = 7U,   /*!< RTC Tamper 3 Callback ID           */
257   HAL_RTC_TAMPER4_EVENT_CB_ID           = 8U,   /*!< RTC Tamper 4 Callback ID           */
258   HAL_RTC_TAMPER5_EVENT_CB_ID           = 9U,   /*!< RTC Tamper 5 Callback ID           */
259   HAL_RTC_TAMPER6_EVENT_CB_ID           = 10U,  /*!< RTC Tamper 6 Callback ID           */
260   HAL_RTC_TAMPER7_EVENT_CB_ID           = 11U,  /*!< RTC Tamper 7 Callback ID           */
261   HAL_RTC_TAMPER8_EVENT_CB_ID           = 12U,  /*!< RTC Tamper 8 Callback ID           */
262   HAL_RTC_INTERNAL_TAMPER1_EVENT_CB_ID  = 13U,  /*!< RTC Internal Tamper 1 Callback ID  */
263   HAL_RTC_INTERNAL_TAMPER2_EVENT_CB_ID  = 14U,  /*!< RTC Internal Tamper 2 Callback ID  */
264   HAL_RTC_INTERNAL_TAMPER3_EVENT_CB_ID  = 15U,  /*!< RTC Internal Tamper 3 Callback ID  */
265   HAL_RTC_INTERNAL_TAMPER4_EVENT_CB_ID  = 16U,  /*!< RTC Internal Tamper 4 Callback ID  */
266   HAL_RTC_INTERNAL_TAMPER5_EVENT_CB_ID  = 17U,  /*!< RTC Internal Tamper 5 Callback ID  */
267   HAL_RTC_INTERNAL_TAMPER6_EVENT_CB_ID  = 18U,  /*!< RTC Internal Tamper 6 Callback ID  */
268   HAL_RTC_INTERNAL_TAMPER7_EVENT_CB_ID  = 19U,  /*!< RTC Internal Tamper 7 Callback ID  */
269   HAL_RTC_INTERNAL_TAMPER8_EVENT_CB_ID  = 20U,  /*!< RTC Internal Tamper 8 Callback ID  */
270   HAL_RTC_INTERNAL_TAMPER9_EVENT_CB_ID  = 21U,  /*!< RTC Internal Tamper 9 Callback ID  */
271   HAL_RTC_INTERNAL_TAMPER11_EVENT_CB_ID = 22U,  /*!< RTC Internal Tamper 11 Callback ID */
272   HAL_RTC_INTERNAL_TAMPER12_EVENT_CB_ID = 23U,  /*!< RTC Internal Tamper 12 Callback ID */
273   HAL_RTC_INTERNAL_TAMPER13_EVENT_CB_ID = 24U,  /*!< RTC Internal Tamper 13 Callback ID */
274   HAL_RTC_INTERNAL_TAMPER15_EVENT_CB_ID = 25U,  /*!< RTC Internal Tamper 15 Callback ID */
275   HAL_RTC_MSPINIT_CB_ID                 = 26U,  /*!< RTC Msp Init callback ID           */
276   HAL_RTC_MSPDEINIT_CB_ID               = 27U   /*!< RTC Msp DeInit callback ID         */
277 } HAL_RTC_CallbackIDTypeDef;
278 
279 /**
280   * @brief  HAL RTC Callback pointer definition
281   */
282 typedef  void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc);  /*!< pointer to an RTC callback function */
283 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
284 
285 /**
286   * @}
287   */
288 
289 /* Exported constants --------------------------------------------------------*/
290 /** @defgroup RTC_Exported_Constants RTC Exported Constants
291   * @{
292   */
293 
294 /** @defgroup RTC_Hour_Formats RTC Hour Formats
295   * @{
296   */
297 #define RTC_HOURFORMAT_24                   0U
298 #define RTC_HOURFORMAT_12                   RTC_CR_FMT
299 /**
300   * @}
301   */
302 
303 /** @defgroup RTCEx_Output_selection_Definitions RTCEx Output Selection Definition
304   * @{
305   */
306 #define RTC_OUTPUT_DISABLE                  0U
307 #define RTC_OUTPUT_ALARMA                   RTC_CR_OSEL_0
308 #define RTC_OUTPUT_ALARMB                   RTC_CR_OSEL_1
309 #define RTC_OUTPUT_WAKEUP                   RTC_CR_OSEL
310 #define RTC_OUTPUT_TAMPER                   RTC_CR_TAMPOE
311 /**
312   * @}
313   */
314 
315 /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions
316   * @{
317   */
318 #define RTC_OUTPUT_POLARITY_HIGH            0U
319 #define RTC_OUTPUT_POLARITY_LOW             RTC_CR_POL
320 /**
321   * @}
322   */
323 
324 /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT
325   * @{
326   */
327 #define RTC_OUTPUT_TYPE_PUSHPULL            0U
328 #define RTC_OUTPUT_TYPE_OPENDRAIN           RTC_CR_TAMPALRM_TYPE
329 /**
330   * @}
331   */
332 
333 /** @defgroup RTC_Output_PullUp_ALARM_OUT RTC Output Pull-Up ALARM OUT
334   * @{
335   */
336 #define RTC_OUTPUT_PULLUP_NONE              0U
337 #define RTC_OUTPUT_PULLUP_ON                RTC_CR_TAMPALRM_PU
338 /**
339   * @}
340   */
341 
342 #if defined(RTC_CR_OUT2EN)
343 /** @defgroup RTC_Output_ALARM_OUT_Remap RTC Output ALARM OUT Remap
344   * @{
345   */
346 #define RTC_OUTPUT_REMAP_NONE               0U
347 #define RTC_OUTPUT_REMAP_POS1               RTC_CR_OUT2EN
348 /**
349   * @}
350   */
351 #endif /* RTC_CR_OUT2EN */
352 
353 /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions
354   * @{
355   */
356 #define RTC_HOURFORMAT12_AM                 0U
357 #define RTC_HOURFORMAT12_PM                 1U
358 /**
359   * @}
360   */
361 
362 /** @defgroup RTC_DayLightSaving_Definitions RTC DayLightSaving Definitions
363   * @{
364   */
365 #define RTC_DAYLIGHTSAVING_SUB1H            RTC_CR_SUB1H
366 #define RTC_DAYLIGHTSAVING_ADD1H            RTC_CR_ADD1H
367 #define RTC_DAYLIGHTSAVING_NONE             0U
368 /**
369   * @}
370   */
371 
372 /** @defgroup RTC_StoreOperation_Definitions RTC StoreOperation Definitions
373   * @{
374   */
375 #define RTC_STOREOPERATION_RESET            0U
376 #define RTC_STOREOPERATION_SET              RTC_CR_BKP
377 /**
378   * @}
379   */
380 
381 /** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions
382   * @{
383   */
384 #define RTC_FORMAT_BIN                      0U
385 #define RTC_FORMAT_BCD                      1U
386 /**
387   * @}
388   */
389 
390 /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions
391   * @{
392   */
393 
394 /* Coded in BCD format */
395 #define RTC_MONTH_JANUARY                   ((uint8_t)0x01U)
396 #define RTC_MONTH_FEBRUARY                  ((uint8_t)0x02U)
397 #define RTC_MONTH_MARCH                     ((uint8_t)0x03U)
398 #define RTC_MONTH_APRIL                     ((uint8_t)0x04U)
399 #define RTC_MONTH_MAY                       ((uint8_t)0x05U)
400 #define RTC_MONTH_JUNE                      ((uint8_t)0x06U)
401 #define RTC_MONTH_JULY                      ((uint8_t)0x07U)
402 #define RTC_MONTH_AUGUST                    ((uint8_t)0x08U)
403 #define RTC_MONTH_SEPTEMBER                 ((uint8_t)0x09U)
404 #define RTC_MONTH_OCTOBER                   ((uint8_t)0x10U)
405 #define RTC_MONTH_NOVEMBER                  ((uint8_t)0x11U)
406 #define RTC_MONTH_DECEMBER                  ((uint8_t)0x12U)
407 
408 /**
409   * @}
410   */
411 
412 /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions
413   * @{
414   */
415 #define RTC_WEEKDAY_MONDAY                  ((uint8_t)0x01U)
416 #define RTC_WEEKDAY_TUESDAY                 ((uint8_t)0x02U)
417 #define RTC_WEEKDAY_WEDNESDAY               ((uint8_t)0x03U)
418 #define RTC_WEEKDAY_THURSDAY                ((uint8_t)0x04U)
419 #define RTC_WEEKDAY_FRIDAY                  ((uint8_t)0x05U)
420 #define RTC_WEEKDAY_SATURDAY                ((uint8_t)0x06U)
421 #define RTC_WEEKDAY_SUNDAY                  ((uint8_t)0x07U)
422 
423 /**
424   * @}
425   */
426 
427 /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC AlarmDateWeekDay Definitions
428   * @{
429   */
430 #define RTC_ALARMDATEWEEKDAYSEL_DATE        0U
431 #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY     RTC_ALRMAR_WDSEL
432 
433 /**
434   * @}
435   */
436 
437 /** @defgroup RTC_AlarmMask_Definitions RTC AlarmMask Definitions
438   * @{
439   */
440 #define RTC_ALARMMASK_NONE                  0U
441 #define RTC_ALARMMASK_DATEWEEKDAY           RTC_ALRMAR_MSK4
442 #define RTC_ALARMMASK_HOURS                 RTC_ALRMAR_MSK3
443 #define RTC_ALARMMASK_MINUTES               RTC_ALRMAR_MSK2
444 #define RTC_ALARMMASK_SECONDS               RTC_ALRMAR_MSK1
445 #define RTC_ALARMMASK_ALL                   (RTC_ALARMMASK_DATEWEEKDAY | RTC_ALARMMASK_HOURS  | \
446                                              RTC_ALARMMASK_MINUTES | RTC_ALARMMASK_SECONDS)
447 
448 /**
449   * @}
450   */
451 
452 /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions
453   * @{
454   */
455 #define RTC_ALARM_A                         RTC_CR_ALRAE
456 #define RTC_ALARM_B                         RTC_CR_ALRBE
457 
458 /**
459   * @}
460   */
461 /** @defgroup RTC_ALARM_Flag_AutoClear_Definitions RTC Alarms Flag Auto Clear Definitions
462   * @{
463   */
464 #define ALARM_FLAG_AUTOCLR_ENABLE           1U
465 #define ALARM_FLAG_AUTOCLR_DISABLE          0U
466 /**
467   * @}
468   */
469 
470 /** @defgroup RTC_Alarm_Sub_Seconds_BCD_Masks_Definitions RTC Alarm Sub Seconds BCD Masks Definitions
471   *           In BCD mode (BIN=00) the overflow bits of the synchronous counter (bits 31:15) are never compared.
472   * @{
473   */
474 #define RTC_ALARMSUBSECONDMASK_ALL          0U                                                                       /*!< All Alarm SS fields are masked. There is no comparison on sub seconds for Alarm */
475 #define RTC_ALARMSUBSECONDMASK_SS14_1       RTC_ALRMASSR_MASKSS_0                                                    /*!< SS[14:1] not used in Alarmcomparison. Only SS[0] is compared                    */
476 #define RTC_ALARMSUBSECONDMASK_SS14_2       RTC_ALRMASSR_MASKSS_1                                                    /*!< SS[14:2] not used in Alarm comparison. Only SS[1:0] are compared                */
477 #define RTC_ALARMSUBSECONDMASK_SS14_3       (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1)                          /*!< SS[14:3] not used in Alarm comparison. Only SS[2:0] are compared                */
478 #define RTC_ALARMSUBSECONDMASK_SS14_4       RTC_ALRMASSR_MASKSS_2                                                    /*!< SS[14:4] not used in Alarm comparison. Only SS[3:0] are compared                */
479 #define RTC_ALARMSUBSECONDMASK_SS14_5       (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2)                          /*!< SS[14:5] not used in Alarm comparison. Only SS[4:0] are compared                */
480 #define RTC_ALARMSUBSECONDMASK_SS14_6       (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)                          /*!< SS[14:6] not used in Alarm comparison. Only SS[5:0] are compared                */
481 #define RTC_ALARMSUBSECONDMASK_SS14_7       (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)  /*!< SS[14:7] not used in Alarm comparison. Only SS[6:0] are compared                */
482 #define RTC_ALARMSUBSECONDMASK_SS14_8       RTC_ALRMASSR_MASKSS_3                                                    /*!< SS[14:8] not used in Alarm comparison. Only SS[7:0] are compared                */
483 #define RTC_ALARMSUBSECONDMASK_SS14_9       (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_3)                          /*!< SS[14:9] not used in Alarm comparison. Only SS[8:0] are compared                */
484 #define RTC_ALARMSUBSECONDMASK_SS14_10      (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)                          /*!< SS[14:10] not used in Alarm comparison. Only SS[9:0] are compared               */
485 #define RTC_ALARMSUBSECONDMASK_SS14_11      (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)  /*!< SS[14:11] not used in Alarm comparison. Only SS[10:0] are compared              */
486 #define RTC_ALARMSUBSECONDMASK_SS14_12      (RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)                          /*!< SS[14:12] not used in Alarm comparison.Only SS[11:0] are compared               */
487 #define RTC_ALARMSUBSECONDMASK_SS14_13      (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)  /*!< SS[14:13] not used in Alarm comparison. Only SS[12:0] are compared              */
488 #define RTC_ALARMSUBSECONDMASK_SS14         (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)  /*!< SS[14] not used in Alarm comparison. Only SS[13:0] are compared                 */
489 #define RTC_ALARMSUBSECONDMASK_NONE         RTC_ALRMASSR_MASKSS                                                      /*!< SS[14:0] are compared and must match to activate alarm                          */
490 /**
491   * @}
492   */
493 
494 /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions
495   * @{
496   */
497 #define RTC_IT_TS                           RTC_CR_TSIE        /*!< Enable Timestamp Interrupt     */
498 #define RTC_IT_WUT                          RTC_CR_WUTIE       /*!< Enable Wakeup timer Interrupt  */
499 #define RTC_IT_SSRU                         RTC_CR_SSRUIE      /*!< Enable SSR Underflow Interrupt */
500 #define RTC_IT_ALRA                         RTC_CR_ALRAIE      /*!< Enable Alarm A Interrupt       */
501 #define RTC_IT_ALRB                         RTC_CR_ALRBIE      /*!< Enable Alarm B Interrupt       */
502 /**
503   * @}
504   */
505 
506 /** @defgroup RTC_Flags_Definitions RTC Flag Mask (5bits) for __HAL_RTC_GET_FLAG()
507   * @{
508   */
509 #define RTC_FLAG_RECALPF                    (1U)               /*!< Recalibration pending flag     */
510 #define RTC_FLAG_INITF                      (2U)               /*!< Initialization flag            */
511 #define RTC_FLAG_RSF                        (3U)               /*!< Registers synchronization flag */
512 #define RTC_FLAG_INITS                      (4U)               /*!< Initialization status flag     */
513 #define RTC_FLAG_SHPF                       (5U)               /*!< Shift operation pending flag   */
514 #define RTC_FLAG_WUTWF                      (6U)               /*!< Wakeup timer write flag        */
515 #define RTC_FLAG_SSRUF                      (7U)               /*!< Clear SSR underflow flag       */
516 #define RTC_FLAG_ITSF                       (8U)               /*!< Clear Internal Time-stamp flag */
517 #define RTC_FLAG_TSOVF                      (9U)               /*!< Clear Time-stamp overflow flag */
518 #define RTC_FLAG_TSF                        (10U)              /*!< Clear Time-stamp flag          */
519 #define RTC_FLAG_WUTF                       (11U)              /*!< Clear Wakeup timer flag        */
520 #define RTC_FLAG_ALRBF                      (12U)              /*!< Clear Alarm B flag             */
521 #define RTC_FLAG_ALRAF                      (13U)              /*!< Clear Alarm A flag             */
522 /**
523   * @}
524   */
525 
526 /** @defgroup RTC_Clear_Flags_Definitions RTC Clear Flags Definitions
527   * @{
528   */
529 #define RTC_CLEAR_SSRUF                     RTC_SCR_CSSRUF   /*!< Clear SSR underflow flag       */
530 #define RTC_CLEAR_ITSF                      RTC_SCR_CITSF    /*!< Clear Internal Time-stamp flag */
531 #define RTC_CLEAR_TSOVF                     RTC_SCR_CTSOVF   /*!< Clear Time-stamp overflow flag */
532 #define RTC_CLEAR_TSF                       RTC_SCR_CTSF     /*!< Clear Time-stamp flag          */
533 #define RTC_CLEAR_WUTF                      RTC_SCR_CWUTF    /*!< Clear Wakeup timer flag        */
534 #define RTC_CLEAR_ALRBF                     RTC_SCR_CALRBF   /*!< Clear Alarm B flag             */
535 #define RTC_CLEAR_ALRAF                     RTC_SCR_CALRAF   /*!< Clear Alarm A flag             */
536 /**
537   * @}
538   */
539 
540 /**
541   * @}
542   */
543 
544 /* Exported macros -----------------------------------------------------------*/
545 /** @defgroup RTC_Exported_Macros RTC Exported Macros
546   * @{
547   */
548 
549 /** @brief Reset RTC handle state
550   * @param  __HANDLE__ RTC handle.
551   * @retval None
552   */
553 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
554 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{\
555                                                       (__HANDLE__)->State = HAL_RTC_STATE_RESET;\
556                                                       (__HANDLE__)->MspInitCallback = NULL;\
557                                                       (__HANDLE__)->MspDeInitCallback = NULL;\
558                                                      }while(0)
559 #else
560 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
561 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
562 
563 /**
564   * @brief  Disable the write protection for RTC registers.
565   * @param  __HANDLE__ specifies the RTC handle.
566   * @retval None
567   */
568 #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__)             \
569   do{                                       \
570     RTC->WPR = 0xCAU;   \
571     RTC->WPR = 0x53U;   \
572   } while(0U)
573 
574 /**
575   * @brief  Enable the write protection for RTC registers.
576   * @param  __HANDLE__ specifies the RTC handle.
577   * @retval None
578   */
579 #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__)              \
580   do{                                       \
581     RTC->WPR = 0xFFU;   \
582   } while(0U)
583 
584 /**
585   * @brief  Add 1 hour (summer time change).
586   * @note   This interface is deprecated.
587   *         To manage Daylight Saving Time, please use HAL_RTC_DST_xxx functions
588   * @param  __HANDLE__ specifies the RTC handle.
589   * @param  __BKP__ Backup
590   *         This parameter can be:
591   *            @arg @ref RTC_STOREOPERATION_RESET
592   *            @arg @ref RTC_STOREOPERATION_SET
593   * @retval None
594   */
595 #define __HAL_RTC_DAYLIGHT_SAVING_TIME_ADD1H(__HANDLE__, __BKP__)                         \
596   do {                                                              \
597     __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__);                \
598     SET_BIT(RTC->CR, RTC_CR_ADD1H);            \
599     MODIFY_REG(RTC->CR, RTC_CR_BKP , (__BKP__)); \
600     __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__);                 \
601   } while(0);
602 
603 /**
604   * @brief  Subtract 1 hour (winter time change).
605   * @note   This interface is deprecated.
606   *         To manage Daylight Saving Time, please use HAL_RTC_DST_xxx functions
607   * @param  __HANDLE__ specifies the RTC handle.
608   * @param  __BKP__ Backup
609   *         This parameter can be:
610   *            @arg @ref RTC_STOREOPERATION_RESET
611   *            @arg @ref RTC_STOREOPERATION_SET
612   * @retval None
613   */
614 #define __HAL_RTC_DAYLIGHT_SAVING_TIME_SUB1H(__HANDLE__, __BKP__)                         \
615   do {                                                              \
616     __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__);                \
617     SET_BIT(RTC->CR, RTC_CR_SUB1H);            \
618     MODIFY_REG(RTC->CR, RTC_CR_BKP , (__BKP__)); \
619     __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__);                 \
620   } while(0);
621 
622 /**
623   * @brief  Enable the RTC ALARMA peripheral.
624   * @param  __HANDLE__ specifies the RTC handle.
625   * @retval None
626   */
627 #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__)  (RTC->CR |= (RTC_CR_ALRAE))
628 
629 /**
630   * @brief  Disable the RTC ALARMA peripheral.
631   * @param  __HANDLE__ specifies the RTC handle.
632   * @retval None
633   */
634 #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__)  (RTC->CR &= ~(RTC_CR_ALRAE))
635 
636 /**
637   * @brief  Enable the RTC ALARMB peripheral.
638   * @param  __HANDLE__ specifies the RTC handle.
639   * @retval None
640   */
641 #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__)   (RTC->CR |= (RTC_CR_ALRBE))
642 
643 /**
644   * @brief  Disable the RTC ALARMB peripheral.
645   * @param  __HANDLE__ specifies the RTC handle.
646   * @retval None
647   */
648 #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__)  (RTC->CR &= ~(RTC_CR_ALRBE))
649 
650 /**
651   * @brief  Enable the RTC Alarm interrupt.
652   * @param  __HANDLE__ specifies the RTC handle.
653   * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
654   *          This parameter can be any combination of the following values:
655   *             @arg @ref RTC_IT_ALRA Alarm A interrupt
656   *             @arg @ref RTC_IT_ALRB Alarm B interrupt
657   * @retval None
658   */
659 #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__)( \
660                                                               ((__INTERRUPT__) == RTC_IT_ALRA) ?\
661                                                               (SET_BIT(RTC->CR, RTC_CR_ALRAIE)):\
662                                                               ((__INTERRUPT__) == RTC_IT_ALRB) ?\
663                                                               (SET_BIT(RTC->CR, RTC_CR_ALRBIE)):\
664                                                               (0U)) /*!< Dummy action because is an invalid parameter value */
665 
666 /**
667   * @brief  Disable the RTC Alarm interrupt.
668   * @param  __HANDLE__ specifies the RTC handle.
669   * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
670   *         This parameter can be any combination of the following values:
671   *            @arg @ref RTC_IT_ALRA Alarm A interrupt
672   *            @arg @ref RTC_IT_ALRB Alarm B interrupt
673   * @retval None
674   */
675 #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__)( \
676                                                                ((__INTERRUPT__) == RTC_IT_ALRA) ?\
677                                                                (CLEAR_BIT(RTC->CR, RTC_CR_ALRAIE)):\
678                                                                ((__INTERRUPT__) == RTC_IT_ALRB) ?\
679                                                                (CLEAR_BIT(RTC->CR, RTC_CR_ALRBIE)):\
680                                                                (0U)) /*!< Dummy action because is an invalid parameter value */
681 
682 /**
683   * @brief  Check whether the specified RTC Alarm interrupt has occurred or not.
684   * @param  __HANDLE__ specifies the RTC handle.
685   * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
686   *         This parameter can be:
687   *            @arg @ref RTC_IT_ALRA Alarm A interrupt
688   *            @arg @ref RTC_IT_ALRB Alarm B interrupt
689   * @retval The state of __INTERRUPT__ (TRUE or FALSE).
690   */
691 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__)( \
692                                                            ((__INTERRUPT__) == RTC_IT_ALRA) ?\
693                                                            (READ_BIT(RTC->MISR, RTC_MISR_ALRAMF) == RTC_MISR_ALRAMF):\
694                                                            ((__INTERRUPT__) == RTC_IT_ALRB) ?\
695                                                            (READ_BIT(RTC->MISR, RTC_MISR_ALRBMF) == RTC_MISR_ALRBMF):\
696                                                            (0U)) /*!< Return 0 because it is an invalid parameter value */
697 
698 /**
699   * @brief  Check whether the specified RTC Alarm interrupt has been enabled or not.
700   * @param  __HANDLE__ specifies the RTC handle.
701   * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
702   *         This parameter can be:
703   *            @arg @ref RTC_IT_ALRA Alarm A interrupt
704   *            @arg @ref RTC_IT_ALRB Alarm B interrupt
705   * @retval The state of __INTERRUPT__ (TRUE or FALSE).
706   */
707 #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)( \
708                                                                   ((__INTERRUPT__) == RTC_IT_ALRA) ?\
709                                                                   (READ_BIT(RTC->CR, RTC_CR_ALRAIE) == RTC_CR_ALRAIE):\
710                                                                   ((__INTERRUPT__) == RTC_IT_ALRB) ?\
711                                                                   (READ_BIT(RTC->CR, RTC_CR_ALRBIE) == RTC_CR_ALRBIE):\
712                                                                   (0U)) /*!< Return 0 because it is an invalid parameter value */
713 
714 /**
715   * @brief  Get the selected RTC Alarms flag status.
716   * @param  __HANDLE__ specifies the RTC handle.
717   * @param  __FLAG__ specifies the RTC Alarm Flag sources to check.
718   *         This parameter can be:
719   *            @arg @ref RTC_FLAG_ALRAF
720   *            @arg @ref RTC_FLAG_ALRBF
721   * @retval The state of __FLAG__ (TRUE or FALSE).
722   */
723 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__)( \
724                                                         ((__FLAG__) == RTC_FLAG_ALRAF) ?\
725                                                         (READ_BIT(RTC->SR, RTC_SR_ALRAF) == RTC_SR_ALRAF):\
726                                                         ((__FLAG__) == RTC_FLAG_ALRBF) ?\
727                                                         (READ_BIT(RTC->SR, RTC_SR_ALRBF) == RTC_SR_ALRBF):\
728                                                         (0U)) /*!< Return 0 because it is an invalid parameter value */
729 
730 /**
731   * @brief  Clear the RTC Alarms pending flags.
732   * @param  __HANDLE__ specifies the RTC handle.
733   * @param  __FLAG__ specifies the RTC Alarm Flag sources to clear.
734   *          This parameter can be:
735   *             @arg @ref RTC_FLAG_ALRAF
736   *             @arg @ref RTC_FLAG_ALRBF
737   * @retval None
738   */
739 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__)( \
740                                                           ((__FLAG__) == RTC_FLAG_ALRAF) ?\
741                                                           (SET_BIT(RTC->SCR, RTC_SCR_CALRAF)):\
742                                                           ((__FLAG__) == RTC_FLAG_ALRBF) ?\
743                                                           (SET_BIT(RTC->SCR, RTC_SCR_CALRBF)):\
744                                                           (0U)) /*!< Dummy action because is an invalid parameter value */
745 
746 /**
747   * @brief  Check whether if the RTC Calendar is initialized.
748   * @param  __HANDLE__ specifies the RTC handle.
749   * @retval The state of RTC Calendar initialization (TRUE or FALSE).
750   */
751 #define __HAL_RTC_IS_CALENDAR_INITIALIZED(__HANDLE__)  ((((RTC->ICSR) & (RTC_ICSR_INITS)) == RTC_ICSR_INITS))
752 
753 /**
754   * @}
755   */
756 
757 /* Include RTC HAL Extended module */
758 #include "stm32h5xx_hal_rtc_ex.h"
759 
760 /* Exported functions --------------------------------------------------------*/
761 /** @defgroup RTC_Exported_Functions RTC Exported Functions
762   * @{
763   */
764 
765 /** @defgroup RTC_Exported_Functions_Group1 Initialization and de-initialization functions
766   * @{
767   */
768 /* Initialization and de-initialization functions  ****************************/
769 HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc);
770 HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc);
771 
772 void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc);
773 void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc);
774 
775 /* Callbacks Register/UnRegister functions  ***********************************/
776 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
777 HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID,
778                                            pRTC_CallbackTypeDef pCallback);
779 HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID);
780 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
781 
782 /**
783   * @}
784   */
785 
786 /** @defgroup RTC_Exported_Functions_Group2 RTC Time and Date functions
787   * @{
788   */
789 /* RTC Time and Date functions ************************************************/
790 HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
791 HAL_StatusTypeDef HAL_RTC_GetTime(const RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
792 HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
793 HAL_StatusTypeDef HAL_RTC_GetDate(const RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
794 void              HAL_RTC_DST_Add1Hour(const RTC_HandleTypeDef *hrtc);
795 void              HAL_RTC_DST_Sub1Hour(const RTC_HandleTypeDef *hrtc);
796 void              HAL_RTC_DST_SetStoreOperation(const RTC_HandleTypeDef *hrtc);
797 void              HAL_RTC_DST_ClearStoreOperation(const RTC_HandleTypeDef *hrtc);
798 uint32_t          HAL_RTC_DST_ReadStoreOperation(const RTC_HandleTypeDef *hrtc);
799 /**
800   * @}
801   */
802 
803 /** @defgroup RTC_Exported_Functions_Group3 RTC Alarm functions
804   * @{
805   */
806 /* RTC Alarm functions ********************************************************/
807 HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
808 HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
809 HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm);
810 HAL_StatusTypeDef HAL_RTC_GetAlarm(const RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm,
811                                    uint32_t Format);
812 void              HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc);
813 HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(const RTC_HandleTypeDef *hrtc, uint32_t Timeout);
814 void              HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc);
815 
816 /**
817   * @}
818   */
819 
820 /** @defgroup  RTC_Exported_Functions_Group4 Peripheral Control functions
821   * @{
822   */
823 /* Peripheral Control functions ***********************************************/
824 HAL_StatusTypeDef   HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc);
825 /**
826   * @}
827   */
828 
829 /** @defgroup RTC_Exported_Functions_Group5 Peripheral State functions
830   * @{
831   */
832 /* Peripheral State functions *************************************************/
833 HAL_RTCStateTypeDef HAL_RTC_GetState(const RTC_HandleTypeDef *hrtc);
834 /**
835   * @}
836   */
837 
838 /**
839   * @}
840   */
841 
842 /* Private types -------------------------------------------------------------*/
843 /* Private variables ---------------------------------------------------------*/
844 /* Private constants ---------------------------------------------------------*/
845 /** @defgroup RTC_Private_Constants RTC Private Constants
846   * @{
847   */
848 /* Masks Definition */
849 #define RTC_TR_RESERVED_MASK                (RTC_TR_PM | RTC_TR_HT | RTC_TR_HU | \
850                                              RTC_TR_MNT | RTC_TR_MNU| RTC_TR_ST | \
851                                              RTC_TR_SU)
852 #define RTC_DR_RESERVED_MASK                (RTC_DR_YT | RTC_DR_YU | RTC_DR_WDU | \
853                                              RTC_DR_MT | RTC_DR_MU | RTC_DR_DT  | \
854                                              RTC_DR_DU)
855 #define RTC_INIT_MASK                       0xFFFFFFFFU
856 #define RTC_RSF_MASK                        (~(RTC_ICSR_INIT | RTC_ICSR_RSF))
857 
858 #define RTC_TIMEOUT_VALUE                   1000U
859 
860 /**
861   * @}
862   */
863 
864 /* Private macros ------------------------------------------------------------*/
865 /** @defgroup RTC_Private_Macros RTC Private Macros
866   * @{
867   */
868 
869 /** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters
870   * @{
871   */
872 #if defined(RTC_CR_OSEL)
873 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
874                                ((OUTPUT) == RTC_OUTPUT_ALARMA)  || \
875                                ((OUTPUT) == RTC_OUTPUT_ALARMB)  || \
876                                ((OUTPUT) == RTC_OUTPUT_WAKEUP)  || \
877                                ((OUTPUT) == RTC_OUTPUT_TAMPER))
878 #endif /* RTC_CR_OSEL */
879 
880 #define IS_RTC_HOUR_FORMAT(FORMAT)     (((FORMAT) == RTC_HOURFORMAT_12) || \
881                                         ((FORMAT) == RTC_HOURFORMAT_24))
882 
883 #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \
884                                 ((POL) == RTC_OUTPUT_POLARITY_LOW))
885 
886 #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \
887                                   ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL))
888 
889 #define IS_RTC_OUTPUT_PULLUP(TYPE) (((TYPE) == RTC_OUTPUT_PULLUP_NONE) || \
890                                     ((TYPE) == RTC_OUTPUT_PULLUP_ON))
891 
892 #if defined(RTC_CR_OUT2EN)
893 #define IS_RTC_OUTPUT_REMAP(REMAP)   (((REMAP) == RTC_OUTPUT_REMAP_NONE) || \
894                                       ((REMAP) == RTC_OUTPUT_REMAP_POS1))
895 #endif /* RTC_CR_OUT2EN */
896 
897 #define IS_RTC_HOURFORMAT12(PM)  (((PM) == RTC_HOURFORMAT12_AM) || \
898                                   ((PM) == RTC_HOURFORMAT12_PM))
899 
900 #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \
901                                       ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \
902                                       ((SAVE) == RTC_DAYLIGHTSAVING_NONE))
903 
904 #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \
905                                            ((OPERATION) == RTC_STOREOPERATION_SET))
906 
907 #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || \
908                                ((FORMAT) == RTC_FORMAT_BCD))
909 
910 #define IS_RTC_YEAR(YEAR)              ((YEAR) <= 99U)
911 
912 #define IS_RTC_MONTH(MONTH)            (((MONTH) >= 1U) && ((MONTH) <= 12U))
913 
914 #define IS_RTC_DATE(DATE)              (((DATE) >= 1U) && ((DATE) <= 31U))
915 
916 #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY)    || \
917                                  ((WEEKDAY) == RTC_WEEKDAY_TUESDAY)   || \
918                                  ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
919                                  ((WEEKDAY) == RTC_WEEKDAY_THURSDAY)  || \
920                                  ((WEEKDAY) == RTC_WEEKDAY_FRIDAY)    || \
921                                  ((WEEKDAY) == RTC_WEEKDAY_SATURDAY)  || \
922                                  ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
923 
924 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0U) && ((DATE) <= 31U))
925 
926 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY)    || \
927                                                     ((WEEKDAY) == RTC_WEEKDAY_TUESDAY)   || \
928                                                     ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
929                                                     ((WEEKDAY) == RTC_WEEKDAY_THURSDAY)  || \
930                                                     ((WEEKDAY) == RTC_WEEKDAY_FRIDAY)    || \
931                                                     ((WEEKDAY) == RTC_WEEKDAY_SATURDAY)  || \
932                                                     ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
933 
934 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \
935                                             ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY))
936 
937 #define IS_RTC_ALARM_MASK(MASK)  (((MASK) & ~(RTC_ALARMMASK_ALL)) == 0UL)
938 
939 #define IS_RTC_ALARM(ALARM)      (((ALARM) == RTC_ALARM_A) || \
940                                   ((ALARM) == RTC_ALARM_B))
941 
942 #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= RTC_ALRMASSR_SS)
943 
944 #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK)          (((MASK) == 0UL) || \
945                                                      (((MASK) >= RTC_ALARMSUBSECONDMASK_SS14_1) && \
946                                                       ((MASK) <= RTC_ALARMSUBSECONDMASK_NONE)))
947 
948 #define IS_RTC_ASYNCH_PREDIV(PREDIV)   ((PREDIV) <= (RTC_PRER_PREDIV_A >> RTC_PRER_PREDIV_A_Pos))
949 
950 #define IS_RTC_SYNCH_PREDIV(PREDIV)    ((PREDIV) <= (RTC_PRER_PREDIV_S >> RTC_PRER_PREDIV_S_Pos))
951 
952 #define IS_RTC_HOUR12(HOUR)            (((HOUR) > 0U) && ((HOUR) <= 12U))
953 
954 #define IS_RTC_HOUR24(HOUR)            ((HOUR) <= 23U)
955 
956 #define IS_RTC_MINUTES(MINUTES)        ((MINUTES) <= 59U)
957 
958 #define IS_RTC_SECONDS(SECONDS)        ((SECONDS) <= 59U)
959 
960 /**
961   * @}
962   */
963 
964 /**
965   * @}
966   */
967 
968 /* Private functions -------------------------------------------------------------*/
969 /** @defgroup RTC_Private_Functions RTC Private Functions
970   * @{
971   */
972 HAL_StatusTypeDef  RTC_EnterInitMode(RTC_HandleTypeDef *hrtc);
973 HAL_StatusTypeDef  RTC_ExitInitMode(RTC_HandleTypeDef *hrtc);
974 uint8_t            RTC_ByteToBcd2(uint8_t Value);
975 uint8_t            RTC_Bcd2ToByte(uint8_t Value);
976 /**
977   * @}
978   */
979 
980 /**
981   * @}
982   */
983 
984 /**
985   * @}
986   */
987 
988 #ifdef __cplusplus
989 }
990 #endif
991 
992 #endif /* STM32H5xx_HAL_RTC_H */
993