RTEMS 6.1-rc5
Loading...
Searching...
No Matches
stm32h7xx_hal_rtc.h
Go to the documentation of this file.
1
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
39/* Exported types ------------------------------------------------------------*/
48typedef enum
49{
54 HAL_RTC_STATE_ERROR = 0x04U
57
61typedef struct
62{
63 uint32_t HourFormat;
66 uint32_t AsynchPrediv;
69 uint32_t SynchPrediv;
72 uint32_t OutPut;
75 uint32_t OutPutRemap;
78 uint32_t OutPutPolarity;
81 uint32_t OutPutType;
83#if defined(TAMP)
84 uint32_t OutPutPullUp;
86#endif /* TAMP */
88
92typedef struct
93{
94 uint8_t Hours;
98 uint8_t Minutes;
101 uint8_t Seconds;
104 uint8_t TimeFormat;
107 uint32_t SubSeconds;
111 uint32_t SecondFraction;
117 uint32_t DayLightSaving;
120 uint32_t StoreOperation;
124
128typedef struct
129{
130 uint8_t WeekDay;
133 uint8_t Month;
136 uint8_t Date;
139 uint8_t Year;
143
147typedef struct
148{
151 uint32_t AlarmMask;
164 uint32_t Alarm;
167
171#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
172typedef struct __RTC_HandleTypeDef
173#else
174typedef struct
175#endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
176{
185#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
186 void (* AlarmAEventCallback)(struct __RTC_HandleTypeDef *hrtc);
188 void (* AlarmBEventCallback)(struct __RTC_HandleTypeDef *hrtc);
190 void (* TimeStampEventCallback)(struct __RTC_HandleTypeDef *hrtc);
192 void (* WakeUpTimerEventCallback)(struct __RTC_HandleTypeDef *hrtc);
194 void (* Tamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc);
196 void (* Tamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc);
198 void (* Tamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc);
200#if defined(TAMP)
201 void (* InternalTamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc);
203 void (* InternalTamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc);
205 void (* InternalTamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc);
207 void (* InternalTamper4EventCallback)(struct __RTC_HandleTypeDef *hrtc);
209 void (* InternalTamper5EventCallback)(struct __RTC_HandleTypeDef *hrtc);
211 void (* InternalTamper6EventCallback)(struct __RTC_HandleTypeDef *hrtc);
213 void (* InternalTamper8EventCallback)(struct __RTC_HandleTypeDef *hrtc);
214#endif /* TAMP */
215
216 void (* MspInitCallback)(struct __RTC_HandleTypeDef *hrtc);
218 void (* MspDeInitCallback)(struct __RTC_HandleTypeDef *hrtc);
220#endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
221
223
224#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
228typedef enum
229{
230 HAL_RTC_ALARM_A_EVENT_CB_ID = 0u,
231 HAL_RTC_ALARM_B_EVENT_CB_ID = 1u,
232 HAL_RTC_TIMESTAMP_EVENT_CB_ID = 2u,
233 HAL_RTC_WAKEUPTIMER_EVENT_CB_ID = 3u,
234 HAL_RTC_TAMPER1_EVENT_CB_ID = 4u,
235 HAL_RTC_TAMPER2_EVENT_CB_ID = 5u,
236 HAL_RTC_TAMPER3_EVENT_CB_ID = 6u,
237#if defined(TAMP)
238 HAL_RTC_INTERNAL_TAMPER1_EVENT_CB_ID = 12u,
239 HAL_RTC_INTERNAL_TAMPER2_EVENT_CB_ID = 13u,
240 HAL_RTC_INTERNAL_TAMPER3_EVENT_CB_ID = 14u,
241 HAL_RTC_INTERNAL_TAMPER4_EVENT_CB_ID = 15u,
242 HAL_RTC_INTERNAL_TAMPER5_EVENT_CB_ID = 16u,
243 HAL_RTC_INTERNAL_TAMPER6_EVENT_CB_ID = 17u,
244 HAL_RTC_INTERNAL_TAMPER8_EVENT_CB_ID = 19u,
245#endif /* TAMP */
246 HAL_RTC_MSPINIT_CB_ID = 20u,
247 HAL_RTC_MSPDEINIT_CB_ID = 21u
248} HAL_RTC_CallbackIDTypeDef;
249
253typedef void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc);
254#endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
255
260/* Exported constants --------------------------------------------------------*/
270#define RTC_HOURFORMAT_24 0x00000000u
271#define RTC_HOURFORMAT_12 RTC_CR_FMT
280#define RTC_OUTPUT_DISABLE 0x00000000u
281#define RTC_OUTPUT_ALARMA RTC_CR_OSEL_0
282#define RTC_OUTPUT_ALARMB RTC_CR_OSEL_1
283#define RTC_OUTPUT_WAKEUP RTC_CR_OSEL
284#if defined(TAMP)
285#define RTC_OUTPUT_TAMPER RTC_CR_TAMPOE
286#endif /* TAMP */
295#define RTC_OUTPUT_POLARITY_HIGH 0x00000000u
296#define RTC_OUTPUT_POLARITY_LOW RTC_CR_POL
305#if defined(TAMP)
306#define RTC_OUTPUT_TYPE_PUSHPULL 0x00000000u
307#define RTC_OUTPUT_TYPE_OPENDRAIN RTC_CR_TAMPALRM_TYPE
308#define RTC_ALARM_OUTPUT_TYPE RTC_CR_TAMPALRM_TYPE
309#else
310#define RTC_OUTPUT_TYPE_PUSHPULL RTC_OR_ALARMOUTTYPE
311#define RTC_OUTPUT_TYPE_OPENDRAIN 0x00000000u
312#define RTC_ALARM_OUTPUT_TYPE RTC_OR_ALARMOUTTYPE
313#endif /* TAMP */
322#if defined(TAMP)
323#define RTC_OUTPUT_PULLUP_NONE 0x00000000u
324#define RTC_OUTPUT_PULLUP_ON RTC_CR_TAMPALRM_PU
325#endif /* TAMP */
334#if defined(TAMP)
335#define RTC_OUTPUT_REMAP_NONE 0x00000000u
336#define RTC_OUTPUT_REMAP_POS1 RTC_CR_OUT2EN
337#else
338#define RTC_OUTPUT_REMAP_NONE 0x00000000u
339#define RTC_OUTPUT_REMAP_POS1 RTC_OR_OUT_RMP
340#endif /* TAMP */
349#define RTC_HOURFORMAT12_AM ((uint8_t)0x00)
350#define RTC_HOURFORMAT12_PM ((uint8_t)0x01)
359#define RTC_DAYLIGHTSAVING_SUB1H RTC_CR_SUB1H
360#define RTC_DAYLIGHTSAVING_ADD1H RTC_CR_ADD1H
361#define RTC_DAYLIGHTSAVING_NONE 0x00000000u
370#define RTC_STOREOPERATION_RESET 0x00000000u
371#define RTC_STOREOPERATION_SET RTC_CR_BKP
380#define RTC_FORMAT_BIN 0x00000000u
381#define RTC_FORMAT_BCD 0x00000001u
390#define RTC_MONTH_JANUARY ((uint8_t)0x01)
391#define RTC_MONTH_FEBRUARY ((uint8_t)0x02)
392#define RTC_MONTH_MARCH ((uint8_t)0x03)
393#define RTC_MONTH_APRIL ((uint8_t)0x04)
394#define RTC_MONTH_MAY ((uint8_t)0x05)
395#define RTC_MONTH_JUNE ((uint8_t)0x06)
396#define RTC_MONTH_JULY ((uint8_t)0x07)
397#define RTC_MONTH_AUGUST ((uint8_t)0x08)
398#define RTC_MONTH_SEPTEMBER ((uint8_t)0x09)
399#define RTC_MONTH_OCTOBER ((uint8_t)0x10)
400#define RTC_MONTH_NOVEMBER ((uint8_t)0x11)
401#define RTC_MONTH_DECEMBER ((uint8_t)0x12)
402
411#define RTC_WEEKDAY_MONDAY ((uint8_t)0x01)
412#define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02)
413#define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03)
414#define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04)
415#define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05)
416#define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06)
417#define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07)
418
427#define RTC_ALARMDATEWEEKDAYSEL_DATE 0x00000000u
428#define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL
429
438#define RTC_ALARMMASK_NONE 0x00000000u
439#define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4
440#define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3
441#define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2
442#define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1
443#define RTC_ALARMMASK_ALL (RTC_ALARMMASK_DATEWEEKDAY | \
444 RTC_ALARMMASK_HOURS | \
445 RTC_ALARMMASK_MINUTES | \
446 RTC_ALARMMASK_SECONDS)
455#define RTC_ALARM_A RTC_CR_ALRAE
456#define RTC_ALARM_B RTC_CR_ALRBE
466#define RTC_ALARMSUBSECONDMASK_ALL 0x00000000u
468#define RTC_ALARMSUBSECONDMASK_SS14_1 RTC_ALRMASSR_MASKSS_0
470#define RTC_ALARMSUBSECONDMASK_SS14_2 RTC_ALRMASSR_MASKSS_1
472#define RTC_ALARMSUBSECONDMASK_SS14_3 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1)
474#define RTC_ALARMSUBSECONDMASK_SS14_4 RTC_ALRMASSR_MASKSS_2
476#define RTC_ALARMSUBSECONDMASK_SS14_5 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2)
478#define RTC_ALARMSUBSECONDMASK_SS14_6 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)
480#define RTC_ALARMSUBSECONDMASK_SS14_7 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)
482#define RTC_ALARMSUBSECONDMASK_SS14_8 RTC_ALRMASSR_MASKSS_3
484#define RTC_ALARMSUBSECONDMASK_SS14_9 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_3)
486#define RTC_ALARMSUBSECONDMASK_SS14_10 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)
488#define RTC_ALARMSUBSECONDMASK_SS14_11 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)
490#define RTC_ALARMSUBSECONDMASK_SS14_12 (RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
492#define RTC_ALARMSUBSECONDMASK_SS14_13 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
494#define RTC_ALARMSUBSECONDMASK_SS14 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
496#define RTC_ALARMSUBSECONDMASK_NONE RTC_ALRMASSR_MASKSS
497
506#define RTC_IT_TS RTC_CR_TSIE
507#define RTC_IT_WUT RTC_CR_WUTIE
508#define RTC_IT_ALRA RTC_CR_ALRAIE
509#define RTC_IT_ALRB RTC_CR_ALRBIE
518#if defined(TAMP)
519#define RTC_FLAG_RECALPF RTC_ICSR_RECALPF
520#define RTC_FLAG_INITF RTC_ICSR_INITF
521#define RTC_FLAG_RSF RTC_ICSR_RSF
522#define RTC_FLAG_INITS RTC_ICSR_INITS
523#define RTC_FLAG_SHPF RTC_ICSR_SHPF
524#define RTC_FLAG_WUTWF RTC_ICSR_WUTWF
525#define RTC_FLAG_ALRBWF RTC_ICSR_ALRBWF
526#define RTC_FLAG_ALRAWF RTC_ICSR_ALRAWF
527#define RTC_FLAG_ITSF RTC_SR_ITSF
528#define RTC_FLAG_TSOVF RTC_SR_TSOVF
529#define RTC_FLAG_TSF RTC_SR_TSF
530#define RTC_FLAG_WUTF RTC_SR_WUTF
531#define RTC_FLAG_ALRBF RTC_SR_ALRBF
532#define RTC_FLAG_ALRAF RTC_SR_ALRAF
533#else
534#define RTC_FLAG_RECALPF RTC_ISR_RECALPF
535#define RTC_FLAG_TSOVF RTC_ISR_TSOVF
536#define RTC_FLAG_TSF RTC_ISR_TSF
537#define RTC_FLAG_ITSF RTC_ISR_ITSF
538#define RTC_FLAG_WUTF RTC_ISR_WUTF
539#define RTC_FLAG_ALRBF RTC_ISR_ALRBF
540#define RTC_FLAG_ALRAF RTC_ISR_ALRAF
541#define RTC_FLAG_INITF RTC_ISR_INITF
542#define RTC_FLAG_RSF RTC_ISR_RSF
543#define RTC_FLAG_INITS RTC_ISR_INITS
544#define RTC_FLAG_SHPF RTC_ISR_SHPF
545#define RTC_FLAG_WUTWF RTC_ISR_WUTWF
546#define RTC_FLAG_ALRBWF RTC_ISR_ALRBWF
547#define RTC_FLAG_ALRAWF RTC_ISR_ALRAWF
548#endif /* TAMP */
557#if defined(TAMP)
558#define RTC_CLEAR_ITSF RTC_SCR_CITSF
559#define RTC_CLEAR_TSOVF RTC_SCR_CTSOVF
560#define RTC_CLEAR_TSF RTC_SCR_CTSF
561#define RTC_CLEAR_WUTF RTC_SCR_CWUTF
562#define RTC_CLEAR_ALRBF RTC_SCR_CALRBF
563#define RTC_CLEAR_ALRAF RTC_SCR_CALRAF
564#endif /* TAMP
565 */
574/* Exported macros -----------------------------------------------------------*/
584#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
585#define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{ \
586 (__HANDLE__)->State = HAL_RTC_STATE_RESET; \
587 (__HANDLE__)->MspInitCallback = NULL; \
588 (__HANDLE__)->MspDeInitCallback = NULL; \
589 }while(0u)
590#else
591#define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
592#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
593
599#define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \
600 do{ \
601 (__HANDLE__)->Instance->WPR = 0xCAU; \
602 (__HANDLE__)->Instance->WPR = 0x53U; \
603 } while(0u)
604
610#define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \
611 do{ \
612 (__HANDLE__)->Instance->WPR = 0xFFU; \
613 } while(0u)
614
620#if defined(TAMP)
621#define __HAL_RTC_IS_CALENDAR_INITIALIZED(__HANDLE__) (((((__HANDLE__)->Instance->ICSR) & (RTC_FLAG_INITS)) == RTC_FLAG_INITS) ? 1U : 0U)
622#else
623#define __HAL_RTC_IS_CALENDAR_INITIALIZED(__HANDLE__) (((((__HANDLE__)->Instance->ISR) & (RTC_FLAG_INITS)) == RTC_FLAG_INITS) ? 1U : 0U)
624#endif /* TAMP */
625
635#define __HAL_RTC_DAYLIGHT_SAVING_TIME_ADD1H(__HANDLE__, __BKP__) \
636 do { \
637 __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__); \
638 SET_BIT((__HANDLE__)->Instance->CR, RTC_CR_ADD1H); \
639 MODIFY_REG((__HANDLE__)->Instance->CR, RTC_CR_BKP , (__BKP__)); \
640 __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__); \
641 } while(0u);
642
652#define __HAL_RTC_DAYLIGHT_SAVING_TIME_SUB1H(__HANDLE__, __BKP__) \
653 do { \
654 __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__); \
655 SET_BIT((__HANDLE__)->Instance->CR, RTC_CR_SUB1H); \
656 MODIFY_REG((__HANDLE__)->Instance->CR, RTC_CR_BKP , (__BKP__)); \
657 __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__); \
658 } while(0u);
659
665#define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE))
666
672#define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE))
673
679#define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE))
680
686#define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE))
687
697#define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
698
708#define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
709
719#if defined(TAMP)
720#define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->MISR)& (__INTERRUPT__ >> 12)) != 0U)? 1U : 0U)
721#else
722#define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR)& (__INTERRUPT__ >> 4)) != 0U)? 1U : 0U)
723#endif /* TAMP */
724
734#define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
735
736#if defined(TAMP)
746#define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->SR) & (__FLAG__)) != 0U) ? 1U : 0U)
747#else
759#define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
760#endif /* TAMP */
761
771#if defined(TAMP)
772#define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SCR = __FLAG__)
773#else
774#define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)))
775#endif /* TAMP */
776
777
782#if defined(EXTI_D1)
783#define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI_D1->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
784#else /* EXTI */
785#define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
786#endif /* EXTI_D1 */
787
792#if defined(EXTI_D1)
793#define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI_D1->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
794#else /* EXTI */
795#define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
796#endif /* EXTI_D1 */
797
802#if defined(EXTI_D1)
803#define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI_D1->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
804#else /* EXTI */
805#define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
806#endif /* EXTI_D1 */
807
812#if defined(EXTI_D1)
813#define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI_D1->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
814#else /* EXTI */
815#define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
816#endif /* EXTI_D1 */
817
818#if defined(DUAL_CORE)
823#define __HAL_RTC_ALARM_EXTID2_ENABLE_IT() (EXTI_D2->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
824
829#define __HAL_RTC_ALARM_EXTID2_DISABLE_IT() (EXTI_D2->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
830
835#define __HAL_RTC_ALARM_EXTID2_ENABLE_EVENT() (EXTI_D2->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
836
841#define __HAL_RTC_ALARM_EXTID2_DISABLE_EVENT() (EXTI_D2->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
842
843#endif /* DUAL_CORE */
848#define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR1 |= RTC_EXTI_LINE_ALARM_EVENT)
849
854#define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
855
860#define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR1 |= RTC_EXTI_LINE_ALARM_EVENT)
861
866#define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
867
872#define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
873 __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE(); \
874 __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE(); \
875 } while(0u)
876
881#define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
882 __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE(); \
883 __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(); \
884 } while(0u)
885
890#if defined(EXTI_D1)
891#define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI_D1->PR1 & RTC_EXTI_LINE_ALARM_EVENT)
892#else /* EXTI */
893#define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR1 & RTC_EXTI_LINE_ALARM_EVENT)
894#endif /* EXTI_D1 */
895
900#if defined(EXTI_D1)
901#define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI_D1->PR1 = (RTC_EXTI_LINE_ALARM_EVENT))
902#else /* EXTI */
903#define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR1 = (RTC_EXTI_LINE_ALARM_EVENT))
904#endif /* EXTI_D1 */
905
906#if defined(DUAL_CORE)
911#define __HAL_RTC_ALARM_EXTID2_GET_FLAG() (EXTI_D2->PR1 & RTC_EXTI_LINE_ALARM_EVENT)
912
917#define __HAL_RTC_ALARM_EXTID2_CLEAR_FLAG() (EXTI_D2->PR1 = (RTC_EXTI_LINE_ALARM_EVENT))
918#endif /* DUAL_CORE */
923#define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() (EXTI->SWIER1 |= RTC_EXTI_LINE_ALARM_EVENT)
924
929/* Include RTC HAL Extended module */
930#include "stm32h7xx_hal_rtc_ex.h"
931
932/* Exported functions --------------------------------------------------------*/
942/* Initialization and de-initialization functions ****************************/
943HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc);
944HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc);
945
946void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc);
947void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc);
948
949/* Callbacks Register/UnRegister functions ***********************************/
950#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
951HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback);
952HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID);
953#endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
962/* RTC Time and Date functions ************************************************/
963HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
964HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
965HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
966HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
975/* RTC Alarm functions ********************************************************/
976HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
977HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
978HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm);
979HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format);
980void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc);
982HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
991/* Peripheral Control functions ***********************************************/
992HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc);
1001/* Peripheral State functions *************************************************/
1002HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc);
1011/* Private types -------------------------------------------------------------*/
1012/* Private variables ---------------------------------------------------------*/
1013/* Private constants ---------------------------------------------------------*/
1018/* Masks Definition */
1019#define RTC_TR_RESERVED_MASK (RTC_TR_PM | RTC_TR_HT | RTC_TR_HU | \
1020 RTC_TR_MNT | RTC_TR_MNU| RTC_TR_ST | \
1021 RTC_TR_SU)
1022
1023#define RTC_DR_RESERVED_MASK (RTC_DR_YT | RTC_DR_YU | RTC_DR_WDU | \
1024 RTC_DR_MT | RTC_DR_MU | RTC_DR_DT | \
1025 RTC_DR_DU)
1026
1027#define RTC_INIT_MASK 0xFFFFFFFFu
1028
1029#if defined(TAMP)
1030#define RTC_ICSR_RESERVED_MASK 0x000100FFu
1031#define RTC_RSF_MASK (~(RTC_ICSR_INIT | RTC_ICSR_RSF))
1032#else
1033#define RTC_ISR_RESERVED_MASK 0x0003FFFFu
1034#define RTC_RSF_MASK (~(RTC_ISR_INIT | RTC_ISR_RSF))
1035#endif /* TAMP */
1036
1037#define RTC_TIMEOUT_VALUE 1000u
1038
1039#define RTC_EXTI_LINE_ALARM_EVENT EXTI_IMR1_IM17
1045/* Private macros ------------------------------------------------------------*/
1056#if defined(TAMP)
1057#define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
1058 ((OUTPUT) == RTC_OUTPUT_ALARMA) || \
1059 ((OUTPUT) == RTC_OUTPUT_ALARMB) || \
1060 ((OUTPUT) == RTC_OUTPUT_WAKEUP) || \
1061 ((OUTPUT) == RTC_OUTPUT_TAMPER))
1062#else
1063#define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
1064 ((OUTPUT) == RTC_OUTPUT_ALARMA) || \
1065 ((OUTPUT) == RTC_OUTPUT_ALARMB) || \
1066 ((OUTPUT) == RTC_OUTPUT_WAKEUP))
1067#endif /* TAMP */
1068
1069#define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HOURFORMAT_12) || \
1070 ((FORMAT) == RTC_HOURFORMAT_24))
1071
1072#define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \
1073 ((POL) == RTC_OUTPUT_POLARITY_LOW))
1074
1075#define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \
1076 ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL))
1077
1078#if defined(TAMP)
1079#define IS_RTC_OUTPUT_PULLUP(TYPE) (((TYPE) == RTC_OUTPUT_PULLUP_NONE) || \
1080 ((TYPE) == RTC_OUTPUT_PULLUP_ON))
1081#endif /* TAMP */
1082
1083#define IS_RTC_OUTPUT_REMAP(REMAP) (((REMAP) == RTC_OUTPUT_REMAP_NONE) || \
1084 ((REMAP) == RTC_OUTPUT_REMAP_POS1))
1085
1086#define IS_RTC_HOURFORMAT12(PM) (((PM) == RTC_HOURFORMAT12_AM) || \
1087 ((PM) == RTC_HOURFORMAT12_PM))
1088
1089#define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \
1090 ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \
1091 ((SAVE) == RTC_DAYLIGHTSAVING_NONE))
1092
1093#define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \
1094 ((OPERATION) == RTC_STOREOPERATION_SET))
1095
1096#define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || \
1097 ((FORMAT) == RTC_FORMAT_BCD))
1098
1099#define IS_RTC_YEAR(YEAR) ((YEAR) <= 99u)
1100
1101#define IS_RTC_MONTH(MONTH) (((MONTH) >= 1u) && ((MONTH) <= 12u))
1102
1103#define IS_RTC_DATE(DATE) (((DATE) >= 1u) && ((DATE) <= 31u))
1104
1105#define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \
1106 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \
1107 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
1108 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \
1109 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \
1110 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \
1111 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
1112
1113#define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0u) && ((DATE) <= 31u))
1114
1115#define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \
1116 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \
1117 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
1118 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \
1119 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \
1120 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \
1121 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
1122
1123#define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \
1124 ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY))
1125
1126#define IS_RTC_ALARM_MASK(MASK) (((MASK) & ~(RTC_ALARMMASK_ALL)) == 0u)
1127
1128#define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_ALARM_A) || \
1129 ((ALARM) == RTC_ALARM_B))
1130
1131#define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= RTC_ALRMASSR_SS)
1132
1133#define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == 0u) || \
1134 (((MASK) >= RTC_ALARMSUBSECONDMASK_SS14_1) && ((MASK) <= RTC_ALARMSUBSECONDMASK_NONE)))
1135
1136#define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= (RTC_PRER_PREDIV_A >> RTC_PRER_PREDIV_A_Pos))
1137
1138#define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= (RTC_PRER_PREDIV_S >> RTC_PRER_PREDIV_S_Pos))
1139
1140#define IS_RTC_HOUR12(HOUR) (((HOUR) > 0u) && ((HOUR) <= 12u))
1141
1142#define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23u)
1143
1144#define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59u)
1145
1146#define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59u)
1147
1156/* Private functions -------------------------------------------------------------*/
1161HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef *hrtc);
1162HAL_StatusTypeDef RTC_ExitInitMode(RTC_HandleTypeDef *hrtc);
1163uint8_t RTC_ByteToBcd2(uint8_t Value);
1164uint8_t RTC_Bcd2ToByte(uint8_t Value);
1165
1178#ifdef __cplusplus
1179}
1180#endif
1181
1182#endif /* STM32H7xx_HAL_RTC_H */
1183
#define __IO
Definition: core_cm4.h:239
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
ALARM A Event Callback in non blocking mode.
Definition: stm32h7xx_hal_timebase_rtc_alarm_template.c:294
HAL_RTCStateTypeDef
HAL State structures definition.
Definition: stm32h7xx_hal_rtc.h:49
@ HAL_RTC_STATE_TIMEOUT
Definition: stm32h7xx_hal_rtc.h:53
@ HAL_RTC_STATE_ERROR
Definition: stm32h7xx_hal_rtc.h:54
@ HAL_RTC_STATE_READY
Definition: stm32h7xx_hal_rtc.h:51
@ HAL_RTC_STATE_BUSY
Definition: stm32h7xx_hal_rtc.h:52
@ HAL_RTC_STATE_RESET
Definition: stm32h7xx_hal_rtc.h:50
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32h7xx_hal_def.h:47
HAL_LockTypeDef
HAL Lock structures definition.
Definition: stm32h7xx_hal_def.h:58
Header file of RTC HAL Extension module.
RTC Alarm structure definition.
Definition: stm32h7xx_hal_rtc.h:148
uint8_t AlarmDateWeekDay
Definition: stm32h7xx_hal_rtc.h:160
RTC_TimeTypeDef AlarmTime
Definition: stm32h7xx_hal_rtc.h:149
uint32_t Alarm
Definition: stm32h7xx_hal_rtc.h:164
uint32_t AlarmDateWeekDaySel
Definition: stm32h7xx_hal_rtc.h:157
uint32_t AlarmMask
Definition: stm32h7xx_hal_rtc.h:151
uint32_t AlarmSubSecondMask
Definition: stm32h7xx_hal_rtc.h:154
RTC Date structure definition.
Definition: stm32h7xx_hal_rtc.h:129
uint8_t Year
Definition: stm32h7xx_hal_rtc.h:139
uint8_t Month
Definition: stm32h7xx_hal_rtc.h:133
uint8_t Date
Definition: stm32h7xx_hal_rtc.h:136
uint8_t WeekDay
Definition: stm32h7xx_hal_rtc.h:130
RTC Handle Structure definition.
Definition: stm32h7xx_hal_rtc.h:176
RTC_TypeDef * Instance
Definition: stm32h7xx_hal_rtc.h:177
RTC_InitTypeDef Init
Definition: stm32h7xx_hal_rtc.h:179
__IO HAL_RTCStateTypeDef State
Definition: stm32h7xx_hal_rtc.h:183
HAL_LockTypeDef Lock
Definition: stm32h7xx_hal_rtc.h:181
RTC Configuration Structure definition.
Definition: stm32h7xx_hal_rtc.h:62
uint32_t OutPutPolarity
Definition: stm32h7xx_hal_rtc.h:78
uint32_t OutPutType
Definition: stm32h7xx_hal_rtc.h:81
uint32_t OutPutRemap
Definition: stm32h7xx_hal_rtc.h:75
uint32_t AsynchPrediv
Definition: stm32h7xx_hal_rtc.h:66
uint32_t HourFormat
Definition: stm32h7xx_hal_rtc.h:63
uint32_t SynchPrediv
Definition: stm32h7xx_hal_rtc.h:69
uint32_t OutPut
Definition: stm32h7xx_hal_rtc.h:72
RTC Time structure definition.
Definition: stm32h7xx_hal_rtc.h:93
uint8_t Seconds
Definition: stm32h7xx_hal_rtc.h:101
uint8_t Minutes
Definition: stm32h7xx_hal_rtc.h:98
uint8_t TimeFormat
Definition: stm32h7xx_hal_rtc.h:104
uint32_t StoreOperation
Definition: stm32h7xx_hal_rtc.h:120
uint32_t SecondFraction
Definition: stm32h7xx_hal_rtc.h:111
uint32_t DayLightSaving
Definition: stm32h7xx_hal_rtc.h:117
uint32_t SubSeconds
Definition: stm32h7xx_hal_rtc.h:107
uint8_t Hours
Definition: stm32h7xx_hal_rtc.h:94
Real-Time Clock.
Definition: stm32h723xx.h:1307