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

📄 rtl8019.lst

📁 运行环境是keil。这是一个实现嵌入式TCP/IP的程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.06   RTL8019                                                               04/05/2006 12:13:02 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE RTL8019
OBJECT MODULE PLACED IN .\DEBUG\rtl8019.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE RTL8019\rtl8019.c LARGE OPTIMIZE(6,SPEED) BROWSE DEBUG OBJECTEXTEND PRINT(.
                    -\DEBUG\rtl8019.lst) OBJECT(.\DEBUG\rtl8019.obj)

stmt level    source

   1          #ifndef  OS_MASTER_FILE
   2          #include    <CORE\includes.h>
   3          #endif
   4          #include <uip\uip.h>
   5          #include <global_para.h>
   6          #include "rtl8019.h"
   7          #include <serial.h>
   8          sbit   RST8019  = P3 ^ 5;
   9          
  10          /*****************************************************************************
  11          *  writeRTL( RTL_ADDRESS, RTL_DATA )
  12          *  Args:        1. unsigned char RTL_ADDRESS - register offset of RTL register
  13          *               2. unsigned char RTL_DATA - data to write to register
  14          *  Created By:  Louis Beaudoin
  15          *  Date:        September 21, 2002
  16          *  Description: Writes byte to RTL8019 register.
  17          *
  18          *  Notes - If using the External SRAM Interface, performs a write to
  19          *            address MEMORY_MAPPED_RTL8019_OFFSET + (RTL_ADDRESS<<8)
  20          *            The address is sent in the non-multiplxed upper address port so
  21          *            no latch is required.
  22          *
  23          *          If using general I/O ports, the data port is left in the input
  24          *            state with pullups enabled
  25          *
  26          *****************************************************************************/
  27          void writeRTL(unsigned char RTL_ADDRESS, unsigned char ppdata)
  28          {
  29   1        INT8U xdata *tmp;
  30   1        tmp=MEMORY_MAPPED_RTL8019_OFFSET + (((unsigned char)(RTL_ADDRESS)) << 8);
  31   1        *tmp=ppdata;
  32   1      }
  33          
  34          
  35          
  36          /*****************************************************************************
  37          *  readRTL(RTL_ADDRESS)
  38          *  Args:        unsigned char RTL_ADDRESS - register offset of RTL register
  39          *  Created By:  Louis Beaudoin
  40          *  Date:        September 21, 2002
  41          *  Description: Reads byte from RTL8019 register
  42          *
  43          *  Notes - If using the External SRAM Interface, performs a read from
  44          *            address MEMORY_MAPPED_RTL8019_OFFSET + (RTL_ADDRESS<<8)
  45          *            The address is sent in the non-multiplxed upper address port so
  46          *            no latch is required.
  47          *
  48          *          If using general I/O ports, the data port is assumed to already be
  49          *            an input, and is left as an input port when done
  50          *
  51          *****************************************************************************/
  52          unsigned char readRTL(unsigned char RTL_ADDRESS)
  53          {
  54   1        INT8U xdata *tmp;
C51 COMPILER V7.06   RTL8019                                                               04/05/2006 12:13:02 PAGE 2   

  55   1        tmp=MEMORY_MAPPED_RTL8019_OFFSET + (((unsigned char)(RTL_ADDRESS)) << 8);
  56   1        return *tmp;
  57   1      }
  58                               
  59          /*****************************************************************************
  60          *  RTL8019setupPorts(void);
  61          *
  62          *  Created By:  Louis Beaudoin
  63          *  Date:        September 21, 2002
  64          *  Description: Sets up the ports used for communication with the RTL8019 NIC
  65          *                 (data bus, address bus, read, write, and reset)
  66          *****************************************************************************/
  67          void RTL8019setupPorts(void)
  68          {
  69   1      
  70   1      
  71   1      }
  72          /*****************************************************************************
  73          *  HARD_RESET_RTL8019()
  74          *
  75          *  Created By:  Louis Beaudoin
  76          *  Date:        September 21, 2002
  77          *  Description: Simply toggles the pin that resets the NIC
  78          *****************************************************************************/
  79          void HARD_RESET_RTL8019(void)
  80          {
  81   1        INT16U COUNT;
  82   1        for(COUNT=0;COUNT<1000;COUNT++);
  83   1        RST8019=1;
  84   1      //Delay_10ms(1);
  85   1        for(COUNT=0;COUNT<5000;COUNT++);
  86   1        RST8019=0;
  87   1        for(COUNT=0;COUNT<2000;COUNT++);
  88   1      }
  89          
  90          /*****************************************************************************
  91          *  overrun(void);
  92          *
  93          *  Created By:  Louis Beaudoin
  94          *  Date:        September 21, 2002
  95          *  Description: "Canned" receive buffer overrun function originally from
  96          *                 a National Semiconductor appnote
  97          *  Notes:       This function must be called before retreiving packets from
  98          *                 the NIC if there is a buffer overrun
  99          *****************************************************************************/
 100          void overrun(void);
 101          
 102          //******************************************************************
 103          //*     REALTEK CONTROL REGISTER OFFSETS
 104          //*   All offsets in Page 0 unless otherwise specified
 105          //*       All functions accessing CR must leave CR in page 0 upon exit
 106          //******************************************************************
 107          #define CR                      0x00
 108          #define PSTART          0x01
 109          #define PAR0            0x01    // Page 1
 110          #define CR9346          0x01    // Page 3
 111          #define PSTOP           0x02
 112          #define BNRY            0x03
 113          #define TSR                     0x04
 114          #define TPSR            0x04
 115          #define TBCR0           0x05
 116          #define NCR                     0x05
C51 COMPILER V7.06   RTL8019                                                               04/05/2006 12:13:02 PAGE 3   

 117          #define TBCR1           0x06
 118          #define ISR                     0x07
 119          #define CURR            0x07   // Page 1
 120          #define RSAR0           0x08
 121          #define CRDA0           0x08
 122          #define RSAR1           0x09
 123          #define CRDA1           0x09
 124          #define RBCR0           0x0A
 125          #define RBCR1           0x0B
 126          #define RSR                     0x0C
 127          #define RCR                     0x0C
 128          #define TCR                     0x0D
 129          #define CNTR0           0x0D
 130          #define DCR                     0x0E
 131          #define CNTR1           0x0E
 132          #define IMR                     0x0F
 133          #define CNTR2           0x0F
 134          #define RDMAPORT        0x10
 135          #define RSTPORT         0x18
 136          
 137          
 138          /*****************************************************************************
 139          *
 140          * RTL ISR Register Bits
 141          *
 142          *****************************************************************************/
 143          #define ISR_RST 7
 144          #define ISR_OVW 4
 145          #define ISR_PRX 0
 146          #define ISR_RDC 6
 147          #define ISR_PTX 1
 148          
 149          
 150          /*****************************************************************************
 151          *
 152          *  RTL Register Initialization Values
 153          *
 154          *****************************************************************************/
 155          // RCR : accept broadcast packets and packets destined to this MAC
 156          //         drop short frames and receive errors
 157          #define RCR_INIT                0x04
 158          
 159          // TCR : default transmit operation - CRC is generated 
 160          #define TCR_INIT                0x00
 161          
 162          // DCR : allows send packet to be used for packet retreival
 163          //         FIFO threshold: 8-bits (works)
 164          //         8-bit transfer mode
 165          #define DCR_INIT                0x58
 166          
 167          // IMR : interrupt enabled for receive and overrun events
 168          #define IMR_INIT                0x11
 169          
 170          // buffer boundaries - transmit has 6 256-byte pages
 171          //   receive has 26 256-byte pages
 172          //   entire available packet buffer space is allocated
 173          #define TXSTART_INIT    0x40
 174          #define RXSTART_INIT    0x46
 175          #define RXSTOP_INIT     0x60
 176          
 177          
 178          
C51 COMPILER V7.06   RTL8019                                                               04/05/2006 12:13:02 PAGE 4   

 179          void RTL8019beginPacketSend(unsigned int packetLength)
 180          {
 181   1              unsigned int sendPacketLength;
 182   1              sendPacketLength = (packetLength>=ETHERNET_MIN_PACKET_LENGTH) ?
 183   1                               packetLength : ETHERNET_MIN_PACKET_LENGTH ;
 184   1              
 185   1              //start the NIC
 186   1              writeRTL(CR,0x22);
 187   1              
 188   1              // still transmitting a packet - wait for it to finish
 189   1              while( readRTL(CR) & 0x04 );
 190   1      
 191   1              //load beginning page for transmit buffer
 192   1              writeRTL(TPSR,TXSTART_INIT);
 193   1              
 194   1              //set start address for remote DMA operation
 195   1              writeRTL(RSAR0,0x00);
 196   1              writeRTL(RSAR1,0x40);
 197   1              
 198   1              //clear the packet stored interrupt
 199   1              writeRTL(ISR,(1<<ISR_PTX));
 200   1      
 201   1              //load data byte count for remote DMA
 202   1              writeRTL(RBCR0, (unsigned char)(packetLength));
 203   1              writeRTL(RBCR1, (unsigned char)(packetLength>>8));
 204   1      
 205   1              writeRTL(TBCR0, (unsigned char)(sendPacketLength));
 206   1              writeRTL(TBCR1, (unsigned char)((sendPacketLength)>>8));
 207   1              
 208   1              //do remote write operation
 209   1              writeRTL(CR,0x12);
 210   1      }
 211          
 212          void RTL8019sendPacketData(unsigned char * localBuffer, unsigned int length)
 213          {
 214   1              unsigned int i;
 215   1              
 216   1              for(i=0;i<length;i++)
 217   1                      writeRTL(RDMAPORT, localBuffer[i]);
 218   1      }
 219          
 220          
 221          
 222          void RTL8019endPacketSend(void)
 223          {
 224   1              //send the contents of the transmit buffer onto the network
 225   1              writeRTL(CR,0x24);
 226   1              
 227   1              // clear the remote DMA interrupt
 228   1              writeRTL(ISR, (1<<ISR_RDC));
 229   1      }
 230          
 231          
 232          //----THE ABOVE IS FOR SEND--------------
 233          //----THE LIST  IS FOR RECEIVE-----------
 234          
 235          // pointers to locations in the RTL8019 receive buffer
 236          static unsigned char nextPage;
 237          static unsigned int currentRetreiveAddress;
 238          
 239          // location of items in the RTL8019's page header
 240          #define  enetpacketstatus     0x00
C51 COMPILER V7.06   RTL8019                                                               04/05/2006 12:13:02 PAGE 5   

 241          #define  nextblock_ptr        0x01
 242          #define  enetpacketLenL           0x02
 243          #define  enetpacketLenH           0x03
 244          
 245          unsigned int RTL8019beginPacketRetreive(void)

⌨️ 快捷键说明

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