/* 1. Compiler: TC 2.0 2. Mode: Large 3. Project: Dt.c Dt.prj ..\lib\8000l.lib ..\lib\tcpipl.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: 8831 It's compiled by Tony ---------------------------------------------------------------------- */ #include #include #include #include #include #include"..\LIB\8000.h" #include"..\LIB\vxcomm.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=Is8000(); /*detect teh current operation system*/ if(type) { ver=GetLibVersion(); Print("Hello 8831! (Flash memory is %d K)\n\r",type); Print("Library version is %d.%02d",ver>>8,ver&0xff); } else { Print("Hello PC!, this program is not run under I-8831."); 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){ 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); GetTime(&hour,&min,&sec); if(oyear!=year || omonth!=month || oday!=day || 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); } } }