A PicoTCP driver for the lpc1768 mbed board

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

Files at this revision

API Documentation at this revision

Comitter:
tass
Date:
Mon Jan 13 09:08:10 2014 +0000
Parent:
11:a85f164b4d28
Child:
15:53fd77850eee
Commit message:
Replaced printf debug commands by dbg_emac that you can map to printf with a define in .cpp file. By default, no debug messages are printed

Changed in this revision

pico_dev_mbed_emac.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/pico_dev_mbed_emac.cpp	Thu Nov 28 10:07:45 2013 +0000
+++ b/pico_dev_mbed_emac.cpp	Mon Jan 13 09:08:10 2014 +0000
@@ -29,6 +29,8 @@
 #include "proxy_endpoint.h"
 
 //static PicoCondition rx_condition;
+//#define dbg_emac         printf
+#define dbg_emac(...)
 
 /*******************************
  * Local structs and typedefs  *
@@ -124,13 +126,13 @@
     if(intStatus & INT_TX_UNDERRUN)
     {
       // this case should be treated
-      //printf("TX_UNDERRUN\r\n");
+      //dbg_emac("TX_UNDERRUN\r\n");
     }
 
     if(intStatus & INT_RX_OVERRUN)
     {
       // this case should be treated
-      //printf("INT_RX_OVERRUN\r\n");
+      //dbg_emac("INT_RX_OVERRUN\r\n");
     }
  
     if(intStatus & INT_RX_DONE)
@@ -149,7 +151,7 @@
 void rxThreadCore(void const *arg)
     {
     struct pico_device_mbed_emac *dev = (struct pico_device_mbed_emac *)arg;
-    printf("rx Thread started.\n");
+    dbg_emac("rx Thread started.\n");
 
     while(true) {
         rx_condition.lock();
@@ -174,12 +176,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]);
+  //dbg_emac("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");
+    //dbg_emac ("ETH> Loop init failed.\n");
     _emac_destroy(&mbdev->dev);
     return NULL;
   }
@@ -203,7 +205,7 @@
   
   //rxThread->set_priority(osPriorityLow);
 
-  //printf("ETH> Device %s created.\r\n", mbdev->dev.name);
+  //dbg_emac("ETH> Device %s created.\r\n", mbdev->dev.name);
 
   return (struct pico_device *)mbdev;
 }
@@ -326,7 +328,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");
+    //dbg_emac("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 +346,7 @@
     regv = _emac_read_PHY (PHY_REG_STS);
     if (regv & 0x0001) {
       // Link is on
-      //printf("PHY> Link active!\r\n");
+      //dbg_emac("PHY> Link active!\r\n");
       break;
     }
   }
@@ -550,13 +552,13 @@
     
     if((LPC_EMAC->TxConsumeIndex -1)== LPC_EMAC->TxProduceIndex)
     {
-        printf("Failed to send frame !\n");
+        dbg_emac("Failed to send frame !\n");
         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);
+    //dbg_emac("p%i c%i stat:%d\r\n",prod,cons,LPC_EMAC->TxStatus);
+    //dbg_emac("Sending returned 0 : %x :%x\n",LPC_EMAC->IntStatus,LPC_EMAC->IntEnable);
     
   }
   
@@ -604,7 +606,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");
+        //dbg_emac("RxError?\r\n");
       }
       retval += RxLen;
       
@@ -651,25 +653,25 @@
     if (linksts & DP8_VALID_LINK)
     {
       led_link = 1;
-      //printf("PHY> Link ACTIVE!     --");
+      //dbg_emac("PHY> Link ACTIVE!     --");
     }
     else
     {
       led_link = 0;
-      //printf("PHY> Link inactive... --");
+      //dbg_emac("PHY> Link inactive... --");
     }
 
     // Full or half duplex
     if (linksts & DP8_FULLDUPLEX)
-      printf(" Full duplex mode ! --");
+      dbg_emac(" Full duplex mode ! --");
     else
-      printf(" No full duplex...! --");
+      dbg_emac(" No full duplex...! --");
 
     // Configure 100MBit/10MBit mode.
     if (linksts & DP8_SPEED10MBPS)
-      printf(" @  10 MBPS\r\n");
+      dbg_emac(" @  10 MBPS\r\n");
     else
-      printf(" @ 100 MBPS\r\n");
+      dbg_emac(" @ 100 MBPS\r\n");
   }
 
   return changed;