📄 drv_8019.lst
字号:
C51 COMPILER V7.07 DRV_8019 04/20/2004 18:04:40 PAGE 1
C51 COMPILER V7.07, COMPILATION OF MODULE DRV_8019
OBJECT MODULE PLACED IN .\out\drv_8019.obj
COMPILER INVOKED BY: F:\Keil\C51\BIN\C51.EXE src\drv_8019.c BROWSE DEBUG OBJECTEXTEND PRINT(.\lst\drv_8019.lst) OBJECT(.
-\out\drv_8019.obj)
stmt level source
1 /*
2 * Copyright (C) 2002 by TechiZ. All rights reserved.
3 *
4 * This program was written in Korean(Comment and some more).
5 *
6 * This program was developed by TechiZ(The Company name).
7 * TechiZ want to share this program with you who loves the 8051 & the TCP/IP.
8 *
9 * You MUST DOWNLOAD THIS CODE from TechiZ Homepage.
10 * You DO NOT USE THIS CODE FOR COMMERCIAL PURPOSE.
11 * This code is ONLY FREE FOR THE STUDY.
12 * If you want more, send me E-mail.
13 *
14 * E-mail: techiz@techiz.com
15 * ( Subject is : [T89C51RD2 & TinyTCP] bla~ bla bla.... )
16 *
17 * Homepage: http://www.techiz.com
18 *
19 * You DO NOT DELETE THIS COPYRIGHT MESSAGE IN THE USING OF THIS CODE.
20 *
21 * In the using of this code, TechiZ does NOT GUARANTEE ABOUT WORKING WITHOUT ERROR.
22 */
23
24 /*****************************************************************************/
25 /* RTL8019AS DRIVER FUNCTIONS */
26 /*****************************************************************************/
27 #include <stdio.h>
28 #include <aduc812.h>
*** WARNING C318 IN LINE 28 OF src\drv_8019.c: can't open file 'aduc812.h'
29 #include "reg_8019.h"
30 #include "depend.h"
31
32 #define WARNING
33
34 /* H/W and IP Address */
35 extern ETHADDR sed_lclEthAddr;
36 //extern ETHADDR sed_ethBcastAddr;
37
38 void ethernet_register_test(void);
39 //void ethernet_get_8390_hdr(word StartAddr, word Count);
40 void ethernet_get_8390_hdr(word StartAddr, word Count) reentrant;
41 void ei_rx_overrun(void);
42 void ethernet_init(void);
43 void ethernet_test(void);
44 void DMA_write(byte *buffer, word StartAddr, word Count);
45 void ei_receive(void) reentrant;
46 //void ei_input(byte *buf, word StartAddr, word Count);
47 void ei_input(byte *buf, word StartAddr, word Count) reentrant;
48 void ei_output( BYTE *buf, WORD StartAddr, WORD Count );
49 BYTE sed_Receive( BYTE *buf );
50 BYTE *sed_IsPacket(void);
51 BYTE *sed_FormatPacket( BYTE *destEAddr, WORD ethType );
52 BYTE sed_CheckPacket( BYTE *BufLocation, WORD expectedType );
53 BYTE sed_Send( WORD pkLengthInOctets );
C51 COMPILER V7.07 DRV_8019 04/20/2004 18:04:40 PAGE 2
54
55 extern void delay(word d);
56 extern void delay_1ms(int times);
57 extern void putb_ser(byte byte_data);
58 extern void print(byte *ch);
59 extern void print_int(const byte *ch);
60 extern word address_ascii_to_hex_echo(void);
61 extern byte two_ascii_to_hex(void);
62 extern void Move( BYTE *src, BYTE *dest, WORD numbytes );
63
64 extern byte current_page;
65 extern byte next_pkt;
66 extern byte rx_frame_errors;
67 extern byte rx_crc_errors;
68 extern byte rx_missed_errors;
69 extern byte EthRxBufRdPtr;
70 extern byte EthRxBufWrPtr;
71 extern byte ethernet_8390_hdr[4];
72 extern byte EthRxBuf[NBUF][SBUFSIZ];
73 extern byte EthTxBuf[BUFSIZ];
74 extern longword pkt_cnt;
75
76 extern struct e8390_pkt_hdr {
77 byte status; /* status of receiver */
78 byte next; /* pointer to next packet. */
79 byte countl; /* header + packet length in bytes */
80 byte counth;
81 };
82
83 void DoS(void);
84
85 void DoS(void)
86 {
87 1 byte temp,count = 0x01,temp1=count;
88 1 word test_packet1_size;
89 1 code byte test_packet1[] = {0x00, 0x10, 0x4b, 0x18, 0xd8, 0x30, 0x00, 0x10,\
90 1 0x4b, 0x18, 0xd8, 0x31, 0x08, 0x00, 0x45, 0x00,\
91 1 0x00, 0x30, 0x05, 0x11, 0x40, 0x00, 0x80, 0x06,\
92 1 0x00, 0x00, 0xca, 0x1e, 0x14, 0xac, 0xca, 0x1e,\
93 1 0x14, 0xaa, 0x00, 0x50, 0x04, 0x47, 0xb2, 0x0e,\
94 1 0x02, 0x66, 0x4c, 0xb8, 0xec, 0x0a, 0x70, 0x12,\
95 1 0x44, 0x70, 0x8f, 0x3d, 0x00, 0x00, 0x02, 0x04,\
96 1 0x05, 0xb4, 0x01, 0x01, 0x04, 0x02};
97 1 EN0_IMR = 0x00; /* 价脚吝俊绰 牢磐反飘啊 救吧府霸 阜酒 初绰促. */
98 1 test_packet1_size = sizeof(test_packet1);
99 1
100 1 while(count--){
101 2 while ((temp=EN_CMD) & EN_TRANS);
102 2 DMA_write(test_packet1, 0x4000, test_packet1_size);
103 2 EN0_TPSR = NE_START_PG; /* Transmit starting page */
104 2 EN0_TCNTLO = test_packet1_size; /* Low byte of tx byte count */
105 2 EN0_TCNTHI = 0; /* High byte of tx byte count Transmit byte count register */
106 2 EN_CMD = EN_PAGE0 + EN_NODMA + EN_TRANS + EN_START; /* Transmit a frame */
107 2 }
108 1 EN0_IMR = ENISR_ALL; /* INTerrupt mask reg */
109 1 print("\n\rTotal Transmitted Packet is ");putb_ser(temp1);
110 1 }
111
112 BYTE sed_Receive( BYTE *buf )
113 {
114 1 return 0;
115 1 }
C51 COMPILER V7.07 DRV_8019 04/20/2004 18:04:40 PAGE 3
*** WARNING C280 IN LINE 112 OF SRC\DRV_8019.C: 'buf': unreferenced local variable
116
117 BYTE *sed_IsPacket(void)
118 {
119 1 BYTE *buf;
120 1 //BYTE *buf;
121 1
122 1 EthRxBufRdPtr++;
123 1 if ( EthRxBufRdPtr == NBUF )
124 1 EthRxBufRdPtr = 0;
125 1
126 1 if( EthRxBufRdPtr == EthRxBufWrPtr ) {
127 2 if ( EthRxBufRdPtr ) EthRxBufRdPtr--;
128 2 else EthRxBufRdPtr = NBUF-1;
129 2 return (BYTE *)NULL;
130 2 }
131 1
132 1 buf = &EthRxBuf[EthRxBufRdPtr][14]; /* ? size of array ? start of IP header */
133 1
134 1 if( EthRxBufRdPtr == NBUF )
135 1 EthRxBufRdPtr = 0;
136 1 return buf;
137 1 }
138
139 /* Make a MAC header */
140 BYTE *sed_FormatPacket( BYTE *destEAddr, WORD ethType )
141 {
142 1 Move( destEAddr, EthTxBuf, 6 ); /* Make a destination address */
143 1 Move( sed_lclEthAddr, EthTxBuf+6, 6 ); /* Make a source address */
144 1
145 1 *(WORD *)(EthTxBuf+12) = ethType; /* Make a Ethertype */
146 1 return ( EthTxBuf+14 );
147 1 }
148
149 BYTE sed_CheckPacket( BYTE *BufLocation, WORD expectedType )
150 {
151 1 if ( *(WORD *)(BufLocation-2) != expectedType ) {
152 2 return ( 0 );
153 2 }
154 1 return (1);
155 1 }
156
157 BYTE sed_Send( WORD pkLengthInOctets )
158 {
159 1 //WORD i;
160 1
161 1 if (EthTxBuf == NULL)
162 1 return 0;
163 1
164 1 if (pkLengthInOctets <= 0)
165 1 return 0;
166 1
167 1 pkLengthInOctets += 14; /* Ethernet Header */
168 1 if ( pkLengthInOctets < MIN_PACKET_SIZE )
169 1 pkLengthInOctets = MIN_PACKET_SIZE+4; /* CRC is 4Byte */
170 1
171 1 /* Mask interrupts from the ethercard. */
172 1 EN0_IMR = 0x00; /* ? */
173 1
174 1 /* Wait for other transmit */
175 1 while ( EN0_ISR & E8390_TRANS );
176 1 /* We should already be in page 0, but to be safe... */
C51 COMPILER V7.07 DRV_8019 04/20/2004 18:04:40 PAGE 4
177 1 EN_CMD = E8390_PAGE0 + E8390_START + E8390_NODMA;
178 1
179 1 #ifndef NE8390_RW_BUGFIX
180 1 EN0_RCNTLO = 0x42;
181 1 EN0_RCNTHI = 0x00;
182 1 EN0_RSARLO = 0x42;
183 1 EN0_RSARHI = 0x00;
184 1 EN_CMD = E8390_RREAD + E8390_START;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -