40static volatile uint32_t g_u32Reg, g_u32Reg1,g_u32hiYear,g_u32loYear,g_u32hiMonth,g_u32loMonth,g_u32hiDay,g_u32loDay;
41static volatile uint32_t g_u32hiHour,g_u32loHour,g_u32hiMin,g_u32loMin,g_u32hiSec,g_u32loSec;
53void RTC_WaitAccessEnable(
void)
62 if(i > u32TimeOutCount)
break;
83 int32_t i32RegInt,i32RegFra ;
87 i32RegFra = (((i32FrequencyX100%100)) * 60) / 100;
90 if ( (i32RegInt < 0) | (i32RegInt > 15) )
95 RTC_WaitAccessEnable();
97 RTC->FREQADJ = (uint32_t)((i32RegInt<<8) | i32RegFra);
129 volatile int32_t i32delay=1000;
135 while(
RTC->INIT != 0x1)
137 if(u32TimeOutCount == 0)
154 RTC_WaitAccessEnable();
155 RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
165 RTC_WaitAccessEnable();
174 u32Reg |= ((sPt->
u32Month / 10) << 12);
175 u32Reg |= ((sPt->
u32Month % 10) << 8);
176 u32Reg |= ((sPt->
u32Day / 10) << 4);
177 u32Reg |= (sPt->
u32Day % 10);
180 RTC_WaitAccessEnable();
182 RTC->CAL = (uint32_t)g_u32Reg;
187 u32Reg = ((sPt->
u32Hour / 10) << 20);
188 u32Reg |= ((sPt->
u32Hour % 10) << 16);
195 RTC_WaitAccessEnable();
197 RTC->TIME = (uint32_t)g_u32Reg;
245 u32Tmp = (g_u32hiYear * 10);
246 u32Tmp += g_u32loYear;
249 u32Tmp = (g_u32hiMonth * 10);
250 sPt->
u32Month = u32Tmp + g_u32loMonth;
252 u32Tmp = (g_u32hiDay * 10);
253 sPt->
u32Day = u32Tmp + g_u32loDay;
257 u32Tmp = (g_u32hiHour * 10);
258 u32Tmp+= g_u32loHour;
271 u32Tmp = (g_u32hiMin * 10);
275 u32Tmp = (g_u32hiSec * 10);
283 u32Tmp = (g_u32hiHour * 10);
284 u32Tmp += g_u32loHour;
287 u32Tmp = (g_u32hiMin * 10);
288 u32Tmp += g_u32loMin;
291 u32Tmp = (g_u32hiSec * 10);
292 u32Tmp += g_u32loSec;
325 RTC_WaitAccessEnable();
334 RTC_WaitAccessEnable();
343 u32Tmp = (g_u32hiYear * 10);
344 u32Tmp += g_u32loYear;
347 u32Tmp = (g_u32hiMonth * 10);
348 sPt->
u32Month = u32Tmp + g_u32loMonth;
350 u32Tmp = (g_u32hiDay * 10);
351 sPt->
u32Day = u32Tmp + g_u32loDay;
355 u32Tmp = (g_u32hiHour * 10);
356 u32Tmp += g_u32loHour;
369 u32Tmp = (g_u32hiMin * 10);
370 u32Tmp += g_u32loMin;
373 u32Tmp = (g_u32hiSec * 10);
374 u32Tmp += g_u32loSec;
381 u32Tmp = (g_u32hiHour * 10);
382 u32Tmp += g_u32loHour;
385 u32Tmp = (g_u32hiMin * 10);
389 u32Tmp = (g_u32hiSec * 10);
390 u32Tmp += g_u32loSec;
424 RTC_WaitAccessEnable();
428 RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
445 u32Reg |= ((sPt->
u32Month / 10) << 12);
446 u32Reg |= ((sPt->
u32Month % 10) << 8);
447 u32Reg |= ((sPt->
u32Day / 10) << 4);
448 u32Reg |= (sPt->
u32Day % 10);
451 RTC_WaitAccessEnable();
453 RTC->CAL = (uint32_t)g_u32Reg;
455 u32Reg = ((sPt->
u32Hour / 10) << 20);
456 u32Reg |= ((sPt->
u32Hour % 10) << 16);
463 RTC_WaitAccessEnable();
465 RTC->TIME = (uint32_t)g_u32Reg;
493 RTC_WaitAccessEnable();
497 RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
515 u32Reg |= ((sPt->
u32Month / 10) << 12);
516 u32Reg |= ((sPt->
u32Month % 10) << 8);
517 u32Reg |= ((sPt->
u32Day / 10) << 4);
518 u32Reg |= (sPt->
u32Day % 10);
521 RTC_WaitAccessEnable();
523 RTC->CALM = (uint32_t)g_u32Reg;
525 u32Reg = ((sPt->
u32Hour / 10) << 20);
526 u32Reg |= ((sPt->
u32Hour % 10) << 16);
533 RTC_WaitAccessEnable();
535 RTC->TALM = (uint32_t)g_u32Reg;
553void RTC_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek)
555 __IO uint32_t u32Reg;
557 RTC_WaitAccessEnable();
563 u32Reg |= ((u32Month / 10) << 12);
564 u32Reg |= ((u32Month % 10) << 8);
565 u32Reg |= ((u32Day / 10) << 4);
566 u32Reg |= (u32Day % 10);
569 RTC_WaitAccessEnable();
571 RTC->CAL = (uint32_t)g_u32Reg;
587void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
589 __IO uint32_t u32Reg;
591 RTC_WaitAccessEnable();
595 RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
605 u32Reg = ((u32Hour / 10) << 20);
606 u32Reg |= ((u32Hour % 10) << 16);
607 u32Reg |= ((u32Minute / 10) << 12);
608 u32Reg |= ((u32Minute % 10) << 8);
609 u32Reg |= ((u32Second / 10) << 4);
610 u32Reg |= (u32Second % 10);
614 RTC_WaitAccessEnable();
616 RTC->TIME = (uint32_t)g_u32Reg;
632 __IO uint32_t u32Reg;
634 RTC_WaitAccessEnable();
638 u32Reg |= ((u32Month / 10) << 12);
639 u32Reg |= ((u32Month % 10) << 8);
640 u32Reg |= ((u32Day / 10) << 4);
641 u32Reg |= (u32Day % 10);
644 RTC_WaitAccessEnable();
646 RTC->CALM = (uint32_t)g_u32Reg;
662void RTC_SetAlarmTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
664 __IO uint32_t u32Reg;
666 RTC_WaitAccessEnable();
670 RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
680 u32Reg = ((u32Hour / 10) << 20);
681 u32Reg |= ((u32Hour % 10) << 16);
682 u32Reg |= ((u32Minute / 10) << 12);
683 u32Reg |= ((u32Minute % 10) << 8);
684 u32Reg |= ((u32Second / 10) << 4);
685 u32Reg |= (u32Second % 10);
689 RTC_WaitAccessEnable();
691 RTC->TALM = (uint32_t)g_u32Reg;
707 RTC_WaitAccessEnable();
713 if(u32TimeOutCount == 0)
741void RTC_EnableTamperDetection(uint32_t u32PinNumber, uint32_t u32PinCondition, uint32_t u32IntFlag, uint32_t u32ClearFlag, uint32_t u32DestroyEn)
745 RTC_WaitAccessEnable();
747 u32Tmp =
RTC->TAMPCTL;
757 u32Tmp &= ~RTC_TAMPCTL_TAMPLV0_Msk;
770 u32Tmp &= ~RTC_TAMPCTL_TAMPLV1_Msk;
779 u32Tmp &= ~RTC_TAMPCTL_TIEN_Msk;
784 u32Tmp &= ~RTC_TAMPCTL_DESTROYEN_Msk;
786 RTC_WaitAccessEnable();
788 RTC->TAMPCTL = u32Tmp;
790 RTC_WaitAccessEnable();
814 RTC_WaitAccessEnable();
818 RTC->TAMPCTL &= ~RTC_TAMPCTL_TAMPEN0_Msk;
822 RTC->TAMPCTL &= ~RTC_TAMPCTL_TAMPEN1_Msk;
860 RTC_WaitAccessEnable();
862 RTC->TICK =
RTC->TICK & ~RTC_TICK_TICKSEL_Msk | u32TickSelection;
877 RTC_WaitAccessEnable();
879 RTC->INTEN |= u32IntFlagMask;
894 RTC_WaitAccessEnable();
898 RTC->INTEN &= ~RTC_INTEN_TICKIEN_Msk;
904 RTC->INTEN &= ~RTC_INTEN_ALMIEN_Msk;
918 CLK->APBCLK0 &= ~CLK_APBCLK0_RTCCKEN_Msk;
NUC472/NUC442 peripheral access layer header file. This file contains all the peripheral register's d...
#define RTC_INTEN_TICKIEN_Msk
#define RTC_TAMPCTL_TAMPEN1_Msk
#define RTC_CAL_TENDAY_Msk
#define RTC_CAL_TENYEAR_Msk
#define RTC_SPRCTL_SPRRWRDY_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_TAMPCTL_TAMPDBEN1_Msk
#define RTC_TALM_TENSEC_Pos
#define RTC_TALM_TENMIN_Msk
#define RTC_CALM_TENYEAR_Msk
#define RTC_TIME_TENHR_Pos
#define RTC_TAMPCTL_TAMPLV0_Msk
#define RTC_CALM_YEAR_Pos
#define RTC_TAMPCTL_TAMPLV1_Msk
#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_TAMPCTL_TAMPEN0_Msk
#define RTC_TALM_TENSEC_Msk
#define RTC_TAMPCTL_TAMPDBEN0_Msk
#define RTC_CAL_TENDAY_Pos
#define RTC_WEEKDAY_WEEKDAY_Msk
#define RTC_CALM_TENMON_Msk
#define RTC_TIME_TENMIN_Pos
#define RTC_TAMPSTS_TAMPSTS1_Msk
#define RTC_TAMPCTL_DESTROYEN_Msk
#define RTC_TALM_TENHR_Pos
#define RTC_CALM_TENDAY_Msk
#define RTC_TAMPSTS_TAMPSTS0_Msk
#define RTC_CALM_YEAR_Msk
#define RTC_TIME_TENHR_Msk
#define RTC_TAMPCTL_TIEN_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)
The function is used to enable specified interrupt.
uint32_t RTC_GetDayOfWeek(void)
This function is used to get day of week.
void RTC_SetDateAndTime(S_RTC_TIME_DATA_T *sPt)
This function is used to update date/time to RTC.
void RTC_EnableTamperDetection(uint32_t u32PinNumber, uint32_t u32PinCondition, uint32_t u32IntFlag, uint32_t u32ClearFlag, uint32_t u32DestroyEn)
This function is used to:
void RTC_GetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt)
Read alarm date/time from RTC setting.
void RTC_Open(S_RTC_TIME_DATA_T *sPt)
This function is used to:
void RTC_SetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt)
This function is used to set alarm date/time to RTC.
void RTC_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek)
This function is used to update date to RTC.
void RTC_DisableTamperDetection(uint32_t u32PinNumber)
This function is used to disable tamper detection function.
void RTC_Close(void)
Disable RTC clock.
void RTC_32KCalibration(int32_t i32FrequencyX100)
Set Frequency Compensation Data.
void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
This function is used to update time to RTC.
void RTC_SetAlarmTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
This function is used to set alarm date to RTC.
void RTC_DisableInt(uint32_t u32IntFlagMask)
The function is used to disable specified interrupt.
void RTC_SetTickPeriod(uint32_t u32TickSelection)
The function is used to set time tick period for periodic time tick Interrupt.
int32_t RTC_EnableSpareAccess(void)
The spare registers access enable.
void RTC_SetAlarmDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day)
This function is used to set alarm date to RTC.
void RTC_GetDateAndTime(S_RTC_TIME_DATA_T *sPt)
Read current date/time from RTC setting.
#define NULL
NULL pointer.
RTC define Time Data Struct.