32#define RTC_INIT_KEY 0xA5EB1357UL
33#define RTC_WRITE_KEY 0x0000A965UL
38#define RTC_CLOCK_12 0UL
39#define RTC_CLOCK_24 1UL
46#define RTC_TICK_1_SEC 0x0UL
47#define RTC_TICK_1_2_SEC 0x1UL
48#define RTC_TICK_1_4_SEC 0x2UL
49#define RTC_TICK_1_8_SEC 0x3UL
50#define RTC_TICK_1_16_SEC 0x4UL
51#define RTC_TICK_1_32_SEC 0x5UL
52#define RTC_TICK_1_64_SEC 0x6UL
53#define RTC_TICK_1_128_SEC 0x7UL
58#define RTC_SUNDAY 0x0UL
59#define RTC_MONDAY 0x1UL
60#define RTC_TUESDAY 0x2UL
61#define RTC_WEDNESDAY 0x3UL
62#define RTC_THURSDAY 0x4UL
63#define RTC_FRIDAY 0x5UL
64#define RTC_SATURDAY 0x6UL
69#define RTC_WAIT_COUNT 0xFFFFFFFFUL
70#define RTC_YEAR2000 2000UL
71#define RTC_FCR_REFERENCE 32761UL
74#define RTC_TAMPER0_SELECT (0x1ul << 0)
75#define RTC_TAMPER1_SELECT (0x1ul << 1)
76#define RTC_TAMPER2_SELECT (0x1ul << 2)
77#define RTC_TAMPER3_SELECT (0x1ul << 3)
78#define RTC_TAMPER4_SELECT (0x1ul << 4)
79#define RTC_TAMPER5_SELECT (0x1ul << 5)
80#define MAX_TAMPER_PIN_NUM 6ul
82#define RTC_TAMPER_HIGH_LEVEL_DETECT 1ul
83#define RTC_TAMPER_LOW_LEVEL_DETECT 0ul
85#define RTC_TAMPER_DEBOUNCE_ENABLE 1ul
86#define RTC_TAMPER_DEBOUNCE_DISABLE 0ul
88#define RTC_PAIR0_SELECT (0x1ul << 0)
89#define RTC_PAIR1_SELECT (0x1ul << 1)
90#define RTC_PAIR2_SELECT (0x1ul << 2)
91#define MAX_PAIR_NUM 3ul
93#define RTC_2POW10_CLK (0x0 << RTC_TAMPCTL_DYNRATE_Pos)
94#define RTC_2POW11_CLK (0x1 << RTC_TAMPCTL_DYNRATE_Pos)
95#define RTC_2POW12_CLK (0x2 << RTC_TAMPCTL_DYNRATE_Pos)
96#define RTC_2POW13_CLK (0x3 << RTC_TAMPCTL_DYNRATE_Pos)
97#define RTC_2POW14_CLK (0x4 << RTC_TAMPCTL_DYNRATE_Pos)
98#define RTC_2POW15_CLK (0x5 << RTC_TAMPCTL_DYNRATE_Pos)
99#define RTC_2POW16_CLK (0x6 << RTC_TAMPCTL_DYNRATE_Pos)
100#define RTC_2POW17_CLK (0x7 << RTC_TAMPCTL_DYNRATE_Pos)
102#define REF_RANDOM_PATTERN 0x0
103#define REF_PREVIOUS_PATTERN 0x1
146#define RTC_IS_LEAP_YEAR() (RTC->LEAPYEAR & RTC_LEAPYEAR_LEAPYEAR_Msk ? 1:0)
158#define RTC_CLEAR_ALARM_INT_FLAG() (RTC->INTSTS = RTC_INTSTS_ALMIF_Msk)
170#define RTC_CLEAR_TICK_INT_FLAG() (RTC->INTSTS = RTC_INTSTS_TICKIF_Msk)
188#define RTC_CLEAR_TAMPER_INT_FLAG(u32TamperFlag) (RTC->INTSTS = (u32TamperFlag))
201#define RTC_GET_ALARM_INT_FLAG() ((RTC->INTSTS & RTC_INTSTS_ALMIF_Msk)? 1:0)
214#define RTC_GET_TICK_INT_FLAG() ((RTC->INTSTS & RTC_INTSTS_TICKIF_Msk)? 1:0)
227#define RTC_GET_TAMPER_INT_FLAG() ((RTC->INTSTS & (0x3F00))? 1:0)
244#define RTC_GET_TAMPER_INT_STATUS() ((RTC->INTSTS & (0x3F00)))
258#define RTC_READ_SPARE_REGISTER(u32RegNum) (RTC->SPR[(u32RegNum)])
273#define RTC_WRITE_SPARE_REGISTER(u32RegNum, u32RegValue) (RTC->SPR[(u32RegNum)] = (u32RegValue))
295 if(i > u32TimeOutCount)
break;
298 if(!(
SYS->CSERVER & 0x1))
308 if(i > u32TimeOutCount)
break;
319void RTC_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek);
320void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm);
322void RTC_SetAlarmTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm);
323void RTC_SetAlarmDateMask(uint8_t u8IsTenYMsk, uint8_t u8IsYMsk, uint8_t u8IsTenMMsk, uint8_t u8IsMMsk, uint8_t u8IsTenDMsk, uint8_t u8IsDMsk);
324void RTC_SetAlarmTimeMask(uint8_t u8IsTenHMsk, uint8_t u8IsHMsk, uint8_t u8IsTenMMsk, uint8_t u8IsMMsk, uint8_t u8IsTenSMsk, uint8_t u8IsSMsk);
333void RTC_DynamicTamperEnable(uint32_t u32PairSel, uint32_t u32DebounceEn, uint32_t u32Pair1Source, uint32_t u32Pair2Source);
335void RTC_DynamicTamperConfig(uint32_t u32ChangeRate, uint32_t u32SeedReload, uint32_t u32RefPattern, uint32_t u32Seed);
#define RTC_RWEN_RTCBUSY_Msk
#define RTC_RWEN_RWENF_Msk
void RTC_EnableInt(uint32_t u32IntFlagMask)
Enable RTC Interrupt.
void RTC_32KCalibration(int32_t i32FrequencyX10000)
Set Frequency Compensation Data.
void RTC_DynamicTamperEnable(uint32_t u32PairSel, uint32_t u32DebounceEn, uint32_t u32Pair1Source, uint32_t u32Pair2Source)
Dynamic Tamper Detect.
uint32_t RTC_GetDayOfWeek(void)
Get Day of the Week.
void RTC_SetDateAndTime(S_RTC_TIME_DATA_T *sPt)
Update Current RTC Date and Time.
void RTC_StaticTamperDisable(uint32_t u32TamperSelect)
Static Tamper Disable.
void RTC_DynamicTamperDisable(uint32_t u32PairSel)
Dynamic Tamper Disable.
void RTC_SetAlarmTimeMask(uint8_t u8IsTenHMsk, uint8_t u8IsHMsk, uint8_t u8IsTenMMsk, uint8_t u8IsMMsk, uint8_t u8IsTenSMsk, uint8_t u8IsSMsk)
Set RTC Alarm Time Mask Function.
void RTC_GetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt)
Get RTC Alarm Date and Time.
void RTC_SetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt)
Update RTC Alarm Date and Time.
void RTC_EnableSpareAccess(void)
Enable Spare Registers Access.
int32_t RTC_Open(S_RTC_TIME_DATA_T *sPt)
Initialize RTC module and start counting.
void RTC_StaticTamperEnable(uint32_t u32TamperSelect, uint32_t u32DetecLevel, uint32_t u32DebounceEn)
Static Tamper Detect.
void RTC_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek)
Update RTC Current Date.
void RTC_SetAlarmDateMask(uint8_t u8IsTenYMsk, uint8_t u8IsYMsk, uint8_t u8IsTenMMsk, uint8_t u8IsMMsk, uint8_t u8IsTenDMsk, uint8_t u8IsDMsk)
Set RTC Alarm Date Mask Function.
void RTC_Close(void)
Disable RTC Clock.
__STATIC_INLINE void RTC_WaitAccessEnable(void)
Wait RTC Access Enable.
void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
Update RTC Current Time.
void RTC_DynamicTamperConfig(uint32_t u32ChangeRate, uint32_t u32SeedReload, uint32_t u32RefPattern, uint32_t u32Seed)
Config dynamic tamper.
void RTC_SetAlarmTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
Update RTC Alarm Time.
void RTC_DisableInt(uint32_t u32IntFlagMask)
Disable RTC Interrupt.
void RTC_DisableSpareRegister(void)
Disable Spare Register.
void RTC_SetTickPeriod(uint32_t u32TickSelection)
Set RTC Tick Period Time.
void RTC_SetAlarmDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day)
Update RTC Alarm Date.
void RTC_GetDateAndTime(S_RTC_TIME_DATA_T *sPt)
Get Current RTC Date and Time.