void qdrtcGetCmosTime() { t_float64 total = (vramVarDWord(0x0000, QDRTC_VBIOS_ADDR_RTC_DAILY_COUNTER) * QDRTC_TICK) / 1000; t_nubit8 hour = (t_nubit8)(total / 3600); t_nubit8 min = (t_nubit8)((total - hour * 3600) / 60); t_nubit8 sec = (t_nubit8)(total - hour * 3600 - min * 60); _ch = Hex2BCD(hour); _cl = Hex2BCD(min); _dh = Hex2BCD(sec); _dl = 0x00; ClrCF; }
void qdrtcGetCmosDate() { struct tm *t = gmtime(&qdrtc.start); if (t->tm_year >= 100) { /* tm_year starts from 1900 */ _ch = 0x20; /* century: 20 (BCD) */ _cl = Hex2BCD(t->tm_year - 100); } else { _ch = 0x19; _cl = Hex2BCD(t->tm_year - 100); } _dh = Hex2BCD(t->tm_mon + 1); _dl = Hex2BCD(t->tm_mday); ClrCF; }
void vcmosRefresh() { static time_t tprev = 0; time_t tcurr; struct tm *ptm; t_nubit8 century,year,month,mday,wday,hour,min,sec; tcurr = time(NULL); if (tcurr == tprev) return; else tprev = tcurr; ptm = LOCALTIME(&tcurr); century = (t_nubit8)(19 + ptm->tm_year / 100); year = (t_nubit8)(ptm->tm_year % 100); month = (t_nubit8)(ptm->tm_mon + 0x01); mday = (t_nubit8)(ptm->tm_mday); wday = (t_nubit8)(ptm->tm_wday + 0x01); hour = (t_nubit8)(ptm->tm_hour); min = (t_nubit8)(ptm->tm_min); sec = (t_nubit8)(ptm->tm_sec); vcmos.reg[VCMOS_RTC_SECOND] = Hex2BCD(sec); vcmos.reg[VCMOS_RTC_MINUTE] = Hex2BCD(min); vcmos.reg[VCMOS_RTC_HOUR] = Hex2BCD(hour); vcmos.reg[VCMOS_RTC_DAY_WEEK] = Hex2BCD(wday); vcmos.reg[VCMOS_RTC_DAY_MONTH] = Hex2BCD(mday); vcmos.reg[VCMOS_RTC_MONTH] = Hex2BCD(month); vcmos.reg[VCMOS_RTC_YEAR] = Hex2BCD(year); vcmos.reg[VCMOS_RTC_CENTURY] = Hex2BCD(century); }