A PicoTCP driver for the lpc1768 mbed board

Dependents:   lpc1768-picotcp-demo TCPSocket_HelloWorld_PicoTCP Pico_TCP_UDP_Test TCPSocket_HelloWorld_PicoTCP ... more

Revision:
12:dc845268281a
Parent:
8:0b675bdd074f
Child:
13:d4716335bf83
--- a/pico_dev_mbed_emac.cpp	Tue Jul 16 06:57:10 2013 +0000
+++ b/pico_dev_mbed_emac.cpp	Tue Jul 23 14:55:25 2013 +0000
@@ -27,6 +27,9 @@
 }
 #include "PicoCondition.h"
 #include "proxy_endpoint.h"
+#include "PicoTerm.h"
+
+#define emac_dbg    ptm_dbg
 
 //static PicoCondition rx_condition;
 
@@ -124,13 +127,13 @@
     if(intStatus & INT_TX_UNDERRUN)
     {
       // this case should be treated
-      //printf("TX_UNDERRUN\r\n");
+      //emac_dbg("TX_UNDERRUN\r\n");
     }
 
     if(intStatus & INT_RX_OVERRUN)
     {
       // this case should be treated
-      //printf("INT_RX_OVERRUN\r\n");
+      //emac_dbg("INT_RX_OVERRUN\r\n");
     }
  
     if(intStatus & INT_RX_DONE)
@@ -149,7 +152,7 @@
 void rxThreadCore(void const *arg)
     {
     struct pico_device_mbed_emac *dev = (struct pico_device_mbed_emac *)arg;
-    printf("rx Thread started.\n");
+    emac_dbg("rx Thread started.\n");
 
     while(true) {
         rx_condition.lock();
@@ -174,12 +177,12 @@
   // Read MAC address from HW
   mbed_mac_address((char *)mbdev->mac);
   
-  //printf("ETH> Set MAC address to: %x:%x:%x:%x:%x:%x\r\n", mbdev->mac[0], mbdev->mac[1], mbdev->mac[2], mbdev->mac[3], mbdev->mac[4], mbdev->mac[5]);
+  //emac_dbg("ETH> Set MAC address to: %x:%x:%x:%x:%x:%x\r\n", mbdev->mac[0], mbdev->mac[1], mbdev->mac[2], mbdev->mac[3], mbdev->mac[4], mbdev->mac[5]);
 
   mbdev->mtu = ETH_MAX_MTU;
 
   if(0 != pico_device_init((struct pico_device *)mbdev, name, mbdev->mac)) {
-    //printf ("ETH> Loop init failed.\n");
+    //emac_dbg ("ETH> Loop init failed.\n");
     _emac_destroy(&mbdev->dev);
     return NULL;
   }
@@ -203,7 +206,7 @@
   
   //rxThread->set_priority(osPriorityLow);
 
-  //printf("ETH> Device %s created.\r\n", mbdev->dev.name);
+  //emac_dbg("ETH> Device %s created.\r\n", mbdev->dev.name);
 
   return (struct pico_device *)mbdev;
 }
@@ -326,7 +329,7 @@
   id2 = _emac_read_PHY (PHY_REG_IDR2);
   if (((id1 << 16) | (id2 & 0xFFF0)) == DP83848C_ID) {
     // Configure the PHY device
-    //printf("PHY> DP83848C_ID PHY found!\r\n");
+    //emac_dbg("PHY> DP83848C_ID PHY found!\r\n");
     // Use autonegotiation about the link speed.
     _emac_write_PHY (PHY_REG_BMCR, PHY_AUTO_NEG);
     // Wait to complete Auto_Negotiation.
@@ -344,7 +347,7 @@
     regv = _emac_read_PHY (PHY_REG_STS);
     if (regv & 0x0001) {
       // Link is on
-      //printf("PHY> Link active!\r\n");
+      //emac_dbg("PHY> Link active!\r\n");
       break;
     }
   }
@@ -552,8 +555,8 @@
         return 0;
     else
         bufferIndex = LPC_EMAC->TxProduceIndex;
-    //printf("p%i c%i stat:%d\r\n",prod,cons,LPC_EMAC->TxStatus);
-    //printf("Sending returned 0 : %x :%x\n",LPC_EMAC->IntStatus,LPC_EMAC->IntEnable);
+    //emac_dbg("p%i c%i stat:%d\r\n",prod,cons,LPC_EMAC->TxStatus);
+    //emac_dbg("Sending returned 0 : %x :%x\n",LPC_EMAC->IntStatus,LPC_EMAC->IntEnable);
     
   }
   
@@ -601,7 +604,7 @@
       if(!( (RxLen >= ETH_MAX_MTU) || (info & RINFO_ERR_MASK) ) ) {
         pico_stack_recv((struct pico_device *)mbdev,(uint8_t *)rptr,RxLen);
       } else {
-        //printf("RxError?\r\n");
+        //emac_dbg("RxError?\r\n");
       }
       retval += RxLen;
       
@@ -647,25 +650,25 @@
     if (linksts & DP8_VALID_LINK)
     {
       led_link = 1;
-      //printf("PHY> Link ACTIVE!     --");
+      //emac_dbg("PHY> Link ACTIVE!     --");
     }
     else
     {
       led_link = 0;
-      //printf("PHY> Link inactive... --");
+      //emac_dbg("PHY> Link inactive... --");
     }
 
     // Full or half duplex
     if (linksts & DP8_FULLDUPLEX)
-      printf(" Full duplex mode ! --");
+      emac_dbg("Full duplex mode ! --");
     else
-      printf(" No full duplex...! --");
+      emac_dbg("No full duplex...! --");
 
     // Configure 100MBit/10MBit mode.
     if (linksts & DP8_SPEED10MBPS)
-      printf(" @  10 MBPS\r\n");
+      emac_dbg("@  10 MBPS\r\n");
     else
-      printf(" @ 100 MBPS\r\n");
+      emac_dbg("@ 100 MBPS\r\n");
   }
 
   return changed;