21static volatile uint32_t g_u32hiYear, g_u32loYear, g_u32hiMonth, g_u32loMonth, g_u32hiDay, g_u32loDay;
22static volatile uint32_t g_u32hiHour, g_u32loHour, g_u32hiMin, g_u32loMin, g_u32hiSec, g_u32loSec;
77 if(u32TimeOutCount == 0)
return -1;
92 if(u32TimeOutCount == 0)
109 CLK->APBCLK0 &= ~CLK_APBCLK0_RTCCKEN_Msk;
123 int32_t i32RegInt, i32RegFra;
127 i32RegFra = (((i32FrequencyX100 % 100)) * 60) / 100;
130 if((i32RegInt < 0) | (i32RegInt > 15))
136 RTC->FREQADJ = (uint32_t)((i32RegInt << 8) | i32RegFra);
181 u32Tmp = (g_u32hiYear * 10);
182 u32Tmp += g_u32loYear;
186 u32Tmp = (g_u32hiMonth * 10);
187 sPt->
u32Month = u32Tmp + g_u32loMonth;
190 u32Tmp = (g_u32hiDay * 10);
191 sPt->
u32Day = u32Tmp + g_u32loDay;
196 u32Tmp = (g_u32hiHour * 10);
197 u32Tmp += g_u32loHour;
210 u32Tmp = (g_u32hiMin * 10);
211 u32Tmp += g_u32loMin;
214 u32Tmp = (g_u32hiSec * 10);
215 u32Tmp += g_u32loSec;
220 u32Tmp = (g_u32hiHour * 10);
221 u32Tmp += g_u32loHour;
224 u32Tmp = (g_u32hiMin * 10);
225 u32Tmp += g_u32loMin;
228 u32Tmp = (g_u32hiSec * 10);
229 u32Tmp += g_u32loSec;
278 u32Tmp = (g_u32hiYear * 10);
279 u32Tmp += g_u32loYear;
283 u32Tmp = (g_u32hiMonth * 10);
284 sPt->
u32Month = u32Tmp + g_u32loMonth;
287 u32Tmp = (g_u32hiDay * 10);
288 sPt->
u32Day = u32Tmp + g_u32loDay;
293 u32Tmp = (g_u32hiHour * 10);
294 u32Tmp += g_u32loHour;
307 u32Tmp = (g_u32hiMin * 10);
308 u32Tmp += g_u32loMin;
311 u32Tmp = (g_u32hiSec * 10);
312 u32Tmp += g_u32loSec;
318 u32Tmp = (g_u32hiHour * 10);
319 u32Tmp += g_u32loHour;
322 u32Tmp = (g_u32hiMin * 10);
323 u32Tmp += g_u32loMin;
326 u32Tmp = (g_u32hiSec * 10);
327 u32Tmp += g_u32loSec;
354 uint32_t u32RegCAL, u32RegTIME;
365 RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
386 u32RegCAL |= ((sPt->
u32Month / 10) << 12);
387 u32RegCAL |= ((sPt->
u32Month % 10) << 8);
388 u32RegCAL |= ((sPt->
u32Day / 10) << 4);
389 u32RegCAL |= (sPt->
u32Day % 10);
391 u32RegTIME = ((sPt->
u32Hour / 10) << 20);
392 u32RegTIME |= ((sPt->
u32Hour % 10) << 16);
393 u32RegTIME |= ((sPt->
u32Minute / 10) << 12);
394 u32RegTIME |= ((sPt->
u32Minute % 10) << 8);
395 u32RegTIME |= ((sPt->
u32Second / 10) << 4);
402 RTC->CAL = (uint32_t)u32RegCAL;
403 RTC->TIME = (uint32_t)u32RegTIME;
428 uint32_t u32RegCALM, u32RegTALM;
439 RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
460 u32RegCALM |= ((sPt->
u32Month / 10) << 12);
461 u32RegCALM |= ((sPt->
u32Month % 10) << 8);
462 u32RegCALM |= ((sPt->
u32Day / 10) << 4);
463 u32RegCALM |= (sPt->
u32Day % 10);
465 u32RegTALM = ((sPt->
u32Hour / 10) << 20);
466 u32RegTALM |= ((sPt->
u32Hour % 10) << 16);
467 u32RegTALM |= ((sPt->
u32Minute / 10) << 12);
468 u32RegTALM |= ((sPt->
u32Minute % 10) << 8);
469 u32RegTALM |= ((sPt->
u32Second / 10) << 4);
473 RTC->CALM = (uint32_t)u32RegCALM;
474 RTC->TALM = (uint32_t)u32RegTALM;
491void RTC_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek)
497 u32RegCAL |= ((u32Month / 10) << 12);
498 u32RegCAL |= ((u32Month % 10) << 8);
499 u32RegCAL |= ((u32Day / 10) << 4);
500 u32RegCAL |= (u32Day % 10);
508 RTC->CAL = (uint32_t)u32RegCAL;
524void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
532 u32RegTIME = ((u32Hour / 10) << 20);
533 u32RegTIME |= ((u32Hour % 10) << 16);
534 u32RegTIME |= ((u32Minute / 10) << 12);
535 u32RegTIME |= ((u32Minute % 10) << 8);
536 u32RegTIME |= ((u32Second / 10) << 4);
537 u32RegTIME |= (u32Second % 10);
545 RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
552 RTC->TIME = (uint32_t)u32RegTIME;
572 u32RegCALM |= ((u32Month / 10) << 12);
573 u32RegCALM |= ((u32Month % 10) << 8);
574 u32RegCALM |= ((u32Day / 10) << 4);
575 u32RegCALM |= (u32Day % 10);
580 RTC->CALM = (uint32_t)u32RegCALM;
596void RTC_SetAlarmTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
604 u32RegTALM = ((u32Hour / 10) << 20);
605 u32RegTALM |= ((u32Hour % 10) << 16);
606 u32RegTALM |= ((u32Minute / 10) << 12);
607 u32RegTALM |= ((u32Minute % 10) << 8);
608 u32RegTALM |= ((u32Second / 10) << 4);
609 u32RegTALM |= (u32Second % 10);
617 RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
625 RTC->TALM = (uint32_t)u32RegTALM;
670 RTC->TICK = (
RTC->TICK & ~RTC_TICK_TICK_Msk) | u32TickSelection;
687 RTC->INTEN |= u32IntFlagMask;
706 RTC->INTEN &= ~RTC_INTEN_ALMIEN_Msk;
712 RTC->INTEN &= ~RTC_INTEN_TICKIEN_Msk;
718 RTC->INTEN &= ~RTC_INTEN_SNPDIEN_Msk;
754 RTC->SPRCTL &= ~RTC_SPRCTL_SPRRWEN_Msk;
790 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
NuMicro peripheral access layer header file.
#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.
static __INLINE int32_t RTC_WaitAccessEnable(void)
Wait RTC Access Enable.
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.
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.