WIZNet W5500 with additional enhancements

Fork of WIZnetInterface by WIZnet

Files at this revision

API Documentation at this revision

Comitter:
Helmut Tschemernjak
Date:
Sat Oct 07 22:10:01 2017 +0200
Parent:
32:f6d76a55a50b
Child:
34:7d44648ec5f2
Commit message:
Added support to read the Ethernet speed, duplex mode, link status
and DNS address.

Changed in this revision

EthernetInterface.cpp Show annotated file Show diff for this revision Revisions of this file
EthernetInterface.h Show annotated file Show diff for this revision Revisions of this file
arch/ext/W5500.cpp Show annotated file Show diff for this revision Revisions of this file
arch/ext/W5500.h Show annotated file Show diff for this revision Revisions of this file
--- a/EthernetInterface.cpp	Sat Oct 07 16:26:55 2017 +0200
+++ b/EthernetInterface.cpp	Sat Oct 07 22:10:01 2017 +0200
@@ -127,6 +127,18 @@
     return gw_string;
 }
 
+
+char* EthernetInterface::getDNSServer()
+{
+    uint32_t ip = getDNSAddr();
+    snprintf(gw_string, sizeof(gw_string), "%d.%d.%d.%d",
+             (uint8_t)((ip>>24)&0xff),
+             (uint8_t)((ip>>16)&0xff),
+             (uint8_t)((ip>>8)&0xff),
+             (uint8_t)(ip&0xff));
+    return gw_string;
+}
+
 char* EthernetInterface::getMACAddress()
 {
     uint8_t mac[6];
--- a/EthernetInterface.h	Sat Oct 07 16:26:55 2017 +0200
+++ b/EthernetInterface.h	Sat Oct 07 22:10:01 2017 +0200
@@ -74,6 +74,7 @@
   char* getIPAddress();
   char* getNetworkMask();
   char* getGateway();
+  char* getDNSServer();
   char* getMACAddress();
 
   int IPrenew(int timeout_ms = 15*1000);
--- a/arch/ext/W5500.cpp	Sat Oct 07 16:26:55 2017 +0200
+++ b/arch/ext/W5500.cpp	Sat Oct 07 22:10:01 2017 +0200
@@ -471,9 +471,21 @@
 
 int WIZnet_Chip::ethernet_link(void) {
 	int val = getPHYCFGR();
-	return (val&0x01);
+	return val & 0x01;
+}
+
+int WIZnet_Chip::ethernet_speed(void) {
+    int val = getPHYCFGR();
+    return val &0x02 ? 100 : 10;
 }
 
+bool WIZnet_Chip::ethernet_fullduplex(void) {
+    int val = getPHYCFGR();
+    return val & 0x04;
+}
+
+
+
 void WIZnet_Chip::ethernet_set_link(int speed, int duplex) {
 	uint32_t val=0;
 	if((speed < 0) || (speed > 1)) {
--- a/arch/ext/W5500.h	Sat Oct 07 16:26:55 2017 +0200
+++ b/arch/ext/W5500.h	Sat Oct 07 22:10:01 2017 +0200
@@ -983,7 +983,13 @@
 
 
 	int ethernet_link(void);
+    int ethernet_speed(void);
+    bool ethernet_fullduplex(void);
 	void ethernet_set_link(int speed, int duplex);
+    
+    uint32_t getDNSAddr(void) {
+        return dnsaddr;
+    };
 protected:
     uint8_t mac[6];
     uint32_t ip;