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.

Dependents:   EvrythngApi Websocket_Ethernet_HelloWorld_W5500 Websocket_Ethernet_W5500 CurrentWeatherData_W5500 ... more

Information

It has EthernetInterface class like official EthernetInterface , but uses Wiznet chip driver codes.

So this library can use only the WIZnet W5500 or WIZ550io users.

This library has referred to many project such as WIZ550ioInterface, WiflyInterface and WIZnet Library.

Thanks all.

Committer:
embeddist
Date:
Tue Apr 28 13:52:23 2015 +0000
Revision:
11:5499fa2d8898
Parent:
6:677dfa3984d1
Remove the setting of tx/rx buffer in SWReset

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Bongjun 0:e11e8793c3ce 1 // EthernetInterface for W5500 2014/8/20
Bongjun 0:e11e8793c3ce 2
Bongjun 0:e11e8793c3ce 3 #pragma once
Bongjun 0:e11e8793c3ce 4 #include "wiznet.h"
Bongjun 0:e11e8793c3ce 5
Bongjun 0:e11e8793c3ce 6 /** Interface using Wiznet W5500 chip to connect to an IP-based network
Bongjun 0:e11e8793c3ce 7 *
Bongjun 0:e11e8793c3ce 8 */
embeddist 11:5499fa2d8898 9
embeddist 11:5499fa2d8898 10
Bongjun 0:e11e8793c3ce 11 class EthernetInterface: public WIZnet_Chip {
Bongjun 0:e11e8793c3ce 12 public:
Bongjun 0:e11e8793c3ce 13
Bongjun 0:e11e8793c3ce 14 /**
Bongjun 0:e11e8793c3ce 15 * Constructor
Bongjun 0:e11e8793c3ce 16 *
Bongjun 0:e11e8793c3ce 17 * \param mosi mbed pin to use for SPI
Bongjun 0:e11e8793c3ce 18 * \param miso mbed pin to use for SPI
Bongjun 0:e11e8793c3ce 19 * \param sclk mbed pin to use for SPI
Bongjun 0:e11e8793c3ce 20 * \param cs chip select of the WIZnet_Chip
Bongjun 0:e11e8793c3ce 21 * \param reset reset pin of the WIZnet_Chip
Bongjun 0:e11e8793c3ce 22 */
Bongjun 0:e11e8793c3ce 23 EthernetInterface(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset);
Bongjun 0:e11e8793c3ce 24 EthernetInterface(SPI* spi, PinName cs, PinName reset);
Bongjun 0:e11e8793c3ce 25
Bongjun 0:e11e8793c3ce 26 /** Initialize the interface with DHCP w/o MAC address
Bongjun 0:e11e8793c3ce 27 * Initialize the interface and configure it to use DHCP (no connection at this point).
Bongjun 0:e11e8793c3ce 28 * \return 0 on success, a negative number on failure
Bongjun 0:e11e8793c3ce 29 */
Bongjun 0:e11e8793c3ce 30 int init(); //With DHCP
Bongjun 0:e11e8793c3ce 31 /** Initialize the interface with DHCP.
Bongjun 0:e11e8793c3ce 32 * Initialize the interface and configure it to use DHCP (no connection at this point).
Bongjun 0:e11e8793c3ce 33 * \param mac the MAC address to use
Bongjun 0:e11e8793c3ce 34 * \return 0 on success, a negative number on failure
Bongjun 0:e11e8793c3ce 35 */
Bongjun 0:e11e8793c3ce 36 int init(uint8_t * mac); //With DHCP
Bongjun 0:e11e8793c3ce 37
Bongjun 0:e11e8793c3ce 38 /** Initialize the interface with a static IP address without MAC.
Bongjun 0:e11e8793c3ce 39 * Initialize the interface and configure it with the following static configuration (no connection at this point).
Bongjun 0:e11e8793c3ce 40 * \param ip the IP address to use
Bongjun 0:e11e8793c3ce 41 * \param mask the IP address mask
Bongjun 0:e11e8793c3ce 42 * \param gateway the gateway to use
Bongjun 0:e11e8793c3ce 43 * \return 0 on success, a negative number on failure
Bongjun 0:e11e8793c3ce 44 */
Bongjun 0:e11e8793c3ce 45
Bongjun 0:e11e8793c3ce 46 int init(const char* ip, const char* mask, const char* gateway);
Bongjun 0:e11e8793c3ce 47 /** Initialize the interface with a static IP address.
Bongjun 0:e11e8793c3ce 48 * Initialize the interface and configure it with the following static configuration (no connection at this point).
Bongjun 0:e11e8793c3ce 49 * \param mac the MAC address to use
Bongjun 0:e11e8793c3ce 50 * \param ip the IP address to use
Bongjun 0:e11e8793c3ce 51 * \param mask the IP address mask
Bongjun 0:e11e8793c3ce 52 * \param gateway the gateway to use
Bongjun 0:e11e8793c3ce 53 * \return 0 on success, a negative number on failure
Bongjun 0:e11e8793c3ce 54 */
Bongjun 0:e11e8793c3ce 55 int init(uint8_t * mac, const char* ip, const char* mask, const char* gateway);
Bongjun 0:e11e8793c3ce 56
Bongjun 0:e11e8793c3ce 57 /** Connect
Bongjun 0:e11e8793c3ce 58 * Bring the interface up, start DHCP if needed.
Bongjun 0:e11e8793c3ce 59 * \return 0 on success, a negative number on failure
Bongjun 0:e11e8793c3ce 60 */
Bongjun 0:e11e8793c3ce 61 int connect();
Bongjun 0:e11e8793c3ce 62
Bongjun 0:e11e8793c3ce 63 /** Disconnect
Bongjun 0:e11e8793c3ce 64 * Bring the interface down
Bongjun 0:e11e8793c3ce 65 * \return 0 on success, a negative number on failure
Bongjun 0:e11e8793c3ce 66 */
Bongjun 0:e11e8793c3ce 67 int disconnect();
Bongjun 0:e11e8793c3ce 68
Bongjun 0:e11e8793c3ce 69 /** Get IP address
Bongjun 0:e11e8793c3ce 70 *
Bongjun 0:e11e8793c3ce 71 * @ returns ip address
Bongjun 0:e11e8793c3ce 72 */
Bongjun 0:e11e8793c3ce 73 char* getIPAddress();
Bongjun 0:e11e8793c3ce 74 char* getNetworkMask();
Bongjun 0:e11e8793c3ce 75 char* getGateway();
Bongjun 0:e11e8793c3ce 76 char* getMACAddress();
Bongjun 0:e11e8793c3ce 77
Bongjun 0:e11e8793c3ce 78 int IPrenew(int timeout_ms = 15*1000);
Bongjun 0:e11e8793c3ce 79
Bongjun 0:e11e8793c3ce 80 private:
embeddist 11:5499fa2d8898 81 char ip_string[17];
embeddist 11:5499fa2d8898 82 char mask_string[17];
embeddist 11:5499fa2d8898 83 char gw_string[17];
Bongjun 0:e11e8793c3ce 84 char mac_string[20];
Bongjun 0:e11e8793c3ce 85 bool ip_set;
embeddist 11:5499fa2d8898 86 void getip(void);
Bongjun 0:e11e8793c3ce 87 };
Bongjun 0:e11e8793c3ce 88
Bongjun 0:e11e8793c3ce 89 #include "TCPSocketConnection.h"
Bongjun 0:e11e8793c3ce 90 #include "TCPSocketServer.h"
Bongjun 0:e11e8793c3ce 91 #include "UDPSocket.h"