/* 1. Compiler: TC 2.0 2. Mode: Small 3. Project: Dt.prj Dt.c i7188s.lib 4. Explain: Auto-read the date & time of RTC peer second. * Press 'd' to set date; 't' to set time; 'y' to set year&time; 'q' to quit this program. 5. Hordware: 7188 It's compiled by Tony -------------------------------------------------------------- */ #include #include #include #include #include #include"..\LIB\i7188.h" /*--------------------------------------------------------------*/ void main(void) { int year,month,day,hour,min,sec; int oyear,omonth,oday,ohour,omin,osec; int quit=0; int type; int ver; type=Is7188(); /*detect teh current operation system*/ if(type) { ver=GetLibVersion(); /*if used in minios7*/ Print("Hello 7188x! (Flash memory is %d K)\n\r",type); Print("Library version is %d.%02d",ver>>8,ver&0xff); } else /*if used in dos*/ { Print("Hello PC!, this program is not run under I-7188."); return; } oyear=omonth=oday=ohour=omin=osec=-1; Print("\r\nPress 'd' to set date"); Print("\r\n't' to set time"); Print("\r\n'y' to set year&time"); Print("\r\n'q' to quit this program."); while(!quit) /*set the key function*/ { if(Kbhit()){ switch(Getch()){ case 'q': quit=1; break; case 'd': /* set date to 02/29/2000 */ SetDate(2000,2,29); break; case 't': SetTime(23,59,50); break; case 'y': /* set date to 02/28/2000 */ SetDate(2000,2,28); SetTime(23,59,50); break; } } GetDate(&year,&month,&day); /*get the system date from RTC*/ GetTime(&hour,&min,&sec); /*get the system date from RTC*/ if(oyear!=year || omonth!=month || oday!=day || /*to ensure the date & time be correct*/ ohour!=hour || omin!=min || osec!=sec){ oyear=year; omonth=month; oday=day; ohour=hour; omin=min; osec=sec; Print("Date=%02d/%02d/%04d Time=%02d:%02d:%02d\n\r", month,day,year,hour,min,sec); } } }