STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
stm32h7xx_hal_rtc.h
Go to the documentation of this file.
1/**
2 ******************************************************************************
3 * @file stm32h7xx_hal_rtc.h
4 * @author MCD Application Team
5 * @brief Header file of RTC HAL module.
6 ******************************************************************************
7 * @attention
8 *
9 * Copyright (c) 2017 STMicroelectronics.
10 * All rights reserved.
11 *
12 * This software is licensed under terms that can be found in the LICENSE file
13 * in the root directory of this software component.
14 * If no LICENSE file comes with this software, it is provided AS-IS.
15 *
16 ******************************************************************************
17 */
18
19/* Define to prevent recursive inclusion -------------------------------------*/
20#ifndef STM32H7xx_HAL_RTC_H
21#define STM32H7xx_HAL_RTC_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/* Includes ------------------------------------------------------------------*/
28#include "stm32h7xx_hal_def.h"
29
30/** @addtogroup STM32H7xx_HAL_Driver
31 * @{
32 */
33
34/** @defgroup RTC RTC
35 * @{
36 */
37
38/* Exported types ------------------------------------------------------------*/
39/** @defgroup RTC_Exported_Types RTC Exported Types
40 * @{
41 */
42
43/**
44 * @brief HAL State structures definition
45 */
46typedef enum
47{
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 */
53
55
56/**
57 * @brief RTC Configuration Structure definition
58 */
59typedef struct
60{
61 uint32_t HourFormat; /*!< Specifies the RTC Hour Format.
62 This parameter can be a value of @ref RTC_Hour_Formats_Definitions */
63
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 */
66
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 */
69
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 */
72
73 uint32_t OutPutRemap; /*!< Specifies the remap for RTC output.
74 This parameter can be a value of @ref RTC_Output_ALARM_OUT_Remap */
75
76 uint32_t OutPutPolarity; /*!< Specifies the polarity of the output signal.
77 This parameter can be a value of @ref RTC_Output_Polarity_Definitions */
78
79 uint32_t OutPutType; /*!< Specifies the RTC Output Pin mode.
80 This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */
81#if defined(TAMP)
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 */
84#endif /* TAMP */
86
87/**
88 * @brief RTC Time structure definition
89 */
90typedef struct
91{
92 uint8_t Hours; /*!< Specifies the RTC Time Hour.
93 This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected.
94 This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */
95
96 uint8_t Minutes; /*!< Specifies the RTC Time Minutes.
97 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
98
99 uint8_t Seconds; /*!< Specifies the RTC Time Seconds.
100 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
101
102 uint8_t TimeFormat; /*!< Specifies the RTC AM/PM Time.
103 This parameter can be a value of @ref RTC_AM_PM_Definitions */
104
105 uint32_t SubSeconds; /*!< Specifies the RTC_SSR RTC Sub Second register content.
106 This parameter corresponds to a time unit range between [0-1] Second
107 with [1 Sec / SecondFraction +1] granularity */
108
109 uint32_t SecondFraction; /*!< Specifies the range or granularity of Sub Second register content
110 corresponding to Synchronous pre-scaler factor value (PREDIV_S)
111 This parameter corresponds to a time unit range between [0-1] Second
112 with [1 Sec / SecondFraction +1] granularity.
113 This field will be used only by HAL_RTC_GetTime function */
114
115 uint32_t DayLightSaving; /*!< Specifies RTC_DayLightSaveOperation: the value of hour adjustment.
116 This parameter can be a value of @ref RTC_DayLightSaving_Definitions */
117
118 uint32_t StoreOperation; /*!< Specifies RTC_StoreOperation value to be written in the BKP bit
119 in CR register to store the operation.
120 This parameter can be a value of @ref RTC_StoreOperation_Definitions */
122
123/**
124 * @brief RTC Date structure definition
125 */
126typedef struct
127{
128 uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay.
129 This parameter can be a value of @ref RTC_WeekDay_Definitions */
130
131 uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format).
132 This parameter can be a value of @ref RTC_Month_Date_Definitions */
133
134 uint8_t Date; /*!< Specifies the RTC Date.
135 This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
136
137 uint8_t Year; /*!< Specifies the RTC Date Year.
138 This parameter must be a number between Min_Data = 0 and Max_Data = 99 */
139
141
142/**
143 * @brief RTC Alarm structure definition
144 */
145typedef struct
146{
147 RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */
148
149 uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks.
150 This parameter can be a value of @ref RTC_AlarmMask_Definitions */
151
152 uint32_t AlarmSubSecondMask; /*!< Specifies the RTC Alarm SubSeconds Masks.
153 This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */
154
155 uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay.
156 This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */
157
158 uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay.
159 If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range.
160 If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */
161
162 uint32_t Alarm; /*!< Specifies the alarm .
163 This parameter can be a value of @ref RTC_Alarms_Definitions */
165
166/**
167 * @brief RTC Handle Structure definition
168 */
169#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
170typedef struct __RTC_HandleTypeDef
171#else
172typedef struct
173#endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
174{
175 RTC_TypeDef *Instance; /*!< Register base address */
176
177 RTC_InitTypeDef Init; /*!< RTC required parameters */
178
179 HAL_LockTypeDef Lock; /*!< RTC locking object */
180
181 __IO HAL_RTCStateTypeDef State; /*!< Time communication state */
182
183#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
184 void (* AlarmAEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm A Event callback */
185
186 void (* AlarmBEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm B Event callback */
187
188 void (* TimeStampEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC TimeStamp Event callback */
189
190 void (* WakeUpTimerEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC WakeUpTimer Event callback */
191
192 void (* Tamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 1 Event callback */
193
194#if defined(RTC_TAMPER2_SUPPORT)
195 void (* Tamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 2 Event callback */
196#endif /* RTC_TAMPER2_SUPPORT */
197
198 void (* Tamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 3 Event callback */
199
200#if defined(TAMP)
201 void (* InternalTamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 1 Event callback */
202
203 void (* InternalTamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 2 Event callback */
204
205 void (* InternalTamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 3 Event callback */
206
207 void (* InternalTamper4EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 4 Event callback */
208
209 void (* InternalTamper5EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 5 Event callback */
210
211 void (* InternalTamper6EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 6 Event callback */
212
213 void (* InternalTamper8EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 8 Event callback */
214#endif /* TAMP */
215
216 void (* MspInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp Init callback */
217
218 void (* MspDeInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp DeInit callback */
219
220#endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
221
223
224#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
225/**
226 * @brief HAL RTC Callback ID enumeration definition
227 */
228typedef enum
229{
230 HAL_RTC_ALARM_A_EVENT_CB_ID = 0u, /*!< RTC Alarm A Event Callback ID */
231 HAL_RTC_ALARM_B_EVENT_CB_ID = 1u, /*!< RTC Alarm B Event Callback ID */
232 HAL_RTC_TIMESTAMP_EVENT_CB_ID = 2u, /*!< RTC TimeStamp Event Callback ID */
233 HAL_RTC_WAKEUPTIMER_EVENT_CB_ID = 3u, /*!< RTC WakeUp Timer Event Callback ID */
234 HAL_RTC_TAMPER1_EVENT_CB_ID = 4u, /*!< RTC Tamper 1 Callback ID */
235#if defined(RTC_TAMPER2_SUPPORT)
236 HAL_RTC_TAMPER2_EVENT_CB_ID = 5u, /*!< RTC Tamper 2 Callback ID */
237#endif /* RTC_TAMPER2_SUPPORT */
238 HAL_RTC_TAMPER3_EVENT_CB_ID = 6u, /*!< RTC Tamper 3 Callback ID */
239#if defined(TAMP)
240 HAL_RTC_INTERNAL_TAMPER1_EVENT_CB_ID = 12u, /*!< RTC Internal Tamper 1 Callback ID */
241 HAL_RTC_INTERNAL_TAMPER2_EVENT_CB_ID = 13u, /*!< RTC Internal Tamper 2 Callback ID */
242 HAL_RTC_INTERNAL_TAMPER3_EVENT_CB_ID = 14u, /*!< RTC Internal Tamper 3 Callback ID */
243 HAL_RTC_INTERNAL_TAMPER4_EVENT_CB_ID = 15u, /*!< RTC Internal Tamper 4 Callback ID */
244 HAL_RTC_INTERNAL_TAMPER5_EVENT_CB_ID = 16u, /*!< RTC Internal Tamper 5 Callback ID */
245 HAL_RTC_INTERNAL_TAMPER6_EVENT_CB_ID = 17u, /*!< RTC Internal Tamper 6 Callback ID */
246 HAL_RTC_INTERNAL_TAMPER8_EVENT_CB_ID = 19u, /*!< RTC Internal Tamper 8 Callback ID */
247#endif /* TAMP */
248 HAL_RTC_MSPINIT_CB_ID = 20u, /*!< RTC Msp Init callback ID */
249 HAL_RTC_MSPDEINIT_CB_ID = 21u /*!< RTC Msp DeInit callback ID */
250} HAL_RTC_CallbackIDTypeDef;
251
252/**
253 * @brief HAL RTC Callback pointer definition
254 */
255typedef void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc); /*!< pointer to an RTC callback function */
256#endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
257
258/**
259 * @}
260 */
261
262/* Exported constants --------------------------------------------------------*/
263/** @defgroup RTC_Exported_Constants RTC Exported Constants
264 * @{
265 */
266
267/** @defgroup RTC_Hour_Formats_Definitions RTC Hour Formats Definitions
268 * @{
269 */
270#define RTC_HOURFORMAT_24 0x00000000u
271#define RTC_HOURFORMAT_12 RTC_CR_FMT
272/**
273 * @}
274 */
275
276/** @defgroup RTC_Output_selection_Definitions RTC Output Selection Definitions
277 * @{
278 */
279#define RTC_OUTPUT_DISABLE 0x00000000u
280#define RTC_OUTPUT_ALARMA RTC_CR_OSEL_0
281#define RTC_OUTPUT_ALARMB RTC_CR_OSEL_1
282#define RTC_OUTPUT_WAKEUP RTC_CR_OSEL
283#if defined(TAMP)
284#define RTC_OUTPUT_TAMPER RTC_CR_TAMPOE
285#endif /* TAMP */
286/**
287 * @}
288 */
289
290/** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions
291 * @{
292 */
293#define RTC_OUTPUT_POLARITY_HIGH 0x00000000u
294#define RTC_OUTPUT_POLARITY_LOW RTC_CR_POL
295/**
296 * @}
297 */
298
299/** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT
300 * @{
301 */
302#if defined(TAMP)
303#define RTC_OUTPUT_TYPE_PUSHPULL 0x00000000u
304#define RTC_OUTPUT_TYPE_OPENDRAIN RTC_CR_TAMPALRM_TYPE
305#define RTC_ALARM_OUTPUT_TYPE RTC_CR_TAMPALRM_TYPE
306#else
307#define RTC_OUTPUT_TYPE_PUSHPULL RTC_OR_ALARMOUTTYPE
308#define RTC_OUTPUT_TYPE_OPENDRAIN 0x00000000u
309#define RTC_ALARM_OUTPUT_TYPE RTC_OR_ALARMOUTTYPE
310#endif /* TAMP */
311/**
312 * @}
313 */
314
315/** @defgroup RTC_Output_PullUp_ALARM_OUT RTC Output Pull-Up ALARM OUT
316 * @{
317 */
318#if defined(TAMP)
319#define RTC_OUTPUT_PULLUP_NONE 0x00000000u
320#define RTC_OUTPUT_PULLUP_ON RTC_CR_TAMPALRM_PU
321#endif /* TAMP */
322/**
323 * @}
324 */
325
326/** @defgroup RTC_Output_ALARM_OUT_Remap RTC Output ALARM OUT Remap
327 * @{
328 */
329#if defined(TAMP)
330#define RTC_OUTPUT_REMAP_NONE 0x00000000u
331#define RTC_OUTPUT_REMAP_POS1 RTC_CR_OUT2EN
332#else
333#define RTC_OUTPUT_REMAP_NONE 0x00000000u
334#define RTC_OUTPUT_REMAP_POS1 RTC_OR_OUT_RMP
335#endif /* TAMP */
336/**
337 * @}
338 */
339
340/** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions
341 * @{
342 */
343#define RTC_HOURFORMAT12_AM ((uint8_t)0x00)
344#define RTC_HOURFORMAT12_PM ((uint8_t)0x01)
345/**
346 * @}
347 */
348
349/** @defgroup RTC_DayLightSaving_Definitions RTC DayLight Saving Definitions
350 * @{
351 */
352#define RTC_DAYLIGHTSAVING_SUB1H RTC_CR_SUB1H
353#define RTC_DAYLIGHTSAVING_ADD1H RTC_CR_ADD1H
354#define RTC_DAYLIGHTSAVING_NONE 0x00000000u
355/**
356 * @}
357 */
358
359/** @defgroup RTC_StoreOperation_Definitions RTC Store Operation Definitions
360 * @{
361 */
362#define RTC_STOREOPERATION_RESET 0x00000000u
363#define RTC_STOREOPERATION_SET RTC_CR_BKP
364/**
365 * @}
366 */
367
368/** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions
369 * @{
370 */
371#define RTC_FORMAT_BIN 0x00000000u
372#define RTC_FORMAT_BCD 0x00000001u
373/**
374 * @}
375 */
376
377/** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions (in BCD format)
378 * @{
379 */
380#define RTC_MONTH_JANUARY ((uint8_t)0x01)
381#define RTC_MONTH_FEBRUARY ((uint8_t)0x02)
382#define RTC_MONTH_MARCH ((uint8_t)0x03)
383#define RTC_MONTH_APRIL ((uint8_t)0x04)
384#define RTC_MONTH_MAY ((uint8_t)0x05)
385#define RTC_MONTH_JUNE ((uint8_t)0x06)
386#define RTC_MONTH_JULY ((uint8_t)0x07)
387#define RTC_MONTH_AUGUST ((uint8_t)0x08)
388#define RTC_MONTH_SEPTEMBER ((uint8_t)0x09)
389#define RTC_MONTH_OCTOBER ((uint8_t)0x10)
390#define RTC_MONTH_NOVEMBER ((uint8_t)0x11)
391#define RTC_MONTH_DECEMBER ((uint8_t)0x12)
392
393/**
394 * @}
395 */
396
397/** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions
398 * @{
399 */
400#define RTC_WEEKDAY_MONDAY ((uint8_t)0x01)
401#define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02)
402#define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03)
403#define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04)
404#define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05)
405#define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06)
406#define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07)
407
408/**
409 * @}
410 */
411
412/** @defgroup RTC_AlarmDateWeekDay_Definitions RTC Alarm Date WeekDay Definitions
413 * @{
414 */
415#define RTC_ALARMDATEWEEKDAYSEL_DATE 0x00000000u
416#define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL
417
418/**
419 * @}
420 */
421
422/** @defgroup RTC_AlarmMask_Definitions RTC Alarm Mask Definitions
423 * @{
424 */
425#define RTC_ALARMMASK_NONE 0x00000000u
426#define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4
427#define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3
428#define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2
429#define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1
430#define RTC_ALARMMASK_ALL (RTC_ALARMMASK_DATEWEEKDAY | \
431 RTC_ALARMMASK_HOURS | \
432 RTC_ALARMMASK_MINUTES | \
433 RTC_ALARMMASK_SECONDS)
434/**
435 * @}
436 */
437
438/** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions
439 * @{
440 */
441#define RTC_ALARM_A RTC_CR_ALRAE
442#define RTC_ALARM_B RTC_CR_ALRBE
443/**
444 * @}
445 */
446
447/** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions
448 * @{
449 */
450/*!< All Alarm SS fields are masked. There is no comparison on sub seconds for Alarm */
451#define RTC_ALARMSUBSECONDMASK_ALL 0x00000000u
452/*!< SS[14:1] are don't care in Alarm comparison. Only SS[0] is compared. */
453#define RTC_ALARMSUBSECONDMASK_SS14_1 RTC_ALRMASSR_MASKSS_0
454/*!< SS[14:2] are don't care in Alarm comparison. Only SS[1:0] are compared. */
455#define RTC_ALARMSUBSECONDMASK_SS14_2 RTC_ALRMASSR_MASKSS_1
456/*!< SS[14:3] are don't care in Alarm comparison. Only SS[2:0] are compared. */
457#define RTC_ALARMSUBSECONDMASK_SS14_3 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1)
458/*!< SS[14:4] are don't care in Alarm comparison. Only SS[3:0] are compared. */
459#define RTC_ALARMSUBSECONDMASK_SS14_4 RTC_ALRMASSR_MASKSS_2
460/*!< SS[14:5] are don't care in Alarm comparison. Only SS[4:0] are compared. */
461#define RTC_ALARMSUBSECONDMASK_SS14_5 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2)
462/*!< SS[14:6] are don't care in Alarm comparison. Only SS[5:0] are compared. */
463#define RTC_ALARMSUBSECONDMASK_SS14_6 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)
464/*!< SS[14:7] are don't care in Alarm comparison. Only SS[6:0] are compared. */
465#define RTC_ALARMSUBSECONDMASK_SS14_7 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)
466/*!< SS[14:8] are don't care in Alarm comparison. Only SS[7:0] are compared. */
467#define RTC_ALARMSUBSECONDMASK_SS14_8 RTC_ALRMASSR_MASKSS_3
468/*!< SS[14:9] are don't care in Alarm comparison. Only SS[8:0] are compared. */
469#define RTC_ALARMSUBSECONDMASK_SS14_9 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_3)
470/*!< SS[14:10] are don't care in Alarm comparison. Only SS[9:0] are compared. */
471#define RTC_ALARMSUBSECONDMASK_SS14_10 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)
472/*!< SS[14:11] are don't care in Alarm comparison. Only SS[10:0] are compared. */
473#define RTC_ALARMSUBSECONDMASK_SS14_11 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)
474/*!< SS[14:12] are don't care in Alarm comparison. Only SS[11:0] are compared. */
475#define RTC_ALARMSUBSECONDMASK_SS14_12 (RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
476/*!< SS[14:13] are don't care in Alarm comparison. Only SS[12:0] are compared. */
477#define RTC_ALARMSUBSECONDMASK_SS14_13 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
478/*!< SS[14] is don't care in Alarm comparison. Only SS[13:0] are compared. */
479#define RTC_ALARMSUBSECONDMASK_SS14 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
480/*!< SS[14:0] are compared and must match to activate alarm. */
481#define RTC_ALARMSUBSECONDMASK_NONE RTC_ALRMASSR_MASKSS
482
483/**
484 * @}
485 */
486
487/** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions
488 * @{
489 */
490#define RTC_IT_TS RTC_CR_TSIE /*!< Enable Timestamp Interrupt */
491#define RTC_IT_WUT RTC_CR_WUTIE /*!< Enable Wakeup timer Interrupt */
492#define RTC_IT_ALRA RTC_CR_ALRAIE /*!< Enable Alarm A Interrupt */
493#define RTC_IT_ALRB RTC_CR_ALRBIE /*!< Enable Alarm B Interrupt */
494/**
495 * @}
496 */
497
498/** @defgroup RTC_Flags_Definitions RTC Flags Definitions
499 * @{
500 */
501#if defined(TAMP)
502#define RTC_FLAG_RECALPF RTC_ICSR_RECALPF /*!< Recalibration pending Flag */
503#define RTC_FLAG_INITF RTC_ICSR_INITF /*!< Initialization pending flag */
504#define RTC_FLAG_RSF RTC_ICSR_RSF /*!< Registers synchronization flag */
505#define RTC_FLAG_INITS RTC_ICSR_INITS /*!< Initialization status flag */
506#define RTC_FLAG_SHPF RTC_ICSR_SHPF /*!< Shift operation pending flag */
507#define RTC_FLAG_WUTWF RTC_ICSR_WUTWF /*!< Wakeup timer write operation pending flag */
508#define RTC_FLAG_ALRBWF RTC_ICSR_ALRBWF /*!< Alarm B write operation pending flag */
509#define RTC_FLAG_ALRAWF RTC_ICSR_ALRAWF /*!< Alarm A write operation pending flag */
510#define RTC_FLAG_ITSF RTC_SR_ITSF /*!< Internal Time-stamp flag */
511#define RTC_FLAG_TSOVF RTC_SR_TSOVF /*!< Time-stamp overflow flag */
512#define RTC_FLAG_TSF RTC_SR_TSF /*!< Time-stamp flag */
513#define RTC_FLAG_WUTF RTC_SR_WUTF /*!< Wakeup timer flag */
514#define RTC_FLAG_ALRBF RTC_SR_ALRBF /*!< Alarm B flag */
515#define RTC_FLAG_ALRAF RTC_SR_ALRAF /*!< Alarm A flag */
516#else
517#define RTC_FLAG_RECALPF RTC_ISR_RECALPF
518#define RTC_FLAG_TSOVF RTC_ISR_TSOVF
519#define RTC_FLAG_TSF RTC_ISR_TSF
520#define RTC_FLAG_ITSF RTC_ISR_ITSF
521#define RTC_FLAG_WUTF RTC_ISR_WUTF
522#define RTC_FLAG_ALRBF RTC_ISR_ALRBF
523#define RTC_FLAG_ALRAF RTC_ISR_ALRAF
524#define RTC_FLAG_INITF RTC_ISR_INITF
525#define RTC_FLAG_RSF RTC_ISR_RSF
526#define RTC_FLAG_INITS RTC_ISR_INITS
527#define RTC_FLAG_SHPF RTC_ISR_SHPF
528#define RTC_FLAG_WUTWF RTC_ISR_WUTWF
529#define RTC_FLAG_ALRBWF RTC_ISR_ALRBWF
530#define RTC_FLAG_ALRAWF RTC_ISR_ALRAWF
531#endif /* TAMP */
532/**
533 * @}
534 */
535
536/** @defgroup RTC_Clear_Flags_Definitions RTC Clear Flags Definitions
537 * @{
538 */
539#if defined(TAMP)
540#define RTC_CLEAR_ITSF RTC_SCR_CITSF /*!< Clear Internal Time-stamp flag */
541#define RTC_CLEAR_TSOVF RTC_SCR_CTSOVF /*!< Clear Time-stamp overflow flag */
542#define RTC_CLEAR_TSF RTC_SCR_CTSF /*!< Clear Time-stamp flag */
543#define RTC_CLEAR_WUTF RTC_SCR_CWUTF /*!< Clear Wakeup timer flag */
544#define RTC_CLEAR_ALRBF RTC_SCR_CALRBF /*!< Clear Alarm B flag */
545#define RTC_CLEAR_ALRAF RTC_SCR_CALRAF /*!< Clear Alarm A flag */
546#endif /* TAMP
547 */
548/**
549 * @}
550 */
551
552/**
553 * @}
554 */
555
556/* Exported macros -----------------------------------------------------------*/
557/** @defgroup RTC_Exported_Macros RTC Exported Macros
558 * @{
559 */
560
561/** @brief Reset RTC handle state
562 * @param __HANDLE__ RTC handle.
563 * @retval None
564 */
565#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
566#define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{ \
567 (__HANDLE__)->State = HAL_RTC_STATE_RESET; \
568 (__HANDLE__)->MspInitCallback = NULL; \
569 (__HANDLE__)->MspDeInitCallback = NULL; \
570 }while(0u)
571#else
572#define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
573#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
574
575/**
576 * @brief Disable the write protection for RTC registers.
577 * @param __HANDLE__ specifies the RTC handle.
578 * @retval None
579 */
580#define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \
581 do{ \
582 (__HANDLE__)->Instance->WPR = 0xCAU; \
583 (__HANDLE__)->Instance->WPR = 0x53U; \
584 } while(0u)
585
586/**
587 * @brief Enable the write protection for RTC registers.
588 * @param __HANDLE__ specifies the RTC handle.
589 * @retval None
590 */
591#define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \
592 do{ \
593 (__HANDLE__)->Instance->WPR = 0xFFU; \
594 } while(0u)
595
596/**
597 * @brief Check whether the RTC Calendar is initialized.
598 * @param __HANDLE__ specifies the RTC handle.
599 * @retval None
600 */
601#if defined(TAMP)
602#define __HAL_RTC_IS_CALENDAR_INITIALIZED(__HANDLE__) (((((__HANDLE__)->Instance->ICSR) & (RTC_FLAG_INITS)) == RTC_FLAG_INITS) ? 1U : 0U)
603#else
604#define __HAL_RTC_IS_CALENDAR_INITIALIZED(__HANDLE__) (((((__HANDLE__)->Instance->ISR) & (RTC_FLAG_INITS)) == RTC_FLAG_INITS) ? 1U : 0U)
605#endif /* TAMP */
606
607/**
608 * @brief Add 1 hour (summer time change).
609 * @param __HANDLE__ specifies the RTC handle.
610 * @param __BKP__ Backup
611 * This parameter can be:
612 * @arg @ref RTC_STOREOPERATION_RESET
613 * @arg @ref RTC_STOREOPERATION_SET
614 * @retval None
615 */
616#define __HAL_RTC_DAYLIGHT_SAVING_TIME_ADD1H(__HANDLE__, __BKP__) \
617 do { \
618 __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__); \
619 SET_BIT((__HANDLE__)->Instance->CR, RTC_CR_ADD1H); \
620 MODIFY_REG((__HANDLE__)->Instance->CR, RTC_CR_BKP , (__BKP__)); \
621 __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__); \
622 } while(0u);
623
624/**
625 * @brief Subtract 1 hour (winter time change).
626 * @param __HANDLE__ specifies the RTC handle.
627 * @param __BKP__ Backup
628 * This parameter can be:
629 * @arg @ref RTC_STOREOPERATION_RESET
630 * @arg @ref RTC_STOREOPERATION_SET
631 * @retval None
632 */
633#define __HAL_RTC_DAYLIGHT_SAVING_TIME_SUB1H(__HANDLE__, __BKP__) \
634 do { \
635 __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__); \
636 SET_BIT((__HANDLE__)->Instance->CR, RTC_CR_SUB1H); \
637 MODIFY_REG((__HANDLE__)->Instance->CR, RTC_CR_BKP , (__BKP__)); \
638 __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__); \
639 } while(0u);
640
641/**
642 * @brief Enable the RTC ALARMA peripheral.
643 * @param __HANDLE__ specifies the RTC handle.
644 * @retval None
645 */
646#define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE))
647
648/**
649 * @brief Disable the RTC ALARMA peripheral.
650 * @param __HANDLE__ specifies the RTC handle.
651 * @retval None
652 */
653#define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE))
654
655/**
656 * @brief Enable the RTC ALARMB peripheral.
657 * @param __HANDLE__ specifies the RTC handle.
658 * @retval None
659 */
660#define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE))
661
662/**
663 * @brief Disable the RTC ALARMB peripheral.
664 * @param __HANDLE__ specifies the RTC handle.
665 * @retval None
666 */
667#define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE))
668
669/**
670 * @brief Enable the RTC Alarm interrupt.
671 * @param __HANDLE__ specifies the RTC handle.
672 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
673 * This parameter can be any combination of the following values:
674 * @arg @ref RTC_IT_ALRA Alarm A interrupt
675 * @arg @ref RTC_IT_ALRB Alarm B interrupt
676 * @retval None
677 */
678#define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
679
680/**
681 * @brief Disable the RTC Alarm interrupt.
682 * @param __HANDLE__ specifies the RTC handle.
683 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
684 * This parameter can be any combination of the following values:
685 * @arg @ref RTC_IT_ALRA Alarm A interrupt
686 * @arg @ref RTC_IT_ALRB Alarm B interrupt
687 * @retval None
688 */
689#define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
690
691/**
692 * @brief Check whether the specified RTC Alarm interrupt has occurred or not.
693 * @param __HANDLE__ specifies the RTC handle.
694 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
695 * This parameter can be:
696 * @arg @ref RTC_IT_ALRA Alarm A interrupt
697 * @arg @ref RTC_IT_ALRB Alarm B interrupt
698 * @retval None
699 */
700#if defined(TAMP)
701#define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->MISR)& (__INTERRUPT__ >> 12)) != 0U)? 1U : 0U)
702#else
703#define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR)& (__INTERRUPT__ >> 4)) != 0U)? 1U : 0U)
704#endif /* TAMP */
705
706/**
707 * @brief Check whether the specified RTC Alarm interrupt has been enabled or not.
708 * @param __HANDLE__ specifies the RTC handle.
709 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
710 * This parameter can be:
711 * @arg @ref RTC_IT_ALRA Alarm A interrupt
712 * @arg @ref RTC_IT_ALRB Alarm B interrupt
713 * @retval None
714 */
715#define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
716
717#if defined(TAMP)
718/**
719 * @brief Get the selected RTC Alarm's flag status.
720 * @param __HANDLE__ specifies the RTC handle.
721 * @param __FLAG__ specifies the RTC Alarm Flag sources to check.
722 * This parameter can be:
723 * @arg @ref RTC_FLAG_ALRAF
724 * @arg @ref RTC_FLAG_ALRBF
725 * @retval None
726 */
727#define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->SR) & (__FLAG__)) != 0U) ? 1U : 0U)
728#else
729/**
730 * @brief Get the selected RTC Alarm's flag status.
731 * @param __HANDLE__ specifies the RTC handle.
732 * @param __FLAG__ specifies the RTC Alarm Flag sources to check.
733 * This parameter can be:
734 * @arg @ref RTC_FLAG_ALRAF
735 * @arg @ref RTC_FLAG_ALRBF
736 * @arg @ref RTC_FLAG_ALRAWF
737 * @arg @ref RTC_FLAG_ALRBWF
738 * @retval None
739 */
740#define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
741#endif /* TAMP */
742
743/**
744 * @brief Clear the RTC Alarm's pending flags.
745 * @param __HANDLE__ specifies the RTC handle.
746 * @param __FLAG__ specifies the RTC Alarm Flag sources to clear.
747 * This parameter can be:
748 * @arg @ref RTC_FLAG_ALRAF
749 * @arg @ref RTC_FLAG_ALRBF
750 * @retval None
751 */
752#if defined(TAMP)
753#define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SCR = __FLAG__)
754#else
755#define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)))
756#endif /* TAMP */
757
758
759/**
760 * @brief Enable interrupt on the RTC Alarm associated Exti line.
761 * @retval None
762 */
763#if defined(EXTI_D1)
764#define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI_D1->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
765#else /* EXTI */
766#define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
767#endif /* EXTI_D1 */
768
769/**
770 * @brief Disable interrupt on the RTC Alarm associated Exti line.
771 * @retval None
772 */
773#if defined(EXTI_D1)
774#define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI_D1->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
775#else /* EXTI */
776#define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
777#endif /* EXTI_D1 */
778
779/**
780 * @brief Enable event on the RTC Alarm associated Exti line.
781 * @retval None.
782 */
783#if defined(EXTI_D1)
784#define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI_D1->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
785#else /* EXTI */
786#define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
787#endif /* EXTI_D1 */
788
789/**
790 * @brief Disable event on the RTC Alarm associated Exti line.
791 * @retval None.
792 */
793#if defined(EXTI_D1)
794#define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI_D1->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
795#else /* EXTI */
796#define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
797#endif /* EXTI_D1 */
798
799#if defined(DUAL_CORE)
800/**
801 * @brief Enable interrupt on the RTC Alarm associated D2 Exti line.
802 * @retval None
803 */
804#define __HAL_RTC_ALARM_EXTID2_ENABLE_IT() (EXTI_D2->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
805
806/**
807 * @brief Disable interrupt on the RTC Alarm associated D2 Exti line.
808 * @retval None
809 */
810#define __HAL_RTC_ALARM_EXTID2_DISABLE_IT() (EXTI_D2->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
811
812/**
813 * @brief Enable event on the RTC Alarm associated D2 Exti line.
814 * @retval None
815 */
816#define __HAL_RTC_ALARM_EXTID2_ENABLE_EVENT() (EXTI_D2->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
817
818/**
819 * @brief Disable event on the RTC Alarm associated D2 Exti line.
820 * @retval None
821 */
822#define __HAL_RTC_ALARM_EXTID2_DISABLE_EVENT() (EXTI_D2->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
823
824#endif /* DUAL_CORE */
825/**
826 * @brief Enable falling edge trigger on the RTC Alarm associated Exti line.
827 * @retval None
828 */
829#define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR1 |= RTC_EXTI_LINE_ALARM_EVENT)
830
831/**
832 * @brief Disable falling edge trigger on the RTC Alarm associated Exti line.
833 * @retval None
834 */
835#define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
836
837/**
838 * @brief Enable rising edge trigger on the RTC Alarm associated Exti line.
839 * @retval None
840 */
841#define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR1 |= RTC_EXTI_LINE_ALARM_EVENT)
842
843/**
844 * @brief Disable rising edge trigger on the RTC Alarm associated Exti line.
845 * @retval None
846 */
847#define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
848
849/**
850 * @brief Enable rising & falling edge trigger on the RTC Alarm associated Exti line.
851 * @retval None
852 */
853#define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
854 __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE(); \
855 __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE(); \
856 } while(0u)
857
858/**
859 * @brief Disable rising & falling edge trigger on the RTC Alarm associated Exti line.
860 * @retval None
861 */
862#define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
863 __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE(); \
864 __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(); \
865 } while(0u)
866
867/**
868 * @brief Check whether the RTC Alarm associated Exti line interrupt flag is set or not.
869 * @retval Line Status.
870 */
871#if defined(EXTI_D1)
872#define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI_D1->PR1 & RTC_EXTI_LINE_ALARM_EVENT)
873#else /* EXTI */
874#define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR1 & RTC_EXTI_LINE_ALARM_EVENT)
875#endif /* EXTI_D1 */
876
877/**
878 * @brief Clear the RTC Alarm associated Exti line flag.
879 * @retval None.
880 */
881#if defined(EXTI_D1)
882#define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI_D1->PR1 = (RTC_EXTI_LINE_ALARM_EVENT))
883#else /* EXTI */
884#define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR1 = (RTC_EXTI_LINE_ALARM_EVENT))
885#endif /* EXTI_D1 */
886
887#if defined(DUAL_CORE)
888/**
889 * @brief Check whether the RTC Alarm associated D2 Exti line interrupt flag is set or not.
890 * @retval Line Status
891 */
892#define __HAL_RTC_ALARM_EXTID2_GET_FLAG() (EXTI_D2->PR1 & RTC_EXTI_LINE_ALARM_EVENT)
893
894/**
895 * @brief Clear the RTC Alarm associated D2 Exti line flag.
896 * @retval None
897 */
898#define __HAL_RTC_ALARM_EXTID2_CLEAR_FLAG() (EXTI_D2->PR1 = (RTC_EXTI_LINE_ALARM_EVENT))
899#endif /* DUAL_CORE */
900/**
901 * @brief Generate a Software interrupt on RTC Alarm associated Exti line.
902 * @retval None
903 */
904#define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() (EXTI->SWIER1 |= RTC_EXTI_LINE_ALARM_EVENT)
905
906/**
907 * @}
908 */
909
910/* Include RTC HAL Extended module */
911#include "stm32h7xx_hal_rtc_ex.h"
912
913/* Exported functions --------------------------------------------------------*/
914/** @defgroup RTC_Exported_Functions RTC Exported Functions
915 * @{
916 */
917
918/** @defgroup RTC_Exported_Functions_Group1 Initialization and de-initialization functions
919 * @{
920 */
921/* Initialization and de-initialization functions ****************************/
924
927
928/* Callbacks Register/UnRegister functions ***********************************/
929#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
930HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback);
931HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID);
932#endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
933/**
934 * @}
935 */
936
937/** @defgroup RTC_Exported_Functions_Group2 RTC Time and Date functions
938 * @{
939 */
940/* RTC Time and Date functions ************************************************/
945/**
946 * @}
947 */
948
949/** @defgroup RTC_Exported_Functions_Group3 RTC Alarm functions
950 * @{
951 */
952/* RTC Alarm functions ********************************************************/
956HAL_StatusTypeDef HAL_RTC_GetAlarm(const RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format);
960/**
961 * @}
962 */
963
964/** @defgroup RTC_Exported_Functions_Group4 Peripheral Control functions
965 * @{
966 */
967/* Peripheral Control functions ***********************************************/
969/**
970 * @}
971 */
972
973/** @defgroup RTC_Exported_Functions_Group5 Peripheral State functions
974 * @{
975 */
976/* Peripheral State functions *************************************************/
978/**
979 * @}
980 */
981
982/**
983 * @}
984 */
985
986/* Private types -------------------------------------------------------------*/
987/* Private variables ---------------------------------------------------------*/
988/* Private constants ---------------------------------------------------------*/
989/** @defgroup RTC_Private_Constants RTC Private Constants
990 * @{
991 */
992/* Masks Definition */
993#define RTC_TR_RESERVED_MASK (RTC_TR_PM | RTC_TR_HT | RTC_TR_HU | \
994 RTC_TR_MNT | RTC_TR_MNU| RTC_TR_ST | \
995 RTC_TR_SU)
996
997#define RTC_DR_RESERVED_MASK (RTC_DR_YT | RTC_DR_YU | RTC_DR_WDU | \
998 RTC_DR_MT | RTC_DR_MU | RTC_DR_DT | \
999 RTC_DR_DU)
1000
1001#define RTC_INIT_MASK 0xFFFFFFFFu
1002
1003#if defined(TAMP)
1004#define RTC_ICSR_RESERVED_MASK 0x000100FFu
1005#define RTC_RSF_MASK (~(RTC_ICSR_INIT | RTC_ICSR_RSF))
1006#else
1007#define RTC_ISR_RESERVED_MASK 0x0003FFFFu
1008#define RTC_RSF_MASK (~(RTC_ISR_INIT | RTC_ISR_RSF))
1009#endif /* TAMP */
1010
1011#define RTC_TIMEOUT_VALUE 1000u
1012
1013#define RTC_EXTI_LINE_ALARM_EVENT EXTI_IMR1_IM17 /*!< External interrupt line 17 Connected to the RTC Alarm event */
1014
1015/**
1016 * @}
1017 */
1018
1019/* Private macros ------------------------------------------------------------*/
1020/** @defgroup RTC_Private_Macros RTC Private Macros
1021 * @{
1022 */
1023
1024/** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters
1025 * @{
1026 */
1027
1028#if defined(TAMP)
1029#define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
1030 ((OUTPUT) == RTC_OUTPUT_ALARMA) || \
1031 ((OUTPUT) == RTC_OUTPUT_ALARMB) || \
1032 ((OUTPUT) == RTC_OUTPUT_WAKEUP) || \
1033 ((OUTPUT) == RTC_OUTPUT_TAMPER))
1034#else
1035#define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
1036 ((OUTPUT) == RTC_OUTPUT_ALARMA) || \
1037 ((OUTPUT) == RTC_OUTPUT_ALARMB) || \
1038 ((OUTPUT) == RTC_OUTPUT_WAKEUP))
1039#endif /* TAMP */
1040
1041#define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HOURFORMAT_12) || \
1042 ((FORMAT) == RTC_HOURFORMAT_24))
1043
1044#define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \
1045 ((POL) == RTC_OUTPUT_POLARITY_LOW))
1046
1047#define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \
1048 ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL))
1049
1050#if defined(TAMP)
1051#define IS_RTC_OUTPUT_PULLUP(TYPE) (((TYPE) == RTC_OUTPUT_PULLUP_NONE) || \
1052 ((TYPE) == RTC_OUTPUT_PULLUP_ON))
1053#endif /* TAMP */
1054
1055#define IS_RTC_OUTPUT_REMAP(REMAP) (((REMAP) == RTC_OUTPUT_REMAP_NONE) || \
1056 ((REMAP) == RTC_OUTPUT_REMAP_POS1))
1057
1058#define IS_RTC_HOURFORMAT12(PM) (((PM) == RTC_HOURFORMAT12_AM) || \
1059 ((PM) == RTC_HOURFORMAT12_PM))
1060
1061#define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \
1062 ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \
1063 ((SAVE) == RTC_DAYLIGHTSAVING_NONE))
1064
1065#define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \
1066 ((OPERATION) == RTC_STOREOPERATION_SET))
1067
1068#define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || \
1069 ((FORMAT) == RTC_FORMAT_BCD))
1070
1071#define IS_RTC_YEAR(YEAR) ((YEAR) <= 99u)
1072
1073#define IS_RTC_MONTH(MONTH) (((MONTH) >= 1u) && ((MONTH) <= 12u))
1074
1075#define IS_RTC_DATE(DATE) (((DATE) >= 1u) && ((DATE) <= 31u))
1076
1077#define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \
1078 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \
1079 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
1080 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \
1081 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \
1082 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \
1083 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
1084
1085#define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0u) && ((DATE) <= 31u))
1086
1087#define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \
1088 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \
1089 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
1090 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \
1091 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \
1092 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \
1093 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
1094
1095#define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \
1096 ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY))
1097
1098#define IS_RTC_ALARM_MASK(MASK) (((MASK) & ~(RTC_ALARMMASK_ALL)) == 0u)
1099
1100#define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_ALARM_A) || \
1101 ((ALARM) == RTC_ALARM_B))
1102
1103#define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= RTC_ALRMASSR_SS)
1104
1105#define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == 0u) || \
1106 (((MASK) >= RTC_ALARMSUBSECONDMASK_SS14_1) && ((MASK) <= RTC_ALARMSUBSECONDMASK_NONE)))
1107
1108#define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= (RTC_PRER_PREDIV_A >> RTC_PRER_PREDIV_A_Pos))
1109
1110#define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= (RTC_PRER_PREDIV_S >> RTC_PRER_PREDIV_S_Pos))
1111
1112#define IS_RTC_HOUR12(HOUR) (((HOUR) > 0u) && ((HOUR) <= 12u))
1113
1114#define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23u)
1115
1116#define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59u)
1117
1118#define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59u)
1119
1120/**
1121 * @}
1122 */
1123
1124/**
1125 * @}
1126 */
1127
1128/* Private functions -------------------------------------------------------------*/
1129/** @defgroup RTC_Private_Functions RTC Private Functions
1130 * @{
1131 */
1134uint8_t RTC_ByteToBcd2(uint8_t Value);
1135uint8_t RTC_Bcd2ToByte(uint8_t Value);
1136
1137/**
1138 * @}
1139 */
1140
1141/**
1142 * @}
1143 */
1144
1145/**
1146 * @}
1147 */
1148
1149#ifdef __cplusplus
1150}
1151#endif
1152
1153#endif /* STM32H7xx_HAL_RTC_H */
1154
#define __IO
Defines 'read / write' permissions.
HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc)
void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc)
RTC MSP De-Initialization This function freeze the hardware resources used in this example.
HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc)
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
RTC MSP Initialization This function configures the hardware resources used in this example.
HAL_StatusTypeDef HAL_RTC_GetDate(const RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format)
HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format)
HAL_StatusTypeDef HAL_RTC_GetTime(const RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format)
HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format)
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm)
HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format)
void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc)
HAL_StatusTypeDef HAL_RTC_GetAlarm(const RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format)
HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format)
HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc)
HAL_RTCStateTypeDef HAL_RTC_GetState(const RTC_HandleTypeDef *hrtc)
HAL_RTCStateTypeDef
HAL State structures definition.
@ HAL_RTC_STATE_TIMEOUT
RTC timeout state.
@ HAL_RTC_STATE_ERROR
RTC error state.
@ HAL_RTC_STATE_READY
RTC initialized and ready for use.
@ HAL_RTC_STATE_BUSY
RTC process is ongoing.
@ HAL_RTC_STATE_RESET
RTC not yet initialized or disabled.
HAL_StatusTypeDef RTC_ExitInitMode(RTC_HandleTypeDef *hrtc)
HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef *hrtc)
uint8_t RTC_ByteToBcd2(uint8_t Value)
uint8_t RTC_Bcd2ToByte(uint8_t Value)
RTC_HandleTypeDef hrtc
Definition main.c:52
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_StatusTypeDef
HAL Status structures definition.
HAL_LockTypeDef
HAL Lock structures definition.
Header file of RTC HAL Extension module.
RTC Alarm structure definition.
uint8_t AlarmDateWeekDay
Specifies the RTC Alarm Date/WeekDay.
RTC_TimeTypeDef AlarmTime
Specifies the RTC Alarm Time members.
uint32_t Alarm
Specifies the alarm .
uint32_t AlarmDateWeekDaySel
Specifies the RTC Alarm is on Date or WeekDay.
uint32_t AlarmMask
Specifies the RTC Alarm Masks.
uint32_t AlarmSubSecondMask
Specifies the RTC Alarm SubSeconds Masks.
RTC Date structure definition.
uint8_t Year
Specifies the RTC Date Year.
uint8_t Month
Specifies the RTC Date Month (in BCD format).
uint8_t Date
Specifies the RTC Date.
uint8_t WeekDay
Specifies the RTC Date WeekDay.
RTC Handle Structure definition.
RTC_TypeDef * Instance
Register base address.
RTC_InitTypeDef Init
RTC required parameters.
__IO HAL_RTCStateTypeDef State
Time communication state.
HAL_LockTypeDef Lock
RTC locking object.
RTC Configuration Structure definition.
uint32_t OutPutPolarity
Specifies the polarity of the output signal.
uint32_t OutPutType
Specifies the RTC Output Pin mode.
uint32_t OutPutRemap
Specifies the remap for RTC output.
uint32_t AsynchPrediv
Specifies the RTC Asynchronous Predivider value.
uint32_t HourFormat
Specifies the RTC Hour Format.
uint32_t SynchPrediv
Specifies the RTC Synchronous Predivider value.
uint32_t OutPut
Specifies which signal will be routed to the RTC output.
RTC Time structure definition.
uint8_t Seconds
Specifies the RTC Time Seconds.
uint8_t Minutes
Specifies the RTC Time Minutes.
uint8_t TimeFormat
Specifies the RTC AM/PM Time.
uint32_t StoreOperation
Specifies RTC_StoreOperation value to be written in the BKP bit in CR register to store the operation...
uint32_t SecondFraction
Specifies the range or granularity of Sub Second register content corresponding to Synchronous pre-sc...
uint32_t DayLightSaving
Specifies RTC_DayLightSaveOperation: the value of hour adjustment.
uint32_t SubSeconds
Specifies the RTC_SSR RTC Sub Second register content.
uint8_t Hours
Specifies the RTC Time Hour.
Real-Time Clock.