`
dogasshole
  • 浏览: 843342 次
文章分类
社区版块
存档分类
最新评论

W7100学习笔记 -W7100部分固件(firmware)解析

 
阅读更多
随着W7100的全新推出,其固件的开发也在不断更新和完善,从而满足不同客户的需求。
WIZnet香港分公司可以针对客户的需要,为不同应用设计适合的固件。
通常情况下,用户使用我们的芯片要比软件协议栈容易的多。由于网络协议全硬件处理,用户只需使用我们提供的驱动程序,调用我们写好的函数,即可完成各项网络功能。
举例来说,如果用户想建议里一个TCP的链接,只需调用connect函数即可。而无需理会connect函数内部的操作。
下面是我对W7100的固件connect函数的注解。其中可以看到,connect函数内部操作其实也不难,即使用户希望自己更改固件,难度也并不大。

uint8 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;

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics