📄 c8051f330_camera.lst
字号:
313 3 {
314 4 SMB_SENDWORDADDR = 0;
315 4 SMB0DAT = WORD_ADDR;
316 4
317 4 if (SMB_RANDOMREAD)
318 4 {
319 5 SEND_START = 1;
320 5 SMB_RW = READ;
321 5 }
322 4
323 4 break;
324 4 }
325 3
326 3 if (SMB_RW==WRITE)
327 3 {
328 4
329 4 if (i < SMB_DATA_LEN)
330 4 {
331 5
332 5 SMB0DAT = *pSMB_DATA_OUT;
333 5 pSMB_DATA_OUT++;
334 5 i++;
335 5 }
336 4 else
337 4 {
338 5 STO = 1;
339 5 SMB_BUSY = 0;
340 5 }
341 4 }
342 3 else {}
343 3 }
344 2 else
345 2 {
346 3 if(SMB_ACKPOLL)
347 3 {
348 4 STA = 1;
349 4 }
350 3 else
C51 COMPILER V9.00 C8051F330_CAMERA 09/22/2012 12:09:15 PAGE 7
351 3 {
352 4 FAIL = 1;
353 4 }
354 3 }
355 2 break;
356 2 case SMB_MRDB:
357 2 if ( i < SMB_DATA_LEN )
358 2 {
359 3 *pSMB_DATA_IN = SMB0DAT;
360 3 pSMB_DATA_IN++;
361 3 i++;
362 3 ACK = 1;
363 3
364 3
365 3 }
366 2
367 2 if (i == SMB_DATA_LEN)
368 2 {
369 3 SMB_BUSY = 0;
370 3 ACK = 0;
371 3
372 3 STO = 1;
373 3 }
374 2
375 2 break;
376 2
377 2 default:
378 2 FAIL = 1;
379 2
380 2 break;
381 2 }
382 1
383 1 if (FAIL)
384 1 {
385 2 SMB0CF &= ~0x80;
386 2 SMB0CF |= 0x80;
387 2 STA = 0;
388 2 STO = 0;
389 2 ACK = 0;
390 2
391 2 SMB_BUSY = 0;
392 2
393 2 //FAIL = 0;
394 2 }
395 1
396 1 SI = 0;
397 1 }
398
399
400 void Timer3_ISR (void) interrupt 14
401 {
402 1 SMB0CF &= ~0x80;
403 1 SMB0CF |= 0x80;
404 1 TMR3CN &= ~0x80;
405 1 STA = 0;
406 1 SMB_BUSY = 0;
407 1 }
408 void Tft_Init(void)
409 {
410 1
411 1 Tft_RST_PIN=1;
412 1 delay_ms(10);
C51 COMPILER V9.00 C8051F330_CAMERA 09/22/2012 12:09:15 PAGE 8
413 1 Tft_RST_PIN=0;
414 1 delay_ms(10);
415 1 Tft_RST_PIN=1;
416 1 delay_ms(150);
417 1
418 1
419 1 TftWrite(0x00e5, 0x8000);
420 1 TftWrite(0x0000, 0x0001);
421 1 TftWrite(0x0001, 0x0100);
422 1 TftWrite(0x0002, 0x0700);
423 1 #if AM==000
TftWrite(0x0003,0x1000);
#elif AM==001
TftWrite(0x0003,0x1008);
#elif AM==010
TftWrite(0x0003,0x1010);
#elif AM==011
430 1 TftWrite(0x0003,0x1018);
431 1 #elif AM==100
TftWrite(0x0003,0x1020);
#elif AM==101
TftWrite(0x0003,0x1028);
#elif AM==110
TftWrite(0x0003,0x1030);
#elif AM==111
TftWrite(0x0003,0x1038);
#endif
440 1 TftWrite(0x0004, 0x0000);
441 1 TftWrite(0x0008, 0x0202);
442 1 TftWrite(0x0009, 0x0000);
443 1 TftWrite(0x000A, 0x0000);
444 1 TftWrite(0x000C, 0x0000);
445 1 TftWrite(0x000D, 0x0000);
446 1 TftWrite(0x000F, 0x0000);
447 1 TftWrite(0x0010, 0x0000);
448 1 TftWrite(0x0011, 0x0007);
449 1 TftWrite(0x0012, 0x0000);
450 1 TftWrite(0x0013, 0x0000);
451 1 delay_ms(1000);
452 1 TftWrite(0x0010, 0x17B0);
453 1 TftWrite(0x0011, 0x0007);
454 1 delay_ms(1000);
455 1 TftWrite(0x0012, 0x013A);
456 1 delay_ms(1000);
457 1 TftWrite(0x0013, 0x1A00);
458 1 TftWrite(0x0029, 0x000c);
459 1 delay_ms(1000);
460 1 TftWrite(0x0030, 0x0000);
461 1 TftWrite(0x0031, 0x0505);
462 1 TftWrite(0x0032, 0x0004);
463 1 TftWrite(0x0035, 0x0006);
464 1 TftWrite(0x0036, 0x0707);
465 1 TftWrite(0x0037, 0x0105);
466 1 TftWrite(0x0038, 0x0002);
467 1 TftWrite(0x0039, 0x0707);
468 1 TftWrite(0x003C, 0x0704);
469 1 TftWrite(0x003D, 0x0807);
470 1 TftWrite(0x0050, 0x0000);
471 1 TftWrite(0x0051, 0x00EF);
472 1 TftWrite(0x0052, 0x0000);
473 1 TftWrite(0x0053, 0x013F);
474 1 TftWrite(0x0060, 0x2700);
C51 COMPILER V9.00 C8051F330_CAMERA 09/22/2012 12:09:15 PAGE 9
475 1 TftWrite(0x0061, 0x0001);
476 1 TftWrite(0x006A, 0x0000);
477 1 #if AM==000
TftWrite(0x0020,0x00ef);
TftWrite(0x0021,0x013f);
#elif AM==001
TftWrite(0x0020,0x00ef);
TftWrite(0x0021,0x013f);
#elif AM==010
TftWrite(0x0020,0x0000);
TftWrite(0x0021,0x013f);
#elif AM==011
487 1 TftWrite(0x0020,0x0000);
488 1 TftWrite(0x0021,0x013f);
489 1 #elif AM==100
TftWrite(0x0020,0x00ef);
TftWrite(0x0021,0x0000);
#elif AM==101
TftWrite(0x0020,0x00ef);
TftWrite(0x0021,0x0000);
#elif AM==110
TftWrite(0x0020,0x0000);
TftWrite(0x0021,0x0000);
#elif AM==111
TftWrite(0x0020,0x0000);
TftWrite(0x0021,0x0000);
#endif
502 1 TftWrite(0x0080, 0x0000);
503 1 TftWrite(0x0081, 0x0000);
504 1 TftWrite(0x0082, 0x0000);
505 1 TftWrite(0x0083, 0x0000);
506 1 TftWrite(0x0084, 0x0000);
507 1 TftWrite(0x0085, 0x0000);
508 1 TftWrite(0x0090, 0x0010);
509 1 TftWrite(0x0092, 0x0000);
510 1 TftWrite(0x0093, 0x0003);
511 1 TftWrite(0x0095, 0x0110);
512 1 TftWrite(0x0097, 0x0000);
513 1 TftWrite(0x0098, 0x0000);
514 1 TftWrite(0x0007, 0x0173);
515 1 delay_ms(1000);
516 1
517 1
518 1
519 1 }
520
521
522 void Tft_WR_DATA16(unsigned int inputdata)
523 {
524 1 unsigned int inputdatah;
525 1 unsigned int inputdatal;
526 1 unsigned int x;
527 1 x=inputdata;
528 1 inputdatal=inputdata&0x00ff;
529 1 inputdatah=(inputdata&0xff00)>>8;
530 1 P1MDOUT= 0XFF;
531 1 Tft_RS_PIN=1;
532 1 P1=0x00;
533 1 P1=inputdatah;
534 1 Tft_WR_PIN=0;
535 1 Tft_WR_PIN=1;
536 1 P1=0x00;
C51 COMPILER V9.00 C8051F330_CAMERA 09/22/2012 12:09:15 PAGE 10
537 1 P1=inputdatal;
538 1 Tft_WR_PIN=0;
539 1 Tft_WR_PIN=1;
540 1 P1MDOUT= 0X00;
541 1
542 1 }
543
544
545 void TftWrite16(unsigned int index)
546 {
547 1 unsigned int indexh;
548 1 unsigned int indexl;
549 1 indexh=(index&0xff00)>>8;
550 1 indexl=index&0x00ff;
551 1 P1MDOUT= 0XFF;
552 1 Tft_RS_PIN=0;
553 1
554 1 P1=0x00;
555 1 P1=indexh;
556 1 Tft_WR_PIN=0;
557 1 Tft_WR_PIN=1;
558 1
559 1 P1=0x00;
560 1 P1=indexl;
561 1
562 1 Tft_WR_PIN=0;
563 1 Tft_WR_PIN=1;
564 1
565 1 P1MDOUT= 0X00;
566 1
567 1 }
568
569
570 void TftWrite(unsigned int index,unsigned int inputdata)
571 {
572 1 unsigned int x;
573 1 unsigned int y;
574 1 unsigned int indexh;
575 1 unsigned int indexl;
576 1 unsigned int inputdatah;
577 1 unsigned int inputdatal;
578 1 x=index;
579 1 y=inputdata;
580 1 indexh=(index&0xff00)>>8;
581 1 indexl=index&0x00ff;
582 1 inputdatah=(inputdata&0xff00)>>8;
583 1 inputdatal=inputdata&0x00ff;
584 1 P1MDOUT= 0XFF;
585 1 Tft_RS_PIN= 0;
586 1
587 1 P1=0;
588 1 P1=indexh;
589 1 Tft_WR_PIN=0;
590 1 Tft_WR_PIN=1;
591 1 P1=0;
592 1 P1=indexl;
593 1 Tft_WR_PIN=0;
594 1 Tft_WR_PIN=1;
595 1
596 1 Tft_RS_PIN=1;
597 1 P1=0;
598 1 P1=inputdatah;
C51 COMPILER V9.00 C8051F330_CAMERA 09/22/2012 12:09:15 PAGE 11
599 1 Tft_WR_PIN=0;
600 1 Tft_WR_PIN=1;
601 1 P1=0;
602 1 P1=inputdatal;
603 1 Tft_WR_PIN=0;
604 1 Tft_WR_PIN=1;
605 1
606 1 P1MDOUT= 0X00;
607 1
608 1 }
609
610 void TftClear(unsigned int Color)
611 {
612 1 unsigned long index = 0;
613 1
614 1 TftWrite(0x0050,0x00);
615 1 TftWrite(0x0051,239);
616 1 TftWrite(0x0052,0x00);
617 1 TftWrite(0x0053,319);
618 1 TftWrite(0x0020,0x0000);
619 1 TftWrite(0x0021,0x0000);
620 1 TftWrite16(0x0022);
621 1
622 1 for(index = 0; index < 76800; index++)
623 1 {
624 2 Tft_WR_DATA16(Color);
625 2
626 2 }
627 1
628 1 }
629
630 void TftWR_SingleStr(unsigned char inputdata,unsigned int color,unsigned int xcolor)
631 {
632 1
633 1 unsigned char avl,i,n;
634 1 TftWrite16(0x0022);
635 1 for (i=0;i<16;i++)
636 1 {
637 2 avl=(english[inputdata-32][i]);
638 2 for (n=0;n<8;n++)
639 2 {
640 3 if(avl&0x80) Tft_WR_DATA16(color);
641 3 else Tft_WR_DATA16(xcolor);
642 3
643 3 avl<<=1;
644 3 }
645 2 }
646 1 }
647 void TftWR_Str(unsigned int x,unsigned int y,unsigned char *s,unsigned int color,unsigned int xcolor)
648 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -