⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 busio.lst

📁 采用台湾MRT晶捷公司的MRT4方案的液晶电视的程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
 609   2                      /* ------------- Finish C0 -------------- */
 610   2              }
 611   1      
 612   1      
C51 COMPILER V6.23a  BUSIO                                                                 09/10/2004 16:09:03 PAGE 11  

 613   1              /* ---- I2C Start and send slave address for C1 ---- */
 614   1              GoI2CMaster(SLAVEADDR_REGW);
 615   1              if(NoAck | BusFault) goto buserror;
 616   1      
 617   1              /* Send command */
 618   1              SendI2CByte(WRITE_BYTE);
 619   1              if(NoAck) goto buserror;
 620   1      
 621   1              /* Send C1 */
 622   1              SendI2CByte(0xC1);
 623   1              if(NoAck) goto buserror;
 624   1      
 625   1              SendI2CByte(index);
 626   1              if(NoAck) goto buserror;
 627   1      
 628   1              SendI2CStop();
 629   1              /* ------------- Finish C1 -------------- */
 630   1      
 631   1              /* ---- I2C Start and send slave address for C2 ---- */
 632   1              GoI2CMaster(SLAVEADDR_REGW);
 633   1              if(NoAck | BusFault) goto buserror;
 634   1      
 635   1              /* Send command */
 636   1              SendI2CByte(WRITE_AUTOINC);
 637   1              if(NoAck) goto buserror;
 638   1      
 639   1              /* Send C2 */
 640   1              SendI2CByte(0xC2);
 641   1              if(NoAck) goto buserror;
 642   1      
 643   1              /* data transmit */
 644   1              for(byteCnt = cnt; byteCnt > 0; byteCnt--) {
 645   2                      SendI2CByte(*s++);
 646   2                      if(NoAck) goto buserror;
 647   2              }
 648   1          goto endi2c;
 649   1      
 650   1              /* ------------- Finish C2 -------------- */
 651   1      buserror:
 652   1      #if DEBUGMSG
                 printf("BUS error (PortDataOut) !!!!\n");
              #endif   
 655   1      
 656   1      endi2c:
 657   1              SendI2CStop();
 658   1      
 659   1      
 660   1      
 661   1      
 662   1      #if DISABLEINT0
 663   1              /* restove interrupt 0 flag */
 664   1              EX0 =   IntFlag;
 665   1      #endif
 666   1      }
 667          
 668          
 669          
 670          
 671          /*********************************************
 672          * Send bytes of data to standard device      *
 673          **********************************************/
 674          void eepByteOut(unsigned int index, unsigned char val)
