00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "..\inc\includes.h"
00010
00011 #define cEventTimeYear 0
00012 #define cEventTimeMonth 1
00013 #define cEventTimeDate 2
00014 #define cEventTimeHour 3
00015 #define cEventTimeMinute 4
00016 #define cEventTimeSecond 5
00017 #define cEventTimeWeekDay 6
00018
00019 sbit RtcSclk=P2^0;
00020 sbit RtcData=P2^1;
00021 sbit RtcCe=P2^2;
00022
00023 #define RTC_COMMAND_MAX 7
00024 INT8U code second[7]={'s','e','c','o','n','d',0};
00025 INT8U code minute[7]={'m','i','n','u','t','e',0};
00026 INT8U code hour[5]={'h','o','u','r',0};
00027 INT8U code date[5]={'d','a','t','e',0};
00028 INT8U code month[6]={'m','o','n','t','h',0};
00029 INT8U code year[5]={'y','e','a','r',0};
00030 INT8U code day[4]={'d','a','y',0};
00031 INT8U code *RtcCommandList[RTC_COMMAND_MAX]={second,minute,hour,date,month,year,day};
00032
00033 struct RTC_CONTROL RtcCtrl;
00034 struct RTC_EVENT RtcEvent;
00035
00036 void F_RtcPowerOnInit(void) LargeReentrant;
00037 void F_RtcSvc(void) LargeReentrant;
00038 void F_RtcWrite(UCHAR,UCHAR) LargeReentrant;
00039 void F_RtcCurrentTimeSet(void) LargeReentrant;
00040 void F_RtcCurrentTimeShow(void) LargeReentrant;
00041 UCHAR F_RtcRead(UCHAR) LargeReentrant;
00042
00043 void F_RtcPowerOnInit(void) LargeReentrant{
00044 INT8U i;
00045
00046 RtcCe=0;
00047 _nop_();
00048 _nop_();
00049 _nop_();
00050 _nop_();
00051 _nop_();
00052 _nop_();
00053 RtcSclk=0;
00054 RtcData=0;
00055 RtcCtrl.Timer=0;
00056 RtcCtrl.State=RtcIdleState;
00057 RtcCtrl.Second=0x00;
00058 RtcCtrl.Minute=0x27;
00059 RtcCtrl.Hour=0x09;
00060 RtcCtrl.WeekDay=7;
00061 RtcCtrl.Date=0x11;
00062 RtcCtrl.Month=0x03;
00063 RtcCtrl.Year=0x07;
00064 RtcEvent.HasEvent=0;
00065 RtcEvent.EventType=0;
00066 RtcEvent.RwFlag=0;
00067 RtcEvent.Data=0;
00068 F_RtcWrite(RtcWriteWriteProtectCmd,0);
00069 F_RtcWrite(0x90,0xa6);
00070
00071
00072
00073 i=F_RtcRead(0x81);
00074 if((i&0x80)!=0) F_RtcWrite(RtcWriteSecondCmd,0x00);
00075 F_RtcCurrentTimeShow();
00076 }
00077 void F_RtcSvc(void) LargeReentrant{
00078
00079 if(RtcEvent.HasEvent==1){
00080 if(RtcEvent.RwFlag==0){
00081 if(RtcEvent.EventType==cEventTimeYear){
00082 RtcCtrl.Year=RtcEvent.Data;
00083 F_RtcWrite(RtcWriteYearCmd,RtcEvent.Data);
00084 F_RtcCurrentTimeShow();
00085 }
00086 else if(RtcEvent.EventType==cEventTimeMonth){
00087 RtcCtrl.Month=RtcEvent.Data;
00088 F_RtcWrite(RtcWriteMonthCmd,RtcEvent.Data);
00089 F_RtcCurrentTimeShow();
00090 }
00091 else if(RtcEvent.EventType==cEventTimeDate){
00092 RtcCtrl.Date=RtcEvent.Data;
00093 F_RtcWrite(RtcWriteDateCmd,RtcEvent.Data);
00094 F_RtcCurrentTimeShow();
00095 }
00096 else if(RtcEvent.EventType==cEventTimeHour){
00097 RtcCtrl.Hour=RtcEvent.Data;
00098 F_RtcWrite(RtcWriteHourCmd,RtcEvent.Data);
00099 F_RtcCurrentTimeShow();
00100 }
00101 else if(RtcEvent.EventType==cEventTimeMinute){
00102 RtcCtrl.Minute=RtcEvent.Data;
00103 F_RtcWrite(RtcWriteMinuteCmd,RtcEvent.Data);
00104 F_RtcCurrentTimeShow();
00105 }
00106 else if(RtcEvent.EventType==cEventTimeSecond){
00107 RtcCtrl.Second=RtcEvent.Data;
00108 F_RtcWrite(RtcWriteSecondCmd,RtcEvent.Data);
00109 F_RtcCurrentTimeShow();
00110 }
00111 else if(RtcEvent.EventType==cEventTimeWeekDay){
00112 RtcCtrl.WeekDay=RtcEvent.Data;
00113 F_RtcWrite(RtcWriteWeekDayCmd,RtcEvent.Data);
00114 F_RtcCurrentTimeShow();
00115 }
00116 }
00117 else{
00118 if(RtcEvent.EventType==cEventTimeYear) RtcEvent.Data=RtcCtrl.Year;
00119 else if(RtcEvent.EventType==cEventTimeMonth) RtcEvent.Data=RtcCtrl.Month;
00120 else if(RtcEvent.EventType==cEventTimeDate) RtcEvent.Data=RtcCtrl.Date;
00121 else if(RtcEvent.EventType==cEventTimeHour) RtcEvent.Data=RtcCtrl.Hour;
00122 else if(RtcEvent.EventType==cEventTimeMinute) RtcEvent.Data=RtcCtrl.Minute;
00123 else if(RtcEvent.EventType==cEventTimeSecond) RtcEvent.Data=RtcCtrl.Second;
00124 else if(RtcEvent.EventType==cEventTimeWeekDay) RtcEvent.Data=RtcCtrl.WeekDay;
00125 }
00126 RtcEvent.HasEvent=0;
00127 }
00128 switch(RtcCtrl.State){
00129 case RtcIdleState:
00130 if(RtcCtrl.Timer==0){
00131 RtcCtrl.Timer=250;
00132 RtcCtrl.State=RtcReadSecondState;
00133 }
00134 break;
00135 case RtcReadSecondState:
00136 RtcCtrl.Second=F_RtcRead(RtcReadSecondCmd);
00137 LcmChar[75]=((RtcCtrl.Second&0x70)>>4)+48;
00138 LcmChar[76]=(RtcCtrl.Second&0x0f)+48;
00139 RtcCtrl.Second=((RtcCtrl.Second&0x70)>>4)*10+(RtcCtrl.Second&0x0f);
00140 if(RtcCtrl.Second==0) RtcCtrl.State=RtcReadMinuteState;
00141 else RtcCtrl.State=RtcIdleState;
00142 break;
00143 case RtcReadMinuteState:
00144 RtcCtrl.Minute=F_RtcRead(RtcReadMinuteCmd);
00145 LcmChar[72]=((RtcCtrl.Minute&0x70)>>4)+48;
00146 LcmChar[73]=(RtcCtrl.Minute&0x0f)+48;
00147 RtcCtrl.Minute=((RtcCtrl.Minute&0x70)>>4)*10+(RtcCtrl.Minute&0x0f);
00148 if(RtcCtrl.Minute==0) RtcCtrl.State=RtcReadHourState;
00149 else RtcCtrl.State=RtcIdleState;
00150 break;
00151 case RtcReadHourState:
00152 RtcCtrl.Hour=F_RtcRead(RtcReadHourCmd);
00153 LcmChar[69]=((RtcCtrl.Hour&0x30)>>4)+48;
00154 LcmChar[70]=(RtcCtrl.Hour&0x0f)+48;
00155 RtcCtrl.Hour=((RtcCtrl.Hour&0x30)>>4)*10+(RtcCtrl.Hour&0x0f);
00156 if(RtcCtrl.Hour==0) RtcCtrl.State=RtcReadWeekdayState;
00157 else RtcCtrl.State=RtcIdleState;
00158 break;
00159 case RtcReadWeekdayState:
00160 RtcCtrl.WeekDay=F_RtcRead(RtcReadWeekDayCmd);
00161 LcmChar[78]=(RtcCtrl.WeekDay&0x07)+48;
00162 RtcCtrl.WeekDay=RtcCtrl.WeekDay&0x07;
00163 RtcCtrl.State=RtcReadDateState;
00164 break;
00165 case RtcReadDateState:
00166 RtcCtrl.Date=F_RtcRead(RtcReadDateCmd);
00167 LcmChar[66]=((RtcCtrl.Date&0x30)>>4)+48;
00168 LcmChar[67]=(RtcCtrl.Date&0x0f)+48;
00169 RtcCtrl.Date=((RtcCtrl.Date&0x30)>>4)*10+(RtcCtrl.Date&0x0f);
00170 if(RtcCtrl.Date==1) RtcCtrl.State=RtcReadMonthState;
00171 else RtcCtrl.State=RtcIdleState;
00172 break;
00173 case RtcReadMonthState:
00174 RtcCtrl.Month=F_RtcRead(RtcReadMonthCmd);
00175 LcmChar[63]=((RtcCtrl.Month&0x10)>>4)+48;
00176 LcmChar[64]=(RtcCtrl.Month&0x0f)+48;
00177 RtcCtrl.Month=((RtcCtrl.Month&0x10)>>4)*10+(RtcCtrl.Month&0x0f);
00178 if(RtcCtrl.Month==1) RtcCtrl.State=RtcReadYearState;
00179 else RtcCtrl.State=RtcIdleState;
00180 break;
00181 case RtcReadYearState:
00182 RtcCtrl.Year=F_RtcRead(RtcReadYearCmd);
00183 LcmChar[60]=((RtcCtrl.Year&0xf0)>>4)+48;
00184 LcmChar[61]=(RtcCtrl.Year&0x0f)+48;
00185 RtcCtrl.Year=((RtcCtrl.Year&0xf0)>>4)*10+(RtcCtrl.Year&0x0f);
00186 RtcCtrl.State=RtcIdleState;
00187 break;
00188 default:
00189 break;
00190 }
00191 }
00192 void F_RtcCurrentTimeSet() LargeReentrant{
00193 F_RtcWrite(RtcWriteYearCmd,RtcCtrl.Year);
00194 F_RtcWrite(RtcWriteWeekDayCmd,RtcCtrl.WeekDay);
00195 F_RtcWrite(RtcWriteMonthCmd,RtcCtrl.Month);
00196 F_RtcWrite(RtcWriteDateCmd,RtcCtrl.Date);
00197 F_RtcWrite(RtcWriteHourCmd,RtcCtrl.Hour);
00198 F_RtcWrite(RtcWriteMinuteCmd,RtcCtrl.Minute);
00199 F_RtcWrite(RtcWriteSecondCmd,RtcCtrl.Second);
00200 }
00201 void F_RtcCurrentTimeShow() LargeReentrant{
00202 RtcCtrl.Second=F_RtcRead(RtcReadSecondCmd);
00203 LcmChar[75]=((RtcCtrl.Second&0x70)>>4)+48;
00204 LcmChar[76]=(RtcCtrl.Second&0x0f)+48;
00205 RtcCtrl.Second=((RtcCtrl.Second&0x70)>>4)*10+(RtcCtrl.Second&0x0f);
00206 RtcCtrl.Minute=F_RtcRead(RtcReadMinuteCmd);
00207 LcmChar[72]=((RtcCtrl.Minute&0x70)>>4)+48;
00208 LcmChar[73]=(RtcCtrl.Minute&0x0f)+48;
00209 RtcCtrl.Minute=((RtcCtrl.Minute&0x70)>>4)*10+(RtcCtrl.Minute&0x0f);
00210 RtcCtrl.Hour=F_RtcRead(RtcReadHourCmd);
00211 LcmChar[69]=((RtcCtrl.Hour&0x30)>>4)+48;
00212 LcmChar[70]=(RtcCtrl.Hour&0x0f)+48;
00213 RtcCtrl.Hour=((RtcCtrl.Hour&0x30)>>4)*10+(RtcCtrl.Hour&0x0f);
00214 RtcCtrl.WeekDay=F_RtcRead(RtcReadWeekDayCmd);
00215 LcmChar[78]=(RtcCtrl.WeekDay&0x07)+48;
00216 RtcCtrl.WeekDay=RtcCtrl.WeekDay&0x07;
00217 RtcCtrl.Date=F_RtcRead(RtcReadDateCmd);
00218 LcmChar[66]=((RtcCtrl.Date&0x30)>>4)+48;
00219 LcmChar[67]=(RtcCtrl.Date&0x0f)+48;
00220 RtcCtrl.Date=((RtcCtrl.Date&0x30)>>4)*10+(RtcCtrl.Date&0x0f);
00221 RtcCtrl.Month=F_RtcRead(RtcReadMonthCmd);
00222 LcmChar[63]=((RtcCtrl.Month&0x10)>>4)+48;
00223 LcmChar[64]=(RtcCtrl.Month&0x0f)+48;
00224 RtcCtrl.Month=((RtcCtrl.Month&0x10)>>4)*10+(RtcCtrl.Month&0x0f);
00225 RtcCtrl.Year=F_RtcRead(RtcReadYearCmd);
00226 LcmChar[60]=((RtcCtrl.Year&0xf0)>>4)+48;
00227 LcmChar[61]=(RtcCtrl.Year&0x0f)+48;
00228 RtcCtrl.Year=F_RtcRead(RtcReadYearCmd);
00229 }
00230 INT8U F_RtcEventCheck(void) LargeReentrant{
00231 if(RtcEvent.HasEvent==1) return 1;
00232 else return 0;
00233 }
00234 void F_RtcYearSet(INT8U Year) LargeReentrant{
00235 if(Year>0x99) return;
00236 RtcEvent.EventType=cEventTimeYear;
00237 RtcEvent.RwFlag=0;
00238 RtcEvent.Data=Year;
00239 RtcEvent.HasEvent=1;
00240 }
00241 void F_RtcMonthSet(INT8U Month) LargeReentrant{
00242 if((Month>0x12)||(Month==0)) return;
00243 RtcEvent.EventType=cEventTimeMonth;
00244 RtcEvent.RwFlag=0;
00245 RtcEvent.Data=Month;
00246 RtcEvent.HasEvent=1;
00247 }
00248 void F_RtcDateSet(INT8U Date) LargeReentrant{
00249 if((Date>0x31)||(Date==0)) return;
00250 RtcEvent.EventType=cEventTimeDate;
00251 RtcEvent.RwFlag=0;
00252 RtcEvent.Data=Date;
00253 RtcEvent.HasEvent=1;
00254 }
00255 void F_RtcHourSet(INT8U Hour) LargeReentrant{
00256 if((Hour>0x24)||(Hour==0)) return;
00257 RtcEvent.EventType=cEventTimeHour;
00258 RtcEvent.RwFlag=0;
00259 RtcEvent.Data=Hour;
00260 RtcEvent.HasEvent=1;
00261 }
00262 void F_RtcMinuteSet(INT8U Minute) LargeReentrant{
00263 if(Minute>0x59) return;
00264 RtcEvent.EventType=cEventTimeMinute;
00265 RtcEvent.RwFlag=0;
00266 RtcEvent.Data=Minute;
00267 RtcEvent.HasEvent=1;
00268 }
00269 void F_RtcSecondSet(INT8U Second) LargeReentrant{
00270 if(Second>0x59) return;
00271 RtcEvent.EventType=cEventTimeSecond;
00272 RtcEvent.RwFlag=0;
00273 RtcEvent.Data=Second;
00274 RtcEvent.HasEvent=1;
00275 }
00276 void F_RtcWeekDaySet(INT8U WeekDay) LargeReentrant{
00277 if(WeekDay>0x8) return;
00278 RtcEvent.EventType=cEventTimeWeekDay;
00279 RtcEvent.RwFlag=0;
00280 RtcEvent.Data=WeekDay;
00281 RtcEvent.HasEvent=1;
00282 }
00283 void F_RtcYearRead() LargeReentrant{
00284 RtcEvent.EventType=cEventTimeYear;
00285 RtcEvent.RwFlag=1;
00286 RtcEvent.Data=0;
00287 RtcEvent.HasEvent=1;
00288 }
00289 void F_RtcMonthRead() LargeReentrant{
00290 RtcEvent.EventType=cEventTimeMonth;
00291 RtcEvent.RwFlag=1;
00292 RtcEvent.Data=0;
00293 RtcEvent.HasEvent=1;
00294 }
00295 void F_RtcDateRead() LargeReentrant{
00296 RtcEvent.EventType=cEventTimeDate;
00297 RtcEvent.RwFlag=1;
00298 RtcEvent.Data=0;
00299 RtcEvent.HasEvent=1;
00300 }
00301 void F_RtcHourRead() LargeReentrant{
00302 RtcEvent.EventType=cEventTimeHour;
00303 RtcEvent.RwFlag=1;
00304 RtcEvent.Data=0;
00305 RtcEvent.HasEvent=1;
00306 }
00307 void F_RtcMinuteRead() LargeReentrant{
00308 RtcEvent.EventType=cEventTimeMinute;
00309 RtcEvent.RwFlag=1;
00310 RtcEvent.Data=0;
00311 RtcEvent.HasEvent=1;
00312 }
00313 void F_RtcSecondRead() LargeReentrant{
00314 RtcEvent.EventType=cEventTimeSecond;
00315 RtcEvent.RwFlag=1;
00316 RtcEvent.Data=0;
00317 RtcEvent.HasEvent=1;
00318 }
00319 void F_RtcWeekDayRead() LargeReentrant{
00320 RtcEvent.EventType=cEventTimeWeekDay;
00321 RtcEvent.RwFlag=1;
00322 RtcEvent.Data=0;
00323 RtcEvent.HasEvent=1;
00324 }
00325 UCHAR F_RtcRead(UCHAR Command) LargeReentrant{
00326 UCHAR data Data;
00327
00328 RtcSclk=0;
00329 _nop_();
00330 _nop_();
00331 RtcCe=1;
00332 _nop_();
00333 _nop_();
00334 _nop_();
00335 _nop_();
00336 _nop_();
00337 _nop_();
00338
00339 if(Command&0x01) RtcData=1;
00340 else RtcData=0;
00341 _nop_();
00342 _nop_();
00343 RtcSclk=1;
00344 _nop_();
00345 _nop_();
00346 RtcSclk=0;
00347 _nop_();
00348 _nop_();
00349
00350 if(Command&0x02) RtcData=1;
00351 else RtcData=0;
00352 _nop_();
00353 _nop_();
00354 RtcSclk=1;
00355 _nop_();
00356 _nop_();
00357 RtcSclk=0;
00358 _nop_();
00359 _nop_();
00360
00361 if(Command&0x04) RtcData=1;
00362 else RtcData=0;
00363 _nop_();
00364 _nop_();
00365 RtcSclk=1;
00366 _nop_();
00367 _nop_();
00368 RtcSclk=0;
00369 _nop_();
00370 _nop_();
00371
00372 if(Command&0x08) RtcData=1;
00373 else RtcData=0;
00374 _nop_();
00375 _nop_();
00376 RtcSclk=1;
00377 _nop_();
00378 _nop_();
00379 RtcSclk=0;
00380 _nop_();
00381 _nop_();
00382
00383 if(Command&0x10) RtcData=1;
00384 else RtcData=0;
00385 _nop_();
00386 _nop_();
00387 RtcSclk=1;
00388 _nop_();
00389 _nop_();
00390 RtcSclk=0;
00391 _nop_();
00392 _nop_();
00393
00394 if(Command&0x20) RtcData=1;
00395 else RtcData=0;
00396 _nop_();
00397 _nop_();
00398 RtcSclk=1;
00399 _nop_();
00400 _nop_();
00401 RtcSclk=0;
00402 _nop_();
00403 _nop_();
00404
00405 if(Command&0x40) RtcData=1;
00406 else RtcData=0;
00407 _nop_();
00408 _nop_();
00409 RtcSclk=1;
00410 _nop_();
00411 _nop_();
00412 RtcSclk=0;
00413 _nop_();
00414 _nop_();
00415
00416 if(Command&0x80) RtcData=1;
00417 else RtcData=0;
00418 _nop_();
00419 _nop_();
00420 RtcSclk=1;
00421 _nop_();
00422 _nop_();
00423 RtcSclk=0;
00424 _nop_();
00425 _nop_();
00426
00427 if(RtcData==0);
00428 Data=0;
00429 if(RtcData==1) Data=Data|0x01;
00430
00431 RtcSclk=1;
00432 _nop_();
00433 _nop_();
00434 RtcSclk=0;
00435 _nop_();
00436 _nop_();
00437 if(RtcData==1) Data=Data|0x02;
00438
00439 RtcSclk=1;
00440 _nop_();
00441 _nop_();
00442 RtcSclk=0;
00443 _nop_();
00444 _nop_();
00445 if(RtcData==1) Data=Data|0x04;
00446
00447 RtcSclk=1;
00448 _nop_();
00449 _nop_();
00450 RtcSclk=0;
00451 _nop_();
00452 _nop_();
00453 if(RtcData==1) Data=Data|0x08;
00454
00455 RtcSclk=1;
00456 _nop_();
00457 _nop_();
00458 RtcSclk=0;
00459 _nop_();
00460 _nop_();
00461 if(RtcData==1) Data=Data|0x10;
00462
00463 RtcSclk=1;
00464 _nop_();
00465 _nop_();
00466 RtcSclk=0;
00467 _nop_();
00468 _nop_();
00469 if(RtcData==1) Data=Data|0x20;
00470
00471 RtcSclk=1;
00472 _nop_();
00473 _nop_();
00474 RtcSclk=0;
00475 _nop_();
00476 _nop_();
00477 if(RtcData==1) Data=Data|0x40;
00478
00479 RtcSclk=1;
00480 _nop_();
00481 _nop_();
00482 RtcSclk=0;
00483 _nop_();
00484 _nop_();
00485 if(RtcData==1) Data=Data|0x80;
00486
00487
00488
00489
00490
00491
00492 RtcCe=0;
00493 _nop_();
00494 _nop_();
00495 _nop_();
00496 _nop_();
00497 _nop_();
00498 _nop_();
00499 return Data;
00500 }
00501 void F_RtcWrite(UCHAR Command,UCHAR Data) LargeReentrant{
00502 RtcSclk=0;
00503 _nop_();
00504 _nop_();
00505 RtcCe=1;
00506 _nop_();
00507 _nop_();
00508 _nop_();
00509 _nop_();
00510 _nop_();
00511 _nop_();
00512
00513 if(Command&0x01) RtcData=1;
00514 else RtcData=0;
00515 _nop_();
00516 _nop_();
00517 RtcSclk=1;
00518 _nop_();
00519 _nop_();
00520 RtcSclk=0;
00521 _nop_();
00522 _nop_();
00523
00524 if(Command&0x02) RtcData=1;
00525 else RtcData=0;
00526 _nop_();
00527 _nop_();
00528 RtcSclk=1;
00529 _nop_();
00530 _nop_();
00531 RtcSclk=0;
00532 _nop_();
00533 _nop_();
00534
00535 if(Command&0x04) RtcData=1;
00536 else RtcData=0;
00537 _nop_();
00538 _nop_();
00539 RtcSclk=1;
00540 _nop_();
00541 _nop_();
00542 RtcSclk=0;
00543 _nop_();
00544 _nop_();
00545
00546 if(Command&0x08) RtcData=1;
00547 else RtcData=0;
00548 _nop_();
00549 _nop_();
00550 RtcSclk=1;
00551 _nop_();
00552 _nop_();
00553 RtcSclk=0;
00554 _nop_();
00555 _nop_();
00556
00557 if(Command&0x10) RtcData=1;
00558 else RtcData=0;
00559 _nop_();
00560 _nop_();
00561 RtcSclk=1;
00562 _nop_();
00563 _nop_();
00564 RtcSclk=0;
00565 _nop_();
00566 _nop_();
00567
00568 if(Command&0x20) RtcData=1;
00569 else RtcData=0;
00570 _nop_();
00571 _nop_();
00572 RtcSclk=1;
00573 _nop_();
00574 _nop_();
00575 RtcSclk=0;
00576 _nop_();
00577 _nop_();
00578
00579 if(Command&0x40) RtcData=1;
00580 else RtcData=0;
00581 _nop_();
00582 _nop_();
00583 RtcSclk=1;
00584 _nop_();
00585 _nop_();
00586 RtcSclk=0;
00587 _nop_();
00588 _nop_();
00589
00590 if(Command&0x80) RtcData=1;
00591 else RtcData=0;
00592 _nop_();
00593 _nop_();
00594 RtcSclk=1;
00595 _nop_();
00596 _nop_();
00597 RtcSclk=0;
00598 _nop_();
00599 _nop_();
00600
00601 if(Data&0x01) RtcData=1;
00602 else RtcData=0;
00603 _nop_();
00604 _nop_();
00605 RtcSclk=1;
00606 _nop_();
00607 _nop_();
00608 RtcSclk=0;
00609 _nop_();
00610 _nop_();
00611
00612 if(Data&0x02) RtcData=1;
00613 else RtcData=0;
00614 _nop_();
00615 _nop_();
00616 RtcSclk=1;
00617 _nop_();
00618 _nop_();
00619 RtcSclk=0;
00620 _nop_();
00621 _nop_();
00622
00623 if(Data&0x04) RtcData=1;
00624 else RtcData=0;
00625 _nop_();
00626 _nop_();
00627 RtcSclk=1;
00628 _nop_();
00629 _nop_();
00630 RtcSclk=0;
00631 _nop_();
00632 _nop_();
00633
00634 if(Data&0x08) RtcData=1;
00635 else RtcData=0;
00636 _nop_();
00637 _nop_();
00638 RtcSclk=1;
00639 _nop_();
00640 _nop_();
00641 RtcSclk=0;
00642 _nop_();
00643 _nop_();
00644
00645 if(Data&0x10) RtcData=1;
00646 else RtcData=0;
00647 _nop_();
00648 _nop_();
00649 RtcSclk=1;
00650 _nop_();
00651 _nop_();
00652 RtcSclk=0;
00653 _nop_();
00654 _nop_();
00655
00656 if(Data&0x20) RtcData=1;
00657 else RtcData=0;
00658 _nop_();
00659 _nop_();
00660 RtcSclk=1;
00661 _nop_();
00662 _nop_();
00663 RtcSclk=0;
00664 _nop_();
00665 _nop_();
00666
00667 if(Data&0x40) RtcData=1;
00668 else RtcData=0;
00669 _nop_();
00670 _nop_();
00671 RtcSclk=1;
00672 _nop_();
00673 _nop_();
00674 RtcSclk=0;
00675 _nop_();
00676 _nop_();
00677
00678 if(Data&0x80) RtcData=1;
00679 else RtcData=0;
00680 _nop_();
00681 _nop_();
00682 RtcSclk=1;
00683 _nop_();
00684 _nop_();
00685 RtcSclk=0;
00686 _nop_();
00687 _nop_();
00688
00689 RtcCe=0;
00690 _nop_();
00691 _nop_();
00692 _nop_();
00693 _nop_();
00694 _nop_();
00695 _nop_();
00696 }
00697 void F_RtcCommandSet(INT8U **pArgv,INT8U Argc) LargeReentrant{
00698 INT8U i,j,k;
00699 INT8U *pString;
00700
00701 if(Argc==0){
00702 printf("\n no command param");
00703 return;
00704 }
00705 else if(Argc==1){
00706 printf("\n command param is too few");
00707 return;
00708 }
00709 for(i=0;i<RTC_COMMAND_MAX;i++){
00710 if(strcmp(pArgv[0],RtcCommandList[i])==0) break;
00711 }
00712 if(i==RTC_COMMAND_MAX){
00713 printf("\n RTC command param invalid");
00714 return;
00715 }
00716 else{
00717 printf("\n RTC command '%s' ",RtcCommandList[i]);
00718 }
00719 j=strlen(pArgv[1]);
00720
00721 if(j>2){
00722 printf("\n RTC value param too long %x ",(INT16U)j);
00723 return;
00724 }
00725 else{
00726 pString=pArgv[1];
00727 if(j==2){
00728 if((pString[0]<0x30)||((pString[0]>0x39))){
00729 printf("\n value param invalid ");
00730 return;
00731 }
00732 if((pString[1]<0x30)||((pString[1]>0x39))){
00733 printf("\n value param invalid ");
00734 return;
00735 }
00736 k=(pString[0]-0x30)*16+(pString[1]-0x30);
00737 }
00738 else{
00739 if((pString[0]<0x30)||((pString[0]>0x39))){
00740 printf("\n value param invalid ");
00741 return;
00742 }
00743 k=pString[0]-0x30;
00744 }
00745 printf("\n input %s %x",pArgv[0],(INT16U)k);
00746 }
00747 switch(i){
00748 case 0:
00749 F_RtcSecondSet(k);
00750 break;
00751 case 1:
00752 F_RtcMinuteSet(k);
00753 break;
00754 case 2:
00755 F_RtcHourSet(k);
00756 break;
00757 case 3:
00758 F_RtcDateSet(k);
00759 break;
00760 case 4:
00761 F_RtcMonthSet(k);
00762 break;
00763 case 5:
00764 F_RtcYearSet(k);
00765 break;
00766 case 6:
00767 F_RtcWeekDaySet(k);
00768 break;
00769 }
00770 }
00771
00772
00773