REAL_TIME API_GetRTCC(void)
const DWORD RTCC_SumMonths[ 13 ] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }; //Normal Year REAL_TIME API_GetRTCC(void) { REAL_TIME mRtccSw; #if !defined(RTCC_SW_DISABLE) RTCC_STRUCT_TIME StrucTime; RTCC_STRUCT_DATE StrucDate; RTCC_GetTime( &StrucTime ); mRtccSw.Date = RTCC_TStampDateToSDate( StrucTime.Days ); #else RTCSYNC = 1; RTCPTR0 = 1; RTCPTR1 = 1; mRtccSw.Date.Year = RTCVALL; // read Year RTCPTR0 = 0; RTCPTR1 = 1; mRtccSw.Date.Day = RTCVALL; // read Day mRtccSw.Date.Month = RTCVALH; // read Month & decrement pointer RTCPTR0 = 1; RTCPTR1 = 0; mRtccSw.Time.Hour = RTCVALL; // read Hours mRtccSw.Date.DayOfWeek = RTCVALH; // read Weekday & decrement pointer RTCPTR0 = 0; RTCPTR1 = 0; mRtccSw.Time.Second = RTCVALL; // read Seconds mRtccSw.Time.Minute = RTCVALH; // read Minutes (pointer already at 0) mRtccSw.Time.Hour = (((mRtccSw.Time.Hour & 0x30) >> 4) * 10) + (mRtccSw.Time.Hour & 0x0F); mRtccSw.Time.Minute = (((mRtccSw.Time.Minute & 0x70) >> 4) * 10) + (mRtccSw.Time.Minute & 0x0F); mRtccSw.Time.Second = (((mRtccSw.Time.Second & 0x70) >> 4) * 10) + (mRtccSw.Time.Second & 0x0F); mRtccSw.Date.Year = (((mRtccSw.Date.Year & 0xF0) >> 4) * 10) + (mRtccSw.Date.Year & 0x0F); mRtccSw.Date.Month = (((mRtccSw.Date.Month & 0x10) >> 4) * 10) + (mRtccSw.Date.Month & 0x0F); mRtccSw.Date.Day = (((mRtccSw.Date.Day & 0x30) >> 4) * 10) + (mRtccSw.Date.Day & 0x0F); mRtccSw.Time.Days = ((DWORD)mRtccSw.Date.Year * 365UL) + (DWORD)(mRtccSw.Date.Year / 4) + RTCC_SumMonths[ mRtccSw.Date.Month - 1 ] + (DWORD)mRtccSw.Date.Day; if( (mRtccSw.Date.Month < 3) && !(mRtccSw.Date.Year % 4) ) mRtccSw.Time.Days--; if(RTCCFG&0x04) mRtccSw.Time.Thousandth = 500; else mRtccSw.Time.Thousandth = 0; #endif return mRtccSw; }