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

📄 serial.lst

📁 terawin的t103 LCD驱动程序
💻 LST
字号:
C51 COMPILER V7.50   SERIAL                                                                10/30/2006 16:14:43 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE SERIAL
OBJECT MODULE PLACED IN .\Obj\serial.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Source\serial.c LARGE OPTIMIZE(6,SPEED) BROWSE INCDIR(.\Include\;.\Source\;
                    -.\Include\Panel\;.\Include\GammaTable\;.\Include\tuner\) DEFINE(T103) DEBUG OBJECTEXTEND PRINT(.\serial.lst) OBJECT(.\Ob
                    -j\serial.obj)

line level    source

   1          
   2          
   3          #define __serProc_C__
   4          #include "reg51.h"
   5          #include "serial.h"
   6          #include "twowire.h"
   7          
   8          void serInterrupt(void) interrupt 4 using 1
   9          {
  10   1              if(RI){
  11   2                      RI=0;
  12   2                      serInBuf[(pserIn+pserInCnt)&7]=SBUF;
  13   2                   
  14   2              pserInCnt++;
  15   2              }else if(TI){
  16   2                      TI=0;
  17   2                      pserOutCnt--;
  18   2                      pserOut++;
  19   2                      pserOut=pserOut&7;
  20   2                      if(pserOutCnt){
  21   3                              SBUF=serOutBuf[pserOut];
  22   3                      }
  23   2              }
  24   1      }
  25          
  26          void serialIni()
  27          {
  28   1              pserIn=pserOut=pserInCnt=pserOutCnt=0;
  29   1              PCON|=0x80;
  30   1              AUXR=0x40;
  31   1              SCON=0x50;//40;
  32   1      //      SADDR=0;
  33   1      //      SADEN=0;
  34   1              TMOD=(TMOD&0xf)|0x20;
  35   1          TMOD=0x21; 
  36   1              TH1=243;//3 19200bps at 12M/1/16
  37   1              TR1=1;
  38   1              RI=TI=0;
  39   1              ES=1;
  40   1          EA=1;
  41   1      }
  42          void serSendByte(U8 d)
  43          {
  44   1              while(pserOutCnt>8);
  45   1              ES=0;
  46   1              serOutBuf[(pserOut+pserOutCnt)&7]=d;
  47   1              if(!pserOutCnt)SBUF=d;
  48   1              pserOutCnt++;
  49   1              ES=1;
  50   1      }
  51          bit serReadByte(U8 *d)
  52          {
  53   1              if(pserInCnt==0) return 0;
C51 COMPILER V7.50   SERIAL                                                                10/30/2006 16:14:43 PAGE 2   

  54   1              *d=serInBuf[pserIn];
  55   1              ES=0;
  56   1              pserIn++,pserInCnt--;
  57   1              pserIn=pserIn&7;
  58   1              ES=1;
  59   1              return 1;
  60   1      }
  61          bit waitData(U8 *d)
  62          {
  63   1              uWORD i;
  64   1              for(i=65535;i!=0;i--){
  65   2                      if(pserInCnt) return(serReadByte(d));
  66   2                      while(!TF1)if(pserInCnt) return(serReadByte(d));
  67   2                      TF1=0;
  68   2                      if(pserInCnt) return(serReadByte(d));
  69   2                      while(!TF1)if(pserInCnt) return(serReadByte(d));
  70   2                      TF1=0;
  71   2                      if(pserInCnt) return(serReadByte(d));
  72   2                      while(!TF1)if(pserInCnt) return(serReadByte(d));
  73   2                      TF1=0;
  74   2                      if(pserInCnt) return(serReadByte(d));
  75   2                      while(!TF1)if(pserInCnt) return(serReadByte(d));
  76   2                      TF1=0;
  77   2              }
  78   1              return 0;
  79   1      }
  80          void serCommand()
  81          {
  82   1              U8 i,d,addr,len,page;
  83   1              if(!serReadByte(& d)) return;
  84   1              if(d!=0x8f) return;
  85   1              if(!waitData(&d)) return;
  86   1              if(d!='T') return;
  87   1              if(!waitData(&d)) return;
  88   1              if(d!='S') return;
  89   1              if(!waitData(&d)) return;
  90   1              if(d!='T') return;
  91   1              serSendByte(0x61);
  92   1              
  93   1              while(1){
  94   2                      if(serReadByte(&d)&&(d==0x83)){
  95   3                              if(!waitData(&page)) continue;
  96   3                              if(page==0xff){
  97   4                                      //3 Stop
  98   4                                      serSendByte(0x6f);
  99   4                                      break;
 100   4                              }
 101   3                              if(page&0x80){
 102   4                                      //2 Read data p a len
 103   4                                      page&=0x7f;
 104   4                                      if(!waitData(&addr)) continue;
 105   4                                      if(!waitData(&len)) continue;
 106   4                                      do{
 107   5                                              serSendByte(I2CReadByte(page, addr));
 108   5                                              addr++;
 109   5                                              len--;
 110   5                                      }while(len);
 111   4                              }else{
 112   4                                      //2 Write data p a len
 113   4                                      if(!waitData(&addr)) continue;
 114   4                                      if(!waitData(&len)) continue;
 115   4                                      i=0;
C51 COMPILER V7.50   SERIAL                                                                10/30/2006 16:14:43 PAGE 3   

 116   4                                      do{
 117   5                                              if(!waitData(&d)) break;
 118   5                                              I2CWriteByte(page, addr, d);
 119   5                                              addr++;
 120   5                                              len--;
 121   5                                              i++;
 122   5                                              if((i&7)==0){
 123   6                                                      serSendByte(0x60);
 124   6                                              }
 125   5                                      }while(len);
 126   4                                      serSendByte(0x61);
 127   4                              }
 128   3                      }
 129   2              }
 130   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    788    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =     20       8
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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