88
88
*/
89
89
#define TXINTGROUP (EMAC_INT_TX_UNDERRUN | EMAC_INT_TX_ERR | EMAC_INT_TX_DONE)
90
90
91
+ /** \brief Signal used for ethernet ISR to signal packet_rx() thread.
92
+ */
93
+ #define RX_SIGNAL 1
94
+
91
95
#else
92
96
#define RXINTGROUP 0
93
97
#define TXINTGROUP 0
@@ -123,7 +127,7 @@ struct lpc_enetdata {
123
127
struct pbuf * txb [LPC_NUM_BUFF_TXDESCS ]; /**< TX pbuf pointer list, zero-copy mode */
124
128
u32_t lpc_last_tx_idx ; /**< TX last descriptor index, zero-copy mode */
125
129
#if NO_SYS == 0
126
- sys_sem_t RxSem ; /**< RX receive thread wakeup semaphore */
130
+ sys_thread_t RxThread ; /**< RX receive thread data object pointer */
127
131
sys_sem_t TxCleanSem ; /**< TX cleanup thread wakeup semaphore */
128
132
sys_mutex_t TXLockMutex ; /**< TX critical section mutex */
129
133
sys_sem_t xTXDCountSem ; /**< TX free buffer counting semaphore */
@@ -346,6 +350,7 @@ static struct pbuf *lpc_low_level_input(struct netif *netif)
346
350
struct lpc_enetdata * lpc_enetif = netif -> state ;
347
351
struct pbuf * p = NULL ;
348
352
u32_t idx , length ;
353
+ u16_t origLength ;
349
354
350
355
#ifdef LOCK_RX_THREAD
351
356
#if NO_SYS == 0
@@ -428,6 +433,7 @@ static struct pbuf *lpc_low_level_input(struct netif *netif)
428
433
429
434
/* Zero-copy */
430
435
p = lpc_enetif -> rxb [idx ];
436
+ origLength = p -> len ;
431
437
p -> len = (u16_t ) length ;
432
438
433
439
/* Free pbuf from descriptor */
@@ -440,6 +446,7 @@ static struct pbuf *lpc_low_level_input(struct netif *netif)
440
446
LINK_STATS_INC (link .drop );
441
447
442
448
/* Re-queue the pbuf for receive */
449
+ p -> len = origLength ;
443
450
lpc_rxqueue_pbuf (lpc_enetif , p );
444
451
445
452
LWIP_DEBUGF (UDP_LPC_EMAC | LWIP_DBG_TRACE ,
@@ -780,8 +787,8 @@ void ENET_IRQHandler(void)
780
787
ints = LPC_EMAC -> IntStatus ;
781
788
782
789
if (ints & RXINTGROUP ) {
783
- /* RX group interrupt(s): Give semaphore to wakeup RX receive task.*/
784
- sys_sem_signal ( & lpc_enetdata .RxSem );
790
+ /* RX group interrupt(s): Give signal to wakeup RX receive task.*/
791
+ osSignalSet ( lpc_enetdata .RxThread -> id , RX_SIGNAL );
785
792
}
786
793
787
794
if (ints & TXINTGROUP ) {
@@ -807,7 +814,7 @@ static void packet_rx(void* pvParameters) {
807
814
808
815
while (1 ) {
809
816
/* Wait for receive task to wakeup */
810
- sys_arch_sem_wait ( & lpc_enetif -> RxSem , 0 );
817
+ osSignalWait ( RX_SIGNAL , osWaitForever );
811
818
812
819
/* Process packets until all empty */
813
820
while (LPC_EMAC -> RxConsumeIndex != LPC_EMAC -> RxProduceIndex )
@@ -1093,9 +1100,8 @@ err_t lpc_enetif_init(struct netif *netif)
1093
1100
LWIP_ASSERT ("TXLockMutex creation error" , (err == ERR_OK ));
1094
1101
1095
1102
/* Packet receive task */
1096
- err = sys_sem_new (& lpc_enetdata .RxSem , 0 );
1097
- LWIP_ASSERT ("RxSem creation error" , (err == ERR_OK ));
1098
- sys_thread_new ("receive_thread" , packet_rx , netif -> state , DEFAULT_THREAD_STACKSIZE , RX_PRIORITY );
1103
+ lpc_enetdata .RxThread = sys_thread_new ("receive_thread" , packet_rx , netif -> state , DEFAULT_THREAD_STACKSIZE , RX_PRIORITY );
1104
+ LWIP_ASSERT ("RxThread creation error" , (lpc_enetdata .RxThread ));
1099
1105
1100
1106
/* Transmit cleanup task */
1101
1107
err = sys_sem_new (& lpc_enetdata .TxCleanSem , 0 );
0 commit comments