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