Wednesday, September 23, 2009

W7100 Study Notes-W7100 parts of the firmware (firmware) parsing

With the launch of our new W7100 chipset, the firmware development is constantly updated and improved to meet the needs of different customers

The Hong Kong Branch of WIZnet Ltd. is now designing customized firmware to accommodate different applications.

Typically, users can easily use our hardware tcp/ip stack without in-depth knowledge of TCP/IP.
As the network protocol is fully processed by hardware, the user simply uses the driver which we provide, and calls different functions to complete various network tasks.
For example, if the user would like to connect by using TCP, the connect function should be called.

The user simply uses socket programming to control our chipset while leaving out the complicated details for our hardware TCP/IP core to process.
Here is my W7100 firmware for the connect function. As you can see, the internal operation of the function is not very difficult. The user can easily change the function to accommodate his/her needs.
int8 connect(SOCKET s, uint8 * addr, uint16 port)
{
uint8 xdata ret;

if
(
((addr[0] == 0xFF) && (addr[1] == 0xFF) && (addr[2] == 0xFF) && (addr[3] == 0xFF))
((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00))
(port == 0x00)
)
Check if the IP address and Port number is coorect (IP cannot be 255.255.255.255, or 0.0.0.0, port cannot be 0
{
ret = 0;
}
else
{
If IP and Port both no problem, continue
ret = 1;
// set destination IP
IINCHIP_WRITE(Sn_DIPR0(s),addr[0]); set Dest IP first byte
IINCHIP_WRITE((Sn_DIPR0(s) + 1),addr[1]);
IINCHIP_WRITE((Sn_DIPR0(s) + 2),addr[2]);
IINCHIP_WRITE((Sn_DIPR0(s) + 3),addr[3]);
IINCHIP_WRITE(Sn_DPORT0(s),(uint8)((port & 0xff00) >> 8)); dest Port lower byte
IINCHIP_WRITE((Sn_DPORT0(s) + 1),(uint8)(port & 0x00ff)); dest Port higher byte
IINCHIP_WRITE(Sn_CR(s),Sn_CR_CONNECT); exe the command of tcp connect
while ( IINCHIP_READ(Sn_CR(s)) ) ; // wait for completion CR
}

return ret;
}

Johnny

Translated from Johnny Yan 0n 13/09/2009
Direct link: http://blog.sina.com.cn/s/blog_61b952280100f1sl.html

No comments:

Post a Comment