2 ******************************************************************************
3 * @file stm32f7xx_hal_rtc.h
4 * @author MCD Application Team
5 * @brief Header file of RTC HAL module.
6 ******************************************************************************
9 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
10 * All rights reserved.</center></h2>
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
17 ******************************************************************************
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef __STM32F7xx_HAL_RTC_H
22 #define __STM32F7xx_HAL_RTC_H
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32f7xx_hal_def.h"
31 /** @addtogroup STM32F7xx_HAL_Driver
39 /* Exported types ------------------------------------------------------------*/
40 /** @defgroup RTC_Exported_Types RTC Exported Types
45 * @brief HAL State structures definition
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 */
58 * @brief RTC Configuration Structure definition
62 uint32_t HourFormat
; /*!< Specifies the RTC Hour Format.
63 This parameter can be a value of @ref RTC_Hour_Formats */
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 */
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 */
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 */
74 uint32_t OutPutPolarity
; /*!< Specifies the polarity of the output signal.
75 This parameter can be a value of @ref RTC_Output_Polarity_Definitions */
77 uint32_t OutPutType
; /*!< Specifies the RTC Output Pin mode.
78 This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */
82 * @brief RTC Time structure definition
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 */
90 uint8_t Minutes
; /*!< Specifies the RTC Time Minutes.
91 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
93 uint8_t Seconds
; /*!< Specifies the RTC Time Seconds.
94 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
96 uint32_t SubSeconds
; /*!< Specifies the RTC_SSR RTC Sub Second register content.
97 This parameter corresponds to a time unit range between [0-1] Second
98 with [1 Sec / SecondFraction +1] granularity */
100 uint32_t SecondFraction
; /*!< Specifies the range or granularity of Sub Second register content
101 corresponding to Synchronous pre-scaler factor value (PREDIV_S)
102 This parameter corresponds to a time unit range between [0-1] Second
103 with [1 Sec / SecondFraction +1] granularity.
104 This field will be used only by HAL_RTC_GetTime function */
106 uint8_t TimeFormat
; /*!< Specifies the RTC AM/PM Time.
107 This parameter can be a value of @ref RTC_AM_PM_Definitions */
109 uint32_t DayLightSaving
; /*!< Specifies RTC_DayLightSaveOperation: the value of hour adjustment.
110 This parameter can be a value of @ref RTC_DayLightSaving_Definitions */
112 uint32_t StoreOperation
; /*!< Specifies RTC_StoreOperation value to be written in the BKP bit
113 in CR register to store the operation.
114 This parameter can be a value of @ref RTC_StoreOperation_Definitions */
118 * @brief RTC Date structure definition
122 uint8_t WeekDay
; /*!< Specifies the RTC Date WeekDay.
123 This parameter can be a value of @ref RTC_WeekDay_Definitions */
125 uint8_t Month
; /*!< Specifies the RTC Date Month (in BCD format).
126 This parameter can be a value of @ref RTC_Month_Date_Definitions */
128 uint8_t Date
; /*!< Specifies the RTC Date.
129 This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
131 uint8_t Year
; /*!< Specifies the RTC Date Year.
132 This parameter must be a number between Min_Data = 0 and Max_Data = 99 */
137 * @brief RTC Alarm structure definition
141 RTC_TimeTypeDef AlarmTime
; /*!< Specifies the RTC Alarm Time members */
143 uint32_t AlarmMask
; /*!< Specifies the RTC Alarm Masks.
144 This parameter can be a value of @ref RTC_AlarmMask_Definitions */
146 uint32_t AlarmSubSecondMask
; /*!< Specifies the RTC Alarm SubSeconds Masks.
147 This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */
149 uint32_t AlarmDateWeekDaySel
; /*!< Specifies the RTC Alarm is on Date or WeekDay.
150 This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */
152 uint8_t AlarmDateWeekDay
; /*!< Specifies the RTC Alarm Date/WeekDay.
153 If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range.
154 If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */
156 uint32_t Alarm
; /*!< Specifies the alarm .
157 This parameter can be a value of @ref RTC_Alarms_Definitions */
161 * @brief RTC Handle Structure definition
163 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
164 typedef struct __RTC_HandleTypeDef
167 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
169 RTC_TypeDef
*Instance
; /*!< Register base address */
171 RTC_InitTypeDef Init
; /*!< RTC required parameters */
173 HAL_LockTypeDef Lock
; /*!< RTC locking object */
175 __IO HAL_RTCStateTypeDef State
; /*!< Time communication state */
177 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
178 void (* AlarmAEventCallback
) ( struct __RTC_HandleTypeDef
* hrtc
); /*!< RTC Alarm A Event callback */
180 void (* AlarmBEventCallback
) ( struct __RTC_HandleTypeDef
* hrtc
); /*!< RTC Alarm B Event callback */
182 void (* TimeStampEventCallback
) ( struct __RTC_HandleTypeDef
* hrtc
); /*!< RTC TimeStamp Event callback */
184 void (* WakeUpTimerEventCallback
) ( struct __RTC_HandleTypeDef
* hrtc
); /*!< RTC WakeUpTimer Event callback */
186 void (* Tamper1EventCallback
) ( struct __RTC_HandleTypeDef
* hrtc
); /*!< RTC Tamper 1 Event callback */
188 void (* Tamper2EventCallback
) ( struct __RTC_HandleTypeDef
* hrtc
); /*!< RTC Tamper 2 Event callback */
190 void (* Tamper3EventCallback
) ( struct __RTC_HandleTypeDef
* hrtc
); /*!< RTC Tamper 3 Event callback */
192 void (* MspInitCallback
) ( struct __RTC_HandleTypeDef
* hrtc
); /*!< RTC Msp Init callback */
194 void (* MspDeInitCallback
) ( struct __RTC_HandleTypeDef
* hrtc
); /*!< RTC Msp DeInit callback */
196 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
200 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
202 * @brief HAL RTC Callback ID enumeration definition
206 HAL_RTC_ALARM_A_EVENT_CB_ID
= 0x00u
, /*!< RTC Alarm A Event Callback ID */
207 HAL_RTC_ALARM_B_EVENT_CB_ID
= 0x01u
, /*!< RTC Alarm B Event Callback ID */
208 HAL_RTC_TIMESTAMP_EVENT_CB_ID
= 0x02u
, /*!< RTC TimeStamp Event Callback ID */
209 HAL_RTC_WAKEUPTIMER_EVENT_CB_ID
= 0x03u
, /*!< RTC Wake-Up Timer Event Callback ID */
210 HAL_RTC_TAMPER1_EVENT_CB_ID
= 0x04u
, /*!< RTC Tamper 1 Callback ID */
211 HAL_RTC_TAMPER2_EVENT_CB_ID
= 0x05u
, /*!< RTC Tamper 2 Callback ID */
212 HAL_RTC_TAMPER3_EVENT_CB_ID
= 0x06u
, /*!< RTC Tamper 3 Callback ID */
213 HAL_RTC_MSPINIT_CB_ID
= 0x0Eu
, /*!< RTC Msp Init callback ID */
214 HAL_RTC_MSPDEINIT_CB_ID
= 0x0Fu
/*!< RTC Msp DeInit callback ID */
215 }HAL_RTC_CallbackIDTypeDef
;
218 * @brief HAL RTC Callback pointer definition
220 typedef void (*pRTC_CallbackTypeDef
)(RTC_HandleTypeDef
* hrtc
); /*!< pointer to an RTC callback function */
221 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
227 /* Exported constants --------------------------------------------------------*/
228 /** @defgroup RTC_Exported_Constants RTC Exported Constants
232 /** @defgroup RTC_Hour_Formats RTC Hour Formats
235 #define RTC_HOURFORMAT_24 0x00000000U
236 #define RTC_HOURFORMAT_12 0x00000040U
242 /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions
245 #define RTC_OUTPUT_POLARITY_HIGH 0x00000000U
246 #define RTC_OUTPUT_POLARITY_LOW 0x00100000U
251 /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT
254 #define RTC_OUTPUT_TYPE_OPENDRAIN 0x00000000U
255 #define RTC_OUTPUT_TYPE_PUSHPULL RTC_OR_ALARMTYPE /* 0x00000008 */
260 /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions
263 #define RTC_HOURFORMAT12_AM ((uint8_t)0x00U)
264 #define RTC_HOURFORMAT12_PM ((uint8_t)0x40U)
269 /** @defgroup RTC_DayLightSaving_Definitions RTC DayLight Saving Definitions
272 #define RTC_DAYLIGHTSAVING_SUB1H 0x00020000U
273 #define RTC_DAYLIGHTSAVING_ADD1H 0x00010000U
274 #define RTC_DAYLIGHTSAVING_NONE 0x00000000U
279 /** @defgroup RTC_StoreOperation_Definitions RTC Store Operation Definitions
282 #define RTC_STOREOPERATION_RESET 0x00000000U
283 #define RTC_STOREOPERATION_SET 0x00040000U
288 /** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions
291 #define RTC_FORMAT_BIN 0x00000000U
292 #define RTC_FORMAT_BCD 0x00000001U
297 /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions
300 /* Coded in BCD format */
301 #define RTC_MONTH_JANUARY ((uint8_t)0x01U)
302 #define RTC_MONTH_FEBRUARY ((uint8_t)0x02U)
303 #define RTC_MONTH_MARCH ((uint8_t)0x03U)
304 #define RTC_MONTH_APRIL ((uint8_t)0x04U)
305 #define RTC_MONTH_MAY ((uint8_t)0x05U)
306 #define RTC_MONTH_JUNE ((uint8_t)0x06U)
307 #define RTC_MONTH_JULY ((uint8_t)0x07U)
308 #define RTC_MONTH_AUGUST ((uint8_t)0x08U)
309 #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09U)
310 #define RTC_MONTH_OCTOBER ((uint8_t)0x10U)
311 #define RTC_MONTH_NOVEMBER ((uint8_t)0x11U)
312 #define RTC_MONTH_DECEMBER ((uint8_t)0x12U)
317 /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions
320 #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01U)
321 #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02U)
322 #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03U)
323 #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04U)
324 #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05U)
325 #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06U)
326 #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07U)
331 /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC Alarm Date WeekDay Definitions
334 #define RTC_ALARMDATEWEEKDAYSEL_DATE 0x00000000U
335 #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY 0x40000000U
340 /** @defgroup RTC_AlarmMask_Definitions RTC Alarm Mask Definitions
343 #define RTC_ALARMMASK_NONE 0x00000000U
344 #define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4
345 #define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3
346 #define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2
347 #define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1
348 #define RTC_ALARMMASK_ALL 0x80808080U
353 /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions
356 #define RTC_ALARM_A RTC_CR_ALRAE
357 #define RTC_ALARM_B RTC_CR_ALRBE
362 /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions
365 #define RTC_ALARMSUBSECONDMASK_ALL 0x00000000U /*!< All Alarm SS fields are masked.
366 There is no comparison on sub seconds
368 #define RTC_ALARMSUBSECONDMASK_SS14_1 0x01000000U /*!< SS[14:1] are don't care in Alarm
369 comparison. Only SS[0] is compared. */
370 #define RTC_ALARMSUBSECONDMASK_SS14_2 0x02000000U /*!< SS[14:2] are don't care in Alarm
371 comparison. Only SS[1:0] are compared */
372 #define RTC_ALARMSUBSECONDMASK_SS14_3 0x03000000U /*!< SS[14:3] are don't care in Alarm
373 comparison. Only SS[2:0] are compared */
374 #define RTC_ALARMSUBSECONDMASK_SS14_4 0x04000000U /*!< SS[14:4] are don't care in Alarm
375 comparison. Only SS[3:0] are compared */
376 #define RTC_ALARMSUBSECONDMASK_SS14_5 0x05000000U /*!< SS[14:5] are don't care in Alarm
377 comparison. Only SS[4:0] are compared */
378 #define RTC_ALARMSUBSECONDMASK_SS14_6 0x06000000U /*!< SS[14:6] are don't care in Alarm
379 comparison. Only SS[5:0] are compared */
380 #define RTC_ALARMSUBSECONDMASK_SS14_7 0x07000000U /*!< SS[14:7] are don't care in Alarm
381 comparison. Only SS[6:0] are compared */
382 #define RTC_ALARMSUBSECONDMASK_SS14_8 0x08000000U /*!< SS[14:8] are don't care in Alarm
383 comparison. Only SS[7:0] are compared */
384 #define RTC_ALARMSUBSECONDMASK_SS14_9 0x09000000U /*!< SS[14:9] are don't care in Alarm
385 comparison. Only SS[8:0] are compared */
386 #define RTC_ALARMSUBSECONDMASK_SS14_10 0x0A000000U /*!< SS[14:10] are don't care in Alarm
387 comparison. Only SS[9:0] are compared */
388 #define RTC_ALARMSUBSECONDMASK_SS14_11 0x0B000000U /*!< SS[14:11] are don't care in Alarm
389 comparison. Only SS[10:0] are compared */
390 #define RTC_ALARMSUBSECONDMASK_SS14_12 0x0C000000U /*!< SS[14:12] are don't care in Alarm
391 comparison.Only SS[11:0] are compared */
392 #define RTC_ALARMSUBSECONDMASK_SS14_13 0x0D000000U /*!< SS[14:13] are don't care in Alarm
393 comparison. Only SS[12:0] are compared */
394 #define RTC_ALARMSUBSECONDMASK_SS14 0x0E000000U /*!< SS[14] is don't care in Alarm
395 comparison.Only SS[13:0] are compared */
396 #define RTC_ALARMSUBSECONDMASK_NONE 0x0F000000U /*!< SS[14:0] are compared and must match
397 to activate alarm. */
402 /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions
405 #define RTC_IT_TS RTC_CR_TSIE
406 #define RTC_IT_WUT RTC_CR_WUTIE
407 #define RTC_IT_ALRA RTC_CR_ALRAIE
408 #define RTC_IT_ALRB RTC_CR_ALRBIE
409 #define RTC_IT_TAMP RTC_TAMPCR_TAMPIE /* Used only to Enable the Tamper Interrupt */
410 #define RTC_IT_TAMP1 RTC_TAMPCR_TAMP1IE
411 #define RTC_IT_TAMP2 RTC_TAMPCR_TAMP2IE
412 #define RTC_IT_TAMP3 RTC_TAMPCR_TAMP3IE
417 /** @defgroup RTC_Flags_Definitions RTC Flags Definitions
420 #define RTC_FLAG_RECALPF RTC_ISR_RECALPF
421 #define RTC_FLAG_TAMP3F RTC_ISR_TAMP3F
422 #define RTC_FLAG_TAMP2F RTC_ISR_TAMP2F
423 #define RTC_FLAG_TAMP1F RTC_ISR_TAMP1F
424 #define RTC_FLAG_TSOVF RTC_ISR_TSOVF
425 #define RTC_FLAG_TSF RTC_ISR_TSF
426 #define RTC_FLAG_ITSF RTC_ISR_ITSF
427 #define RTC_FLAG_WUTF RTC_ISR_WUTF
428 #define RTC_FLAG_ALRBF RTC_ISR_ALRBF
429 #define RTC_FLAG_ALRAF RTC_ISR_ALRAF
430 #define RTC_FLAG_INITF RTC_ISR_INITF
431 #define RTC_FLAG_RSF RTC_ISR_RSF
432 #define RTC_FLAG_INITS RTC_ISR_INITS
433 #define RTC_FLAG_SHPF RTC_ISR_SHPF
434 #define RTC_FLAG_WUTWF RTC_ISR_WUTWF
435 #define RTC_FLAG_ALRBWF RTC_ISR_ALRBWF
436 #define RTC_FLAG_ALRAWF RTC_ISR_ALRAWF
445 /* Exported macro ------------------------------------------------------------*/
446 /** @defgroup RTC_Exported_Macros RTC Exported Macros
450 /** @brief Reset RTC handle state
451 * @param __HANDLE__ specifies the RTC handle.
454 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
455 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{\
456 (__HANDLE__)->State = HAL_RTC_STATE_RESET;\
457 (__HANDLE__)->MspInitCallback = NULL;\
458 (__HANDLE__)->MspDeInitCallback = NULL;\
461 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
462 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
465 * @brief Disable the write protection for RTC registers.
466 * @param __HANDLE__ specifies the RTC handle.
469 #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \
471 (__HANDLE__)->Instance->WPR = 0xCAU; \
472 (__HANDLE__)->Instance->WPR = 0x53U; \
476 * @brief Enable the write protection for RTC registers.
477 * @param __HANDLE__ specifies the RTC handle.
480 #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \
482 (__HANDLE__)->Instance->WPR = 0xFFU; \
486 * @brief Enable the RTC ALARMA peripheral.
487 * @param __HANDLE__ specifies the RTC handle.
490 #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE))
493 * @brief Disable the RTC ALARMA peripheral.
494 * @param __HANDLE__ specifies the RTC handle.
497 #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE))
500 * @brief Enable the RTC ALARMB peripheral.
501 * @param __HANDLE__ specifies the RTC handle.
504 #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE))
507 * @brief Disable the RTC ALARMB peripheral.
508 * @param __HANDLE__ specifies the RTC handle.
511 #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE))
514 * @brief Enable the RTC Alarm interrupt.
515 * @param __HANDLE__ specifies the RTC handle.
516 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
517 * This parameter can be any combination of the following values:
518 * @arg RTC_IT_ALRA: Alarm A interrupt
519 * @arg RTC_IT_ALRB: Alarm B interrupt
522 #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
525 * @brief Disable the RTC Alarm interrupt.
526 * @param __HANDLE__ specifies the RTC handle.
527 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
528 * This parameter can be any combination of the following values:
529 * @arg RTC_IT_ALRA: Alarm A interrupt
530 * @arg RTC_IT_ALRB: Alarm B interrupt
533 #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
536 * @brief Check whether the specified RTC Alarm interrupt has occurred or not.
537 * @param __HANDLE__ specifies the RTC handle.
538 * @param __INTERRUPT__ specifies the RTC Alarm interrupt to check.
539 * This parameter can be:
540 * @arg RTC_IT_ALRA: Alarm A interrupt
541 * @arg RTC_IT_ALRB: Alarm B interrupt
544 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) ((((((__HANDLE__)->Instance->ISR)& ((__INTERRUPT__)>> 4U)) & 0x0000FFFFU) != RESET)? SET : RESET)
547 * @brief Get the selected RTC Alarm's flag status.
548 * @param __HANDLE__ specifies the RTC handle.
549 * @param __FLAG__ specifies the RTC Alarm Flag to check.
550 * This parameter can be:
551 * @arg RTC_FLAG_ALRAF
552 * @arg RTC_FLAG_ALRBF
553 * @arg RTC_FLAG_ALRAWF
554 * @arg RTC_FLAG_ALRBWF
557 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
560 * @brief Clear the RTC Alarm's pending flags.
561 * @param __HANDLE__ specifies the RTC handle.
562 * @param __FLAG__ specifies the RTC Alarm Flag sources to be enabled or disabled.
563 * This parameter can be:
564 * @arg RTC_FLAG_ALRAF
565 * @arg RTC_FLAG_ALRBF
568 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& 0x0000FFFFU)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
571 * @brief Check whether the specified RTC Alarm interrupt has been enabled or not.
572 * @param __HANDLE__ specifies the RTC handle.
573 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
574 * This parameter can be:
575 * @arg RTC_IT_ALRA: Alarm A interrupt
576 * @arg RTC_IT_ALRB: Alarm B interrupt
579 #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
582 * @brief Enable interrupt on the RTC Alarm associated Exti line.
585 #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_ALARM_EVENT)
588 * @brief Disable interrupt on the RTC Alarm associated Exti line.
591 #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI->IMR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
594 * @brief Enable event on the RTC Alarm associated Exti line.
597 #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_ALARM_EVENT)
600 * @brief Disable event on the RTC Alarm associated Exti line.
603 #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
606 * @brief Enable falling edge trigger on the RTC Alarm associated Exti line.
609 #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_ALARM_EVENT)
612 * @brief Disable falling edge trigger on the RTC Alarm associated Exti line.
615 #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
618 * @brief Enable rising edge trigger on the RTC Alarm associated Exti line.
621 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_ALARM_EVENT)
624 * @brief Disable rising edge trigger on the RTC Alarm associated Exti line.
627 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
630 * @brief Enable rising & falling edge trigger on the RTC Alarm associated Exti line.
633 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE();__HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE();
636 * @brief Disable rising & falling edge trigger on the RTC Alarm associated Exti line.
639 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE();__HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE();
642 * @brief Check whether the RTC Alarm associated Exti line interrupt flag is set or not.
643 * @retval Line Status.
645 #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_ALARM_EVENT)
648 * @brief Clear the RTC Alarm associated Exti line flag.
651 #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_ALARM_EVENT)
654 * @brief Generate a Software interrupt on RTC Alarm associated Exti line.
657 #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_ALARM_EVENT)
662 /* Include RTC HAL Extension module */
663 #include "stm32f7xx_hal_rtc_ex.h"
665 /* Exported functions --------------------------------------------------------*/
666 /** @addtogroup RTC_Exported_Functions
670 /** @addtogroup RTC_Exported_Functions_Group1
673 /* Initialization and de-initialization functions ****************************/
674 HAL_StatusTypeDef
HAL_RTC_Init(RTC_HandleTypeDef
*hrtc
);
675 HAL_StatusTypeDef
HAL_RTC_DeInit(RTC_HandleTypeDef
*hrtc
);
676 void HAL_RTC_MspInit(RTC_HandleTypeDef
*hrtc
);
677 void HAL_RTC_MspDeInit(RTC_HandleTypeDef
*hrtc
);
679 /* Callbacks Register/UnRegister functions ***********************************/
680 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
681 HAL_StatusTypeDef
HAL_RTC_RegisterCallback(RTC_HandleTypeDef
*hrtc
, HAL_RTC_CallbackIDTypeDef CallbackID
, pRTC_CallbackTypeDef pCallback
);
682 HAL_StatusTypeDef
HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef
*hrtc
, HAL_RTC_CallbackIDTypeDef CallbackID
);
683 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
688 /** @addtogroup RTC_Exported_Functions_Group2
691 /* RTC Time and Date functions ************************************************/
692 HAL_StatusTypeDef
HAL_RTC_SetTime(RTC_HandleTypeDef
*hrtc
, RTC_TimeTypeDef
*sTime
, uint32_t Format
);
693 HAL_StatusTypeDef
HAL_RTC_GetTime(RTC_HandleTypeDef
*hrtc
, RTC_TimeTypeDef
*sTime
, uint32_t Format
);
694 HAL_StatusTypeDef
HAL_RTC_SetDate(RTC_HandleTypeDef
*hrtc
, RTC_DateTypeDef
*sDate
, uint32_t Format
);
695 HAL_StatusTypeDef
HAL_RTC_GetDate(RTC_HandleTypeDef
*hrtc
, RTC_DateTypeDef
*sDate
, uint32_t Format
);
700 /** @addtogroup RTC_Exported_Functions_Group3
703 /* RTC Alarm functions ********************************************************/
704 HAL_StatusTypeDef
HAL_RTC_SetAlarm(RTC_HandleTypeDef
*hrtc
, RTC_AlarmTypeDef
*sAlarm
, uint32_t Format
);
705 HAL_StatusTypeDef
HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef
*hrtc
, RTC_AlarmTypeDef
*sAlarm
, uint32_t Format
);
706 HAL_StatusTypeDef
HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef
*hrtc
, uint32_t Alarm
);
707 HAL_StatusTypeDef
HAL_RTC_GetAlarm(RTC_HandleTypeDef
*hrtc
, RTC_AlarmTypeDef
*sAlarm
, uint32_t Alarm
, uint32_t Format
);
708 void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef
*hrtc
);
709 HAL_StatusTypeDef
HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef
*hrtc
, uint32_t Timeout
);
710 void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef
*hrtc
);
715 /** @addtogroup RTC_Exported_Functions_Group4
718 /* Peripheral Control functions ***********************************************/
719 HAL_StatusTypeDef
HAL_RTC_WaitForSynchro(RTC_HandleTypeDef
* hrtc
);
724 /** @addtogroup RTC_Exported_Functions_Group5
727 /* Peripheral State functions *************************************************/
728 HAL_RTCStateTypeDef
HAL_RTC_GetState(RTC_HandleTypeDef
*hrtc
);
737 /* Private types -------------------------------------------------------------*/
738 /* Private variables ---------------------------------------------------------*/
739 /* Private constants ---------------------------------------------------------*/
740 /** @defgroup RTC_Private_Constants RTC Private Constants
743 /* Masks Definition */
744 #define RTC_TR_RESERVED_MASK 0x007F7F7FU
745 #define RTC_DR_RESERVED_MASK 0x00FFFF3FU
746 #define RTC_INIT_MASK 0xFFFFFFFFU
747 #define RTC_RSF_MASK 0xFFFFFF5FU
749 #define RTC_TIMEOUT_VALUE 1000U
751 #define RTC_EXTI_LINE_ALARM_EVENT EXTI_IMR_IM17 /*!< External interrupt line 17 Connected to the RTC Alarm event */
756 /* Private macros ------------------------------------------------------------*/
757 /** @defgroup RTC_Private_Macros RTC Private Macros
761 /** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters
764 #define IS_RTC_HOUR_FORMAT(__FORMAT__) (((__FORMAT__) == RTC_HOURFORMAT_12) || \
765 ((__FORMAT__) == RTC_HOURFORMAT_24))
766 #define IS_RTC_OUTPUT_POL(__POL__) (((__POL__) == RTC_OUTPUT_POLARITY_HIGH) || \
767 ((__POL__) == RTC_OUTPUT_POLARITY_LOW))
768 #define IS_RTC_OUTPUT_TYPE(__TYPE__) (((__TYPE__) == RTC_OUTPUT_TYPE_OPENDRAIN) || \
769 ((__TYPE__) == RTC_OUTPUT_TYPE_PUSHPULL))
770 #define IS_RTC_ASYNCH_PREDIV(__PREDIV__) ((__PREDIV__) <= 0x7FU)
771 #define IS_RTC_SYNCH_PREDIV(__PREDIV__) ((__PREDIV__) <= 0x7FFFU)
772 #define IS_RTC_HOUR12(__HOUR__) (((__HOUR__) > 0U) && ((__HOUR__) <= 12U))
773 #define IS_RTC_HOUR24(__HOUR__) ((__HOUR__) <= 23U)
774 #define IS_RTC_MINUTES(__MINUTES__) ((__MINUTES__) <= 59U)
775 #define IS_RTC_SECONDS(__SECONDS__) ((__SECONDS__) <= 59U)
776 #define IS_RTC_HOURFORMAT12(__PM__) (((__PM__) == RTC_HOURFORMAT12_AM) || ((__PM__) == RTC_HOURFORMAT12_PM))
777 #define IS_RTC_DAYLIGHT_SAVING(__SAVE__) (((__SAVE__) == RTC_DAYLIGHTSAVING_SUB1H) || \
778 ((__SAVE__) == RTC_DAYLIGHTSAVING_ADD1H) || \
779 ((__SAVE__) == RTC_DAYLIGHTSAVING_NONE))
780 #define IS_RTC_STORE_OPERATION(__OPERATION__) (((__OPERATION__) == RTC_STOREOPERATION_RESET) || \
781 ((__OPERATION__) == RTC_STOREOPERATION_SET))
782 #define IS_RTC_FORMAT(__FORMAT__) (((__FORMAT__) == RTC_FORMAT_BIN) || ((__FORMAT__) == RTC_FORMAT_BCD))
783 #define IS_RTC_YEAR(__YEAR__) ((__YEAR__) <= 99U)
784 #define IS_RTC_MONTH(__MONTH__) (((__MONTH__) >= 1U) && ((__MONTH__) <= 12U))
785 #define IS_RTC_DATE(__DATE__) (((__DATE__) >= 1U) && ((__DATE__) <= 31U))
786 #define IS_RTC_WEEKDAY(__WEEKDAY__) (((__WEEKDAY__) == RTC_WEEKDAY_MONDAY) || \
787 ((__WEEKDAY__) == RTC_WEEKDAY_TUESDAY) || \
788 ((__WEEKDAY__) == RTC_WEEKDAY_WEDNESDAY) || \
789 ((__WEEKDAY__) == RTC_WEEKDAY_THURSDAY) || \
790 ((__WEEKDAY__) == RTC_WEEKDAY_FRIDAY) || \
791 ((__WEEKDAY__) == RTC_WEEKDAY_SATURDAY) || \
792 ((__WEEKDAY__) == RTC_WEEKDAY_SUNDAY))
794 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(__DATE__) (((__DATE__) >0U) && ((__DATE__) <= 31U))
795 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(__WEEKDAY__) (((__WEEKDAY__) == RTC_WEEKDAY_MONDAY) || \
796 ((__WEEKDAY__) == RTC_WEEKDAY_TUESDAY) || \
797 ((__WEEKDAY__) == RTC_WEEKDAY_WEDNESDAY) || \
798 ((__WEEKDAY__) == RTC_WEEKDAY_THURSDAY) || \
799 ((__WEEKDAY__) == RTC_WEEKDAY_FRIDAY) || \
800 ((__WEEKDAY__) == RTC_WEEKDAY_SATURDAY) || \
801 ((__WEEKDAY__) == RTC_WEEKDAY_SUNDAY))
802 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \
803 ((__SEL__) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY))
804 #define IS_RTC_ALARM_MASK(__MASK__) (((__MASK__) & 0x7F7F7F7FU) == (uint32_t)RESET)
805 #define IS_RTC_ALARM(__ALARM__) (((__ALARM__) == RTC_ALARM_A) || ((__ALARM__) == RTC_ALARM_B))
806 #define IS_RTC_ALARM_SUB_SECOND_VALUE(__VALUE__) ((__VALUE__) <= 0x00007FFFU)
807 #define IS_RTC_ALARM_SUB_SECOND_MASK(__MASK__) (((__MASK__) == RTC_ALARMSUBSECONDMASK_ALL) || \
808 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_1) || \
809 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_2) || \
810 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_3) || \
811 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_4) || \
812 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_5) || \
813 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_6) || \
814 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_7) || \
815 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_8) || \
816 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_9) || \
817 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_10) || \
818 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_11) || \
819 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_12) || \
820 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_13) || \
821 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14) || \
822 ((__MASK__) == RTC_ALARMSUBSECONDMASK_NONE))
832 /* Private functions ---------------------------------------------------------*/
833 /** @defgroup RTC_Private_Functions RTC Private Functions
836 HAL_StatusTypeDef
RTC_EnterInitMode(RTC_HandleTypeDef
* hrtc
);
837 uint8_t RTC_ByteToBcd2(uint8_t Value
);
838 uint8_t RTC_Bcd2ToByte(uint8_t Value
);
855 #endif /* __STM32F7xx_HAL_RTC_H */
857 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/