2 ******************************************************************************
3 * @file stm32h7xx_hal_rtc.h
4 * @author MCD Application Team
5 * @brief Header file of RTC HAL module.
6 ******************************************************************************
9 * Copyright (c) 2017 STMicroelectronics.
10 * All rights reserved.
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.
16 ******************************************************************************
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32H7xx_HAL_RTC_H
21 #define STM32H7xx_HAL_RTC_H
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32h7xx_hal_def.h"
30 /** @addtogroup STM32H7xx_HAL_Driver
38 /* Exported types ------------------------------------------------------------*/
39 /** @defgroup RTC_Exported_Types RTC Exported Types
44 * @brief HAL State structures definition
48 HAL_RTC_STATE_RESET
= 0x00U
, /*!< RTC not yet initialized or disabled */
49 HAL_RTC_STATE_READY
= 0x01U
, /*!< RTC initialized and ready for use */
50 HAL_RTC_STATE_BUSY
= 0x02U
, /*!< RTC process is ongoing */
51 HAL_RTC_STATE_TIMEOUT
= 0x03U
, /*!< RTC timeout state */
52 HAL_RTC_STATE_ERROR
= 0x04U
/*!< RTC error state */
54 } HAL_RTCStateTypeDef
;
57 * @brief RTC Configuration Structure definition
61 uint32_t HourFormat
; /*!< Specifies the RTC Hour Format.
62 This parameter can be a value of @ref RTC_Hour_Formats_Definitions */
64 uint32_t AsynchPrediv
; /*!< Specifies the RTC Asynchronous Predivider value.
65 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */
67 uint32_t SynchPrediv
; /*!< Specifies the RTC Synchronous Predivider value.
68 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF */
70 uint32_t OutPut
; /*!< Specifies which signal will be routed to the RTC output.
71 This parameter can be a value of @ref RTC_Output_selection_Definitions */
73 uint32_t OutPutRemap
; /*!< Specifies the remap for RTC output.
74 This parameter can be a value of @ref RTC_Output_ALARM_OUT_Remap */
76 uint32_t OutPutPolarity
; /*!< Specifies the polarity of the output signal.
77 This parameter can be a value of @ref RTC_Output_Polarity_Definitions */
79 uint32_t OutPutType
; /*!< Specifies the RTC Output Pin mode.
80 This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */
82 uint32_t OutPutPullUp
; /*!< Specifies the RTC Output Pull-Up mode.
83 This parameter can be a value of @ref RTC_Output_PullUp_ALARM_OUT */
88 * @brief RTC Time structure definition
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 */
96 uint8_t Minutes
; /*!< Specifies the RTC Time Minutes.
97 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
99 uint8_t Seconds
; /*!< Specifies the RTC Time Seconds.
100 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
102 uint8_t TimeFormat
; /*!< Specifies the RTC AM/PM Time.
103 This parameter can be a value of @ref RTC_AM_PM_Definitions */
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 */
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 */
115 uint32_t DayLightSaving
; /*!< Specifies RTC_DayLightSaveOperation: the value of hour adjustment.
116 This parameter can be a value of @ref RTC_DayLightSaving_Definitions */
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 */
124 * @brief RTC Date structure definition
128 uint8_t WeekDay
; /*!< Specifies the RTC Date WeekDay.
129 This parameter can be a value of @ref RTC_WeekDay_Definitions */
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 */
134 uint8_t Date
; /*!< Specifies the RTC Date.
135 This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
137 uint8_t Year
; /*!< Specifies the RTC Date Year.
138 This parameter must be a number between Min_Data = 0 and Max_Data = 99 */
143 * @brief RTC Alarm structure definition
147 RTC_TimeTypeDef AlarmTime
; /*!< Specifies the RTC Alarm Time members */
149 uint32_t AlarmMask
; /*!< Specifies the RTC Alarm Masks.
150 This parameter can be a value of @ref RTC_AlarmMask_Definitions */
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 */
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 */
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 */
162 uint32_t Alarm
; /*!< Specifies the alarm .
163 This parameter can be a value of @ref RTC_Alarms_Definitions */
167 * @brief RTC Handle Structure definition
169 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
170 typedef struct __RTC_HandleTypeDef
173 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
175 RTC_TypeDef
*Instance
; /*!< Register base address */
177 RTC_InitTypeDef Init
; /*!< RTC required parameters */
179 HAL_LockTypeDef Lock
; /*!< RTC locking object */
181 __IO HAL_RTCStateTypeDef State
; /*!< Time communication state */
183 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
184 void (* AlarmAEventCallback
)(struct __RTC_HandleTypeDef
*hrtc
); /*!< RTC Alarm A Event callback */
186 void (* AlarmBEventCallback
)(struct __RTC_HandleTypeDef
*hrtc
); /*!< RTC Alarm B Event callback */
188 void (* TimeStampEventCallback
)(struct __RTC_HandleTypeDef
*hrtc
); /*!< RTC TimeStamp Event callback */
190 void (* WakeUpTimerEventCallback
)(struct __RTC_HandleTypeDef
*hrtc
); /*!< RTC WakeUpTimer Event callback */
192 void (* Tamper1EventCallback
)(struct __RTC_HandleTypeDef
*hrtc
); /*!< RTC Tamper 1 Event callback */
194 void (* Tamper2EventCallback
)(struct __RTC_HandleTypeDef
*hrtc
); /*!< RTC Tamper 2 Event callback */
196 void (* Tamper3EventCallback
)(struct __RTC_HandleTypeDef
*hrtc
); /*!< RTC Tamper 3 Event callback */
199 void (* InternalTamper1EventCallback
)(struct __RTC_HandleTypeDef
*hrtc
); /*!< RTC Internal Tamper 1 Event callback */
201 void (* InternalTamper2EventCallback
)(struct __RTC_HandleTypeDef
*hrtc
); /*!< RTC Internal Tamper 2 Event callback */
203 void (* InternalTamper3EventCallback
)(struct __RTC_HandleTypeDef
*hrtc
); /*!< RTC Internal Tamper 3 Event callback */
205 void (* InternalTamper4EventCallback
)(struct __RTC_HandleTypeDef
*hrtc
); /*!< RTC Internal Tamper 4 Event callback */
207 void (* InternalTamper5EventCallback
)(struct __RTC_HandleTypeDef
*hrtc
); /*!< RTC Internal Tamper 5 Event callback */
209 void (* InternalTamper6EventCallback
)(struct __RTC_HandleTypeDef
*hrtc
); /*!< RTC Internal Tamper 6 Event callback */
211 void (* InternalTamper8EventCallback
)(struct __RTC_HandleTypeDef
*hrtc
); /*!< RTC Internal Tamper 8 Event callback */
214 void (* MspInitCallback
)(struct __RTC_HandleTypeDef
*hrtc
); /*!< RTC Msp Init callback */
216 void (* MspDeInitCallback
)(struct __RTC_HandleTypeDef
*hrtc
); /*!< RTC Msp DeInit callback */
218 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
222 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
224 * @brief HAL RTC Callback ID enumeration definition
228 HAL_RTC_ALARM_A_EVENT_CB_ID
= 0u, /*!< RTC Alarm A Event Callback ID */
229 HAL_RTC_ALARM_B_EVENT_CB_ID
= 1u, /*!< RTC Alarm B Event Callback ID */
230 HAL_RTC_TIMESTAMP_EVENT_CB_ID
= 2u, /*!< RTC TimeStamp Event Callback ID */
231 HAL_RTC_WAKEUPTIMER_EVENT_CB_ID
= 3u, /*!< RTC WakeUp Timer Event Callback ID */
232 HAL_RTC_TAMPER1_EVENT_CB_ID
= 4u, /*!< RTC Tamper 1 Callback ID */
233 HAL_RTC_TAMPER2_EVENT_CB_ID
= 5u, /*!< RTC Tamper 2 Callback ID */
234 HAL_RTC_TAMPER3_EVENT_CB_ID
= 6u, /*!< RTC Tamper 3 Callback ID */
236 HAL_RTC_INTERNAL_TAMPER1_EVENT_CB_ID
= 12u, /*!< RTC Internal Tamper 1 Callback ID */
237 HAL_RTC_INTERNAL_TAMPER2_EVENT_CB_ID
= 13u, /*!< RTC Internal Tamper 2 Callback ID */
238 HAL_RTC_INTERNAL_TAMPER3_EVENT_CB_ID
= 14u, /*!< RTC Internal Tamper 3 Callback ID */
239 HAL_RTC_INTERNAL_TAMPER4_EVENT_CB_ID
= 15u, /*!< RTC Internal Tamper 4 Callback ID */
240 HAL_RTC_INTERNAL_TAMPER5_EVENT_CB_ID
= 16u, /*!< RTC Internal Tamper 5 Callback ID */
241 HAL_RTC_INTERNAL_TAMPER6_EVENT_CB_ID
= 17u, /*!< RTC Internal Tamper 6 Callback ID */
242 HAL_RTC_INTERNAL_TAMPER8_EVENT_CB_ID
= 19u, /*!< RTC Internal Tamper 8 Callback ID */
244 HAL_RTC_MSPINIT_CB_ID
= 20u, /*!< RTC Msp Init callback ID */
245 HAL_RTC_MSPDEINIT_CB_ID
= 21u /*!< RTC Msp DeInit callback ID */
246 } HAL_RTC_CallbackIDTypeDef
;
249 * @brief HAL RTC Callback pointer definition
251 typedef void (*pRTC_CallbackTypeDef
)(RTC_HandleTypeDef
*hrtc
); /*!< pointer to an RTC callback function */
252 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
258 /* Exported constants --------------------------------------------------------*/
259 /** @defgroup RTC_Exported_Constants RTC Exported Constants
263 /** @defgroup RTC_Hour_Formats_Definitions RTC Hour Formats Definitions
266 #define RTC_HOURFORMAT_24 0x00000000u
267 #define RTC_HOURFORMAT_12 RTC_CR_FMT
272 /** @defgroup RTC_Output_selection_Definitions RTC Output Selection Definitions
275 #define RTC_OUTPUT_DISABLE 0x00000000u
276 #define RTC_OUTPUT_ALARMA RTC_CR_OSEL_0
277 #define RTC_OUTPUT_ALARMB RTC_CR_OSEL_1
278 #define RTC_OUTPUT_WAKEUP RTC_CR_OSEL
280 #define RTC_OUTPUT_TAMPER RTC_CR_TAMPOE
286 /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions
289 #define RTC_OUTPUT_POLARITY_HIGH 0x00000000u
290 #define RTC_OUTPUT_POLARITY_LOW RTC_CR_POL
295 /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT
299 #define RTC_OUTPUT_TYPE_PUSHPULL 0x00000000u
300 #define RTC_OUTPUT_TYPE_OPENDRAIN RTC_CR_TAMPALRM_TYPE
301 #define RTC_ALARM_OUTPUT_TYPE RTC_CR_TAMPALRM_TYPE
303 #define RTC_OUTPUT_TYPE_PUSHPULL RTC_OR_ALARMOUTTYPE
304 #define RTC_OUTPUT_TYPE_OPENDRAIN 0x00000000u
305 #define RTC_ALARM_OUTPUT_TYPE RTC_OR_ALARMOUTTYPE
311 /** @defgroup RTC_Output_PullUp_ALARM_OUT RTC Output Pull-Up ALARM OUT
315 #define RTC_OUTPUT_PULLUP_NONE 0x00000000u
316 #define RTC_OUTPUT_PULLUP_ON RTC_CR_TAMPALRM_PU
322 /** @defgroup RTC_Output_ALARM_OUT_Remap RTC Output ALARM OUT Remap
326 #define RTC_OUTPUT_REMAP_NONE 0x00000000u
327 #define RTC_OUTPUT_REMAP_POS1 RTC_CR_OUT2EN
329 #define RTC_OUTPUT_REMAP_NONE 0x00000000u
330 #define RTC_OUTPUT_REMAP_POS1 RTC_OR_OUT_RMP
336 /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions
339 #define RTC_HOURFORMAT12_AM ((uint8_t)0x00)
340 #define RTC_HOURFORMAT12_PM ((uint8_t)0x01)
345 /** @defgroup RTC_DayLightSaving_Definitions RTC DayLight Saving Definitions
348 #define RTC_DAYLIGHTSAVING_SUB1H RTC_CR_SUB1H
349 #define RTC_DAYLIGHTSAVING_ADD1H RTC_CR_ADD1H
350 #define RTC_DAYLIGHTSAVING_NONE 0x00000000u
355 /** @defgroup RTC_StoreOperation_Definitions RTC Store Operation Definitions
358 #define RTC_STOREOPERATION_RESET 0x00000000u
359 #define RTC_STOREOPERATION_SET RTC_CR_BKP
364 /** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions
367 #define RTC_FORMAT_BIN 0x00000000u
368 #define RTC_FORMAT_BCD 0x00000001u
373 /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions (in BCD format)
376 #define RTC_MONTH_JANUARY ((uint8_t)0x01)
377 #define RTC_MONTH_FEBRUARY ((uint8_t)0x02)
378 #define RTC_MONTH_MARCH ((uint8_t)0x03)
379 #define RTC_MONTH_APRIL ((uint8_t)0x04)
380 #define RTC_MONTH_MAY ((uint8_t)0x05)
381 #define RTC_MONTH_JUNE ((uint8_t)0x06)
382 #define RTC_MONTH_JULY ((uint8_t)0x07)
383 #define RTC_MONTH_AUGUST ((uint8_t)0x08)
384 #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09)
385 #define RTC_MONTH_OCTOBER ((uint8_t)0x10)
386 #define RTC_MONTH_NOVEMBER ((uint8_t)0x11)
387 #define RTC_MONTH_DECEMBER ((uint8_t)0x12)
393 /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions
396 #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01)
397 #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02)
398 #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03)
399 #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04)
400 #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05)
401 #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06)
402 #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07)
408 /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC Alarm Date WeekDay Definitions
411 #define RTC_ALARMDATEWEEKDAYSEL_DATE 0x00000000u
412 #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL
418 /** @defgroup RTC_AlarmMask_Definitions RTC Alarm Mask Definitions
421 #define RTC_ALARMMASK_NONE 0x00000000u
422 #define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4
423 #define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3
424 #define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2
425 #define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1
426 #define RTC_ALARMMASK_ALL (RTC_ALARMMASK_DATEWEEKDAY | \
427 RTC_ALARMMASK_HOURS | \
428 RTC_ALARMMASK_MINUTES | \
429 RTC_ALARMMASK_SECONDS)
434 /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions
437 #define RTC_ALARM_A RTC_CR_ALRAE
438 #define RTC_ALARM_B RTC_CR_ALRBE
443 /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions
446 /*!< All Alarm SS fields are masked. There is no comparison on sub seconds for Alarm */
447 #define RTC_ALARMSUBSECONDMASK_ALL 0x00000000u
448 /*!< SS[14:1] are don't care in Alarm comparison. Only SS[0] is compared. */
449 #define RTC_ALARMSUBSECONDMASK_SS14_1 RTC_ALRMASSR_MASKSS_0
450 /*!< SS[14:2] are don't care in Alarm comparison. Only SS[1:0] are compared. */
451 #define RTC_ALARMSUBSECONDMASK_SS14_2 RTC_ALRMASSR_MASKSS_1
452 /*!< SS[14:3] are don't care in Alarm comparison. Only SS[2:0] are compared. */
453 #define RTC_ALARMSUBSECONDMASK_SS14_3 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1)
454 /*!< SS[14:4] are don't care in Alarm comparison. Only SS[3:0] are compared. */
455 #define RTC_ALARMSUBSECONDMASK_SS14_4 RTC_ALRMASSR_MASKSS_2
456 /*!< SS[14:5] are don't care in Alarm comparison. Only SS[4:0] are compared. */
457 #define RTC_ALARMSUBSECONDMASK_SS14_5 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2)
458 /*!< SS[14:6] are don't care in Alarm comparison. Only SS[5:0] are compared. */
459 #define RTC_ALARMSUBSECONDMASK_SS14_6 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)
460 /*!< SS[14:7] are don't care in Alarm comparison. Only SS[6:0] are compared. */
461 #define RTC_ALARMSUBSECONDMASK_SS14_7 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)
462 /*!< SS[14:8] are don't care in Alarm comparison. Only SS[7:0] are compared. */
463 #define RTC_ALARMSUBSECONDMASK_SS14_8 RTC_ALRMASSR_MASKSS_3
464 /*!< SS[14:9] are don't care in Alarm comparison. Only SS[8:0] are compared. */
465 #define RTC_ALARMSUBSECONDMASK_SS14_9 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_3)
466 /*!< SS[14:10] are don't care in Alarm comparison. Only SS[9:0] are compared. */
467 #define RTC_ALARMSUBSECONDMASK_SS14_10 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)
468 /*!< SS[14:11] are don't care in Alarm comparison. Only SS[10:0] are compared. */
469 #define RTC_ALARMSUBSECONDMASK_SS14_11 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)
470 /*!< SS[14:12] are don't care in Alarm comparison. Only SS[11:0] are compared. */
471 #define RTC_ALARMSUBSECONDMASK_SS14_12 (RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
472 /*!< SS[14:13] are don't care in Alarm comparison. Only SS[12:0] are compared. */
473 #define RTC_ALARMSUBSECONDMASK_SS14_13 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
474 /*!< SS[14] is don't care in Alarm comparison. Only SS[13:0] are compared. */
475 #define RTC_ALARMSUBSECONDMASK_SS14 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
476 /*!< SS[14:0] are compared and must match to activate alarm. */
477 #define RTC_ALARMSUBSECONDMASK_NONE RTC_ALRMASSR_MASKSS
483 /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions
486 #define RTC_IT_TS RTC_CR_TSIE /*!< Enable Timestamp Interrupt */
487 #define RTC_IT_WUT RTC_CR_WUTIE /*!< Enable Wakeup timer Interrupt */
488 #define RTC_IT_ALRA RTC_CR_ALRAIE /*!< Enable Alarm A Interrupt */
489 #define RTC_IT_ALRB RTC_CR_ALRBIE /*!< Enable Alarm B Interrupt */
494 /** @defgroup RTC_Flags_Definitions RTC Flags Definitions
498 #define RTC_FLAG_RECALPF RTC_ICSR_RECALPF /*!< Recalibration pending Flag */
499 #define RTC_FLAG_INITF RTC_ICSR_INITF /*!< Initialization pending flag */
500 #define RTC_FLAG_RSF RTC_ICSR_RSF /*!< Registers synchronization flag */
501 #define RTC_FLAG_INITS RTC_ICSR_INITS /*!< Initialization status flag */
502 #define RTC_FLAG_SHPF RTC_ICSR_SHPF /*!< Shift operation pending flag */
503 #define RTC_FLAG_WUTWF RTC_ICSR_WUTWF /*!< Wakeup timer write operation pending flag */
504 #define RTC_FLAG_ALRBWF RTC_ICSR_ALRBWF /*!< Alarm B write operation pending flag */
505 #define RTC_FLAG_ALRAWF RTC_ICSR_ALRAWF /*!< Alarm A write operation pending flag */
506 #define RTC_FLAG_ITSF RTC_SR_ITSF /*!< Internal Time-stamp flag */
507 #define RTC_FLAG_TSOVF RTC_SR_TSOVF /*!< Time-stamp overflow flag */
508 #define RTC_FLAG_TSF RTC_SR_TSF /*!< Time-stamp flag */
509 #define RTC_FLAG_WUTF RTC_SR_WUTF /*!< Wakeup timer flag */
510 #define RTC_FLAG_ALRBF RTC_SR_ALRBF /*!< Alarm B flag */
511 #define RTC_FLAG_ALRAF RTC_SR_ALRAF /*!< Alarm A flag */
513 #define RTC_FLAG_RECALPF RTC_ISR_RECALPF
514 #define RTC_FLAG_TSOVF RTC_ISR_TSOVF
515 #define RTC_FLAG_TSF RTC_ISR_TSF
516 #define RTC_FLAG_ITSF RTC_ISR_ITSF
517 #define RTC_FLAG_WUTF RTC_ISR_WUTF
518 #define RTC_FLAG_ALRBF RTC_ISR_ALRBF
519 #define RTC_FLAG_ALRAF RTC_ISR_ALRAF
520 #define RTC_FLAG_INITF RTC_ISR_INITF
521 #define RTC_FLAG_RSF RTC_ISR_RSF
522 #define RTC_FLAG_INITS RTC_ISR_INITS
523 #define RTC_FLAG_SHPF RTC_ISR_SHPF
524 #define RTC_FLAG_WUTWF RTC_ISR_WUTWF
525 #define RTC_FLAG_ALRBWF RTC_ISR_ALRBWF
526 #define RTC_FLAG_ALRAWF RTC_ISR_ALRAWF
532 /** @defgroup RTC_Clear_Flags_Definitions RTC Clear Flags Definitions
536 #define RTC_CLEAR_ITSF RTC_SCR_CITSF /*!< Clear Internal Time-stamp flag */
537 #define RTC_CLEAR_TSOVF RTC_SCR_CTSOVF /*!< Clear Time-stamp overflow flag */
538 #define RTC_CLEAR_TSF RTC_SCR_CTSF /*!< Clear Time-stamp flag */
539 #define RTC_CLEAR_WUTF RTC_SCR_CWUTF /*!< Clear Wakeup timer flag */
540 #define RTC_CLEAR_ALRBF RTC_SCR_CALRBF /*!< Clear Alarm B flag */
541 #define RTC_CLEAR_ALRAF RTC_SCR_CALRAF /*!< Clear Alarm A flag */
552 /* Exported macros -----------------------------------------------------------*/
553 /** @defgroup RTC_Exported_Macros RTC Exported Macros
557 /** @brief Reset RTC handle state
558 * @param __HANDLE__ RTC handle.
561 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
562 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{ \
563 (__HANDLE__)->State = HAL_RTC_STATE_RESET; \
564 (__HANDLE__)->MspInitCallback = NULL; \
565 (__HANDLE__)->MspDeInitCallback = NULL; \
568 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
569 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
572 * @brief Disable the write protection for RTC registers.
573 * @param __HANDLE__ specifies the RTC handle.
576 #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \
578 (__HANDLE__)->Instance->WPR = 0xCAU; \
579 (__HANDLE__)->Instance->WPR = 0x53U; \
583 * @brief Enable the write protection for RTC registers.
584 * @param __HANDLE__ specifies the RTC handle.
587 #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \
589 (__HANDLE__)->Instance->WPR = 0xFFU; \
593 * @brief Check whether the RTC Calendar is initialized.
594 * @param __HANDLE__ specifies the RTC handle.
598 #define __HAL_RTC_IS_CALENDAR_INITIALIZED(__HANDLE__) (((((__HANDLE__)->Instance->ICSR) & (RTC_FLAG_INITS)) == RTC_FLAG_INITS) ? 1U : 0U)
600 #define __HAL_RTC_IS_CALENDAR_INITIALIZED(__HANDLE__) (((((__HANDLE__)->Instance->ISR) & (RTC_FLAG_INITS)) == RTC_FLAG_INITS) ? 1U : 0U)
604 * @brief Add 1 hour (summer time change).
605 * @param __HANDLE__ specifies the RTC handle.
606 * @param __BKP__ Backup
607 * This parameter can be:
608 * @arg @ref RTC_STOREOPERATION_RESET
609 * @arg @ref RTC_STOREOPERATION_SET
612 #define __HAL_RTC_DAYLIGHT_SAVING_TIME_ADD1H(__HANDLE__, __BKP__) \
614 __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__); \
615 SET_BIT((__HANDLE__)->Instance->CR, RTC_CR_ADD1H); \
616 MODIFY_REG((__HANDLE__)->Instance->CR, RTC_CR_BKP , (__BKP__)); \
617 __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__); \
621 * @brief Subtract 1 hour (winter time change).
622 * @param __HANDLE__ specifies the RTC handle.
623 * @param __BKP__ Backup
624 * This parameter can be:
625 * @arg @ref RTC_STOREOPERATION_RESET
626 * @arg @ref RTC_STOREOPERATION_SET
629 #define __HAL_RTC_DAYLIGHT_SAVING_TIME_SUB1H(__HANDLE__, __BKP__) \
631 __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__); \
632 SET_BIT((__HANDLE__)->Instance->CR, RTC_CR_SUB1H); \
633 MODIFY_REG((__HANDLE__)->Instance->CR, RTC_CR_BKP , (__BKP__)); \
634 __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__); \
638 * @brief Enable the RTC ALARMA peripheral.
639 * @param __HANDLE__ specifies the RTC handle.
642 #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE))
645 * @brief Disable the RTC ALARMA peripheral.
646 * @param __HANDLE__ specifies the RTC handle.
649 #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE))
652 * @brief Enable the RTC ALARMB peripheral.
653 * @param __HANDLE__ specifies the RTC handle.
656 #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE))
659 * @brief Disable the RTC ALARMB peripheral.
660 * @param __HANDLE__ specifies the RTC handle.
663 #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE))
666 * @brief Enable the RTC Alarm interrupt.
667 * @param __HANDLE__ specifies the RTC handle.
668 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
669 * This parameter can be any combination of the following values:
670 * @arg @ref RTC_IT_ALRA Alarm A interrupt
671 * @arg @ref RTC_IT_ALRB Alarm B interrupt
674 #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
677 * @brief Disable the RTC Alarm interrupt.
678 * @param __HANDLE__ specifies the RTC handle.
679 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
680 * This parameter can be any combination of the following values:
681 * @arg @ref RTC_IT_ALRA Alarm A interrupt
682 * @arg @ref RTC_IT_ALRB Alarm B interrupt
685 #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
688 * @brief Check whether the specified RTC Alarm interrupt has occurred or not.
689 * @param __HANDLE__ specifies the RTC handle.
690 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
691 * This parameter can be:
692 * @arg @ref RTC_IT_ALRA Alarm A interrupt
693 * @arg @ref RTC_IT_ALRB Alarm B interrupt
697 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->MISR)& (__INTERRUPT__ >> 12)) != 0U)? 1U : 0U)
699 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR)& (__INTERRUPT__ >> 4)) != 0U)? 1U : 0U)
703 * @brief Check whether the specified RTC Alarm interrupt has been enabled or not.
704 * @param __HANDLE__ specifies the RTC handle.
705 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
706 * This parameter can be:
707 * @arg @ref RTC_IT_ALRA Alarm A interrupt
708 * @arg @ref RTC_IT_ALRB Alarm B interrupt
711 #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
715 * @brief Get the selected RTC Alarm's flag status.
716 * @param __HANDLE__ specifies the RTC handle.
717 * @param __FLAG__ specifies the RTC Alarm Flag sources to check.
718 * This parameter can be:
719 * @arg @ref RTC_FLAG_ALRAF
720 * @arg @ref RTC_FLAG_ALRBF
723 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->SR) & (__FLAG__)) != 0U) ? 1U : 0U)
726 * @brief Get the selected RTC Alarm's flag status.
727 * @param __HANDLE__ specifies the RTC handle.
728 * @param __FLAG__ specifies the RTC Alarm Flag sources to check.
729 * This parameter can be:
730 * @arg @ref RTC_FLAG_ALRAF
731 * @arg @ref RTC_FLAG_ALRBF
732 * @arg @ref RTC_FLAG_ALRAWF
733 * @arg @ref RTC_FLAG_ALRBWF
736 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
740 * @brief Clear the RTC Alarm's pending flags.
741 * @param __HANDLE__ specifies the RTC handle.
742 * @param __FLAG__ specifies the RTC Alarm Flag sources to clear.
743 * This parameter can be:
744 * @arg @ref RTC_FLAG_ALRAF
745 * @arg @ref RTC_FLAG_ALRBF
749 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SCR = __FLAG__)
751 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)))
756 * @brief Enable interrupt on the RTC Alarm associated Exti line.
760 #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI_D1->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
762 #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
766 * @brief Disable interrupt on the RTC Alarm associated Exti line.
770 #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI_D1->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
772 #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
776 * @brief Enable event on the RTC Alarm associated Exti line.
780 #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI_D1->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
782 #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
786 * @brief Disable event on the RTC Alarm associated Exti line.
790 #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI_D1->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
792 #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
795 #if defined(DUAL_CORE)
797 * @brief Enable interrupt on the RTC Alarm associated D2 Exti line.
800 #define __HAL_RTC_ALARM_EXTID2_ENABLE_IT() (EXTI_D2->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
803 * @brief Disable interrupt on the RTC Alarm associated D2 Exti line.
806 #define __HAL_RTC_ALARM_EXTID2_DISABLE_IT() (EXTI_D2->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
809 * @brief Enable event on the RTC Alarm associated D2 Exti line.
812 #define __HAL_RTC_ALARM_EXTID2_ENABLE_EVENT() (EXTI_D2->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
815 * @brief Disable event on the RTC Alarm associated D2 Exti line.
818 #define __HAL_RTC_ALARM_EXTID2_DISABLE_EVENT() (EXTI_D2->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
820 #endif /* DUAL_CORE */
822 * @brief Enable falling edge trigger on the RTC Alarm associated Exti line.
825 #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR1 |= RTC_EXTI_LINE_ALARM_EVENT)
828 * @brief Disable falling edge trigger on the RTC Alarm associated Exti line.
831 #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
834 * @brief Enable rising edge trigger on the RTC Alarm associated Exti line.
837 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR1 |= RTC_EXTI_LINE_ALARM_EVENT)
840 * @brief Disable rising edge trigger on the RTC Alarm associated Exti line.
843 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
846 * @brief Enable rising & falling edge trigger on the RTC Alarm associated Exti line.
849 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
850 __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE(); \
851 __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE(); \
855 * @brief Disable rising & falling edge trigger on the RTC Alarm associated Exti line.
858 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
859 __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE(); \
860 __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(); \
864 * @brief Check whether the RTC Alarm associated Exti line interrupt flag is set or not.
865 * @retval Line Status.
868 #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI_D1->PR1 & RTC_EXTI_LINE_ALARM_EVENT)
870 #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR1 & RTC_EXTI_LINE_ALARM_EVENT)
874 * @brief Clear the RTC Alarm associated Exti line flag.
878 #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI_D1->PR1 = (RTC_EXTI_LINE_ALARM_EVENT))
880 #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR1 = (RTC_EXTI_LINE_ALARM_EVENT))
883 #if defined(DUAL_CORE)
885 * @brief Check whether the RTC Alarm associated D2 Exti line interrupt flag is set or not.
886 * @retval Line Status
888 #define __HAL_RTC_ALARM_EXTID2_GET_FLAG() (EXTI_D2->PR1 & RTC_EXTI_LINE_ALARM_EVENT)
891 * @brief Clear the RTC Alarm associated D2 Exti line flag.
894 #define __HAL_RTC_ALARM_EXTID2_CLEAR_FLAG() (EXTI_D2->PR1 = (RTC_EXTI_LINE_ALARM_EVENT))
895 #endif /* DUAL_CORE */
897 * @brief Generate a Software interrupt on RTC Alarm associated Exti line.
900 #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() (EXTI->SWIER1 |= RTC_EXTI_LINE_ALARM_EVENT)
906 /* Include RTC HAL Extended module */
907 #include "stm32h7xx_hal_rtc_ex.h"
909 /* Exported functions --------------------------------------------------------*/
910 /** @defgroup RTC_Exported_Functions RTC Exported Functions
914 /** @defgroup RTC_Exported_Functions_Group1 Initialization and de-initialization functions
917 /* Initialization and de-initialization functions ****************************/
918 HAL_StatusTypeDef
HAL_RTC_Init(RTC_HandleTypeDef
*hrtc
);
919 HAL_StatusTypeDef
HAL_RTC_DeInit(RTC_HandleTypeDef
*hrtc
);
921 void HAL_RTC_MspInit(RTC_HandleTypeDef
*hrtc
);
922 void HAL_RTC_MspDeInit(RTC_HandleTypeDef
*hrtc
);
924 /* Callbacks Register/UnRegister functions ***********************************/
925 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
926 HAL_StatusTypeDef
HAL_RTC_RegisterCallback(RTC_HandleTypeDef
*hrtc
, HAL_RTC_CallbackIDTypeDef CallbackID
, pRTC_CallbackTypeDef pCallback
);
927 HAL_StatusTypeDef
HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef
*hrtc
, HAL_RTC_CallbackIDTypeDef CallbackID
);
928 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
933 /** @defgroup RTC_Exported_Functions_Group2 RTC Time and Date functions
936 /* RTC Time and Date functions ************************************************/
937 HAL_StatusTypeDef
HAL_RTC_SetTime(RTC_HandleTypeDef
*hrtc
, RTC_TimeTypeDef
*sTime
, uint32_t Format
);
938 HAL_StatusTypeDef
HAL_RTC_GetTime(const RTC_HandleTypeDef
*hrtc
, RTC_TimeTypeDef
*sTime
, uint32_t Format
);
939 HAL_StatusTypeDef
HAL_RTC_SetDate(RTC_HandleTypeDef
*hrtc
, RTC_DateTypeDef
*sDate
, uint32_t Format
);
940 HAL_StatusTypeDef
HAL_RTC_GetDate(const RTC_HandleTypeDef
*hrtc
, RTC_DateTypeDef
*sDate
, uint32_t Format
);
945 /** @defgroup RTC_Exported_Functions_Group3 RTC Alarm functions
948 /* RTC Alarm functions ********************************************************/
949 HAL_StatusTypeDef
HAL_RTC_SetAlarm(RTC_HandleTypeDef
*hrtc
, RTC_AlarmTypeDef
*sAlarm
, uint32_t Format
);
950 HAL_StatusTypeDef
HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef
*hrtc
, RTC_AlarmTypeDef
*sAlarm
, uint32_t Format
);
951 HAL_StatusTypeDef
HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef
*hrtc
, uint32_t Alarm
);
952 HAL_StatusTypeDef
HAL_RTC_GetAlarm(const RTC_HandleTypeDef
*hrtc
, RTC_AlarmTypeDef
*sAlarm
, uint32_t Alarm
, uint32_t Format
);
953 void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef
*hrtc
);
954 void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef
*hrtc
);
955 HAL_StatusTypeDef
HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef
*hrtc
, uint32_t Timeout
);
960 /** @defgroup RTC_Exported_Functions_Group4 Peripheral Control functions
963 /* Peripheral Control functions ***********************************************/
964 HAL_StatusTypeDef
HAL_RTC_WaitForSynchro(RTC_HandleTypeDef
*hrtc
);
969 /** @defgroup RTC_Exported_Functions_Group5 Peripheral State functions
972 /* Peripheral State functions *************************************************/
973 HAL_RTCStateTypeDef
HAL_RTC_GetState(const RTC_HandleTypeDef
*hrtc
);
982 /* Private types -------------------------------------------------------------*/
983 /* Private variables ---------------------------------------------------------*/
984 /* Private constants ---------------------------------------------------------*/
985 /** @defgroup RTC_Private_Constants RTC Private Constants
988 /* Masks Definition */
989 #define RTC_TR_RESERVED_MASK (RTC_TR_PM | RTC_TR_HT | RTC_TR_HU | \
990 RTC_TR_MNT | RTC_TR_MNU| RTC_TR_ST | \
993 #define RTC_DR_RESERVED_MASK (RTC_DR_YT | RTC_DR_YU | RTC_DR_WDU | \
994 RTC_DR_MT | RTC_DR_MU | RTC_DR_DT | \
997 #define RTC_INIT_MASK 0xFFFFFFFFu
1000 #define RTC_ICSR_RESERVED_MASK 0x000100FFu
1001 #define RTC_RSF_MASK (~(RTC_ICSR_INIT | RTC_ICSR_RSF))
1003 #define RTC_ISR_RESERVED_MASK 0x0003FFFFu
1004 #define RTC_RSF_MASK (~(RTC_ISR_INIT | RTC_ISR_RSF))
1007 #define RTC_TIMEOUT_VALUE 1000u
1009 #define RTC_EXTI_LINE_ALARM_EVENT EXTI_IMR1_IM17 /*!< External interrupt line 17 Connected to the RTC Alarm event */
1015 /* Private macros ------------------------------------------------------------*/
1016 /** @defgroup RTC_Private_Macros RTC Private Macros
1020 /** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters
1025 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
1026 ((OUTPUT) == RTC_OUTPUT_ALARMA) || \
1027 ((OUTPUT) == RTC_OUTPUT_ALARMB) || \
1028 ((OUTPUT) == RTC_OUTPUT_WAKEUP) || \
1029 ((OUTPUT) == RTC_OUTPUT_TAMPER))
1031 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
1032 ((OUTPUT) == RTC_OUTPUT_ALARMA) || \
1033 ((OUTPUT) == RTC_OUTPUT_ALARMB) || \
1034 ((OUTPUT) == RTC_OUTPUT_WAKEUP))
1037 #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HOURFORMAT_12) || \
1038 ((FORMAT) == RTC_HOURFORMAT_24))
1040 #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \
1041 ((POL) == RTC_OUTPUT_POLARITY_LOW))
1043 #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \
1044 ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL))
1047 #define IS_RTC_OUTPUT_PULLUP(TYPE) (((TYPE) == RTC_OUTPUT_PULLUP_NONE) || \
1048 ((TYPE) == RTC_OUTPUT_PULLUP_ON))
1051 #define IS_RTC_OUTPUT_REMAP(REMAP) (((REMAP) == RTC_OUTPUT_REMAP_NONE) || \
1052 ((REMAP) == RTC_OUTPUT_REMAP_POS1))
1054 #define IS_RTC_HOURFORMAT12(PM) (((PM) == RTC_HOURFORMAT12_AM) || \
1055 ((PM) == RTC_HOURFORMAT12_PM))
1057 #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \
1058 ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \
1059 ((SAVE) == RTC_DAYLIGHTSAVING_NONE))
1061 #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \
1062 ((OPERATION) == RTC_STOREOPERATION_SET))
1064 #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || \
1065 ((FORMAT) == RTC_FORMAT_BCD))
1067 #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99u)
1069 #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1u) && ((MONTH) <= 12u))
1071 #define IS_RTC_DATE(DATE) (((DATE) >= 1u) && ((DATE) <= 31u))
1073 #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \
1074 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \
1075 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
1076 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \
1077 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \
1078 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \
1079 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
1081 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0u) && ((DATE) <= 31u))
1083 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \
1084 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \
1085 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
1086 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \
1087 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \
1088 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \
1089 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
1091 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \
1092 ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY))
1094 #define IS_RTC_ALARM_MASK(MASK) (((MASK) & ~(RTC_ALARMMASK_ALL)) == 0u)
1096 #define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_ALARM_A) || \
1097 ((ALARM) == RTC_ALARM_B))
1099 #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= RTC_ALRMASSR_SS)
1101 #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == 0u) || \
1102 (((MASK) >= RTC_ALARMSUBSECONDMASK_SS14_1) && ((MASK) <= RTC_ALARMSUBSECONDMASK_NONE)))
1104 #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= (RTC_PRER_PREDIV_A >> RTC_PRER_PREDIV_A_Pos))
1106 #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= (RTC_PRER_PREDIV_S >> RTC_PRER_PREDIV_S_Pos))
1108 #define IS_RTC_HOUR12(HOUR) (((HOUR) > 0u) && ((HOUR) <= 12u))
1110 #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23u)
1112 #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59u)
1114 #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59u)
1124 /* Private functions -------------------------------------------------------------*/
1125 /** @defgroup RTC_Private_Functions RTC Private Functions
1128 HAL_StatusTypeDef
RTC_EnterInitMode(RTC_HandleTypeDef
*hrtc
);
1129 HAL_StatusTypeDef
RTC_ExitInitMode(RTC_HandleTypeDef
*hrtc
);
1130 uint8_t RTC_ByteToBcd2(uint8_t Value
);
1131 uint8_t RTC_Bcd2ToByte(uint8_t Value
);
1149 #endif /* STM32H7xx_HAL_RTC_H */