• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2   ******************************************************************************
3   * @file    stm32mp1xx_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 STM32MP1xx_HAL_RTC_H
22 #define STM32MP1xx_HAL_RTC_H
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32mp1xx_hal_def.h"
30 
31 /** @addtogroup STM32MP1xx_HAL_Driver
32   * @{
33   */
34 
35 /** @defgroup RTC RTC
36   * @{
37   */
38 
39 /* Exported types ------------------------------------------------------------*/
40 /** @defgroup RTC_Exported_Types RTC Exported Types
41   * @{
42   */
43 
44 /**
45   * @brief  HAL State structures definition
46   */
47 typedef enum
48 {
49   HAL_RTC_STATE_RESET             = 0x00U,  /*!< RTC not yet initialized or disabled */
50   HAL_RTC_STATE_READY             = 0x01U,  /*!< RTC initialized and ready for use   */
51   HAL_RTC_STATE_BUSY              = 0x02U,  /*!< RTC process is ongoing              */
52   HAL_RTC_STATE_TIMEOUT           = 0x03U,  /*!< RTC timeout state                   */
53   HAL_RTC_STATE_ERROR             = 0x04U   /*!< RTC error state                     */
54 
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 = 0x00 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 RTCEx_Output_selection_Definitions */
73 
74   uint32_t OutPutRemap;       /*!< Specifies the remap for RTC output.
75                                  This parameter can be a value of @ref  RTC_Output_ALARM_OUT_Remap */
76 
77   uint32_t OutPutPolarity;    /*!< Specifies the polarity of the output signal.
78                                  This parameter can be a value of @ref RTC_Output_Polarity_Definitions */
79 
80   uint32_t OutPutType;        /*!< Specifies the RTC Output Pin mode.
81                                  This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */
82 
83   uint32_t OutPutPullUp;      /*!< Specifies the RTC Output Pull-Up mode.
84                                  This parameter can be a value of @ref RTC_Output_PullUp_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 BKP 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 /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
174 {
175   RTC_TypeDef               *Instance;  /*!< Legacy register base address. Not used anymore, the driver directly uses cmsis 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   void (* AlarmBEventCallback)(struct __RTC_HandleTypeDef *hrtc);                    /*!< RTC Alarm B Event callback            */
186   void (* TimeStampEventCallback)(struct __RTC_HandleTypeDef *hrtc);                 /*!< RTC TimeStamp Event callback          */
187   void (* WakeUpTimerEventCallback)(struct __RTC_HandleTypeDef *hrtc);               /*!< RTC WakeUpTimer Event callback        */
188   void (* Tamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc);                   /*!< RTC Tamper 1 Event callback           */
189   void (* Tamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc);                   /*!< RTC Tamper 2 Event callback           */
190   void (* Tamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc);                   /*!< RTC Tamper 3 Event callback           */
191   void (* InternalTamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Internal Tamper 1 Event callback  */
192   void (* InternalTamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Internal Tamper 2 Event callback  */
193   void (* InternalTamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Internal Tamper 3 Event callback  */
194   void (* InternalTamper4EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Internal Tamper 4 Event callback  */
195   void (* InternalTamper5EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Internal Tamper 5 Event callback  */
196   void (* InternalTamper8EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Internal Tamper 8 Event callback  */
197   void (* MspInitCallback)(struct __RTC_HandleTypeDef *hrtc);                        /*!< RTC Msp Init callback                 */
198   void (* MspDeInitCallback)(struct __RTC_HandleTypeDef *hrtc);                      /*!< RTC Msp DeInit callback               */
199 
200 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
201 
202 } RTC_HandleTypeDef;
203 
204 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
205 /**
206   * @brief  HAL RTC Callback ID enumeration definition
207   */
208 typedef enum
209 {
210   HAL_RTC_ALARM_A_EVENT_CB_ID            = 0U,    /*!< RTC Alarm A Event Callback ID      */
211   HAL_RTC_ALARM_B_EVENT_CB_ID            = 1U,    /*!< RTC Alarm B Event Callback ID      */
212   HAL_RTC_TIMESTAMP_EVENT_CB_ID          = 2U,    /*!< RTC TimeStamp Event Callback ID    */
213   HAL_RTC_WAKEUPTIMER_EVENT_CB_ID        = 3U,    /*!< RTC WakeUp Timer Event Callback ID */
214   HAL_RTC_TAMPER1_EVENT_CB_ID            = 4U,    /*!< RTC Tamper 1 Callback ID           */
215   HAL_RTC_TAMPER2_EVENT_CB_ID            = 5U,    /*!< RTC Tamper 2 Callback ID           */
216   HAL_RTC_TAMPER3_EVENT_CB_ID            = 6U,    /*!< RTC Tamper 3 Callback ID           */
217   HAL_RTC_INTERNAL_TAMPER1_EVENT_CB_ID   = 12U,    /*!< RTC Internal Tamper 1 Callback ID  */
218   HAL_RTC_INTERNAL_TAMPER2_EVENT_CB_ID   = 13U,    /*!< RTC Internal Tamper 2 Callback ID  */
219   HAL_RTC_INTERNAL_TAMPER3_EVENT_CB_ID   = 14U,    /*!< RTC Internal Tamper 3 Callback ID  */
220   HAL_RTC_INTERNAL_TAMPER5_EVENT_CB_ID   = 15U,    /*!< RTC Internal Tamper 5 Callback ID  */
221   HAL_RTC_INTERNAL_TAMPER8_EVENT_CB_ID   = 16U,    /*!< RTC Internal Tamper 8 Callback ID  */
222   HAL_RTC_MSPINIT_CB_ID                  = 34U,    /*!< RTC Msp Init callback ID           */
223   HAL_RTC_MSPDEINIT_CB_ID                = 35U     /*!< RTC Msp DeInit callback ID         */
224 } HAL_RTC_CallbackIDTypeDef;
225 
226 /**
227   * @brief  HAL RTC Callback pointer definition
228   */
229 typedef  void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc);  /*!< pointer to an RTC callback function */
230 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
231 
232 /**
233   * @}
234   */
235 
236 /* Exported constants --------------------------------------------------------*/
237 /** @defgroup RTC_Exported_Constants RTC Exported Constants
238   * @{
239   */
240 
241 /** @defgroup RTC_Hour_Formats RTC Hour Formats
242   * @{
243   */
244 #define RTC_HOURFORMAT_24                   0x00000000u
245 #define RTC_HOURFORMAT_12                   RTC_CR_FMT
246 /**
247   * @}
248   */
249 
250 /** @defgroup RTCEx_Output_selection_Definitions RTCEx Output Selection Definition
251   * @{
252   */
253 #define RTC_OUTPUT_DISABLE                  0x00000000u
254 #define RTC_OUTPUT_ALARMA                   RTC_CR_OSEL_0
255 #define RTC_OUTPUT_ALARMB                   RTC_CR_OSEL_1
256 #define RTC_OUTPUT_WAKEUP                   RTC_CR_OSEL
257 #define RTC_OUTPUT_TAMPER                   RTC_CR_TAMPOE
258 /**
259   * @}
260   */
261 
262 
263 /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions
264   * @{
265   */
266 #define RTC_OUTPUT_POLARITY_HIGH            0x00000000u
267 #define RTC_OUTPUT_POLARITY_LOW             RTC_CR_POL
268 /**
269   * @}
270   */
271 
272 /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT
273   * @{
274   */
275 #define RTC_OUTPUT_TYPE_PUSHPULL            0x00000000u
276 #define RTC_OUTPUT_TYPE_OPENDRAIN           RTC_CR_TAMPALRM_TYPE
277 /**
278   * @}
279   */
280 
281 /** @defgroup RTC_Output_PullUp_ALARM_OUT RTC Output Pull-Up ALARM OUT
282   * @{
283   */
284 #define RTC_OUTPUT_PULLUP_NONE              0x00000000u
285 #define RTC_OUTPUT_PULLUP_ON                RTC_CR_TAMPALRM_PU
286 /**
287   * @}
288   */
289 
290 /** @defgroup RTC_Output_ALARM_OUT_Remap RTC Output ALARM OUT Remap
291   * @{
292   */
293 #define RTC_OUTPUT_REMAP_NONE               0x00000000u
294 #define RTC_OUTPUT_REMAP_POS1               RTC_CR_OUT2EN
295 /**
296   * @}
297   */
298 
299 /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions
300   * @{
301   */
302 #define RTC_HOURFORMAT12_AM                 0x0u
303 #define RTC_HOURFORMAT12_PM                 0x1u
304 /**
305   * @}
306   */
307 
308 /** @defgroup RTC_DayLightSaving_Definitions RTC DayLightSaving Definitions
309   * @{
310   */
311 #define RTC_DAYLIGHTSAVING_SUB1H            RTC_CR_SUB1H
312 #define RTC_DAYLIGHTSAVING_ADD1H            RTC_CR_ADD1H
313 #define RTC_DAYLIGHTSAVING_NONE             0x00000000u
314 /**
315   * @}
316   */
317 
318 /** @defgroup RTC_StoreOperation_Definitions RTC StoreOperation Definitions
319   * @{
320   */
321 #define RTC_STOREOPERATION_RESET            0x00000000u
322 #define RTC_STOREOPERATION_SET              RTC_CR_BKP
323 /**
324   * @}
325   */
326 
327 /** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions
328   * @{
329   */
330 #define RTC_FORMAT_BIN                      0x00000000u
331 #define RTC_FORMAT_BCD                      0x00000001u
332 /**
333   * @}
334   */
335 
336 /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions
337   * @{
338   */
339 
340 /* Coded in BCD format */
341 #define RTC_MONTH_JANUARY                   ((uint8_t)0x01U)
342 #define RTC_MONTH_FEBRUARY                  ((uint8_t)0x02U)
343 #define RTC_MONTH_MARCH                     ((uint8_t)0x03U)
344 #define RTC_MONTH_APRIL                     ((uint8_t)0x04U)
345 #define RTC_MONTH_MAY                       ((uint8_t)0x05U)
346 #define RTC_MONTH_JUNE                      ((uint8_t)0x06U)
347 #define RTC_MONTH_JULY                      ((uint8_t)0x07U)
348 #define RTC_MONTH_AUGUST                    ((uint8_t)0x08U)
349 #define RTC_MONTH_SEPTEMBER                 ((uint8_t)0x09U)
350 #define RTC_MONTH_OCTOBER                   ((uint8_t)0x10U)
351 #define RTC_MONTH_NOVEMBER                  ((uint8_t)0x11U)
352 #define RTC_MONTH_DECEMBER                  ((uint8_t)0x12U)
353 
354 /**
355   * @}
356   */
357 
358 /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions
359   * @{
360   */
361 #define RTC_WEEKDAY_MONDAY                  ((uint8_t)0x01U)
362 #define RTC_WEEKDAY_TUESDAY                 ((uint8_t)0x02U)
363 #define RTC_WEEKDAY_WEDNESDAY               ((uint8_t)0x03U)
364 #define RTC_WEEKDAY_THURSDAY                ((uint8_t)0x04U)
365 #define RTC_WEEKDAY_FRIDAY                  ((uint8_t)0x05U)
366 #define RTC_WEEKDAY_SATURDAY                ((uint8_t)0x06U)
367 #define RTC_WEEKDAY_SUNDAY                  ((uint8_t)0x07U)
368 
369 /**
370   * @}
371   */
372 
373 /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC AlarmDateWeekDay Definitions
374   * @{
375   */
376 #define RTC_ALARMDATEWEEKDAYSEL_DATE        0x00000000u
377 #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY     RTC_ALRMAR_WDSEL
378 
379 /**
380   * @}
381   */
382 
383 /** @defgroup RTC_AlarmMask_Definitions RTC AlarmMask Definitions
384   * @{
385   */
386 #define RTC_ALARMMASK_NONE                  0x00000000u
387 #define RTC_ALARMMASK_DATEWEEKDAY           RTC_ALRMAR_MSK4
388 #define RTC_ALARMMASK_HOURS                 RTC_ALRMAR_MSK3
389 #define RTC_ALARMMASK_MINUTES               RTC_ALRMAR_MSK2
390 #define RTC_ALARMMASK_SECONDS               RTC_ALRMAR_MSK1
391 #define RTC_ALARMMASK_ALL                   (RTC_ALARMMASK_DATEWEEKDAY | RTC_ALARMMASK_HOURS  | \
392                                              RTC_ALARMMASK_MINUTES | RTC_ALARMMASK_SECONDS)
393 
394 /**
395   * @}
396   */
397 
398 /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions
399   * @{
400   */
401 #define RTC_ALARM_A                         RTC_CR_ALRAE
402 #define RTC_ALARM_B                         RTC_CR_ALRBE
403 
404 /**
405   * @}
406   */
407 
408 
409 /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions
410   * @{
411   */
412 #define RTC_ALARMSUBSECONDMASK_ALL          0x00000000u                                                              /*!< All Alarm SS fields are masked.
413                                                                                                                           There is no comparison on sub seconds
414                                                                                                                           for Alarm */
415 #define RTC_ALARMSUBSECONDMASK_SS14_1       RTC_ALRMASSR_MASKSS_0                                                    /*!< SS[14:1] not used in Alarm
416                                                                                                                           comparison. Only SS[0] is compared.    */
417 #define RTC_ALARMSUBSECONDMASK_SS14_2       RTC_ALRMASSR_MASKSS_1                                                    /*!< SS[14:2] not used in Alarm
418                                                                                                                           comparison. Only SS[1:0] are compared  */
419 #define RTC_ALARMSUBSECONDMASK_SS14_3       (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1)                          /*!< SS[14:3] not used in Alarm
420                                                                                                                           comparison. Only SS[2:0] are compared  */
421 #define RTC_ALARMSUBSECONDMASK_SS14_4       RTC_ALRMASSR_MASKSS_2                                                    /*!< SS[14:4] not used in Alarm
422                                                                                                                           comparison. Only SS[3:0] are compared  */
423 #define RTC_ALARMSUBSECONDMASK_SS14_5       (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2)                          /*!< SS[14:5] not used in Alarm
424                                                                                                                           comparison. Only SS[4:0] are compared  */
425 #define RTC_ALARMSUBSECONDMASK_SS14_6       (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)                          /*!< SS[14:6] not used in Alarm
426                                                                                                                           comparison. Only SS[5:0] are compared  */
427 #define RTC_ALARMSUBSECONDMASK_SS14_7       (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)  /*!< SS[14:7] not used in Alarm
428                                                                                                                           comparison. Only SS[6:0] are compared  */
429 #define RTC_ALARMSUBSECONDMASK_SS14_8       RTC_ALRMASSR_MASKSS_3                                                    /*!< SS[14:8] not used in Alarm
430                                                                                                                           comparison. Only SS[7:0] are compared  */
431 #define RTC_ALARMSUBSECONDMASK_SS14_9       (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_3)                          /*!< SS[14:9] not used in Alarm
432                                                                                                                           comparison. Only SS[8:0] are compared  */
433 #define RTC_ALARMSUBSECONDMASK_SS14_10      (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)                          /*!< SS[14:10] not used in Alarm
434                                                                                                                           comparison. Only SS[9:0] are compared  */
435 #define RTC_ALARMSUBSECONDMASK_SS14_11      (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)  /*!< SS[14:11] not used in Alarm
436                                                                                                                           comparison. Only SS[10:0] are compared */
437 #define RTC_ALARMSUBSECONDMASK_SS14_12      (RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)                          /*!< SS[14:12] not used in Alarm
438                                                                                                                           comparison.Only SS[11:0] are compared  */
439 #define RTC_ALARMSUBSECONDMASK_SS14_13      (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)  /*!< SS[14:13] not used in Alarm
440                                                                                                                           comparison. Only SS[12:0] are compared */
441 #define RTC_ALARMSUBSECONDMASK_SS14         (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)  /*!< SS[14] not used in Alarm
442                                                                                                                           comparison. Only SS[13:0] are compared  */
443 #define RTC_ALARMSUBSECONDMASK_NONE         RTC_ALRMASSR_MASKSS                                                      /*!< SS[14:0] are compared and must match
444                                                                                                                           to activate alarm. */
445 /**
446   * @}
447   */
448 
449 /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions
450   * @{
451   */
452 #define RTC_IT_TS                           RTC_CR_TSIE        /*!< Enable Timestamp Interrupt    */
453 #define RTC_IT_WUT                          RTC_CR_WUTIE       /*!< Enable Wakeup timer Interrupt */
454 #define RTC_IT_ALRA                         RTC_CR_ALRAIE      /*!< Enable Alarm A Interrupt      */
455 #define RTC_IT_ALRB                         RTC_CR_ALRBIE      /*!< Enable Alarm B Interrupt      */
456 /**
457   * @}
458   */
459 
460 /** @defgroup RTC_Flag_Mask    RTC Flag Mask (5bits) describe in RTC_Flags_Definitions
461   * @{
462   */
463 #define RTC_FLAG_MASK                       0x001Fu            /*!< RTC flags mask (5bits) */
464 /**
465   * @}
466   */
467 
468 /** @defgroup RTC_Flags_Definitions RTC Flags Definitions
469   *        Elements values convention: 000000XX000YYYYYb
470   *           - YYYYY  : Interrupt flag position in the XX register (5bits)
471   *           - XX  : Interrupt status register (2bits)
472   *                 - 01: ICSR register
473   *                 - 10: SR or SCR or MISR or SMISR registers
474   * @{
475   */
476 #define RTC_FLAG_RECALPF                    (0x00000100U | RTC_ICSR_RECALPF_Pos) /*!< Recalibration pending Flag */
477 #define RTC_FLAG_INITF                      (0x00000100U | RTC_ICSR_INITF_Pos)   /*!< Initialization flag */
478 #define RTC_FLAG_RSF                        (0x00000100U | RTC_ICSR_RSF_Pos)     /*!< Registers synchronization flag */
479 #define RTC_FLAG_INITS                      (0x00000100U | RTC_ICSR_INITS_Pos)   /*!< Initialization status flag */
480 #define RTC_FLAG_SHPF                       (0x00000100U | RTC_ICSR_SHPF_Pos)    /*!< Shift operation pending flag */
481 #define RTC_FLAG_WUTWF                      (0x00000100U | RTC_ICSR_WUTWF_Pos)   /*!< Wakeup timer write flag */
482 #define RTC_FLAG_ITSF                       (0x00000200U | RTC_SR_ITSF_Pos)      /*!< Internal Time-stamp flag */
483 #define RTC_FLAG_TSOVF                      (0x00000200U | RTC_SR_TSOVF_Pos)     /*!< Time-stamp overflow flag */
484 #define RTC_FLAG_TSF                        (0x00000200U | RTC_SR_TSF_Pos)       /*!< Time-stamp flag */
485 #define RTC_FLAG_WUTF                       (0x00000200U | RTC_SR_WUTF_Pos)      /*!< Wakeup timer flag */
486 #define RTC_FLAG_ALRBF                      (0x00000200U | RTC_SR_ALRBF_Pos)     /*!< Alarm B flag */
487 #define RTC_FLAG_ALRAF                      (0x00000200U | RTC_SR_ALRAF_Pos)     /*!< Alarm A flag */
488 /**
489   * @}
490   */
491 
492 /** @defgroup RTC_Clear_Flags_Definitions RTC Clear Flags Definitions
493   * @{
494   */
495 #define RTC_CLEAR_ITSF                      RTC_SCR_CITSF    /*!< Clear Internal Time-stamp flag */
496 #define RTC_CLEAR_TSOVF                     RTC_SCR_CTSOVF   /*!< Clear Time-stamp overflow flag */
497 #define RTC_CLEAR_TSF                       RTC_SCR_CTSF     /*!< Clear Time-stamp flag */
498 #define RTC_CLEAR_WUTF                      RTC_SCR_CWUTF    /*!< Clear Wakeup timer flag */
499 #define RTC_CLEAR_ALRBF                     RTC_SCR_CALRBF   /*!< Clear Alarm B flag */
500 #define RTC_CLEAR_ALRAF                     RTC_SCR_CALRAF   /*!< Clear Alarm A flag */
501 /**
502   * @}
503   */
504 
505 /**
506   * @}
507   */
508 
509 /* Exported macros -----------------------------------------------------------*/
510 /** @defgroup RTC_Exported_Macros RTC Exported Macros
511   * @{
512   */
513 
514 /** @brief Reset RTC handle state
515   * @param  __HANDLE__ RTC handle.
516   * @retval None
517   */
518 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
519 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{\
520                                                       (__HANDLE__)->State = HAL_RTC_STATE_RESET;\
521                                                       (__HANDLE__)->MspInitCallback = NULL;\
522                                                       (__HANDLE__)->MspDeInitCallback = NULL;\
523                                                      }while(0)
524 #else
525 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
526 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
527 
528 /**
529   * @brief  Disable the write protection for RTC registers.
530   * @param  __HANDLE__ specifies the RTC handle.
531   * @retval None
532   */
533 #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__)             \
534                         do{                                       \
535                             RTC->WPR = 0xCAU;   \
536                             RTC->WPR = 0x53U;   \
537                           } while(0U)
538 
539 /**
540   * @brief  Enable the write protection for RTC registers.
541   * @param  __HANDLE__ specifies the RTC handle.
542   * @retval None
543   */
544 #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__)              \
545                         do{                                       \
546                             RTC->WPR = 0xFFU;   \
547                           } while(0U)
548 
549 /**
550   * @brief  Add 1 hour (summer time change).
551   * @param  __HANDLE__ specifies the RTC handle.
552   * @param  __BKP__ Backup
553   *         This parameter can be:
554   *            @arg @ref RTC_STOREOPERATION_RESET
555   *            @arg @ref RTC_STOREOPERATION_SET
556   * @retval None
557   */
558 #define __HAL_RTC_DAYLIGHT_SAVING_TIME_ADD1H(__HANDLE__, __BKP__)                         \
559                         do {                                                              \
560                             __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__);                \
561                             SET_BIT(RTC->CR, RTC_CR_ADD1H);            \
562                             MODIFY_REG(RTC->CR, RTC_CR_BKP , (__BKP__)); \
563                             __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__);                 \
564                         } while(0);
565 
566 /**
567   * @brief  Subtract 1 hour (winter time change).
568   * @param  __HANDLE__ specifies the RTC handle.
569   * @param  __BKP__ Backup
570   *         This parameter can be:
571   *            @arg @ref RTC_STOREOPERATION_RESET
572   *            @arg @ref RTC_STOREOPERATION_SET
573   * @retval None
574   */
575 #define __HAL_RTC_DAYLIGHT_SAVING_TIME_SUB1H(__HANDLE__, __BKP__)                         \
576                         do {                                                              \
577                             __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__);                \
578                             SET_BIT(RTC->CR, RTC_CR_SUB1H);            \
579                             MODIFY_REG(RTC->CR, RTC_CR_BKP , (__BKP__)); \
580                             __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__);                 \
581                         } while(0);
582 
583 /**
584  * @brief  Enable the RTC ALARMA peripheral.
585  * @param  __HANDLE__ specifies the RTC handle.
586  * @retval None
587  */
588 #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__)  (RTC->CR |= (RTC_CR_ALRAE))
589 
590 /**
591   * @brief  Disable the RTC ALARMA peripheral.
592   * @param  __HANDLE__ specifies the RTC handle.
593   * @retval None
594   */
595 #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__)  (RTC->CR &= ~(RTC_CR_ALRAE))
596 
597 /**
598   * @brief  Enable the RTC ALARMB peripheral.
599   * @param  __HANDLE__ specifies the RTC handle.
600   * @retval None
601   */
602 #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__)   (RTC->CR |= (RTC_CR_ALRBE))
603 
604 /**
605   * @brief  Disable the RTC ALARMB peripheral.
606   * @param  __HANDLE__ specifies the RTC handle.
607   * @retval None
608   */
609 #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__)  (RTC->CR &= ~(RTC_CR_ALRBE))
610 
611 /**
612   * @brief  Enable the RTC Alarm interrupt.
613   * @param  __HANDLE__ specifies the RTC handle.
614   * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
615   *          This parameter can be any combination of the following values:
616   *             @arg @ref RTC_IT_ALRA Alarm A interrupt
617   *             @arg @ref RTC_IT_ALRB Alarm B interrupt
618   * @retval None
619   */
620 #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__)   (RTC->CR |= (__INTERRUPT__))
621 
622 /**
623   * @brief  Disable the RTC Alarm interrupt.
624   * @param  __HANDLE__ specifies the RTC handle.
625   * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
626   *         This parameter can be any combination of the following values:
627   *            @arg @ref RTC_IT_ALRA Alarm A interrupt
628   *            @arg @ref RTC_IT_ALRB Alarm B interrupt
629   * @retval None
630   */
631 #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) (RTC->CR &= ~(__INTERRUPT__))
632 
633 /**
634   * @brief  Check whether the specified RTC Alarm interrupt has occurred or not.
635   * @param  __HANDLE__ specifies the RTC handle.
636   * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
637   *         This parameter can be:
638   *            @arg @ref RTC_IT_ALRA Alarm A interrupt
639   *            @arg @ref RTC_IT_ALRB Alarm B interrupt
640   * @retval None
641   */
642 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) ((((RTC->MISR)& ((__INTERRUPT__)>> 12U)) != 0U) ? 1UL : 0UL)
643 
644 /**
645   * @brief  Check whether the specified RTC Alarm interrupt has been enabled or not.
646   * @param  __HANDLE__ specifies the RTC handle.
647   * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
648   *         This parameter can be:
649   *            @arg @ref RTC_IT_ALRA Alarm A interrupt
650   *            @arg @ref RTC_IT_ALRB Alarm B interrupt
651   * @retval None
652   */
653 #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)     ((((RTC->CR) & (__INTERRUPT__)) != 0U) ? 1UL : 0UL)
654 
655 /**
656   * @brief  Get the selected RTC Alarms flag status.
657   * @param  __HANDLE__ specifies the RTC handle.
658   * @param  __FLAG__ specifies the RTC Alarm Flag sources to check.
659   *         This parameter can be:
660   *            @arg @ref RTC_FLAG_ALRAF
661   *            @arg @ref RTC_FLAG_ALRBF
662   * @retval None
663   */
664 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__)   (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__)))
665 
666 /**
667   * @brief  Clear the RTC Alarms pending flags.
668   * @param  __HANDLE__ specifies the RTC handle.
669   * @param  __FLAG__ specifies the RTC Alarm Flag sources to clear.
670   *          This parameter can be:
671   *             @arg @ref RTC_FLAG_ALRAF
672   *             @arg @ref RTC_FLAG_ALRBF
673   * @retval None
674   */
675 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__)   (((__FLAG__) == RTC_FLAG_ALRAF) ? ((RTC->SCR = (RTC_CLEAR_ALRAF))) : \
676                                                            (RTC->SCR = (RTC_CLEAR_ALRBF)))
677 
678 #if defined(CORE_CM4)
679 /**
680   * @brief  Enable interrupt on the RTC Alarm associated Exti line.
681   * @retval None
682   */
683 #define __HAL_RTC_ALARM_EXTI_ENABLE_IT()            (EXTI_C2->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
684 
685 /**
686   * @brief  Disable interrupt on the RTC Alarm associated Exti line.
687   * @retval None
688   */
689 #define __HAL_RTC_ALARM_EXTI_DISABLE_IT()           (EXTI_C2->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
690 
691 /**
692   * @brief  Enable event on the RTC Alarm associated Exti line.
693   * @retval None
694   */
695 #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT()         (EXTI_C2->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
696 
697 /**
698   * @brief  Disable event on the RTC Alarm associated Exti line.
699   * @retval None
700   */
701 #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT()         (EXTI_C2->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
702 
703 #elif defined(CORE_CA7)
704 
705 #define __HAL_RTC_ALARM_EXTI_ENABLE_IT()            (EXTI_C1->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
706 
707 /**
708   * @brief  Disable interrupt on the RTC Alarm associated Exti line.
709   * @retval None
710   */
711 #define __HAL_RTC_ALARM_EXTI_DISABLE_IT()           (EXTI_C1->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
712 
713 /**
714   * @brief  Enable event on the RTC Alarm associated Exti line.
715   * @retval None
716   */
717 #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT()         (EXTI_C1->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
718 
719 /**
720   * @brief  Disable event on the RTC Alarm associated Exti line.
721   * @retval None
722   */
723 #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT()         (EXTI_C1->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
724 
725 #else /* !CORE_CA7 */
726 
727 #error Please #define CORE_CM4 or CORE_CA7
728 
729 #endif
730 /**
731   * @}
732   */
733 
734 /* Include RTC HAL Extended module */
735 #include "stm32mp1xx_hal_rtc_ex.h"
736 
737 /* Exported functions --------------------------------------------------------*/
738 /** @defgroup RTC_Exported_Functions RTC Exported Functions
739   * @{
740   */
741 
742 /** @defgroup RTC_Exported_Functions_Group1 Initialization and de-initialization functions
743   * @{
744   */
745 /* Initialization and de-initialization functions  ****************************/
746 HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc);
747 HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc);
748 
749 void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc);
750 void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc);
751 
752 /* Callbacks Register/UnRegister functions  ***********************************/
753 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
754 HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback);
755 HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID);
756 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
757 
758 /**
759   * @}
760   */
761 
762 /** @defgroup RTC_Exported_Functions_Group2 RTC Time and Date functions
763   * @{
764   */
765 /* RTC Time and Date functions ************************************************/
766 HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
767 HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
768 HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
769 HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
770 /**
771   * @}
772   */
773 
774 /** @defgroup RTC_Exported_Functions_Group3 RTC Alarm functions
775   * @{
776   */
777 /* RTC Alarm functions ********************************************************/
778 HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
779 HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
780 HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm);
781 HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format);
782 void              HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc);
783 HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
784 void              HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc);
785 /**
786   * @}
787   */
788 
789 /** @defgroup  RTC_Exported_Functions_Group4 Peripheral Control functions
790   * @{
791   */
792 /* Peripheral Control functions ***********************************************/
793 HAL_StatusTypeDef   HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc);
794 /**
795   * @}
796   */
797 
798 /** @defgroup RTC_Exported_Functions_Group5 Peripheral State functions
799   * @{
800   */
801 /* Peripheral State functions *************************************************/
802 HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc);
803 /**
804   * @}
805   */
806 
807 /**
808   * @}
809   */
810 
811 /* Private types -------------------------------------------------------------*/
812 /* Private variables ---------------------------------------------------------*/
813 /* Private constants ---------------------------------------------------------*/
814 /** @defgroup RTC_Private_Constants RTC Private Constants
815   * @{
816   */
817 /* Masks Definition */
818 #define RTC_TR_RESERVED_MASK                (RTC_TR_PM | RTC_TR_HT | RTC_TR_HU | \
819                                             RTC_TR_MNT | RTC_TR_MNU| RTC_TR_ST | \
820                                             RTC_TR_SU)
821 #define RTC_DR_RESERVED_MASK                (RTC_DR_YT | RTC_DR_YU | RTC_DR_WDU | \
822                                             RTC_DR_MT | RTC_DR_MU | RTC_DR_DT  | \
823                                             RTC_DR_DU)
824 #define RTC_INIT_MASK                       0xFFFFFFFFu
825 #define RTC_RSF_MASK                        (~(RTC_ICSR_INIT | RTC_ICSR_RSF))
826 
827 #define RTC_TIMEOUT_VALUE                   1000u
828 
829 /**
830   * @}
831   */
832 
833 /* Private macros ------------------------------------------------------------*/
834 /** @defgroup RTC_Private_Macros RTC Private Macros
835   * @{
836   */
837 
838 /** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters
839   * @{
840   */
841 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
842                                 ((OUTPUT) == RTC_OUTPUT_ALARMA)  || \
843                                 ((OUTPUT) == RTC_OUTPUT_ALARMB)  || \
844                                 ((OUTPUT) == RTC_OUTPUT_WAKEUP)  || \
845                                 ((OUTPUT) == RTC_OUTPUT_TAMPER))
846 
847 #define IS_RTC_HOUR_FORMAT(FORMAT)     (((FORMAT) == RTC_HOURFORMAT_12) || \
848                                         ((FORMAT) == RTC_HOURFORMAT_24))
849 
850 #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \
851                                 ((POL) == RTC_OUTPUT_POLARITY_LOW))
852 
853 #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \
854                                   ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL))
855 
856 #define IS_RTC_OUTPUT_PULLUP(TYPE) (((TYPE) == RTC_OUTPUT_PULLUP_NONE) || \
857                                     ((TYPE) == RTC_OUTPUT_PULLUP_ON))
858 
859 #define IS_RTC_OUTPUT_REMAP(REMAP)   (((REMAP) == RTC_OUTPUT_REMAP_NONE) || \
860                                       ((REMAP) == RTC_OUTPUT_REMAP_POS1))
861 
862 #define IS_RTC_HOURFORMAT12(PM)  (((PM) == RTC_HOURFORMAT12_AM) || \
863                                   ((PM) == RTC_HOURFORMAT12_PM))
864 
865 #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \
866                                       ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \
867                                       ((SAVE) == RTC_DAYLIGHTSAVING_NONE))
868 
869 #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \
870                                            ((OPERATION) == RTC_STOREOPERATION_SET))
871 
872 #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || \
873                                ((FORMAT) == RTC_FORMAT_BCD))
874 
875 #define IS_RTC_YEAR(YEAR)              ((YEAR) <= 99u)
876 
877 #define IS_RTC_MONTH(MONTH)            (((MONTH) >= 1u) && ((MONTH) <= 12u))
878 
879 #define IS_RTC_DATE(DATE)              (((DATE) >= 1u) && ((DATE) <= 31u))
880 
881 #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY)    || \
882                                  ((WEEKDAY) == RTC_WEEKDAY_TUESDAY)   || \
883                                  ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
884                                  ((WEEKDAY) == RTC_WEEKDAY_THURSDAY)  || \
885                                  ((WEEKDAY) == RTC_WEEKDAY_FRIDAY)    || \
886                                  ((WEEKDAY) == RTC_WEEKDAY_SATURDAY)  || \
887                                  ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
888 
889 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) >0u) && ((DATE) <= 31u))
890 
891 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY)    || \
892                                                     ((WEEKDAY) == RTC_WEEKDAY_TUESDAY)   || \
893                                                     ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
894                                                     ((WEEKDAY) == RTC_WEEKDAY_THURSDAY)  || \
895                                                     ((WEEKDAY) == RTC_WEEKDAY_FRIDAY)    || \
896                                                     ((WEEKDAY) == RTC_WEEKDAY_SATURDAY)  || \
897                                                     ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
898 
899 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \
900                                             ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY))
901 
902 #define IS_RTC_ALARM_MASK(MASK)  (((MASK) & ~(RTC_ALARMMASK_ALL)) == 0UL)
903 
904 #define IS_RTC_ALARM(ALARM)      (((ALARM) == RTC_ALARM_A) || \
905                                   ((ALARM) == RTC_ALARM_B))
906 
907 #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= RTC_ALRMASSR_SS)
908 
909 #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK)          (((MASK) == 0UL) || \
910                                                     (((MASK) >= RTC_ALARMSUBSECONDMASK_SS14_1) && ((MASK) <= RTC_ALARMSUBSECONDMASK_NONE)))
911 
912 #define IS_RTC_ASYNCH_PREDIV(PREDIV)   ((PREDIV) <= (RTC_PRER_PREDIV_A >> RTC_PRER_PREDIV_A_Pos))
913 
914 #define IS_RTC_SYNCH_PREDIV(PREDIV)    ((PREDIV) <= (RTC_PRER_PREDIV_S >> RTC_PRER_PREDIV_S_Pos))
915 
916 #define IS_RTC_HOUR12(HOUR)            (((HOUR) > 0u) && ((HOUR) <= 12u))
917 
918 #define IS_RTC_HOUR24(HOUR)            ((HOUR) <= 23u)
919 
920 #define IS_RTC_MINUTES(MINUTES)        ((MINUTES) <= 59u)
921 
922 #define IS_RTC_SECONDS(SECONDS)        ((SECONDS) <= 59u)
923 
924 /**
925   * @}
926   */
927 
928 /**
929   * @}
930   */
931 
932 /* Private functions -------------------------------------------------------------*/
933 /** @defgroup RTC_Private_Functions RTC Private Functions
934   * @{
935   */
936 HAL_StatusTypeDef  RTC_EnterInitMode(RTC_HandleTypeDef *hrtc);
937 HAL_StatusTypeDef  RTC_ExitInitMode(RTC_HandleTypeDef *hrtc);
938 uint8_t            RTC_ByteToBcd2(uint8_t Value);
939 uint8_t            RTC_Bcd2ToByte(uint8_t Value);
940 /**
941   * @}
942   */
943 
944 /**
945   * @}
946   */
947 
948 /**
949   * @}
950   */
951 
952 #ifdef __cplusplus
953 }
954 #endif
955 
956 #endif /* STM32MP1xx_HAL_RTC_H */
957 
958 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
959 
960