C51 COMPILER V6.23a  BUSIO                                                                 09/10/2004 16:09:03 PAGE 12  

 675          {
 676   1         unsigned char slv;
 677   1      
 678   1      #if DISABLEINT0
 679   1              bit IntFlag;
 680   1      
 681   1              /* disable interrupt 0 */
 682   1              IntFlag = EX0;
 683   1              EX0 = 0;
 684   1      #endif
 685   1      
 686   1              WPPin = 0;
 687   1      
 688   1         if(index < 256)
 689   1            slv = SLAVEADDR_EEPW0;
 690   1         else
 691   1         if(index < 512) {
 692   2            slv = SLAVEADDR_EEPW1;
 693   2            index -= 256;
 694   2         } else
 695   1         if(index < 768) {
 696   2            slv = SLAVEADDR_EEPW2;
 697   2            index -= 512;
 698   2         } else {
 699   2            slv = SLAVEADDR_EEPW3;
 700   2            index -= 768;
 701   2         }
 702   1              /* I2C Start and send WRITE slave address */
 703   1              GoI2CMaster(slv);
 704   1              if(NoAck | BusFault) goto buserror;
 705   1      
 706   1              /* Send index */
 707   1              SendI2CByte((unsigned char)index);
 708   1              if(NoAck) goto buserror;
 709   1      
 710   1              /* data transmit */
 711   1              SendI2CByte(val);
 712   1          //miscDelay(20);
 713   1      
 714   1          goto endi2c;
 715   1      
 716   1      buserror:       
 717   1      #if DEBUGMSG
                 printf("BUS error (eepByteOut) !!!!\n");
              #endif   
 720   1      
 721   1      endi2c:
 722   1              SendI2CStop();
 723   1          miscDelay(15);
 724   1          
 725   1       //   WPPin = 1;
 726   1          
 727   1      #if DISABLEINT0
 728   1              /* restove interrupt 0 flag */
 729   1              EX0 =   IntFlag;
 730   1      #endif    
 731   1      }
 732          
 733          unsigned char eepByteIn(unsigned int index)
 734          {
 735   1         unsigned char bval;
 736   1         unsigned char slv;
C51 COMPILER V6.23a  BUSIO                                                                 09/10/2004 16:09:03 PAGE 13  

 737   1      
 738   1         if(index < 256)
 739   1            slv = SLAVEADDR_EEPW0;
 740   1         else
 741   1         if(index < 512) {
 742   2            slv = SLAVEADDR_EEPW1;
 743   2            index -= 256;
 744   2         } else
 745   1         if(index < 768) {
 746   2            slv = SLAVEADDR_EEPW2;
 747   2            index -= 512;
 748   2         } else {
 749   2            slv = SLAVEADDR_EEPW3;
 750   2            index -= 768;
 751   2         }
 752   1      
 753   1              /* I2C Start and send WRITE slave address */
 754   1              GoI2CMaster(slv);
 755   1              if(NoAck | BusFault) goto buserror;
 756   1      
 757   1              /* Send index */
 758   1              SendI2CByte((unsigned char) index);
 759   1              if(NoAck) goto buserror;
 760   1      
 761   1              /* I2C Start and send READ slave address */
 762   1              GoI2CMaster(slv | 0x01);
 763   1              if(NoAck) goto buserror;
 764   1      
 765   1              /* data transmit */
 766   1              bval = RcvI2CByte(1);
 767   1      
 768   1          goto endi2c;
 769   1      
 770   1      buserror:       
 771   1      #if DEBUGMSG
                 printf("BUS error (eepByteIn) !!!!\n");
              #endif   
 774   1      
 775   1      endi2c:
 776   1              /* Finish trasmition */
 777   1              SendI2CStop();
 778   1      
 779   1              return(bval);
 780   1      }
 781          
 782          /**********************************************
 783          * Receive bytes of data from Standard device  *
 784          ***********************************************/
 785          void eepDataIn(unsigned int index, unsigned char *s, int cnt)
 786          {
 787   1              int data byteCnt;
 788   1         unsigned char slv;
 789   1      
 790   1         if(index < 256)
 791   1            slv = SLAVEADDR_EEPW0;
 792   1         else
 793   1         if(index < 512) {
 794   2            slv = SLAVEADDR_EEPW1;
 795   2            index -= 256;
 796   2         } else
 797   1         if(index < 768) {
 798   2            slv = SLAVEADDR_EEPW2;
C51 COMPILER V6.23a  BUSIO                                                                 09/10/2004 16:09:03 PAGE 14  

 799   2            index -= 512;
 800   2         } else {
 801   2            slv = SLAVEADDR_EEPW3;
 802   2            index -= 768;
 803   2         }
 804   1      
 805   1              /* I2C Start and send WRITE slave address */
 806   1              GoI2CMaster(slv);
 807   1              if(NoAck | BusFault) goto buserror;
 808   1      
 809   1              /* Send index */
 810   1              SendI2CByte((unsigned char) index);
 811   1              if(NoAck) goto buserror;
 812   1      
 813   1              /* I2C Start and send READ slave address */
 814   1              GoI2CMaster(slv | 0x01);
 815   1              if(NoAck) goto buserror;
 816   1      
 817   1              /* data transmit */
 818   1              for(byteCnt = cnt; byteCnt > 0; byteCnt--) {
 819   2                      *s++ = RcvI2CByte(byteCnt);
 820   2              }
 821   1          goto endi2c;
 822   1      
 823   1      buserror:       
 824   1      #if DEBUGMSG
                 printf("BUS error (eepDataIn) !!!!\n");
              #endif   
 827   1      
 828   1      endi2c:
 829   1              /* Finish trasmition */
 830   1              SendI2CStop();
 831   1      }
 832          
 833          /*********************************************
 834          * Send bytes of data to standard device      *
 835          **********************************************/
 836          void eepDataOut(unsigned int index, unsigned char *s, int cnt)
 837          {
 838   1              
 839   1      
 840   1          int data byteCnt = cnt;
 841   1          unsigned char data slv,i;
 842   1      
 843   1      #if DISABLEINT0
 844   1              bit IntFlag;
 845   1      
 846   1              /* disable interrupt 0 */
 847   1              IntFlag = EX0;
 848   1              EX0 = 0;
 849   1      #endif
 850   1      
 851   1              WPPin = 0;
 852   1      
 853   1      
 854   1         if(index < 256)
 855   1         {
 856   2            slv = SLAVEADDR_EEPW0;
 857   2         }   
 858   1         else if(index < 512)
 859   1         {
 860   2            slv = SLAVEADDR_EEPW1;
C51 COMPILER V6.23a  BUSIO                                                                 09/10/2004 16:09:03 PAGE 15  

 861   2           index -= 256;
 862   2         }
 863   1         else if(index < 768)
 864   1         {
 865   2            slv = SLAVEADDR_EEPW2;
 866   2            index -= 512;
 867   2         }
 868   1         else
 869   1         {
 870   2            slv = SLAVEADDR_EEPW3;
 871   2            index -= 768;
 872   2         }
 873   1      
 874   1         while(1)
 875   1         {
 876   2              // Slave addr
 877   2              GoI2CMaster(slv);
 878   2              if(NoAck | BusFault)   goto buserror;
 879   2      
 880   2              // Start addr
 881   2              SendI2CByte(index);
 882   2              if(NoAck)   goto buserror;
 883   2      
 884   2              // Send Data
 885   2              for (i = 0; i < 8; i++)
 886   2              {
 887   3                    SendI2CByte(*s++);
 888   3               
 889   3                    if(NoAck)           goto buserror;
 890   3      
 891   3                    if(--byteCnt == 0)  goto endi2c;
 892   3                    
 893   3                    index++;
 894   3                    if((index % 16 )== 0)
 895   3                    {
 896   4                      if(index == 256)
 897   4                      {
 898   5                              index = 0;
 899   5                              slv += 2;
 900   5                      }
 901   4                      break;
 902   4                    }
 903   3              }
 904   2              SendI2CStop();
 905   2              miscDelay(15);
 906   2        }
 907   1      
 908   1        goto endi2c;
 909   1      
 910   1      buserror:
 911   1      #if DEBUGMSG
                 printf("BUS error (eepDataOut) !!!!\n");
              #endif   
 914   1      
 915   1      endi2c:
 916   1         SendI2CStop();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -