📄 rtl8019.lst
字号:
C51 COMPILER V8.05a RTL8019 11/16/2006 19:20:21 PAGE 1
C51 COMPILER V8.05a, COMPILATION OF MODULE RTL8019
OBJECT MODULE PLACED IN .\RTL8019.obj
COMPILER INVOKED BY: C:\Keil\keil\C51\BIN\C51.EXE ..\Netif\RTL8019.c BROWSE DEBUG OBJECTEXTEND PRINT(.\RTL8019.lst) OBJE
-CT(.\RTL8019.obj)
line level source
1 /*
2 * Copyright (c) 2003 Electronic Engineering department of NAN KAI university
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 * OF SUCH DAMAGE.
26 *
27 * Author: zlin <wzzlin@eyou.com>
28 *
29 */
30 #include "..\GloblDef\GloblDef.h"
31 #include "..\TCPIP\TCPIPmem.h"
32 #include "..\Netif\RTL8019.h"
33
34 /* to prevent call RTLSendPacket() when RTLSendPackt() is already is called, InSending
35 is used. example when process run in RTLSendPacket() and a interrupt ocurr then call
36 RTLSendPacket again, then the Register would have changed when interrupt return. */
37 static BYTE DT_XDATA InSending;
38
39 sbit reset8019=P3^4;
40 void rtl8019as_rst();
41
42
43 void rtl8019as_rst()
44 {
45 1 unsigned int idata i;
46 1
47 1 reset8019=1; /*采用冷启动复位 */
48 1 for(i=0;i<250;i++);
49 1 reset8019=0;
50 1 for(i=0;i<250;i++);
51 1 }
52
53
54
C51 COMPILER V8.05a RTL8019 11/16/2006 19:20:21 PAGE 2
55 static BYTE DT_XDATA StartPageOfPacket;
56 /* receive head information */
57 /*struct RTLReceiveHeader
58 {
59 BYTE ReceiveStatus;
60 BYTE NextPacketStartPage;
61 BYTE PacketSizeLow;
62 BYTE PacketSizeHigh;
63 }Head;for some unknown resean Head must be a gloal value. */
64 static BYTE DT_XDATA Head[4];
65
66 /* last trasmit start page */
67 static BYTE DT_XDATA LastSendStartPage;
68
69 /* read rtl8019 register. port is reg address */
70 /*BYTE ReadReg(WORD port)
71 {
72 return *((BYTE xdata *)port);
73 }*/
74 #define ReadReg(port) (*((BYTE DT_XDATA *)port))
75
76 /* write value to register */
77 /*void WriteReg(WORD port,BYTE value)
78 {
79 *((BYTE xdata *)port) = value;
80 }*/
81 #define WriteReg(port,value) (*((BYTE DT_XDATA *)port) = value)
82
83 /* select which page of register to use*/
84 /* TO DO:set bit 7-6 in CR, CR_TXP must be 0(if 1 the packet is retrasmit) */
85 #define RTLPage(Index) WriteReg(CR,(ReadReg(CR) & 0x3B)|(BYTE)(Index << 6))
86
87 /* reset rtl8019 and init registers, LocalMacAddr is MAC address */
88 void RTLInit(BYTE LocalMACAddr[]) REENTRANT_MUL
89 {
90 1 BYTE temp;
91 1 int i;
92 1
93 1
94 1 rtl8019as_rst();
95 1
96 1
97 1 /* after hardware reset a longdelay is necessary for rtl to self-initial */
98 1 for(i=0; i < RTL_DELAY_AFTER_HARDWARE_RESET; i++);
99 1
100 1 /* reset: write to reset prot */
101 1 temp = ReadReg(RESET_PORT);
102 1 WriteReg(RESET_PORT,temp);
103 1
104 1 /* init RTL registers*/
105 1 WriteReg(CR,(CR_PAGE0 | CR_ABORT_COMPLETE_DMA | CR_STOP_COMMAND)); /* set page0, stop command. command is
- stop after power up. */
106 1
107 1 WriteReg(PSTART_WPAGE0, RECEIVE_START_PAGE); /* Pstart */
108 1 WriteReg(PSTOP_WPAGE0, RECEIVE_STOP_PAGE); /* Pstop */
109 1 WriteReg(BNRY_WPAGE0, RECEIVE_START_PAGE); /* BNRY */
110 1 WriteReg(TPSR_WPAGE0, SEND_START_PAGE0); /* TPSR */
111 1
112 1 WriteReg(RCR_WPAGE0, 0xCE); /* RCR: refer to define of RCR in Rtl8019as.h */
113 1 WriteReg(TCR_WPAGE0, 0xE0); /* TCR: refer to define of TCR in Rtl8019as.h */
114 1 WriteReg(DCR_WPAGE0, 0xC8); /* DCR: refer to define of DCR in Rtl8019as.h */
115 1
C51 COMPILER V8.05a RTL8019 11/16/2006 19:20:21 PAGE 3
116 1 WriteReg(IMR_WPAGE0,0); /* RTL recieve interrupt enabled */
117 1 WriteReg(ISR_WPAGE0, 0xFF); /* write FF to clear up all interrupt status */
118 1
119 1 RTLPage(1);
120 1
121 1 WriteReg(CURR_WPAGE1,RECEIVE_START_PAGE + 1);
122 1
123 1 /* MAR0 */
124 1 /*WriteReg(0x08,0x00);
125 1 WriteReg(0x09,0x41);
126 1 WriteReg(0x0a,0x00);
127 1 WriteReg(0x0b,0x80);
128 1 WriteReg(0x0c,0x00);
129 1 WriteReg(0x0d,0x00);
130 1 WriteReg(0x0e,0x00);
131 1 WriteReg(0x0f,0x00);*/
132 1
133 1 /* set phisical address */
134 1 WriteReg(PRA0_WPAGE1,LocalMACAddr[0]);
135 1 WriteReg(PRA1_WPAGE1,LocalMACAddr[1]);
136 1 WriteReg(PRA2_WPAGE1,LocalMACAddr[2]);
137 1 WriteReg(PRA3_WPAGE1,LocalMACAddr[3]);
138 1 WriteReg(PRA4_WPAGE1,LocalMACAddr[4]);
139 1 WriteReg(PRA5_WPAGE1,LocalMACAddr[5]);
140 1
141 1 /* transimit start page */
142 1 LastSendStartPage = SEND_START_PAGE0;
143 1 StartPageOfPacket = RECEIVE_START_PAGE + 1;
144 1
145 1 /* in the beginning, no packet is in sending */
146 1 InSending = FALSE;
147 1
148 1 /* initial over, start command and receive */
149 1 WriteReg(CR,(CR_PAGE0 | CR_ABORT_COMPLETE_DMA | CR_START_COMMAND));
150 1 }
151
152 /* write buffer to rlt ram */
153 void RTLWriteRam(WORD address, WORD size, BYTE DT_XDATA * buff) REENTRANT_SIG
154 {
155 1 BYTE DT_XDATA *Endp;
156 1 BYTE PrePage; /* store page */
157 1 PrePage = ReadReg(CR);
158 1 RTLPage(0);
159 1 WriteReg(RSARH_WPAGE0,(BYTE)((address>>8)&0x00ff));
160 1 WriteReg(RSARL_WPAGE0,(BYTE)address);
161 1 WriteReg(RBCRH_WPAGE0,(BYTE)((size>>8)&0x00ff));
162 1 WriteReg(RBCRL_WPAGE0,(BYTE)size);
163 1 WriteReg(CR,(0x00 | CR_REMOTE_WRITE | CR_START_COMMAND));
164 1 for(Endp = buff + size; buff < Endp;)
165 1 {
166 2 WriteReg(REMOTE_DMA_PORT,*(buff++));
167 2 }
168 1 /* complete dma */
169 1 WriteReg(RBCRH_WPAGE0,0);
170 1 WriteReg(RBCRL_WPAGE0,0);
171 1 WriteReg(CR,((PrePage&0xC0) | CR_ABORT_COMPLETE_DMA | CR_START_COMMAND));
172 1 }
173
174 /* read rlt ram data to buffer */
175 void RTLReadRam(WORD address,WORD size,BYTE DT_XDATA * buff) REENTRANT_MUL
176 {
177 1 BYTE DT_XDATA * Endp;
C51 COMPILER V8.05a RTL8019 11/16/2006 19:20:21 PAGE 4
178 1 BYTE PrePage; /* store page */
179 1
180 1 PrePage = ReadReg(CR);
181 1 RTLPage(0);
182 1 WriteReg(RSARH_WPAGE0,(BYTE)((address>>8)&0x00ff));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -