Merge pull request #11270 from haslinghuis/rename_attr
[betaflight.git] / lib / main / STM32H7 / Drivers / STM32H7xx_HAL_Driver / Inc / stm32h7xx_hal_rtc.h
blob99c0dd1e9c9f1998238775c2a6ec7d74935dee1e
1 /**
2 ******************************************************************************
3 * @file stm32h7xx_hal_rtc.h
4 * @author MCD Application Team
5 * @brief Header file of RTC HAL module.
6 ******************************************************************************
7 * @attention
9 * <h2><center>&copy; 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 STM32H7xx_HAL_RTC_H
22 #define STM32H7xx_HAL_RTC_H
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32h7xx_hal_def.h"
31 /** @addtogroup STM32H7xx_HAL_Driver
32 * @{
35 /** @defgroup RTC RTC
36 * @{
39 /* Exported types ------------------------------------------------------------*/
40 /** @defgroup RTC_Exported_Types RTC Exported Types
41 * @{
44 /**
45 * @brief HAL State structures definition
47 typedef enum
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 */
55 } HAL_RTCStateTypeDef;
57 /**
58 * @brief RTC Configuration Structure definition
60 typedef struct
62 uint32_t HourFormat; /*!< Specifies the RTC Hour Format.
63 This parameter can be a value of @ref RTC_Hour_Formats_Definitions */
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 RTC_Output_selection_Definitions */
74 uint32_t OutPutRemap; /*!< Specifies the remap for RTC output.
75 This parameter can be a value of @ref RTC_Output_ALARM_OUT_Remap */
77 uint32_t OutPutPolarity; /*!< Specifies the polarity of the output signal.
78 This parameter can be a value of @ref RTC_Output_Polarity_Definitions */
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 #if defined(RTC_CR_TAMPALRM_PU)
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 #endif /* RTC_CR_TAMPALRM_PU */
86 } RTC_InitTypeDef;
88 /**
89 * @brief RTC Time structure definition
91 typedef struct
93 uint8_t Hours; /*!< Specifies the RTC Time Hour.
94 This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected.
95 This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */
97 uint8_t Minutes; /*!< Specifies the RTC Time Minutes.
98 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
100 uint8_t Seconds; /*!< Specifies the RTC Time Seconds.
101 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
103 uint8_t TimeFormat; /*!< Specifies the RTC AM/PM Time.
104 This parameter can be a value of @ref RTC_AM_PM_Definitions */
106 uint32_t SubSeconds; /*!< Specifies the RTC_SSR RTC Sub Second register content.
107 This parameter corresponds to a time unit range between [0-1] Second
108 with [1 Sec / SecondFraction +1] granularity */
110 uint32_t SecondFraction; /*!< Specifies the range or granularity of Sub Second register content
111 corresponding to Synchronous pre-scaler factor value (PREDIV_S)
112 This parameter corresponds to a time unit range between [0-1] Second
113 with [1 Sec / SecondFraction +1] granularity.
114 This field will be used only by HAL_RTC_GetTime function */
116 uint32_t DayLightSaving; /*!< Specifies RTC_DayLightSaveOperation: the value of hour adjustment.
117 This parameter can be a value of @ref RTC_DayLightSaving_Definitions */
119 uint32_t StoreOperation; /*!< Specifies RTC_StoreOperation value to be written in the BKP bit
120 in CR register to store the operation.
121 This parameter can be a value of @ref RTC_StoreOperation_Definitions */
122 } RTC_TimeTypeDef;
125 * @brief RTC Date structure definition
127 typedef struct
129 uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay.
130 This parameter can be a value of @ref RTC_WeekDay_Definitions */
132 uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format).
133 This parameter can be a value of @ref RTC_Month_Date_Definitions */
135 uint8_t Date; /*!< Specifies the RTC Date.
136 This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
138 uint8_t Year; /*!< Specifies the RTC Date Year.
139 This parameter must be a number between Min_Data = 0 and Max_Data = 99 */
141 } RTC_DateTypeDef;
144 * @brief RTC Alarm structure definition
146 typedef struct
148 RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */
150 uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks.
151 This parameter can be a value of @ref RTC_AlarmMask_Definitions */
153 uint32_t AlarmSubSecondMask; /*!< Specifies the RTC Alarm SubSeconds Masks.
154 This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */
156 uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay.
157 This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */
159 uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay.
160 If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range.
161 If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */
163 uint32_t Alarm; /*!< Specifies the alarm .
164 This parameter can be a value of @ref RTC_Alarms_Definitions */
165 } RTC_AlarmTypeDef;
168 * @brief RTC Handle Structure definition
170 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
171 typedef struct __RTC_HandleTypeDef
172 #else
173 typedef struct
174 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
176 RTC_TypeDef *Instance; /*!< Register base address */
178 RTC_InitTypeDef Init; /*!< RTC required parameters */
180 HAL_LockTypeDef Lock; /*!< RTC locking object */
182 __IO HAL_RTCStateTypeDef State; /*!< Time communication state */
184 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
185 void (* AlarmAEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm A Event callback */
187 void (* AlarmBEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm B Event callback */
189 void (* TimeStampEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC TimeStamp Event callback */
191 void (* WakeUpTimerEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC WakeUpTimer Event callback */
193 void (* Tamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 1 Event callback */
195 void (* Tamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 2 Event callback */
197 void (* Tamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 3 Event callback */
199 #if defined(TAMP_CR1_ITAMP1E)
200 void (* InternalTamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 1 Event callback */
201 #endif /* TAMP_CR1_ITAMP1E */
203 #if defined(TAMP_CR1_ITAMP2E)
204 void (* InternalTamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 2 Event callback */
205 #endif /* TAMP_CR1_ITAMP2E */
207 #if defined(TAMP_CR1_ITAMP3E)
208 void (* InternalTamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 3 Event callback */
209 #endif /* TAMP_CR1_ITAMP3E */
211 #if defined(TAMP_CR1_ITAMP4E)
212 void (* InternalTamper4EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 4 Event callback */
213 #endif /* TAMP_CR1_ITAMP4E */
215 #if defined(TAMP_CR1_ITAMP5E)
216 void (* InternalTamper5EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 5 Event callback */
217 #endif /* TAMP_CR1_ITAMP5E */
219 #if defined(TAMP_CR1_ITAMP6E)
220 void (* InternalTamper6EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 6 Event callback */
221 #endif /* TAMP_CR1_ITAMP6E */
223 #if defined(TAMP_CR1_ITAMP8E)
224 void (* InternalTamper8EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 8 Event callback */
225 #endif /* TAMP_CR1_ITAMP8E */
227 void (* MspInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp Init callback */
229 void (* MspDeInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp DeInit callback */
231 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
233 } RTC_HandleTypeDef;
235 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
237 * @brief HAL RTC Callback ID enumeration definition
239 typedef enum
241 HAL_RTC_ALARM_A_EVENT_CB_ID = 0u, /*!< RTC Alarm A Event Callback ID */
242 HAL_RTC_ALARM_B_EVENT_CB_ID = 1u, /*!< RTC Alarm B Event Callback ID */
243 HAL_RTC_TIMESTAMP_EVENT_CB_ID = 2u, /*!< RTC TimeStamp Event Callback ID */
244 HAL_RTC_WAKEUPTIMER_EVENT_CB_ID = 3u, /*!< RTC WakeUp Timer Event Callback ID */
245 HAL_RTC_TAMPER1_EVENT_CB_ID = 4u, /*!< RTC Tamper 1 Callback ID */
246 HAL_RTC_TAMPER2_EVENT_CB_ID = 5u, /*!< RTC Tamper 2 Callback ID */
247 HAL_RTC_TAMPER3_EVENT_CB_ID = 6u, /*!< RTC Tamper 3 Callback ID */
249 #if defined(TAMP_CR1_ITAMP1E)
250 HAL_RTC_INTERNAL_TAMPER1_EVENT_CB_ID = 12u, /*!< RTC Internal Tamper 1 Callback ID */
251 #endif /* TAMP_CR1_ITAMP1E */
252 #if defined(TAMP_CR1_ITAMP2E)
253 HAL_RTC_INTERNAL_TAMPER2_EVENT_CB_ID = 13u, /*!< RTC Internal Tamper 2 Callback ID */
254 #endif /* TAMP_CR1_ITAMP2E */
255 #if defined(TAMP_CR1_ITAMP3E)
256 HAL_RTC_INTERNAL_TAMPER3_EVENT_CB_ID = 14u, /*!< RTC Internal Tamper 3 Callback ID */
257 #endif /* TAMP_CR1_ITAMP3E */
258 #if defined(TAMP_CR1_ITAMP4E)
259 HAL_RTC_INTERNAL_TAMPER4_EVENT_CB_ID = 15u, /*!< RTC Internal Tamper 4 Callback ID */
260 #endif /* TAMP_CR1_ITAMP4E */
261 #if defined(TAMP_CR1_ITAMP5E)
262 HAL_RTC_INTERNAL_TAMPER5_EVENT_CB_ID = 16u, /*!< RTC Internal Tamper 5 Callback ID */
263 #endif /* TAMP_CR1_ITAMP5E */
264 #if defined(TAMP_CR1_ITAMP6E)
265 HAL_RTC_INTERNAL_TAMPER6_EVENT_CB_ID = 17u, /*!< RTC Internal Tamper 6 Callback ID */
266 #endif /* TAMP_CR1_ITAMP6E */
267 #if defined(TAMP_CR1_ITAMP8E)
268 HAL_RTC_INTERNAL_TAMPER8_EVENT_CB_ID = 19u, /*!< RTC Internal Tamper 8 Callback ID */
269 #endif /* TAMP_CR1_ITAMP8E */
270 HAL_RTC_MSPINIT_CB_ID = 20u, /*!< RTC Msp Init callback ID */
271 HAL_RTC_MSPDEINIT_CB_ID = 21u /*!< RTC Msp DeInit callback ID */
272 } HAL_RTC_CallbackIDTypeDef;
275 * @brief HAL RTC Callback pointer definition
277 typedef void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc); /*!< pointer to an RTC callback function */
278 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
281 * @}
284 /* Exported constants --------------------------------------------------------*/
285 /** @defgroup RTC_Exported_Constants RTC Exported Constants
286 * @{
289 /** @defgroup RTC_Hour_Formats_Definitions RTC Hour Formats Definitions
290 * @{
292 #define RTC_HOURFORMAT_24 0x00000000u
293 #define RTC_HOURFORMAT_12 RTC_CR_FMT
295 * @}
298 /** @defgroup RTC_Output_selection_Definitions RTC Output Selection Definitions
299 * @{
301 #define RTC_OUTPUT_DISABLE 0x00000000u
302 #define RTC_OUTPUT_ALARMA RTC_CR_OSEL_0
303 #define RTC_OUTPUT_ALARMB RTC_CR_OSEL_1
304 #define RTC_OUTPUT_WAKEUP RTC_CR_OSEL
305 #if defined(RTC_CR_TAMPOE)
306 #define RTC_OUTPUT_TAMPER RTC_CR_TAMPOE
307 #endif /* RTC_CR_TAMPOE */
309 * @}
312 /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions
313 * @{
315 #define RTC_OUTPUT_POLARITY_HIGH 0x00000000u
316 #define RTC_OUTPUT_POLARITY_LOW RTC_CR_POL
318 * @}
321 /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT
322 * @{
324 #if defined(RTC_CR_TAMPALRM_TYPE)
325 #define RTC_OUTPUT_TYPE_PUSHPULL 0x00000000u
326 #define RTC_OUTPUT_TYPE_OPENDRAIN RTC_CR_TAMPALRM_TYPE
327 #define RTC_ALARM_OUTPUT_TYPE RTC_CR_TAMPALRM_TYPE
328 #endif /* RTC_CR_TAMPALRM_TYPE */
330 #if defined(RTC_OR_ALARMOUTTYPE)
331 #define RTC_OUTPUT_TYPE_PUSHPULL RTC_OR_ALARMOUTTYPE
332 #define RTC_OUTPUT_TYPE_OPENDRAIN 0x00000000u
333 #define RTC_ALARM_OUTPUT_TYPE RTC_OR_ALARMOUTTYPE
334 #endif /* RTC_OR_ALARMOUTTYPE */
336 * @}
339 /** @defgroup RTC_Output_PullUp_ALARM_OUT RTC Output Pull-Up ALARM OUT
340 * @{
342 #if defined(RTC_CR_TAMPALRM_PU)
343 #define RTC_OUTPUT_PULLUP_NONE 0x00000000u
344 #define RTC_OUTPUT_PULLUP_ON RTC_CR_TAMPALRM_PU
345 #endif /* RTC_CR_TAMPALRM_PU */
347 * @}
350 /** @defgroup RTC_Output_ALARM_OUT_Remap RTC Output ALARM OUT Remap
351 * @{
353 #if defined(RTC_CR_OUT2EN)
354 #define RTC_OUTPUT_REMAP_NONE 0x00000000u
355 #define RTC_OUTPUT_REMAP_POS1 RTC_CR_OUT2EN
356 #endif /* RTC_CR_OUT2EN */
358 #if defined(RTC_OR_OUT_RMP)
359 #define RTC_OUTPUT_REMAP_NONE 0x00000000u
360 #define RTC_OUTPUT_REMAP_POS1 RTC_OR_OUT_RMP
361 #endif /* RTC_OR_OUT_RMP */
363 * @}
366 /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions
367 * @{
369 #define RTC_HOURFORMAT12_AM ((uint8_t)0x00)
370 #define RTC_HOURFORMAT12_PM ((uint8_t)0x01)
372 * @}
375 /** @defgroup RTC_DayLightSaving_Definitions RTC DayLight Saving Definitions
376 * @{
378 #define RTC_DAYLIGHTSAVING_SUB1H RTC_CR_SUB1H
379 #define RTC_DAYLIGHTSAVING_ADD1H RTC_CR_ADD1H
380 #define RTC_DAYLIGHTSAVING_NONE 0x00000000u
382 * @}
385 /** @defgroup RTC_StoreOperation_Definitions RTC Store Operation Definitions
386 * @{
388 #define RTC_STOREOPERATION_RESET 0x00000000u
389 #define RTC_STOREOPERATION_SET RTC_CR_BKP
391 * @}
394 /** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions
395 * @{
397 #define RTC_FORMAT_BIN 0x00000000u
398 #define RTC_FORMAT_BCD 0x00000001u
400 * @}
403 /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions (in BCD format)
404 * @{
406 #define RTC_MONTH_JANUARY ((uint8_t)0x01)
407 #define RTC_MONTH_FEBRUARY ((uint8_t)0x02)
408 #define RTC_MONTH_MARCH ((uint8_t)0x03)
409 #define RTC_MONTH_APRIL ((uint8_t)0x04)
410 #define RTC_MONTH_MAY ((uint8_t)0x05)
411 #define RTC_MONTH_JUNE ((uint8_t)0x06)
412 #define RTC_MONTH_JULY ((uint8_t)0x07)
413 #define RTC_MONTH_AUGUST ((uint8_t)0x08)
414 #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09)
415 #define RTC_MONTH_OCTOBER ((uint8_t)0x10)
416 #define RTC_MONTH_NOVEMBER ((uint8_t)0x11)
417 #define RTC_MONTH_DECEMBER ((uint8_t)0x12)
420 * @}
423 /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions
424 * @{
426 #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01)
427 #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02)
428 #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03)
429 #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04)
430 #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05)
431 #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06)
432 #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07)
435 * @}
438 /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC Alarm Date WeekDay Definitions
439 * @{
441 #define RTC_ALARMDATEWEEKDAYSEL_DATE 0x00000000u
442 #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL
445 * @}
448 /** @defgroup RTC_AlarmMask_Definitions RTC Alarm Mask Definitions
449 * @{
451 #define RTC_ALARMMASK_NONE 0x00000000u
452 #define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4
453 #define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3
454 #define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2
455 #define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1
456 #define RTC_ALARMMASK_ALL (RTC_ALARMMASK_DATEWEEKDAY | \
457 RTC_ALARMMASK_HOURS | \
458 RTC_ALARMMASK_MINUTES | \
459 RTC_ALARMMASK_SECONDS)
461 * @}
464 /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions
465 * @{
467 #define RTC_ALARM_A RTC_CR_ALRAE
468 #define RTC_ALARM_B RTC_CR_ALRBE
470 * @}
473 /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions
474 * @{
476 /*!< All Alarm SS fields are masked. There is no comparison on sub seconds for Alarm */
477 #define RTC_ALARMSUBSECONDMASK_ALL 0x00000000u
478 /*!< SS[14:1] are don't care in Alarm comparison. Only SS[0] is compared. */
479 #define RTC_ALARMSUBSECONDMASK_SS14_1 RTC_ALRMASSR_MASKSS_0
480 /*!< SS[14:2] are don't care in Alarm comparison. Only SS[1:0] are compared. */
481 #define RTC_ALARMSUBSECONDMASK_SS14_2 RTC_ALRMASSR_MASKSS_1
482 /*!< SS[14:3] are don't care in Alarm comparison. Only SS[2:0] are compared. */
483 #define RTC_ALARMSUBSECONDMASK_SS14_3 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1)
484 /*!< SS[14:4] are don't care in Alarm comparison. Only SS[3:0] are compared. */
485 #define RTC_ALARMSUBSECONDMASK_SS14_4 RTC_ALRMASSR_MASKSS_2
486 /*!< SS[14:5] are don't care in Alarm comparison. Only SS[4:0] are compared. */
487 #define RTC_ALARMSUBSECONDMASK_SS14_5 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2)
488 /*!< SS[14:6] are don't care in Alarm comparison. Only SS[5:0] are compared. */
489 #define RTC_ALARMSUBSECONDMASK_SS14_6 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)
490 /*!< SS[14:7] are don't care in Alarm comparison. Only SS[6:0] are compared. */
491 #define RTC_ALARMSUBSECONDMASK_SS14_7 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)
492 /*!< SS[14:8] are don't care in Alarm comparison. Only SS[7:0] are compared. */
493 #define RTC_ALARMSUBSECONDMASK_SS14_8 RTC_ALRMASSR_MASKSS_3
494 /*!< SS[14:9] are don't care in Alarm comparison. Only SS[8:0] are compared. */
495 #define RTC_ALARMSUBSECONDMASK_SS14_9 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_3)
496 /*!< SS[14:10] are don't care in Alarm comparison. Only SS[9:0] are compared. */
497 #define RTC_ALARMSUBSECONDMASK_SS14_10 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)
498 /*!< SS[14:11] are don't care in Alarm comparison. Only SS[10:0] are compared. */
499 #define RTC_ALARMSUBSECONDMASK_SS14_11 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)
500 /*!< SS[14:12] are don't care in Alarm comparison. Only SS[11:0] are compared. */
501 #define RTC_ALARMSUBSECONDMASK_SS14_12 (RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
502 /*!< SS[14:13] are don't care in Alarm comparison. Only SS[12:0] are compared. */
503 #define RTC_ALARMSUBSECONDMASK_SS14_13 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
504 /*!< SS[14] is don't care in Alarm comparison. Only SS[13:0] are compared. */
505 #define RTC_ALARMSUBSECONDMASK_SS14 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
506 /*!< SS[14:0] are compared and must match to activate alarm. */
507 #define RTC_ALARMSUBSECONDMASK_NONE RTC_ALRMASSR_MASKSS
510 * @}
513 /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions
514 * @{
516 #define RTC_IT_TS RTC_CR_TSIE /*!< Enable Timestamp Interrupt */
517 #define RTC_IT_WUT RTC_CR_WUTIE /*!< Enable Wakeup timer Interrupt */
518 #define RTC_IT_ALRA RTC_CR_ALRAIE /*!< Enable Alarm A Interrupt */
519 #define RTC_IT_ALRB RTC_CR_ALRBIE /*!< Enable Alarm B Interrupt */
521 * @}
524 /** @defgroup RTC_Flags_Definitions RTC Flags Definitions
525 * @{
527 #if defined(RTC_ICSR_RECALPF)
528 #define RTC_FLAG_RECALPF RTC_ICSR_RECALPF /*!< Recalibration pending Flag */
529 #endif /* RTC_ICSR_RECALPF */
530 #if defined(RTC_ICSR_INITF)
531 #define RTC_FLAG_INITF RTC_ICSR_INITF /*!< Initialization pending flag */
532 #endif /* RTC_ICSR_INITF */
533 #if defined(RTC_ICSR_RSF)
534 #define RTC_FLAG_RSF RTC_ICSR_RSF /*!< Registers synchronization flag */
535 #endif /* RTC_ICSR_RSF */
536 #if defined(RTC_ICSR_INITS)
537 #define RTC_FLAG_INITS RTC_ICSR_INITS /*!< Initialization status flag */
538 #endif /* RTC_ICSR_INITS */
539 #if defined(RTC_ICSR_SHPF)
540 #define RTC_FLAG_SHPF RTC_ICSR_SHPF /*!< Shift operation pending flag */
541 #endif /* RTC_ICSR_SHPF */
542 #if defined(RTC_ICSR_WUTWF)
543 #define RTC_FLAG_WUTWF RTC_ICSR_WUTWF /*!< Wakeup timer write operation pending flag */
544 #endif /* RTC_ICSR_WUTWF */
545 #if defined(RTC_ICSR_ALRBWF)
546 #define RTC_FLAG_ALRBWF RTC_ICSR_ALRBWF /*!< Alarm B write operation pending flag */
547 #endif /* RTC_ICSR_ALRBWF */
548 #if defined(RTC_ICSR_ALRAWF)
549 #define RTC_FLAG_ALRAWF RTC_ICSR_ALRAWF /*!< Alarm A write operation pending flag */
550 #endif /* RTC_ICSR_ALRAWF */
551 #if defined(RTC_SR_ITSF)
552 #define RTC_FLAG_ITSF RTC_SR_ITSF /*!< Internal Time-stamp flag */
553 #endif /* RTC_SR_ITSF */
554 #if defined(RTC_SR_TSOVF)
555 #define RTC_FLAG_TSOVF RTC_SR_TSOVF /*!< Time-stamp overflow flag */
556 #endif /* RTC_SR_TSOVF */
557 #if defined(RTC_SR_TSF)
558 #define RTC_FLAG_TSF RTC_SR_TSF /*!< Time-stamp flag */
559 #endif /* RTC_SR_TSF */
560 #if defined(RTC_SR_WUTF)
561 #define RTC_FLAG_WUTF RTC_SR_WUTF /*!< Wakeup timer flag */
562 #endif /* RTC_SR_WUTF */
563 #if defined(RTC_SR_ALRBF)
564 #define RTC_FLAG_ALRBF RTC_SR_ALRBF /*!< Alarm B flag */
565 #endif /* RTC_SR_ALRBF */
566 #if defined(RTC_SR_ALRAF)
567 #define RTC_FLAG_ALRAF RTC_SR_ALRAF /*!< Alarm A flag */
568 #endif /* RTC_SR_ALRAF */
570 * @}
573 /** @defgroup RTC_Clear_Flags_Definitions RTC Clear Flags Definitions
574 * @{
576 #if defined(RTC_SCR_CITSF)
577 #define RTC_CLEAR_ITSF RTC_SCR_CITSF /*!< Clear Internal Time-stamp flag */
578 #endif /* RTC_SCR_CITSF */
579 #if defined(RTC_SCR_CTSOVF)
580 #define RTC_CLEAR_TSOVF RTC_SCR_CTSOVF /*!< Clear Time-stamp overflow flag */
581 #endif /* RTC_SCR_CTSOVF */
582 #if defined(RTC_SCR_CTSF)
583 #define RTC_CLEAR_TSF RTC_SCR_CTSF /*!< Clear Time-stamp flag */
584 #endif /* RTC_SCR_CTSF */
585 #if defined(RTC_SCR_CWUTF)
586 #define RTC_CLEAR_WUTF RTC_SCR_CWUTF /*!< Clear Wakeup timer flag */
587 #endif /* RTC_SCR_CWUTF */
588 #if defined(RTC_SCR_CALRBF)
589 #define RTC_CLEAR_ALRBF RTC_SCR_CALRBF /*!< Clear Alarm B flag */
590 #endif /* RTC_SCR_CALRBF */
591 #if defined(RTC_SCR_CALRAF)
592 #define RTC_CLEAR_ALRAF RTC_SCR_CALRAF /*!< Clear Alarm A flag */
593 #endif /* RTC_SCR_CALRAF */
595 * @}
598 /** @defgroup RTC_Flags_Definitions RTC Flags Definitions
599 * @{
601 #if defined(RTC_ISR_RECALPF)
602 #define RTC_FLAG_RECALPF RTC_ISR_RECALPF
603 #endif /* RTC_ISR_RECALPF */
604 #if defined(RTC_ISR_TSOVF)
605 #define RTC_FLAG_TSOVF RTC_ISR_TSOVF
606 #endif /* RTC_ISR_TSOVF */
607 #if defined(RTC_ISR_TSF)
608 #define RTC_FLAG_TSF RTC_ISR_TSF
609 #endif /* RTC_ISR_TSF */
610 #if defined(RTC_ISR_ITSF)
611 #define RTC_FLAG_ITSF RTC_ISR_ITSF
612 #endif /* RTC_ISR_ITSF */
613 #if defined(RTC_ISR_WUTF)
614 #define RTC_FLAG_WUTF RTC_ISR_WUTF
615 #endif /* RTC_ISR_WUTF */
616 #if defined(RTC_ISR_ALRBF)
617 #define RTC_FLAG_ALRBF RTC_ISR_ALRBF
618 #endif /* RTC_ISR_ALRBF */
619 #if defined(RTC_ISR_ALRAF)
620 #define RTC_FLAG_ALRAF RTC_ISR_ALRAF
621 #endif /* RTC_ISR_ALRAF */
622 #if defined(RTC_ISR_INITF)
623 #define RTC_FLAG_INITF RTC_ISR_INITF
624 #endif /* RTC_ISR_INITF */
625 #if defined(RTC_ISR_RSF)
626 #define RTC_FLAG_RSF RTC_ISR_RSF
627 #endif /* RTC_ISR_RSF */
628 #if defined(RTC_ISR_INITS)
629 #define RTC_FLAG_INITS RTC_ISR_INITS
630 #endif /* RTC_ISR_INITS */
631 #if defined(RTC_ISR_SHPF)
632 #define RTC_FLAG_SHPF RTC_ISR_SHPF
633 #endif /* RTC_ISR_SHPF */
634 #if defined(RTC_ISR_WUTWF)
635 #define RTC_FLAG_WUTWF RTC_ISR_WUTWF
636 #endif /* RTC_ISR_WUTWF */
637 #if defined(RTC_ISR_ALRBWF)
638 #define RTC_FLAG_ALRBWF RTC_ISR_ALRBWF
639 #endif /* RTC_ISR_ALRBWF */
640 #if defined(RTC_ISR_ALRAWF)
641 #define RTC_FLAG_ALRAWF RTC_ISR_ALRAWF
642 #endif /* RTC_ISR_ALRAWF */
644 * @}
648 * @}
651 /* Exported macros -----------------------------------------------------------*/
652 /** @defgroup RTC_Exported_Macros RTC Exported Macros
653 * @{
656 /** @brief Reset RTC handle state
657 * @param __HANDLE__ RTC handle.
658 * @retval None
660 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
661 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{ \
662 (__HANDLE__)->State = HAL_RTC_STATE_RESET; \
663 (__HANDLE__)->MspInitCallback = NULL; \
664 (__HANDLE__)->MspDeInitCallback = NULL; \
665 }while(0u)
666 #else
667 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
668 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
671 * @brief Disable the write protection for RTC registers.
672 * @param __HANDLE__ specifies the RTC handle.
673 * @retval None
675 #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \
676 do{ \
677 (__HANDLE__)->Instance->WPR = 0xCAU; \
678 (__HANDLE__)->Instance->WPR = 0x53U; \
679 } while(0u)
682 * @brief Enable the write protection for RTC registers.
683 * @param __HANDLE__ specifies the RTC handle.
684 * @retval None
686 #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \
687 do{ \
688 (__HANDLE__)->Instance->WPR = 0xFFU; \
689 } while(0u)
692 * @brief Add 1 hour (summer time change).
693 * @param __HANDLE__ specifies the RTC handle.
694 * @param __BKP__ Backup
695 * This parameter can be:
696 * @arg @ref RTC_STOREOPERATION_RESET
697 * @arg @ref RTC_STOREOPERATION_SET
698 * @retval None
700 #define __HAL_RTC_DAYLIGHT_SAVING_TIME_ADD1H(__HANDLE__, __BKP__) \
701 do { \
702 __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__); \
703 SET_BIT((__HANDLE__)->Instance->CR, RTC_CR_ADD1H); \
704 MODIFY_REG((__HANDLE__)->Instance->CR, RTC_CR_BKP , (__BKP__)); \
705 __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__); \
706 } while(0u);
709 * @brief Subtract 1 hour (winter time change).
710 * @param __HANDLE__ specifies the RTC handle.
711 * @param __BKP__ Backup
712 * This parameter can be:
713 * @arg @ref RTC_STOREOPERATION_RESET
714 * @arg @ref RTC_STOREOPERATION_SET
715 * @retval None
717 #define __HAL_RTC_DAYLIGHT_SAVING_TIME_SUB1H(__HANDLE__, __BKP__) \
718 do { \
719 __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__); \
720 SET_BIT((__HANDLE__)->Instance->CR, RTC_CR_SUB1H); \
721 MODIFY_REG((__HANDLE__)->Instance->CR, RTC_CR_BKP , (__BKP__)); \
722 __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__); \
723 } while(0u);
726 * @brief Enable the RTC ALARMA peripheral.
727 * @param __HANDLE__ specifies the RTC handle.
728 * @retval None
730 #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE))
733 * @brief Disable the RTC ALARMA peripheral.
734 * @param __HANDLE__ specifies the RTC handle.
735 * @retval None
737 #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE))
740 * @brief Enable the RTC ALARMB peripheral.
741 * @param __HANDLE__ specifies the RTC handle.
742 * @retval None
744 #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE))
747 * @brief Disable the RTC ALARMB peripheral.
748 * @param __HANDLE__ specifies the RTC handle.
749 * @retval None
751 #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE))
754 * @brief Enable the RTC Alarm interrupt.
755 * @param __HANDLE__ specifies the RTC handle.
756 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
757 * This parameter can be any combination of the following values:
758 * @arg @ref RTC_IT_ALRA Alarm A interrupt
759 * @arg @ref RTC_IT_ALRB Alarm B interrupt
760 * @retval None
762 #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
765 * @brief Disable the RTC Alarm interrupt.
766 * @param __HANDLE__ specifies the RTC handle.
767 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
768 * This parameter can be any combination of the following values:
769 * @arg @ref RTC_IT_ALRA Alarm A interrupt
770 * @arg @ref RTC_IT_ALRB Alarm B interrupt
771 * @retval None
773 #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
776 * @brief Check whether the specified RTC Alarm interrupt has occurred or not.
777 * @param __HANDLE__ specifies the RTC handle.
778 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
779 * This parameter can be:
780 * @arg @ref RTC_IT_ALRA Alarm A interrupt
781 * @arg @ref RTC_IT_ALRB Alarm B interrupt
782 * @retval None
784 #if defined(RTC_MISR_ALRAMF)
785 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->MISR)& (__INTERRUPT__ >> 12)) != 0U)? 1U : 0U)
786 #endif /* RTC_MISR_ALRAMF */
787 #if defined(RTC_ISR_ALRAF)
788 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR)& (__INTERRUPT__ >> 4)) != 0U)? 1U : 0U)
789 #endif /* RTC_ISR_ALRAF */
792 * @brief Check whether the specified RTC Alarm interrupt has been enabled or not.
793 * @param __HANDLE__ specifies the RTC handle.
794 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
795 * This parameter can be:
796 * @arg @ref RTC_IT_ALRA Alarm A interrupt
797 * @arg @ref RTC_IT_ALRB Alarm B interrupt
798 * @retval None
800 #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
802 #if defined(RTC_SR_ALRAF)
804 * @brief Get the selected RTC Alarm's flag status.
805 * @param __HANDLE__ specifies the RTC handle.
806 * @param __FLAG__ specifies the RTC Alarm Flag sources to check.
807 * This parameter can be:
808 * @arg @ref RTC_FLAG_ALRAF
809 * @arg @ref RTC_FLAG_ALRBF
810 * @retval None
812 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->SR) & (__FLAG__)) != 0U) ? 1U : 0U)
813 #endif /* RTC_SR_ALRAF */
814 #if defined(RTC_ISR_ALRAF)
816 * @brief Get the selected RTC Alarm's flag status.
817 * @param __HANDLE__ specifies the RTC handle.
818 * @param __FLAG__ specifies the RTC Alarm Flag sources to check.
819 * This parameter can be:
820 * @arg @ref RTC_FLAG_ALRAF
821 * @arg @ref RTC_FLAG_ALRBF
822 * @arg @ref RTC_FLAG_ALRAWF
823 * @arg @ref RTC_FLAG_ALRBWF
824 * @retval None
826 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
827 #endif /* RTC_ISR_ALRAF */
830 * @brief Clear the RTC Alarm's pending flags.
831 * @param __HANDLE__ specifies the RTC handle.
832 * @param __FLAG__ specifies the RTC Alarm Flag sources to clear.
833 * This parameter can be:
834 * @arg @ref RTC_FLAG_ALRAF
835 * @arg @ref RTC_FLAG_ALRBF
836 * @retval None
838 #if defined(RTC_SCR_CALRAF)
839 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SCR |= __FLAG__)
840 #endif /* RTC_SCR_CALRAF */
841 #if defined(RTC_ISR_ALRAF)
842 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)))
843 #endif /* RTC_ISR_ALRAF */
847 * @brief Enable interrupt on the RTC Alarm associated Exti line.
848 * @retval None
850 #if defined(EXTI_D1)
851 #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI_D1->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
852 #else /* EXTI */
853 #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
854 #endif /* EXTI_D1 */
857 * @brief Disable interrupt on the RTC Alarm associated Exti line.
858 * @retval None
860 #if defined(EXTI_D1)
861 #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI_D1->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
862 #else /* EXTI */
863 #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
864 #endif /* EXTI_D1 */
867 * @brief Enable event on the RTC Alarm associated Exti line.
868 * @retval None.
870 #if defined(EXTI_D1)
871 #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI_D1->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
872 #else /* EXTI */
873 #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
874 #endif /* EXTI_D1 */
877 * @brief Disable event on the RTC Alarm associated Exti line.
878 * @retval None.
880 #if defined(EXTI_D1)
881 #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI_D1->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
882 #else /* EXTI */
883 #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
884 #endif /* EXTI_D1 */
886 #if defined(DUAL_CORE)
888 * @brief Enable interrupt on the RTC Alarm associated D2 Exti line.
889 * @retval None
891 #define __HAL_RTC_ALARM_EXTID2_ENABLE_IT() (EXTI_D2->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
894 * @brief Disable interrupt on the RTC Alarm associated D2 Exti line.
895 * @retval None
897 #define __HAL_RTC_ALARM_EXTID2_DISABLE_IT() (EXTI_D2->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
900 * @brief Enable event on the RTC Alarm associated D2 Exti line.
901 * @retval None
903 #define __HAL_RTC_ALARM_EXTID2_ENABLE_EVENT() (EXTI_D2->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
906 * @brief Disable event on the RTC Alarm associated D2 Exti line.
907 * @retval None
909 #define __HAL_RTC_ALARM_EXTID2_DISABLE_EVENT() (EXTI_D2->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
911 #endif
913 * @brief Enable falling edge trigger on the RTC Alarm associated Exti line.
914 * @retval None
916 #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR1 |= RTC_EXTI_LINE_ALARM_EVENT)
919 * @brief Disable falling edge trigger on the RTC Alarm associated Exti line.
920 * @retval None
922 #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
925 * @brief Enable rising edge trigger on the RTC Alarm associated Exti line.
926 * @retval None
928 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR1 |= RTC_EXTI_LINE_ALARM_EVENT)
931 * @brief Disable rising edge trigger on the RTC Alarm associated Exti line.
932 * @retval None
934 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
937 * @brief Enable rising & falling edge trigger on the RTC Alarm associated Exti line.
938 * @retval None
940 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
941 __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE(); \
942 __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE(); \
943 } while(0u)
946 * @brief Disable rising & falling edge trigger on the RTC Alarm associated Exti line.
947 * @retval None
949 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
950 __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE(); \
951 __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(); \
952 } while(0u)
955 * @brief Check whether the RTC Alarm associated Exti line interrupt flag is set or not.
956 * @retval Line Status.
958 #if defined(EXTI_D1)
959 #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI_D1->PR1 & RTC_EXTI_LINE_ALARM_EVENT)
960 #else /* EXTI */
961 #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR1 & RTC_EXTI_LINE_ALARM_EVENT)
962 #endif /* EXTI_D1 */
965 * @brief Clear the RTC Alarm associated Exti line flag.
966 * @retval None.
968 #if defined(EXTI_D1)
969 #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI_D1->PR1 = (RTC_EXTI_LINE_ALARM_EVENT))
970 #else /* EXTI */
971 #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR1 = (RTC_EXTI_LINE_ALARM_EVENT))
972 #endif /* EXTI_D1 */
974 #if defined(DUAL_CORE)
976 * @brief Check whether the RTC Alarm associated D2 Exti line interrupt flag is set or not.
977 * @retval Line Status
979 #define __HAL_RTC_ALARM_EXTID2_GET_FLAG() (EXTI_D2->PR1 & RTC_EXTI_LINE_ALARM_EVENT)
982 * @brief Clear the RTC Alarm associated D2 Exti line flag.
983 * @retval None
985 #define __HAL_RTC_ALARM_EXTID2_CLEAR_FLAG() (EXTI_D2->PR1 = (RTC_EXTI_LINE_ALARM_EVENT))
986 #endif
988 * @brief Generate a Software interrupt on RTC Alarm associated Exti line.
989 * @retval None
991 #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() (EXTI->SWIER1 |= RTC_EXTI_LINE_ALARM_EVENT)
994 * @}
997 /* Include RTC HAL Extended module */
998 #include "stm32h7xx_hal_rtc_ex.h"
1000 /* Exported functions --------------------------------------------------------*/
1001 /** @defgroup RTC_Exported_Functions RTC Exported Functions
1002 * @{
1005 /** @defgroup RTC_Exported_Functions_Group1 Initialization and de-initialization functions
1006 * @{
1008 /* Initialization and de-initialization functions ****************************/
1009 HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc);
1010 HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc);
1012 void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc);
1013 void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc);
1015 /* Callbacks Register/UnRegister functions ***********************************/
1016 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
1017 HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback);
1018 HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID);
1019 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
1021 * @}
1024 /** @defgroup RTC_Exported_Functions_Group2 RTC Time and Date functions
1025 * @{
1027 /* RTC Time and Date functions ************************************************/
1028 HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
1029 HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
1030 HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
1031 HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
1033 * @}
1036 /** @defgroup RTC_Exported_Functions_Group3 RTC Alarm functions
1037 * @{
1039 /* RTC Alarm functions ********************************************************/
1040 HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
1041 HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
1042 HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm);
1043 HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format);
1044 void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc);
1045 void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc);
1046 HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
1048 * @}
1051 /** @defgroup RTC_Exported_Functions_Group4 Peripheral Control functions
1052 * @{
1054 /* Peripheral Control functions ***********************************************/
1055 HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc);
1057 * @}
1060 /** @defgroup RTC_Exported_Functions_Group5 Peripheral State functions
1061 * @{
1063 /* Peripheral State functions *************************************************/
1064 HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc);
1066 * @}
1070 * @}
1073 /* Private types -------------------------------------------------------------*/
1074 /* Private variables ---------------------------------------------------------*/
1075 /* Private constants ---------------------------------------------------------*/
1076 /** @defgroup RTC_Private_Constants RTC Private Constants
1077 * @{
1079 /* Masks Definition */
1080 #define RTC_TR_RESERVED_MASK (RTC_TR_PM | RTC_TR_HT | RTC_TR_HU | \
1081 RTC_TR_MNT | RTC_TR_MNU| RTC_TR_ST | \
1082 RTC_TR_SU)
1084 #define RTC_DR_RESERVED_MASK (RTC_DR_YT | RTC_DR_YU | RTC_DR_WDU | \
1085 RTC_DR_MT | RTC_DR_MU | RTC_DR_DT | \
1086 RTC_DR_DU)
1088 #define RTC_INIT_MASK 0xFFFFFFFFu
1090 #if defined(RTC_ICSR_INIT) && defined(RTC_ICSR_RSF)
1091 #define RTC_RSF_MASK (~(RTC_ICSR_INIT | RTC_ICSR_RSF))
1092 #endif /* RTC_ICSR_INIT && RTC_ICSR_RSF */
1094 #if defined(RTC_ISR_INIT) && defined(RTC_ISR_RSF)
1095 #define RTC_RSF_MASK (~(RTC_ISR_INIT | RTC_ISR_RSF))
1096 #endif /* RTC_ISR_INIT && RTC_ISR_RSF */
1098 #define RTC_TIMEOUT_VALUE 1000u
1100 #define RTC_EXTI_LINE_ALARM_EVENT EXTI_IMR1_IM17 /*!< External interrupt line 17 Connected to the RTC Alarm event */
1103 * @}
1106 /* Private macros ------------------------------------------------------------*/
1107 /** @defgroup RTC_Private_Macros RTC Private Macros
1108 * @{
1111 /** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters
1112 * @{
1115 #if defined(RTC_CR_TAMPOE)
1116 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
1117 ((OUTPUT) == RTC_OUTPUT_ALARMA) || \
1118 ((OUTPUT) == RTC_OUTPUT_ALARMB) || \
1119 ((OUTPUT) == RTC_OUTPUT_WAKEUP) || \
1120 ((OUTPUT) == RTC_OUTPUT_TAMPER))
1121 #else /* RTC_CR_TAMPOE not defined */
1122 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
1123 ((OUTPUT) == RTC_OUTPUT_ALARMA) || \
1124 ((OUTPUT) == RTC_OUTPUT_ALARMB) || \
1125 ((OUTPUT) == RTC_OUTPUT_WAKEUP))
1126 #endif /* RTC_CR_TAMPOE */
1128 #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HOURFORMAT_12) || \
1129 ((FORMAT) == RTC_HOURFORMAT_24))
1131 #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \
1132 ((POL) == RTC_OUTPUT_POLARITY_LOW))
1134 #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \
1135 ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL))
1137 #if defined(RTC_CR_TAMPALRM_PU)
1138 #define IS_RTC_OUTPUT_PULLUP(TYPE) (((TYPE) == RTC_OUTPUT_PULLUP_NONE) || \
1139 ((TYPE) == RTC_OUTPUT_PULLUP_ON))
1140 #endif /* RTC_CR_TAMPALRM_PU */
1142 #define IS_RTC_OUTPUT_REMAP(REMAP) (((REMAP) == RTC_OUTPUT_REMAP_NONE) || \
1143 ((REMAP) == RTC_OUTPUT_REMAP_POS1))
1145 #define IS_RTC_HOURFORMAT12(PM) (((PM) == RTC_HOURFORMAT12_AM) || \
1146 ((PM) == RTC_HOURFORMAT12_PM))
1148 #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \
1149 ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \
1150 ((SAVE) == RTC_DAYLIGHTSAVING_NONE))
1152 #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \
1153 ((OPERATION) == RTC_STOREOPERATION_SET))
1155 #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || \
1156 ((FORMAT) == RTC_FORMAT_BCD))
1158 #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99u)
1160 #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1u) && ((MONTH) <= 12u))
1162 #define IS_RTC_DATE(DATE) (((DATE) >= 1u) && ((DATE) <= 31u))
1164 #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \
1165 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \
1166 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
1167 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \
1168 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \
1169 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \
1170 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
1172 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0u) && ((DATE) <= 31u))
1174 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \
1175 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \
1176 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
1177 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \
1178 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \
1179 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \
1180 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
1182 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \
1183 ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY))
1185 #define IS_RTC_ALARM_MASK(MASK) (((MASK) & ~(RTC_ALARMMASK_ALL)) == 0u)
1187 #define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_ALARM_A) || \
1188 ((ALARM) == RTC_ALARM_B))
1190 #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= RTC_ALRMASSR_SS)
1192 #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == 0u) || \
1193 (((MASK) >= RTC_ALARMSUBSECONDMASK_SS14_1) && ((MASK) <= RTC_ALARMSUBSECONDMASK_NONE)))
1195 #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= (RTC_PRER_PREDIV_A >> RTC_PRER_PREDIV_A_Pos))
1197 #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= (RTC_PRER_PREDIV_S >> RTC_PRER_PREDIV_S_Pos))
1199 #define IS_RTC_HOUR12(HOUR) (((HOUR) > 0u) && ((HOUR) <= 12u))
1201 #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23u)
1203 #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59u)
1205 #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59u)
1208 * @}
1212 * @}
1215 /* Private functions -------------------------------------------------------------*/
1216 /** @defgroup RTC_Private_Functions RTC Private Functions
1217 * @{
1219 HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef *hrtc);
1220 HAL_StatusTypeDef RTC_ExitInitMode(RTC_HandleTypeDef *hrtc);
1221 uint8_t RTC_ByteToBcd2(uint8_t Value);
1222 uint8_t RTC_Bcd2ToByte(uint8_t Value);
1225 * @}
1229 * @}
1233 * @}
1236 #ifdef __cplusplus
1238 #endif
1240 #endif /* STM32H7xx_HAL_RTC_H */
1242 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/