25static volatile uint32_t g_u32hiYear, g_u32loYear, g_u32hiMonth, g_u32loMonth, g_u32hiDay, g_u32loDay;
26static volatile uint32_t g_u32hiHour, g_u32loHour, g_u32hiMin, g_u32loMin, g_u32hiSec, g_u32loSec;
81 if(u32TimeOutCount == 0)
return -1;
96 if(u32TimeOutCount == 0)
return -1;
114 CLK->APBCLK0 &= ~CLK_APBCLK0_RTCCKEN_Msk;
128 int32_t i32RegInt, i32RegFra;
132 i32RegFra = (((i32FrequencyX100 % 100)) * 60) / 100;
135 if((i32RegInt < 0) | (i32RegInt > 15))
141 RTC->FREQADJ = (uint32_t)((i32RegInt << 8) | i32RegFra);
186 u32Tmp = (g_u32hiYear * 10);
187 u32Tmp += g_u32loYear;
191 u32Tmp = (g_u32hiMonth * 10);
192 sPt->
u32Month = u32Tmp + g_u32loMonth;
195 u32Tmp = (g_u32hiDay * 10);
196 sPt->
u32Day = u32Tmp + g_u32loDay;
201 u32Tmp = (g_u32hiHour * 10);
202 u32Tmp += g_u32loHour;
215 u32Tmp = (g_u32hiMin * 10);
216 u32Tmp += g_u32loMin;
219 u32Tmp = (g_u32hiSec * 10);
220 u32Tmp += g_u32loSec;
225 u32Tmp = (g_u32hiHour * 10);
226 u32Tmp += g_u32loHour;
229 u32Tmp = (g_u32hiMin * 10);
230 u32Tmp += g_u32loMin;
233 u32Tmp = (g_u32hiSec * 10);
234 u32Tmp += g_u32loSec;
283 u32Tmp = (g_u32hiYear * 10);
284 u32Tmp += g_u32loYear;
288 u32Tmp = (g_u32hiMonth * 10);
289 sPt->
u32Month = u32Tmp + g_u32loMonth;
292 u32Tmp = (g_u32hiDay * 10);
293 sPt->
u32Day = u32Tmp + g_u32loDay;
298 u32Tmp = (g_u32hiHour * 10);
299 u32Tmp += g_u32loHour;
312 u32Tmp = (g_u32hiMin * 10);
313 u32Tmp += g_u32loMin;
316 u32Tmp = (g_u32hiSec * 10);
317 u32Tmp += g_u32loSec;
323 u32Tmp = (g_u32hiHour * 10);
324 u32Tmp += g_u32loHour;
327 u32Tmp = (g_u32hiMin * 10);
328 u32Tmp += g_u32loMin;
331 u32Tmp = (g_u32hiSec * 10);
332 u32Tmp += g_u32loSec;
359 uint32_t u32RegCAL, u32RegTIME;
370 RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
391 u32RegCAL |= ((sPt->
u32Month / 10) << 12);
392 u32RegCAL |= ((sPt->
u32Month % 10) << 8);
393 u32RegCAL |= ((sPt->
u32Day / 10) << 4);
394 u32RegCAL |= (sPt->
u32Day % 10);
396 u32RegTIME = ((sPt->
u32Hour / 10) << 20);
397 u32RegTIME |= ((sPt->
u32Hour % 10) << 16);
398 u32RegTIME |= ((sPt->
u32Minute / 10) << 12);
399 u32RegTIME |= ((sPt->
u32Minute % 10) << 8);
400 u32RegTIME |= ((sPt->
u32Second / 10) << 4);
407 RTC->CAL = (uint32_t)u32RegCAL;
408 RTC->TIME = (uint32_t)u32RegTIME;
433 uint32_t u32RegCALM, u32RegTALM;
444 RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
465 u32RegCALM |= ((sPt->
u32Month / 10) << 12);
466 u32RegCALM |= ((sPt->
u32Month % 10) << 8);
467 u32RegCALM |= ((sPt->
u32Day / 10) << 4);
468 u32RegCALM |= (sPt->
u32Day % 10);
470 u32RegTALM = ((sPt->
u32Hour / 10) << 20);
471 u32RegTALM |= ((sPt->
u32Hour % 10) << 16);
472 u32RegTALM |= ((sPt->
u32Minute / 10) << 12);
473 u32RegTALM |= ((sPt->
u32Minute % 10) << 8);
474 u32RegTALM |= ((sPt->
u32Second / 10) << 4);
478 RTC->CALM = (uint32_t)u32RegCALM;
479 RTC->TALM = (uint32_t)u32RegTALM;
496void RTC_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek)
502 u32RegCAL |= ((u32Month / 10) << 12);
503 u32RegCAL |= ((u32Month % 10) << 8);
504 u32RegCAL |= ((u32Day / 10) << 4);
505 u32RegCAL |= (u32Day % 10);
513 RTC->CAL = (uint32_t)u32RegCAL;
529void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
537 u32RegTIME = ((u32Hour / 10) << 20);
538 u32RegTIME |= ((u32Hour % 10) << 16);
539 u32RegTIME |= ((u32Minute / 10) << 12);
540 u32RegTIME |= ((u32Minute % 10) << 8);
541 u32RegTIME |= ((u32Second / 10) << 4);
542 u32RegTIME |= (u32Second % 10);
550 RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
557 RTC->TIME = (uint32_t)u32RegTIME;
577 u32RegCALM |= ((u32Month / 10) << 12);
578 u32RegCALM |= ((u32Month % 10) << 8);
579 u32RegCALM |= ((u32Day / 10) << 4);
580 u32RegCALM |= (u32Day % 10);
585 RTC->CALM = (uint32_t)u32RegCALM;
601void RTC_SetAlarmTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
609 u32RegTALM = ((u32Hour / 10) << 20);
610 u32RegTALM |= ((u32Hour % 10) << 16);
611 u32RegTALM |= ((u32Minute / 10) << 12);
612 u32RegTALM |= ((u32Minute % 10) << 8);
613 u32RegTALM |= ((u32Second / 10) << 4);
614 u32RegTALM |= (u32Second % 10);
622 RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
630 RTC->TALM = (uint32_t)u32RegTALM;
675 RTC->TICK = (
RTC->TICK & ~RTC_TICK_TICK_Msk) | u32TickSelection;
692 RTC->INTEN |= u32IntFlagMask;
711 RTC->INTEN &= ~RTC_INTEN_ALMIEN_Msk;
717 RTC->INTEN &= ~RTC_INTEN_TICKIEN_Msk;
723 RTC->INTEN &= ~RTC_INTEN_SNPDIEN_Msk;
746 if(u32TimeOutCount == 0)
return;
764 RTC->SPRCTL &= ~RTC_SPRCTL_SPRRWEN_Msk;
800 RTC->SPRCTL &= ~RTC_SPRCTL_SNPDEN_Msk;
#define RTC_INTEN_TICKIEN_Msk
#define RTC_CAL_TENDAY_Msk
#define RTC_CAL_TENYEAR_Msk
#define RTC_SPRCTL_SPRRWRDY_Msk
#define RTC_SPRCTL_SNPDEN_Msk
#define RTC_INTSTS_SNPDIF_Msk
#define RTC_TIME_TENSEC_Msk
#define RTC_TALM_TENMIN_Pos
#define RTC_INTSTS_ALMIF_Msk
#define RTC_TIME_TENSEC_Pos
#define RTC_SPRCTL_SPRRWEN_Msk
#define RTC_TALM_TENSEC_Pos
#define RTC_TALM_TENMIN_Msk
#define RTC_CALM_TENYEAR_Msk
#define RTC_TIME_TENHR_Pos
#define RTC_CALM_YEAR_Pos
#define RTC_INTEN_ALMIEN_Msk
#define RTC_CAL_TENMON_Pos
#define RTC_CALM_TENDAY_Pos
#define RTC_CLKFMT_24HEN_Msk
#define RTC_CALM_TENMON_Pos
#define RTC_CAL_TENMON_Msk
#define RTC_INTSTS_TICKIF_Msk
#define RTC_CAL_TENYEAR_Pos
#define RTC_TIME_TENMIN_Msk
#define RTC_TALM_TENSEC_Msk
#define RTC_CAL_TENDAY_Pos
#define RTC_WEEKDAY_WEEKDAY_Msk
#define RTC_INTEN_SNPDIEN_Msk
#define RTC_CALM_TENMON_Msk
#define RTC_TIME_TENMIN_Pos
#define RTC_INIT_ACTIVE_Msk
#define RTC_TALM_TENHR_Pos
#define RTC_CALM_TENDAY_Msk
#define RTC_CALM_YEAR_Msk
#define RTC_TIME_TENHR_Msk
#define RTC_TALM_TENHR_Msk
#define RTC_RWEN_RWENF_Msk
#define RTC_CALM_TENYEAR_Pos
#define RTC_FCR_REFERENCE
void RTC_EnableInt(uint32_t u32IntFlagMask)
Enable RTC Interrupt.
void RTC_DisableSnooperDetection(void)
Disable Snooper Pin 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_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_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek)
Update RTC Current Date.
void RTC_Close(void)
Disable RTC Clock.
void RTC_32KCalibration(int32_t i32FrequencyX100)
Set 32k Frequency Compensation Data.
void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
Update RTC Current Time.
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.
static __INLINE void RTC_WaitAccessEnable(void)
Wait RTC Access Enable.
void RTC_DisableSpareRegister(void)
Disable Spare Register.
void RTC_SetTickPeriod(uint32_t u32TickSelection)
Set RTC Tick Period Time.
void RTC_EnableSnooperDetection(uint32_t u32PinCondition)
Enable Snooper Pin Detect.
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.