A stack which works with or without an Mbed os library. Provides IPv4 or IPv6 with a full 1500 byte buffer.

Dependents:   oldheating gps motorhome heating

Revision:
63:9d67a5eaa93c
Parent:
61:aad055f1b0d1
Child:
67:b89a81c6ed99
--- a/link/link.c	Tue Jan 16 17:35:16 2018 +0000
+++ b/link/link.c	Tue Jan 16 22:03:16 2018 +0000
@@ -11,37 +11,19 @@
 
 #define  phyLinkNeg_MASK 1UL << 25 //P1.25 input
 #define phySpeedNeg_MASK 1UL << 26 //P1.26 input
-#define   ethLedGrL_MASK 1UL << 31 //P1.31 ==> p20 output
-#define   ethLedYeR_MASK 1UL << 30 //P1.30 ==> p19 output
 
 
 bool LinkTrace = false;
 
-static int count = 0;
-static void lights()
-{
-    if (count)
-    {
-        LPC_GPIO1->FIOCLR = ethLedGrL_MASK;
-        LPC_GPIO1->FIOCLR = ethLedYeR_MASK;
-        count--;
-    }
-    else
-    {
-        if (LPC_GPIO1->FIOPIN &  phyLinkNeg_MASK) LPC_GPIO1->FIOCLR = ethLedGrL_MASK;
-        else                                      LPC_GPIO1->FIOSET = ethLedGrL_MASK;
-        if (LPC_GPIO1->FIOPIN & phySpeedNeg_MASK) LPC_GPIO1->FIOCLR = ethLedYeR_MASK;
-        else                                      LPC_GPIO1->FIOSET = ethLedYeR_MASK;
-    }
-}
-static void lightsBlink()
-{
-    count = 500; //==50ms at 100ns per scan
-}
+bool LinkPhyLink  = false;
+bool LinkPhySpeed = false;
+bool LinkActivity = false;
+
 void LinkMain()
 {
     //Flash lights
-    lights();
+    LinkPhyLink  = !(LPC_GPIO1->FIOPIN &  phyLinkNeg_MASK);
+    LinkPhySpeed = !(LPC_GPIO1->FIOPIN & phySpeedNeg_MASK);
     
     if (!NicLinkIsUp()) return;
     
@@ -55,9 +37,11 @@
     
     NetTraceHostResetMatched();
     
+    LinkActivity = false;
+    
     if (pRx)
     {
-        lightsBlink();
+        LinkActivity = true;
         
         if (pTx) action = EthHandlePacket(pRx, sizeRx, pTx, &sizeTx);
     
@@ -69,7 +53,7 @@
     
         if ( action)
         {
-            lightsBlink();
+            LinkActivity = true;
             NicSendTransmitPacket(sizeTx);
         }
     }
@@ -77,8 +61,6 @@
 
 void LinkInit()
 {
-    LPC_GPIO1->FIODIR |= ethLedGrL_MASK; //Set the direction to 1 == output
-    LPC_GPIO1->FIODIR |= ethLedYeR_MASK; //Set the direction to 1 == output
     NicInit();
     NicLinkAddress(MacLocal);
     if (LinkTrace)