diff options
author | Damien George <damien.p.george@gmail.com> | 2014-09-01 00:06:05 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-09-01 22:52:37 +0100 |
commit | 7da9145e470fd223084f673dc4727ec08a7789dc (patch) | |
tree | b3fe23f3f5f71e2188f825292c88ff41ce862fc1 /drivers/wiznet5k/ethernet/socket.c | |
parent | 0c0550bff0d9a64c842c8247d364e1cc4a5cef87 (diff) |
drivers, wiznet5k: Properly fix ARP bug with W5200 chipset.
Diffstat (limited to 'drivers/wiznet5k/ethernet/socket.c')
-rw-r--r-- | drivers/wiznet5k/ethernet/socket.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/wiznet5k/ethernet/socket.c b/drivers/wiznet5k/ethernet/socket.c index 4c2348139..79e082cb5 100644 --- a/drivers/wiznet5k/ethernet/socket.c +++ b/drivers/wiznet5k/ethernet/socket.c @@ -204,13 +204,19 @@ int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port) setSn_DIPR(sn,addr); setSn_DPORT(sn,port); #if _WIZCHIP_ == 5200 // for W5200 ARP errata - setSUBR(0); + setSUBR(wizchip_getsubn()); #endif setSn_CR(sn,Sn_CR_CONNECT); while(getSn_CR(sn)); if(sock_io_mode & (1<<sn)) return SOCK_BUSY; while(getSn_SR(sn) != SOCK_ESTABLISHED) { + if (getSn_SR(sn) == SOCK_CLOSED) { + #if _WIZCHIP_ == 5200 // for W5200 ARP errata + setSUBR((uint8_t*)"\x00\x00\x00\x00"); + #endif + return SOCKERR_SOCKCLOSED; + } if (getSn_IR(sn) & Sn_IR_TIMEOUT) { setSn_IR(sn, Sn_IR_TIMEOUT); @@ -390,15 +396,12 @@ int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t wiz_send_data(sn, buf, len); #if _WIZCHIP_ == 5200 // for W5200 ARP errata - setSUBR(0); + setSUBR(wizchip_getsubn()); #endif setSn_CR(sn,Sn_CR_SEND); /* wait to process the command... */ while(getSn_CR(sn)); - #if _WIZCHIP_ == 5200 // for W5200 ARP errata - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - #endif while(1) { tmp = getSn_IR(sn); @@ -412,10 +415,16 @@ int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t else if(tmp & Sn_IR_TIMEOUT) { setSn_IR(sn, Sn_IR_TIMEOUT); + #if _WIZCHIP_ == 5200 // for W5200 ARP errata + setSUBR((uint8_t*)"\x00\x00\x00\x00"); + #endif return SOCKERR_TIMEOUT; } //////////// } + #if _WIZCHIP_ == 5200 // for W5200 ARP errata + setSUBR((uint8_t*)"\x00\x00\x00\x00"); + #endif return len; } |