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

📄 cs8900.lst

📁 cs8900 c51应用
💻 LST
字号:
C51 COMPILER V7.06   CS8900                                                                11/26/2004 11:32:45 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE CS8900
OBJECT MODULE PLACED IN .\8052-obj\cs8900.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\cs8900.c LARGE OPTIMIZE(SIZE) BROWSE INTVECTOR(0X2000) INCDIR(D:\Work\op
                    -entcp\1-0-2\src\include\) DEFINE(MONITOR,CS8900) DEBUG OBJECTEXTEND CODE SYMBOLS PRINT(.\8052-lst\cs8900.lst) PREPRINT(.
                    -\8052-lst\cs8900.i) OBJECT(.\8052-obj\cs8900.obj)

stmt level    source

   1          /*
   2          * CS8900A driver, (c) Alexey Selischev, 03/2003
   3          */
   4          #include <inet/datatypes.h>
*** WARNING C318 IN LINE 4 OF ..\cs8900.c: can't open file 'inet/datatypes.h'
   5          #include <inet/system.h>
*** WARNING C318 IN LINE 5 OF ..\cs8900.c: can't open file 'inet/system.h'
   6          #include <inet/ethernet.h>      /* include ethernet stuff */
*** WARNING C318 IN LINE 6 OF ..\cs8900.c: can't open file 'inet/ethernet.h'
   7          #include <inet/cs8900.h>
*** WARNING C318 IN LINE 7 OF ..\cs8900.c: can't open file 'inet/cs8900.h'
   8          
   9          #include <inet/arch/config.h>
*** WARNING C318 IN LINE 9 OF ..\cs8900.c: can't open file 'inet/arch/config.h'
  10          
  11          /* Macro to access external data memory area, where CS8900A is connected */
  12          #define CS(i)           (*((volatile UINT8 xdata *)(i)))
  13          
  14          /* Structures moved here from ethernet.c, defined in ethernet.h */
  15          struct ethernet_frame received_frame;
  16          struct ethernet_frame send_frame;
  17          
  18          /* Buffers to store input and output packets */
  19          UINT8 xdata RxBuf1[ETH_MTU];
*** ERROR C129 IN LINE 19 OF ..\CS8900.C: missing ';' before 'xdata'
  20          UINT8 xdata TxBuf1[ETH_MTU];
  21          
  22          /* Pointers to these buffers */
  23          UINT8 xdata * RxPtr;
  24          UINT8 xdata * TxPtr;
  25          
  26          /* The length of received frame */
  27          UINT16 RxLength;
  28          
  29          /*
  30          * Init CS8900A chip before use it: reset and set config. REGs 
  31          */
  32          void CSInit (UINT8* mac)
  33          {
  34                  UINT8 chip_id[4]; /* */
  35                  /* HW Reset of the CS8900, _|--|_____ */
  36                  P1_3 = 1;
  37                  wait(0xFFFF);
  38                  P1_3 = 0;
  39                  wait(0xFFFF);
  40          
  41                  CS(PPPtr) = 0x58;
  42                  CS(PPPtrp1) = 0x01;
  43          
  44                  CS(PPData) = *(mac+5);                  /* Set MAC Address  */
  45                  CS(PPDatap1) = *(mac+4);
  46          
  47                  CS(PPPtr) = 0x5A;
C51 COMPILER V7.06   CS8900                                                                11/26/2004 11:32:45 PAGE 2   

  48                  CS(PPPtrp1) = 0x01;
  49          
  50                  CS(PPData) = *(mac+3);                  /* Set MAC Address  */
  51                  CS(PPDatap1) = *(mac+2);
  52          
  53                  CS(PPPtr) = 0x5C;
  54                  CS(PPPtrp1) = 0x01;
  55          
  56                  CS(PPData) = *(mac+1);                  /* Set MAC Address  */
  57                  CS(PPDatap1) = *(mac);
  58          
  59                  // Configure RxCTL
  60                  CS(PPPtr) = 0x04;
  61                  CS(PPPtrp1) = 0x01;
  62                  CS(PPData) = 0x00;
  63                  CS(PPDatap1) = 0x0D;
  64          
  65                  // Set 10BaseT, SerRxOn, SerTxOn in LineCTL
  66                  CS(PPPtr) = 0x12;
  67                  CS(PPPtrp1) = 0x01;
  68                  CS(PPData) = 0xc0;
  69                  CS(PPDatap1) = 0x00;
  70          
  71          /* Useful, when MONITOR is supported or DEBUG messages are enabled.
  72          * Read the CS8900 chip ID that should be like 0x0E63xxxx. If wrong ID received,
  73          * check target hardware ;)
  74          */
  75                  CS(PPPtr)=0x00;
  76                  CS(PPPtrp1)=0x00;
  77          
  78                  chip_id[0]=CS(PPData);
  79                  chip_id[1]=CS(PPDatap1);
  80          
  81                  CS(PPPtr)=0x02;
  82                  CS(PPPtrp1)=0x00;
  83          
  84                  chip_id[2]=CS(PPData);
  85                  chip_id[3]=CS(PPDatap1);
  86          /*      */
  87          }
  88          
  89          
  90          UINT8 CSCheckRxFrame (void)
  91          {
  92                  UINT8 highbyte, lowbyte;
  93                  CS(PPPtr) = 0x24;
  94                  CS(PPPtrp1) = 0x01;
  95                  highbyte = CS(PPDatap1);
  96                  lowbyte = CS(PPData);
  97                  return highbyte;
  98          }
  99          
 100          
 101          UINT8 CSReceiveFrame (void)
 102          {
 103                  UINT8 temp,lenh, lenl;
 104                  UINT8 i;
 105          
 106                  if (CSCheckRxFrame() == FALSE)  /* Do we have a new frame? */
 107                          return(FALSE); /* no */
 108          
 109                  RxPtr = &RxBuf1[0];
C51 COMPILER V7.06   CS8900                                                                11/26/2004 11:32:45 PAGE 3   

 110          
 111                  temp=CS(RxTxDatap1);
 112                  temp=CS(RxTxData);
 113                  lenh=CS(RxTxDatap1);
 114                  lenl=CS(RxTxData);
 115                  RxLength=(UINT16)((lenh<<8)+lenl);
 116                  for (i=0;i<(RxLength>>1);i++)
 117                  {
 118                          *RxPtr++=CS(RxTxData);
 119                          *RxPtr++=CS(RxTxDatap1);
 120                  }
 121                  if((RxLength&0x0001)==1)
 122                  {
 123                          *RxPtr++=CS(RxTxData);
 124                  }
 125                  
 126          
 127                  RxPtr = &RxBuf1[0];
 128          /* Record Frame Size                                    */
 129                  
 130                  received_frame.frame_size = lenl;
 131                  received_frame.frame_size |= ((UINT16)lenh) << 8;
 132                  
 133                  if(received_frame.frame_size > 4)
 134                          received_frame.frame_size -= 0;                 /* Remove chip specific bytes   */
 135                  else
 136                          return(FALSE);
 137                  
 138                  /* Record destination Ethernet Address  */
 139                  
 140                  received_frame.destination[5] = *RxPtr++;                                               
 141                  received_frame.destination[4] = *RxPtr++;
 142                  received_frame.destination[3] = *RxPtr++;
 143                  received_frame.destination[2] = *RxPtr++;
 144                  received_frame.destination[1] = *RxPtr++;
 145                  received_frame.destination[0] = *RxPtr++;
 146                  
 147                  /* Record senders Ethernet address              */
 148                  
 149                  received_frame.source[5] = *RxPtr++;
 150                  received_frame.source[4] = *RxPtr++;
 151                  received_frame.source[3] = *RxPtr++;
 152                  received_frame.source[2] = *RxPtr++;
 153                  received_frame.source[1] = *RxPtr++;
 154                  received_frame.source[0] = *RxPtr++; 
 155                  
 156                  /* Record Protocol      */
 157                  
 158                  received_frame.protocol = *RxPtr++;
 159                  received_frame.protocol <<= 8;
 160                  received_frame.protocol |= *RxPtr++;
 161                  
 162                  /* Give the next layer data start buffer index from the start   */
 163                  
 164                  received_frame.buf_index = ETH_HEADER_LEN;
 165                  
 166          //      ETH_DEBUGOUT("Ethernet Frame Received\n\r");
 167                  
 168                  return(TRUE);                                           /* Indicate we got packet */
 169          }
 170          
 171          
C51 COMPILER V7.06   CS8900                                                                11/26/2004 11:32:45 PAGE 4   

 172          void CSSendFrame (UINT16 len)   //NETWORK_COMPLETE_SEND()
 173          {
 174                  UINT8 BusST;
 175                  UINT16 i = 0;
 176                  TxPtr = &TxBuf1[0];
 177                  CS(TxCmd)= 0xc0;
 178                  CS(TxCmd + 1) = 0x00;
 179                  CS(TxLength) = (UINT8) (len & 0x00FF);
 180                  CS(TxLength + 1) = (UINT8) (len >> 8);
 181                  CS(PPPtr) = 0x38;
 182                  CS(PPPtr + 1) = 0x01;
 183                  do      
 184                  {
 185                          BusST = CS(PPData);
 186                          BusST = CS(PPDatap1);
 187                  } while(!(BusST==0x01));
 188                  while (i<(len>>1))
 189                  {
 190                          CS(RxTxData) = *(TxPtr++);
 191                          CS(RxTxDatap1) = *(TxPtr++);
 192                          i++;
 193                  }
 194                  if((len&0x0001)==1)
 195                  {
 196                          CS(RxTxData) = *(TxPtr);
 197                  }
 198          }
 199          
 200          
 201          /*      Invoke this function (through NETWORK_RECEIVE_INITIALIZE() macro) 
 202           *      to prepare NIC for reading from the specified position. */
 203          
 204          void CSInitRx_position (UINT16 pos)
 205          {
 206                  RxPtr = &RxBuf1[0] + pos; 
 207                  /* Now just read by inBUF()             */
 208          }
 209          
 210          /*      Invoke this function (through NETWORK_SEND_INITIALIZE() macro) 
 211           *      to prepare NIC for reading from the specified position. */
 212          
 213          void CSInitTx_position (UINT16 pos)
 214          {
 215                  TxPtr = &TxBuf1[0] + pos; 
 216                  /* Now just write by outBUF()           */
 217          }
 218          
 219          void CSDumpRxFrame (void)
 220          {
 221                  ; 
 222          }
 223          
 224          void outBUF (UINT8 dat)
 225          {
 226                  *TxPtr++ = dat;
 227          }
 228          
 229          
 230          UINT8 inBUF (void)
 231          {
 232                  return(*RxPtr++);
 233          }
C51 COMPILER V7.06   CS8900                                                                11/26/2004 11:32:45 PAGE 5   

 234          
 235          /*      Invoke this function (through NETWORK_ADD_DATALINK() macro) to create
 236           *      an Ethernet header in the NIC's transmit buffer. Do this only after
 237           *      invoking NETWORK_SEND_INITIALIZE() macro.*/
 238          
 239          void CSWriteEthernetHeader (struct ethernet_frame* frame)
 240          {
 241                  INT8 i;
 242                  
 243                  /* Write destination Ethernet Address   */
 244                  TxPtr = &TxBuf1[0];
 245                  for(i=ETH_ADDRESS_LEN-1; i >= 0; i--) {
 246                                  *TxPtr++ = frame->destination[i];
 247                  }
 248          
 249                  /* Write sender (our) Ethernet address  */
 250                  
 251                  for(i=ETH_ADDRESS_LEN-1; i >= 0; i--) {
 252                                  *TxPtr++ = frame->source[i];
 253                  }
 254                  
 255                  /* Write protocol                                               */
 256                  
 257                          *TxPtr++ = (UINT8)(frame->protocol >> 8);
 258                          *TxPtr++ = (UINT8)frame->protocol;
 259          
 260          }
 261          
 262          
 263          /*
 264          
 265          //Unused functions
 266          void outCS(UINT16 address, UINT8 value)
 267          {
 268                  CS(address) = value;
 269          }
 270          
 271          
 272          UINT8 inCS (UINT16 address)
 273          {
 274                  return CS(address);
 275          }
 276          
 277          
 278          void CSCheckOverFlow (void)
 279          {
 280          
 281          }
 282          
 283          void InitTransmission (UINT8 page)
 284          {
 285                  ;
 286          }
 287          
 288          void CSDMAInit (UINT8 page)
 289          {
 290                  ;
 291          }
 292          
 293          
 294          void CSEnterSleep (void) 
 295          {
C51 COMPILER V7.06   CS8900                                                                11/26/2004 11:32:45 PAGE 6   

 296                  ;
 297          }
 298          
 299          void CSExitSleep (void) 
 300          {
 301                  ;               
 302          }
 303          
 304          */

C51 COMPILATION COMPLETE.  5 WARNING(S),  1 ERROR(S)

⌨️ 快捷键说明

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