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