📄 monitor.lst
字号:
278 1
279 1 MonWdata = MonRdata;
280 1 }
281
282 void MonNewWriteI2C(void)
283 {
284 1 BYTE Slave;
285 1
286 1 if( argc<4 ) {
287 2 Printf(" --> Missing parameter !!!");
288 2 return;
289 2 }
290 1
291 1 MonIndex = Asc2Bin( argv[2] );
292 1 MonWdata = Asc2Bin( argv[3] );
293 1 Slave = Asc2Bin(argv[1]);
294 1
295 1 if ( Slave == TW88I2CAddress ) {
296 2 WriteTW88(MonIndex, MonWdata);
297 2 MonRdata = ReadTW88(MonIndex);
298 2 }
299 1 else {
300 2 WriteI2C(Slave, MonIndex, MonWdata);
301 2 MonRdata = ReadI2C(Slave, MonIndex);
302 2 }
C51 COMPILER V7.50 MONITOR 04/01/2008 15:02:20 PAGE 6
303 1
304 1 if( echo )
305 1 Printf("\r\n<R>%2x[%2x]=%2x", (WORD)Slave, (WORD)MonIndex, (WORD)MonRdata);
306 1
307 1 }
308
309 void MonNewDumpI2C(void)
310 {
311 1 BYTE ToMonIndex, Slave;
312 1 WORD i;
313 1
314 1 if( argc>=2 ) MonIndex = Asc2Bin(argv[2]);
315 1 if( argc>=3 ) ToMonIndex = Asc2Bin(argv[3]);
316 1 Slave = Asc2Bin(argv[1]);
317 1
318 1 if( echo ) {
319 2 if ( Slave == TW88I2CAddress ) {
320 3 for(i=MonIndex; i<=ToMonIndex; i++) {
321 4 MonRdata = ReadTW88(i);
322 4 Printf("\r\n<R>%2x[%2x]=%2x", (WORD)Slave, (WORD)i, (WORD)MonRdata);
323 4 }
324 3 }
325 2 else {
326 3 for(i=MonIndex; i<=ToMonIndex; i++) {
327 4 MonRdata = ReadI2C(Slave, i);
328 4 Printf("\r\n<R>%2x[%2x]=%2x", (WORD)Slave, (WORD)i, (WORD)MonRdata);
329 4 }
330 3 }
331 2 }
332 1 else {
333 2 if ( Slave == TW88I2CAddress ) {
334 3 for(i=MonIndex; i<=ToMonIndex; i++) {
335 4 MonRdata = ReadTW88(i);
336 4 }
337 3 }
338 2 else {
339 3 for(i=MonIndex; i<=ToMonIndex; i++) {
340 4 MonRdata = ReadI2C(Slave, i);
341 4 }
342 3 }
343 2 }
344 1 }
345
346
347 void MonWriteBit(void)
348 {
349 1 BYTE mask, i, FromBit, ToBit, MonMask, val;
350 1 BYTE Slave;
351 1 // b 88 index startbit|endbit data
352 1
353 1 if( argc<5 ) {
354 2 Printf(" --> Missing parameter !!!");
355 2 return;
356 2 }
357 1 Slave = Asc2Bin(argv[1]);
358 1
359 1 MonIndex = Asc2Bin( argv[2] );
360 1 FromBit = (Asc2Bin( argv[3] ) >> 4) & 0x0f;
361 1 ToBit = Asc2Bin( argv[3] ) & 0x0f;
362 1 MonMask = Asc2Bin( argv[4] );
363 1
364 1 if( FromBit<ToBit || FromBit>7 || ToBit>7) {
C51 COMPILER V7.50 MONITOR 04/01/2008 15:02:20 PAGE 7
365 2 Printf("\r\n --> Wrong range of bit operation !!!");
366 2 return;
367 2 }
368 1
369 1 mask = 0xff;
370 1 val=0x7f;
371 1 for(i=7; i>FromBit; i--) {
372 2 mask &= val;
373 2 val = val>>1;
374 2 }
375 1
376 1 val=0xfe;
377 1 for(i=0; i<ToBit; i++) {
378 2 mask &= val;
379 2 val = val<<1;
380 2 }
381 1
382 1 if ( Slave == TW88I2CAddress ) {
383 2 MonRdata = ReadTW88(MonIndex);
384 2 MonWdata = (MonRdata & (~mask)) | (MonMask & mask);
385 2
386 2 WriteTW88(MonIndex, MonWdata);
387 2 MonRdata = ReadTW88(MonIndex);
388 2 }
389 1 else {
390 2 MonRdata = ReadI2C(Slave, MonIndex);
391 2 MonWdata = (MonRdata & (~mask)) | (MonMask & mask);
392 2
393 2 WriteI2C(Slave, MonIndex, MonWdata);
394 2 MonRdata = ReadI2C(Slave, MonIndex);
395 2 }
396 1
397 1 if( echo )
398 1 Printf("\r\n<R>%2x[%2x]=%2x", (WORD)Slave, (WORD)MonIndex, (WORD)MonRdata);
399 1
400 1 }
401
402 #if defined( SUPPORT_PC ) || defined( SUPPORT_DTV )
403 void PclkAccess(void)
404 {
405 1 DWORD pclk;
406 1
407 1 if( argc > 2 ) {
408 2 Printf(" --> Too many parameter !!!");
409 2 return;
410 2 }
411 1
412 1 if( argc==2 ) {
413 2 pclk = (DWORD)a2i(argv[1]) * 1000000;
414 2 Printf("\r\n --> Set Pclk: %ld Hz ", pclk);
415 2 // Printf("\r\n Not Suuport ");
416 2 ChangeInternPLL(pclk);
417 2 }
418 1
419 1 if( argc==1) GetPPF();
420 1
421 1 }
422 #endif
423
424 void MonTxDump(void)
425 {
426 1 WORD count;
C51 COMPILER V7.50 MONITOR 04/01/2008 15:02:20 PAGE 8
427 1
428 1 if ( argc < 2 ) {
429 2 Puts("\r\nInsufficient parameters...");
430 2 return;
431 2 }
432 1 count = (WORD)a2i(argv[1]);
433 1 do {
434 2 RS_tx((count&0x1F)+0x20);
435 2 count--;
436 2 } while ( count != 0 );
437 1 }
438
439 //=============================================================================
440 // Help Message
441 //=============================================================================
442 void MonHelp(void)
443 {
444 1 Printf("\r\n=======================================================");
445 1 Printf("\r\n>>> Welcome to Techwell Monitor Rev 1.00 <<<");
446 1 Printf("\r\n=======================================================");
447 1 Printf("\r\n R ii ; Read data");
448 1 Printf("\r\n W ii dd ; Write data");
449 1 Printf("\r\n D [ii] [cc] ; Dump");
450 1 Printf("\r\n C aa ; Change I2C address");
451 1 Printf("\r\n M ? ; Current Input");
452 1 Printf("\r\n M dd ; Change Input");
453 1 Printf("\r\n AutoDetect [0,1] ; PC Automode On/OFF");
454 1 Printf("\r\n PCAuto ; RUN PC Auto Adjust");
455 1 Printf("\r\n Debug [0..255] ; Debuging display level");
456 1 Printf("\r\n Echo On/Off ; Terminal Echoing On/Off");
457 1 Printf("\r\n Delta ; Init DeltaRGB Panel");
458 1 Printf("\r\n Delta w ii dh dl; SPI Write to DeltaRGB Panel");
459 1 Printf("\r\n");
460 1 Printf("\r\n=======================================================");
461 1 Printf("\r\n");
462 1 }
463
464 //=============================================================================
465 //
466 //=============================================================================
467 BYTE MonGetCommand(void)
468 {
469 1 static BYTE comment=0;
470 1 static BYTE incnt=0, last_argc=0;
471 1 BYTE i, ch;
472 1 BYTE ret=0;
473 1
474 1 if( !RS_ready() ) return 0;
475 1 ch = RS_rx();
476 1
477 1 //----- if comment, echo back and ignore -----
478 1 if( comment ) {
479 2 if( ch=='\r' || ch==0x1b ) comment = 0;
480 2 else {
481 3 Mon_tx(ch);
482 3 return 0;
483 3 }
484 2 }
485 1 else if( ch==';' ) {
486 2 comment = 1;
487 2 Mon_tx(ch);
488 2 return 0;
C51 COMPILER V7.50 MONITOR 04/01/2008 15:02:20 PAGE 9
489 2 }
490 1
491 1 //=====================================
492 1 switch( ch ) {
493 2
494 2 case 0x1b:
495 2 argc = 0;
496 2 incnt = 0;
497 2 comment = 0;
498 2 Prompt();
499 2 return 0;
500 2
501 2 //--- end of string
502 2 case '\r':
503 2
504 2 if( incnt==0 ) {
505 3 Prompt();
506 3 break;
507 3 }
508 2
509 2 monstr[incnt++] = '\0';
510 2 argc=0;
511 2
512 2 for(i=0; i<incnt; i++) if( monstr[i]!=' ' ) break;
513 2
514 2 if( !monstr[i] ) {
515 3 incnt = 0;
516 3 comment = 0;
517 3 Prompt();
518 3 return 0;
519 3 }
520 2 argv[0] = &monstr[i];
521 2 for(; i<incnt; i++) {
522 3 if( monstr[i]==' ' || monstr[i]=='\0' ) {
523 4 monstr[i]='\0';
524 4 //Printf("(%s) ", argv[argc]);
525 4 i++;
526 4 while( monstr[i]==' ' ) i++;
527 4 argc++;
528 4 if( monstr[i] ){
529 5 argv[argc] = &monstr[i];
530 5 }
531 4 }
532 3 }
533 2
534 2 ret = 1;
535 2 last_argc = argc;
536 2 incnt = 0;
537 2
538 2 break;
539 2
540 2 //--- repeat command
541 2 case '/':
542 2 argc = last_argc;
543 2 ret = 1;
544 2 break;
545 2
546 2 //--- back space
547 2 case 0x08:
548 2 if( incnt ) {
549 3 incnt--;
550 3 Mon_tx(ch);
C51 COMPILER V7.50 MONITOR 04/01/2008 15:02:20 PAGE 10
551 3 Mon_tx(' ');
552 3 Mon_tx(ch);
553 3 }
554 2 break;
555 2
556 2 //--- decreamental write
557 2 case ',':
558 2 if( incnt ) {
559 3 Mon_tx(ch);
560 3 monstr[incnt++] = ch;
561 3 }
562 2 else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -