WIZnetInterface using namespace

Dependents:   DualNetworkInterface-Basic

Fork of WIZnetInterface by WIZnet

Revision:
8:4c02de1dbf3a
Parent:
6:94a81e80c675
Child:
9:40d25592e6a0
--- a/arch/ext/W5500.h	Mon Jun 15 23:43:56 2015 +0000
+++ b/arch/ext/W5500.h	Tue Jun 16 11:11:11 2015 +0900
@@ -26,9 +26,6 @@
 
 #define DEFAULT_WAIT_RESP_TIMEOUT 500
 
-
-
-
 #define SOCK_ERROR            0        
 #define SOCKERR_SOCKNUM       (SOCK_ERROR - 1)     ///< Invalid socket number
 #define SOCKERR_SOCKOPT       (SOCK_ERROR - 2)     ///< Invalid socket option
@@ -54,7 +51,6 @@
 #define SUBR      0x0005
 #define SHAR      0x0009
 #define SIPR      0x000f
-#define INTLEVEL  0x0013
 #define IR        0x0015
 #define IMR       0x0016
 #define SIR       0x0017
@@ -116,8 +112,6 @@
 #define Sn_IR_DISCON                 0x02
 #define Sn_IR_CON                    0x01
 
-
-
 /* PHYCFGR register value */
 #define PHYCFGR_RST                  ~(1<<7)  //< For PHY reset, must operate AND mask.
 #define PHYCFGR_OPMD                 (1<<6)   // Configre PHY with OPMDC value
@@ -150,6 +144,14 @@
 #define PHY_POWER_NORM           0     ///< PHY power normal mode
 #define PHY_POWER_DOWN           1     ///< PHY power down mode 
 
+enum PHYMode {
+	AutoNegotiate = 0,
+	HalfDuplex10  = 1,
+	FullDuplex10  = 2,
+	HalfDuplex100 = 3,
+	FullDuplex100 = 4,
+};
+
 class WIZnet_Chip {
 public:
 enum Protocol {
@@ -217,13 +219,6 @@
     bool setip();
 
     /*
-    * Get Link Status
-    *
-    * @return true if Link up, false Link down
-    */
-    bool linkstatus();
-
-    /*
     * Disconnect the connection
     *
     * @ returns true 
@@ -257,6 +252,20 @@
     int wait_writeable(int socket, int wait_time_ms, int req_size = 0);
 
     /*
+    * Check if an ethernet link is pressent or not.
+    *
+    * @returns true if successful
+    */
+    bool link(int wait_time_ms= 3*1000);
+
+    /*
+    * Sets the speed and duplex parameters of an ethernet link.
+    *
+	* @returns true if successful
+    */
+    void set_link(PHYMode phymode);
+
+    /*
     * Check if a tcp link is active
     *
     * @returns true if successful
@@ -1012,6 +1021,8 @@
     DigitalOut cs;
     DigitalOut reset_pin;
 };
+extern int ethernet_link(void);
+extern void ethernet_set_link(int speed, int duplex);
 
 extern uint32_t str_to_ip(const char* str);
 extern void printfBytes(char* str, uint8_t* buf, int len);