📄 socket.lst
字号:
C51 COMPILER V8.02 SOCKET 10/17/2006 16:52:42 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE SOCKET
OBJECT MODULE PLACED IN SOCKET.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE SOCKET.C BROWSE DEBUG OBJECTEXTEND
line level source
1 /*
2 ********************************************************************************
3 * Wiznet.
4 * 5F Simmtech Bldg., 228-3, Nonhyun-dong, Kangnam-gu,
5 * Seoul, Korea
6 *
7 * (c) Copyright 2002, Wiznet, Seoul, Korea
8 *
9 * Filename : socket.c
10 * Programmer(s) : Wooyoul Kim
11 * Version : 2.2
12 * Created : 2002/04/10
13 * Modified : 2002/06/20 - added delay in initseqnum() function
14 to complete write operation of TX Pointer Registers.
15 2002/09/27 - Vesion Up
16 - Global Interrupt Status Variable & MACRO Renaming
17 S_STATUS[] --> I_STATUS[]
18 INT_STATUS --> INT_REG
19 STATUS(i) --> INT_STATUS(i)
20 C_STATUS(i) --> SOCK_STATUS(i)
21 - When you read UDP or IP RAW Header at recvfrom() function, Verify Rx_Pointer Wrap-off
22 - At close() function, Modify "while(S_STATUS[s] != SCLOSED)" statement to while(!(S_STATUS[s] &
-SCLOSED)).
23 - At sendto()function, Checke previous send command before destination update
24 Error handling
25 - At select() and recvfrom() function,
26 Received UDP data process is modified 'packet size' to 'bulk size'
27 2002/10/20 - Version Up
28 - At select() function,
29 Modify to caculate free buffer size at UDP,IP_RAW protocol
30 2002/10/28 - Version Up
31 - At select(), integrated each received size caculation of TCP, UDP or IP_RAW into one calculation
-.
32 - At recvfrom(), Received data is processed by packet unit.
33
34 * Description : Driver API program of W3100A (Big Endian for Keil Compiler)
35 ********************************************************************************
36 */
37
38 /*
39 ###############################################################################
40 File Include Section
41 ###############################################################################
42 */
43 #include <at89x51.h> // 8051 SFR definition file
44 //#include <stdio.h>
45 #include "serial.h" // serial related functions
46 #include "socket.h" // W3100A driver file
47
48 /*
49 ###############################################################################
50 Define Part
51 ###############################################################################
52 */
53 //#define DEBUG // Add debugging code
C51 COMPILER V8.02 SOCKET 10/17/2006 16:52:42 PAGE 2
54
55 /*
56 ###############################################################################
57 Local Variable Declaration Section
58 ###############################################################################
59 */
60 u_char xdata I_STATUS[4]; // Store Interrupt Status according to channels
61 u_int xdata Local_Port; // Designate Local Port
62 un_l2cval xdata SEQ_NUM; // Set initial sequence number
63
64 u_long xdata SMASK[MAX_SOCK_NUM]; // Variable to store MASK of Tx in each channel, on setting dynamic
- memory size.
65 u_long xdata RMASK[MAX_SOCK_NUM]; // Variable to store MASK of Rx in each channel, on setting dynamic
- memory size.
66 int xdata SSIZE[MAX_SOCK_NUM]; // Maximun Tx memory size by each channel
67 int xdata RSIZE[MAX_SOCK_NUM]; // Maximun Rx memory size by each channel
68 u_char xdata* SBUFBASEADDRESS[MAX_SOCK_NUM]; // Maximun Tx memory base address by each channel
69 u_char xdata* RBUFBASEADDRESS[MAX_SOCK_NUM]; // Maximun Rx memory base address by each channel
70
71 /*
72 ###############################################################################
73 Function Implementation Section
74 ###############################################################################
75 */
76
77
78 /*
79 ********************************************************************************
80 * Interrupt handling function of the W3100A
81 *
82 * Description :
83 * Stores the status information that each function waits for in the global variable S_STATUS for transfe
-r.
84 * S_STATUS stores the interrupt status value for each channel.
85 * Arguments : None
86 * Returns : None
87 * Note : Internal Function
88 ********************************************************************************
89 */
90 void Int0(void) interrupt 0
91 {
92 1 u_char status;
93 1
94 1 EX0 = 0; // INT0 DISABLE
95 1
96 1 status = INT_REG;
97 1
98 1 while (status) {
99 2 if (status & 0x01) { // channel 0 interrupt(sysinit, sockinit, established, closed, timeout, send_o
-k, recv_ok)
100 3 I_STATUS[0] = INT_STATUS(0);
101 3
102 3 // if (I_STATUS[0] & SESTABLISHED) ISR_ESTABLISHED(0);
103 3 // if (I_STATUS[0] & SCLOSED) ISR_CLOSED(0);
104 3
105 3 INT_REG = 0x01;
106 3 }
107 2
108 2 if (status & 0x02) { // channel 1 interrupt(sysinit, sockinit, established, closed, timeout, send_o
-k, recv_ok)
109 3 I_STATUS[1] = INT_STATUS(1);
110 3
C51 COMPILER V8.02 SOCKET 10/17/2006 16:52:42 PAGE 3
111 3 // if (I_STATUS[1] & SESTABLISHED) ISR_ESTABLISHED(1);
112 3 // if (I_STATUS[1] & SCLOSED) ISR_CLOSED(1);
113 3
114 3 INT_REG = 0x02;
115 3 }
116 2
117 2 if (status & 0x04) { // channel 2 interrupt(sysinit, sockinit, established, closed, timeout, send_o
-k, recv_ok)
118 3 I_STATUS[2] = INT_STATUS(2);
119 3
120 3 // if (I_STATUS[2] & SESTABLISHED) ISR_ESTABLISHED(2);
121 3 // if (I_STATUS[2] & SCLOSED) ISR_CLOSED(2);
122 3
123 3 INT_REG = 0x04;
124 3 }
125 2
126 2 if (status & 0x08) { // channel 3 interrupt(sysinit, sockinit, established, closed, timeout, send_o
-k, recv_ok)
127 3 I_STATUS[3] = INT_STATUS(3);
128 3
129 3 // if (I_STATUS[3] & SESTABLISHED) ISR_ESTABLISHED(3);
130 3 // if (I_STATUS[3] & SCLOSED) ISR_CLOSED(3);
131 3
132 3 INT_REG = 0x08;
133 3 }
134 2
135 2 if (status & 0x10) { // channel 0 receive interrupt
136 3 // ISR_RX(0);
137 3 INT_REG = 0x10;
138 3 }
139 2
140 2 if (status & 0x20) { // channel 1 receive interrupt
141 3 // ISR_RX(1);
142 3 INT_REG = 0x20;
143 3 }
144 2
145 2 if (status & 0x40) { // channel 2 receive interrupt
146 3 // ISR_RX(2);
147 3 INT_REG = 0x40;
148 3 }
149 2
150 2 if (status & 0x80) { // channel 3 receive interrupt
151 3 // ISR_RX(3);
152 3 INT_REG = 0x80;
153 3 }
154 2
155 2 status = INT_REG;
156 2 }
157 1
158 1 INT_REG = 0xFF;
159 1
160 1 EX0 = 1;
161 1 }
162
163 /*
164 ********************************************************************************
165 * Established connection interrupt handling function.
166 *
167 * Description :
168 * Called upon connection establishment, and may be inserted in user code if needed by the programmer.
169 * Arguments : None
170 * Returns : None
C51 COMPILER V8.02 SOCKET 10/17/2006 16:52:42 PAGE 4
171 * Note : Internal Function
172 ********************************************************************************
173 */
174 /*
175 void ISR_ESTABLISHED(SOCKET s)
176 {
177 // TO ADD YOUR CODE
178 }
179 */
180
181 /*
182 ********************************************************************************
183 * Closed connection interrupt handling function
184 *
185 * Description :
186 * Called upon connection closure, and may be inserted in user code if needed by the programmer.
187 * Arguments : None
188 * Returns : None
189 * Note : Internal Function
190 ********************************************************************************
191 */
192 /*
193 void ISR_CLOSED(SOCKET s)
194 {
195 // TO ADD YOUR CODE
196 }
197 */
198
199 /*
200 ********************************************************************************
201 * Received data interrupt handling function
202 *
203 * Description :
204 * Called upon receiving data, and may be inserted in user code if needed by the programmer.
205 * Arguments : None
206 * Returns : None
207 * Note : Internal Function
208 ********************************************************************************
209 */
210 /*
211 void ISR_RX(SOCKET s)
212 {
213 // TO ADD YOUR CODE
214 }
215 */
216
217 /*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -