This is WIZnet Ethernet Interface using Hardware TCP/IP chip, W5500, W5200 and W5100. One of them can be selected by enabling it in wiznet.h.
Dependents: Embedded_web EmailButton EmailButton HTTPClient_Weather ... more
other drivers
for only W5500 / WIZ550io user, you could use
Import libraryW5500Interface
This is the Interface library for WIZnet W5500 chip which forked of EthernetInterfaceW5500, WIZnetInterface and WIZ550ioInterface. This library has simple name as "W5500Interface". and can be used for Wiz550io users also.
Revision 8:cb8808b47e69, committed 2015-05-31
- Comitter:
- Bongjun
- Date:
- Sun May 31 10:25:40 2015 +0000
- Parent:
- 7:7c67a8922ec5
- Commit message:
- fix some codes of reading Sn_RX_RSR, Sn_TX_FSR in W5100.cpp, W5200.cpp; added is_fin_received() in W5100, W5200 files
Changed in this revision
--- a/WIZnetInterface/WIZnet/W5100.cpp Sun May 31 10:06:41 2015 +0000 +++ b/WIZnetInterface/WIZnet/W5100.cpp Sun May 31 10:25:40 2015 +0000 @@ -140,6 +140,18 @@ return false; } + +bool WIZnet_Chip::is_fin_received(int socket) +{ + uint8_t tmpSn_SR; + tmpSn_SR = sreg<uint8_t>(socket, Sn_SR); + // packet sending is possible, when state is SOCK_CLOSE_WAIT. + if (tmpSn_SR == SOCK_CLOSE_WAIT) { + return true; + } + return false; +} + void WIZnet_Chip::reset() { reset_pin = 1; @@ -202,7 +214,14 @@ t.reset(); t.start(); while(1) { - int size = sreg<uint16_t>(socket, Sn_TX_FSR); + //int size = sreg<uint16_t>(socket, Sn_TX_FSR); + // during the reading Sn_TX_FSR, it has the possible change of this register. + // so read twice and get same value then use size information. + int size, size2; + do { + size = sreg<uint16_t>(socket, Sn_TX_FSR); + size2 = sreg<uint16_t>(socket, Sn_TX_FSR); + } while (size != size2); if (size > req_size) { return size; }
--- a/WIZnetInterface/WIZnet/W5100.h Sun May 31 10:06:41 2015 +0000 +++ b/WIZnetInterface/WIZnet/W5100.h Sun May 31 10:25:40 2015 +0000 @@ -145,6 +145,13 @@ */ bool is_connected(int socket); + /* + * Check if FIN received. + * + * @returns true if successful + */ + bool is_fin_received(int socket); + /* * Close a tcp connection *
--- a/WIZnetInterface/WIZnet/W5200.cpp Sun May 31 10:06:41 2015 +0000 +++ b/WIZnetInterface/WIZnet/W5200.cpp Sun May 31 10:25:40 2015 +0000 @@ -102,6 +102,18 @@ return true; } + +bool WIZnet_Chip::is_fin_received(int socket) +{ + uint8_t tmpSn_SR; + tmpSn_SR = sreg<uint8_t>(socket, Sn_SR); + // packet sending is possible, when state is SOCK_CLOSE_WAIT. + if (tmpSn_SR == SOCK_CLOSE_WAIT) { + return true; + } + return false; +} + bool WIZnet_Chip::gethostbyname(const char* host, uint32_t* ip) { uint32_t addr = str_to_ip(host); @@ -171,7 +183,15 @@ t.reset(); t.start(); while(1) { - int size = sreg<uint16_t>(socket, Sn_RX_RSR); + //int size = sreg<uint16_t>(socket, Sn_RX_RSR); + // during the reading Sn_RX_RXR, it has the possible change of this register. + // so read twice and get same value then use size information. + int size, size2; + do { + size = sreg<uint16_t>(socket, Sn_RX_RSR); + size2 = sreg<uint16_t>(socket, Sn_RX_RSR); + } while (size != size2); + if (size > req_size) { return size; } @@ -191,7 +211,15 @@ t.reset(); t.start(); while(1) { - int size = sreg<uint16_t>(socket, Sn_TX_FSR); + //int size = sreg<uint16_t>(socket, Sn_TX_FSR); + // during the reading Sn_TX_FSR, it has the possible change of this register. + // so read twice and get same value then use size information. + int size, size2; + do { + size = sreg<uint16_t>(socket, Sn_TX_FSR); + size2 = sreg<uint16_t>(socket, Sn_TX_FSR); + } while (size != size2); + if (size > req_size) { return size; }
--- a/WIZnetInterface/WIZnet/W5200.h Sun May 31 10:06:41 2015 +0000 +++ b/WIZnetInterface/WIZnet/W5200.h Sun May 31 10:25:40 2015 +0000 @@ -147,6 +147,13 @@ */ bool is_connected(int socket); + /* + * Check if FIN received. + * + * @returns true if successful + */ + bool is_fin_received(int socket); + /* * Close a tcp connection *