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

📄 serial.lst

📁 cf8020+cp2200(网络)的驱动实现
💻 LST
字号:
C51 COMPILER V7.09   SERIAL                                                                07/03/2007 12:14:47 PAGE 1   


C51 COMPILER V7.09, COMPILATION OF MODULE SERIAL
OBJECT MODULE PLACED IN SERIAL.obj
COMPILER INVOKED BY: F:\Keil\C51\BIN\C51.EXE tcp\SERIAL.C LARGE BROWSE DEBUG OBJECTEXTEND PRINT(.\SERIAL.lst) OBJECT(SER
                    -IAL.obj)

line level    source

   1          //-----------------------------------------------------------------------------
   2          // Copyright (c) 2002 Jim Brady
   3          // Do not use commercially without author's permission
   4          // Last revised August 2002
   5          // Net SERIAL.C
   6          //
   7          // This module handles RS-232 messages and associated tasks
   8          //-----------------------------------------------------------------------------
   9          
  10          #include "net1.h"
*** WARNING C318 IN LINE 10 OF tcp\SERIAL.C: can't open file 'net1.h'
  11          #include "serial1.h"
*** WARNING C318 IN LINE 11 OF tcp\SERIAL.C: can't open file 'serial1.h'
  12          #include "stdio.h"
  13          
  14          // bit CommRecDataOverflowFlag,FlagRecComm,SendItComm;
  15          // 
  16          // unsigned char CommSendBufferHead, CommSendBufferTail;
  17          // unsigned char CommRecBufferHead, CommRecBufferTail;
  18          // 
  19          // unsigned char xdata CommSendBuffer[DB_SENDMAXSIZE] _at_ 0 ; //串行口缓冲区定位在内部4K XRAM中
  20          // unsigned char xdata CommRecBuffer[DB_RECMAXSIZE] _at_ DB_SENDMAXSIZE; 
  21          //  
  22          // void ClearCommRecBuffer(void)
  23          // {
  24          //      unsigned char i;
  25          //      CommRecBufferHead=CommRecBufferTail=0;
  26          //      CommSendBufferHead=CommSendBufferTail=0;
  27          //      FlagRecComm=0;
  28          //      for (i=0;i<DB_SENDMAXSIZE;i++)
  29          //      {
  30          //              CommSendBuffer[i]=0;
  31          //      }
  32          //      for (i=0;i<DB_RECMAXSIZE;i++)
  33          //      {
  34          //              CommRecBuffer[i]=0;
  35          //      }
  36          // }
  37          // 
  38          // void init_serial(void)
  39          // {
  40          //      ClearCommRecBuffer();
  41          //      OpenComm();
  42          // }
  43          // 
  44          // void OpenComm(void) 
  45          // {
  46          //      PCON |= 0x80;           // SMOD=1 (HW_UART uses Timer 1 overflow with no divide down).
  47          //      TMOD |= 0x20;           // Configure Timer 1 for use by UART0
  48          //      CKCON |= 0x10;          // Timer 1 derived from SYSCLK
  49          // 
  50          //      RCAP2H=(65536-(SYSCLK/BAUDRATE0/32))/256;
  51          //      RCAP2L=(65536-(SYSCLK/BAUDRATE0/32))%256;
  52          //      TH2=RCAP2H;TL2=RCAP2L;
C51 COMPILER V7.09   SERIAL                                                                07/03/2007 12:14:47 PAGE 2   

  53          //      CT2=0;                          //T2:timer mode 
  54          //      TR2=1;
  55          //      TCLK=1;RCLK=1;          //说明:52,对于SIO0,可选择T1(TCLK=0,RCLK=0)或T2(TCLK=1,RCLK=1)作为波特率发生器
  56          //                                          //            SIO1只能用T1作为波特率发生器
  57          //                                          //baud=OSC/(32*(65536-[RCAP2H,RCAP2L])
  58          //      CommSendBufferHead=CommSendBufferTail=0; // set the head and tail to the base of the ring buffer
  59          //      CommRecBufferHead=CommRecBufferTail=0;
  60          //      FlagRecComm=0;
  61          //      RI0=0;                                  // Clear HW_UART receive and transmit
  62          //      TI0=0;                                  // complete indicators.
  63          //      SCON0 = 0x50;                   // Configure UART0 for mode 1, receiver enabled.
  64          //      ES0=1;                                  // allow the serial interrupt
  65          //      SendItComm=1;
  66          // }
  67          /*
  68          void SendCommChar(char ch)
  69          {
  70                  CommSendBuffer[CommSendBufferTail]=ch; 
  71                  CommSendBufferTail++;
  72                  if (CommSendBufferTail==DB_SENDMAXSIZE)
  73                  {       
  74                          CommSendBufferTail=0;
  75                  }
  76                  if (SendItComm)
  77                  {        
  78                          SendItComm=0;
  79                          SBUF0=CommSendBuffer[CommSendBufferHead]; 
  80                  }
  81                  while (CommSendBufferHead!=CommSendBufferTail);
  82                  return ;
  83          }
  84          
  85          code unsigned char hex[]="0123456789ABCDEF";
  86          void SendCommHex(unsigned char senddata)//往串口发送hex码 表示的一个字符 例如senddata=0x3A那么将向串口发送
             -两个字符'3','A'hex[]为转换表,在前面有定义
  87          {
  88                  unsigned char ch;
  89                  ch=senddata>>4;
  90                  SendCommChar(hex[ch]);
  91                  ch=senddata&0x0F;
  92                  SendCommChar(hex[ch]);
  93          }
  94          void SendCommWord(unsigned int asciiword)
  95          //向串口发送一个int型的 hex码表示的字符 例如:asciiword=0x124D 将向串口发送4个字符:'1','2','4','D'
  96          {
  97                  unsigned char ascii;
  98                  ascii=asciiword>>8;
  99                  SendCommHex(ascii);
 100                  ascii=asciiword&0xff;
 101                  SendCommHex(ascii);
 102          }
 103          
 104          void SendCommLong(unsigned long asciilong)
 105          {
 106                  SendCommWord(asciilong>>16);
 107                  SendCommWord(asciilong&0xffff);
 108          }
 109          */
 110          void serial_send(unsigned char *base)
 111          {
 112   1              printf((char*)base);
 113   1      }
C51 COMPILER V7.09   SERIAL                                                                07/03/2007 12:14:47 PAGE 3   

 114          
 115          // void SendCommString(unsigned char *base) 
 116          // {
 117          // unsigned char i=0;
 118          //      if (base[0]==0) return;
 119          //      for (;;)
 120          //      {       
 121          //              if (base[i]==0) break;
 122          //              CommSendBuffer[CommSendBufferTail]=base[i]; 
 123          //              CommSendBufferTail++; 
 124          //              if (CommSendBufferTail==DB_SENDMAXSIZE)
 125          //              {                                               
 126          //                      CommSendBufferTail=0;
 127          //              }
 128          //              i++;
 129          //      }
 130          //      if (SendItComm)
 131          //      {                                                       
 132          //              SendItComm=0;
 133          //              SBUF0=CommSendBuffer[CommSendBufferHead];
 134          //      }
 135          //      while (CommSendBufferHead!=CommSendBufferTail);
 136          // }
 137          // /*
 138          // void SendCommBuffer(unsigned char *base, unsigned char size) 
 139          // {
 140          // unsigned char i=0;
 141          //      if (!size) { return; }  
 142          //      while (i<size) 
 143          //      {        
 144          //              CommSendBuffer[CommSendBufferTail]=base[i]; 
 145          //              i++;
 146          //              CommSendBufferTail++; 
 147          //              if (CommSendBufferTail==DB_SENDMAXSIZE)
 148          //              { 
 149          //                      CommSendBufferTail=0;
 150          //              }
 151          //      }
 152          //      if (SendItComm)
 153          //      {        
 154          //              SendItComm=0;
 155          //              SBUF0=CommSendBuffer[CommSendBufferHead]; 
 156          //      }
 157          // }
 158          // */
 159          // void CommISR(void) interrupt 4
 160          // {
 161          //      if (_testbit_(TI0))
 162          //      {
 163          //              TI0=0;
 164          //              CommSendBufferHead++;   
 165          //              if (CommSendBufferHead==DB_SENDMAXSIZE)
 166          //              {        
 167          //                      CommSendBufferHead=0;
 168          //              }
 169          //              if (CommSendBufferHead!=CommSendBufferTail)
 170          //              {        
 171          //                      SBUF0=CommSendBuffer[CommSendBufferHead]; // send the next byte
 172          //                      SendItComm=0;
 173          //              }
 174          //              else
 175          //              {
C51 COMPILER V7.09   SERIAL                                                                07/03/2007 12:14:47 PAGE 4   

 176          //                      SendItComm=1;
 177          //              }
 178          //      }
 179          //      if (_testbit_(RI0))     
 180          //      {        
 181          //              RI0=0;
 182          //              if (CommRecBufferTail==CommRecBufferHead)
 183          //              {
 184          //                      CommRecDataOverflowFlag=1;                              //接收缓冲区溢出
 185          //              }
 186          //              CommRecBuffer[CommRecBufferTail]=SBUF0;     //receive data           
 187          //          CommRecBufferTail++;
 188          //          if (CommRecBufferTail==DB_RECMAXSIZE)
 189          //          {
 190          //              CommRecBufferTail=0;
 191          //          }
 192          //              FlagRecComm=1;
 193          //      }
 194          // }
 195          // 
 196          // //从接收缓冲区读数据 ,无数据返回0,有数据返回1
 197          // /*bit GetCommChar(unsigned char idata *ch)      
 198          // { 
 199          //      if (CommRecBufferTail==CommRecBufferHead) return 0;     
 200          //      *ch=CommRecBuffer[CommRecBufferHead];
 201          //      CommRecBufferHead++;
 202          //      if (CommRecBufferHead==DB_RECMAXSIZE)
 203          //      {
 204          //              CommRecBufferHead=0;
 205          //      }
 206          //      if (CommRecBufferTail==CommRecBufferHead) FlagRecComm=0;
 207          //      return 1;
 208          // }
 209          // /*
 210          // //在T(0-255)毫秒内从接收缓冲区读数据 ,无数据返回0,有数据返回1
 211          // bit GetCommCharWait(unsigned char idata *ch,unsigned char T)  //T ms    
 212          // { 
 213          //      Count1ms=T;*ch=0;
 214          //      while (Count1ms)
 215          //      {
 216          //              if (CommRecBufferTail!=CommRecBufferHead) break;
 217          //      }
 218          //      if (Count1ms==0) return 0;
 219          //      *ch=CommRecBuffer[CommRecBufferHead];
 220          //      CommRecBufferHead++;
 221          //      if (CommRecBufferHead==DB_RECMAXSIZE)
 222          //      {
 223          //              CommRecBufferHead=0;
 224          //      }
 225          //      return 1;
 226          // }
 227          // */
 228          // 
 229          // //------------------------------------------------------------------------
 230          // // This function converts an integer to an ASCII string.  It is a 
 231          // // normally provided as a standard library function but the Keil
 232          // // libraries do not include it.  Caution: The string passed to this
 233          // // must be at least 12 bytes long
 234          // //------------------------------------------------------------------------
 235          // char * itoa(UINT value, char * buf, UCHAR radix)
 236          // {
 237          //      UINT i;
C51 COMPILER V7.09   SERIAL                                                                07/03/2007 12:14:47 PAGE 5   

 238          //      char * ptr;
 239          //      char * temphold;
 240          // 
 241          //      temphold = buf;
 242          //      ptr = buf + 12;
 243          //      *--ptr = 0;             // Insert NULL char
 244          //      do
 245          //      {
 246          //         // First create string in reverse order
 247          //         i = (value % radix) + 0x30;
 248          //              if(i > 0x39) i += 7;
 249          //              *--ptr = i;
 250          //       value = value / radix;
 251          //      } while(value != 0);
 252          // 
 253          //      // Next, move the string 6 places to the left
 254          //      // Include NULL character
 255          //      for( ; (*buf++ = *ptr++); );    
 256          //      return(temphold);
 257          // }
 258          
 259          


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


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

⌨️ 快捷键说明

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