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 8:59490137c7a7, committed 2013-09-10
- Comitter:
- bogdanm
- Date:
- Tue Sep 10 15:14:48 2013 +0300
- Parent:
- 7:5754e05385b8
- Child:
- 9:4694f865720b
- Commit message:
- Sync with git revision 171dda705c947bf910926a0b73d6a4797802554d
Changed in this revision
arch/lpc17_emac.c | Show annotated file Show diff for this revision Revisions of this file |
--- a/arch/lpc17_emac.c Mon Aug 19 18:39:00 2013 +0300 +++ b/arch/lpc17_emac.c Tue Sep 10 15:14:48 2013 +0300 @@ -88,6 +88,10 @@ */ #define TXINTGROUP (EMAC_INT_TX_UNDERRUN | EMAC_INT_TX_ERR | EMAC_INT_TX_DONE) +/** \brief Signal used for ethernet ISR to signal packet_rx() thread. + */ +#define RX_SIGNAL 1 + #else #define RXINTGROUP 0 #define TXINTGROUP 0 @@ -123,7 +127,7 @@ struct pbuf *txb[LPC_NUM_BUFF_TXDESCS]; /**< TX pbuf pointer list, zero-copy mode */ u32_t lpc_last_tx_idx; /**< TX last descriptor index, zero-copy mode */ #if NO_SYS == 0 - sys_sem_t RxSem; /**< RX receive thread wakeup semaphore */ + sys_thread_t RxThread; /**< RX receive thread data object pointer */ sys_sem_t TxCleanSem; /**< TX cleanup thread wakeup semaphore */ sys_mutex_t TXLockMutex; /**< TX critical section mutex */ sys_sem_t xTXDCountSem; /**< TX free buffer counting semaphore */ @@ -346,6 +350,7 @@ struct lpc_enetdata *lpc_enetif = netif->state; struct pbuf *p = NULL; u32_t idx, length; + u16_t origLength; #ifdef LOCK_RX_THREAD #if NO_SYS == 0 @@ -428,6 +433,7 @@ /* Zero-copy */ p = lpc_enetif->rxb[idx]; + origLength = p->len; p->len = (u16_t) length; /* Free pbuf from descriptor */ @@ -440,6 +446,7 @@ LINK_STATS_INC(link.drop); /* Re-queue the pbuf for receive */ + p->len = origLength; lpc_rxqueue_pbuf(lpc_enetif, p); LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE, @@ -780,8 +787,8 @@ ints = LPC_EMAC->IntStatus; if (ints & RXINTGROUP) { - /* RX group interrupt(s): Give semaphore to wakeup RX receive task.*/ - sys_sem_signal(&lpc_enetdata.RxSem); + /* RX group interrupt(s): Give signal to wakeup RX receive task.*/ + osSignalSet(lpc_enetdata.RxThread->id, RX_SIGNAL); } if (ints & TXINTGROUP) { @@ -807,7 +814,7 @@ while (1) { /* Wait for receive task to wakeup */ - sys_arch_sem_wait(&lpc_enetif->RxSem, 0); + osSignalWait(RX_SIGNAL, osWaitForever); /* Process packets until all empty */ while (LPC_EMAC->RxConsumeIndex != LPC_EMAC->RxProduceIndex) @@ -1093,9 +1100,8 @@ LWIP_ASSERT("TXLockMutex creation error", (err == ERR_OK)); /* Packet receive task */ - err = sys_sem_new(&lpc_enetdata.RxSem, 0); - LWIP_ASSERT("RxSem creation error", (err == ERR_OK)); - sys_thread_new("receive_thread", packet_rx, netif->state, DEFAULT_THREAD_STACKSIZE, RX_PRIORITY); + lpc_enetdata.RxThread = sys_thread_new("receive_thread", packet_rx, netif->state, DEFAULT_THREAD_STACKSIZE, RX_PRIORITY); + LWIP_ASSERT("RxThread creation error", (lpc_enetdata.RxThread)); /* Transmit cleanup task */ err = sys_sem_new(&lpc_enetdata.TxCleanSem, 0);