NXP LPC1768 Ethernet driver for lwip and CMSIS-RTOS

Dependents:   EthernetInterface EthernetInterface EthernetInterface_RSF EthernetInterface ... more

Legacy Networking Libraries

This is an mbed 2 networking library. For mbed 5, the networking libraries have been revised to better support additional network stacks and thread safety here.

This library is based on the code of the NXP LPC port of the Lightweight TCP/IP Stack

Copyright(C) 2011, NXP Semiconductor
All rights reserved.

Software that is described herein is for illustrative purposes only
which provides customers with programming information regarding the
products. This software is supplied "AS IS" without any warranties.
NXP Semiconductors assumes no responsibility or liability for the
use of the software, conveys no license or title under any patent,
copyright, or mask work right to the product. NXP Semiconductors
reserves the right to make changes in the software without
notification. NXP Semiconductors also make no representation or
warranty that such application will be suitable for the specified
use without further testing or modification.
Revision:
2:5208926bd863
Parent:
1:0c9d93e2f51c
Child:
3:dd8b8f5b449a
--- a/arch/lpc17_emac.c	Fri Jun 22 11:17:21 2012 +0000
+++ b/arch/lpc17_emac.c	Fri Jun 22 11:57:39 2012 +0000
@@ -482,10 +482,9 @@
  */
 static s32_t lpc_packet_addr_notsafe(void *addr) {
     /* Check for legal address ranges */
-    if ((((u32_t) addr >= 0x20000000) && ((u32_t) addr < 0x20008000)) ||
-        (((u32_t) addr >= 0x80000000) && ((u32_t) addr < 0xF0000000)))
+    if ((((u32_t) addr >= 0x2007C000) && ((u32_t) addr < 0x20083FFF))) {
         return 0;
-
+    }
     return 1;
 }
 
@@ -837,9 +836,9 @@
 
     /* Enable MII clocking */
     LPC_SC->PCONP |= CLKPWR_PCONP_PCENET;
-	
-	LPC_PINCON->PINSEL2 = 0x50150105;  /* Enable P1 Ethernet Pins. */
-	LPC_PINCON->PINSEL3 = (LPC_PINCON->PINSEL3 & ~0x0000000F) | 0x00000005;
+    
+    LPC_PINCON->PINSEL2 = 0x50150105;  /* Enable P1 Ethernet Pins. */
+    LPC_PINCON->PINSEL3 = (LPC_PINCON->PINSEL3 & ~0x0000000F) | 0x00000005;
 
     /* Reset all MAC logic */
     LPC_EMAC->MAC1 = EMAC_MAC1_RES_TX | EMAC_MAC1_RES_MCS_TX |
@@ -1013,7 +1012,7 @@
     lpc_enetdata.xTXDCountSem.def.semaphore = lpc_enetdata.xTXDCountSem.data;
     #endif
     lpc_enetdata.xTXDCountSem.id = osSemaphoreCreate(&lpc_enetdata.xTXDCountSem.def, LPC_NUM_BUFF_TXDESCS);
-	LWIP_ASSERT("xTXDCountSem creation error", (lpc_enetdata.xTXDCountSem.id != NULL));
+    LWIP_ASSERT("xTXDCountSem creation error", (lpc_enetdata.xTXDCountSem.id != NULL));
 
     err = sys_mutex_new(&lpc_enetdata.TXLockMutex);
     LWIP_ASSERT("TXLockMutex creation error", (err == ERR_OK));
@@ -1024,11 +1023,13 @@
     sys_thread_new("receive_thread", packet_rx, netif->state, DEFAULT_THREAD_STACKSIZE, RX_PRIORITY);
 
     /* Transmit cleanup task */
+   	err = sys_sem_new(&lpc_enetdata.TxCleanSem, 0);
+	LWIP_ASSERT("TxCleanSem creation error", (err == ERR_OK));
     sys_thread_new("txclean_thread", packet_tx, netif->state, DEFAULT_THREAD_STACKSIZE, TX_PRIORITY);
-	
-	/* periodic PHY status update */
-	osTimerId phy_timer = osTimerCreate(osTimer(phy_update), osTimerPeriodic, (void *)netif);
-	osTimerStart(phy_timer, 250);
+    
+    /* periodic PHY status update */
+    osTimerId phy_timer = osTimerCreate(osTimer(phy_update), osTimerPeriodic, (void *)netif);
+    osTimerStart(phy_timer, 250);
 #endif
 
     return ERR_OK;