From: richardbarry Date: Sat, 23 Apr 2011 15:21:59 +0000 (+0000) Subject: Change interface between the MAC and uIP task in the RX62N/RDK/Renesas demo to use... X-Git-Tag: V7.0.1~47 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f3dc54fd3d6142f156d2b58e167980e8280983f3;p=freertos Change interface between the MAC and uIP task in the RX62N/RDK/Renesas demo to use a queue in place of the binary semaphore. This is so the queue can be used to indicate the type of event that has occurred. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1377 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Demo/RX600_RX62N-RDK_Renesas/RTOSDemo/webserver/EMAC.c b/Demo/RX600_RX62N-RDK_Renesas/RTOSDemo/webserver/EMAC.c index 88dd28094..53951cff8 100644 --- a/Demo/RX600_RX62N-RDK_Renesas/RTOSDemo/webserver/EMAC.c +++ b/Demo/RX600_RX62N-RDK_Renesas/RTOSDemo/webserver/EMAC.c @@ -246,23 +246,29 @@ unsigned long ulBytesReceived; if( ulBytesReceived > 0 ) { - pxCurrentRxDesc->status &= ~( FP1 | FP0 ); - pxCurrentRxDesc->status |= ACT; - - if( EDMAC.EDRRR.LONG == 0x00000000L ) - { - /* Restart Ethernet if it has stopped */ - EDMAC.EDRRR.LONG = 0x00000001L; - } - /* Mark the pxDescriptor buffer as free as uip_buf is going to be set to the buffer that contains the received data. */ prvReturnBuffer( uip_buf ); - + + /* Point uip_buf to the data about ot be processed. */ uip_buf = ( void * ) pxCurrentRxDesc->buf_p; + + /* Allocate a new buffer to the descriptor, as uip_buf is now using it's + old descriptor. */ + pxCurrentRxDesc->buf_p = prvGetNextBuffer(); + + /* Prepare the descriptor to go again. */ + pxCurrentRxDesc->status &= ~( FP1 | FP0 ); + pxCurrentRxDesc->status |= ACT; /* Move onto the next buffer in the ring. */ pxCurrentRxDesc = pxCurrentRxDesc->next; + + if( EDMAC.EDRRR.LONG == 0x00000000L ) + { + /* Restart Ethernet if it has stopped */ + EDMAC.EDRRR.LONG = 0x00000001L; + } } return ulBytesReceived; @@ -504,7 +510,6 @@ static void prvConfigureEtherCAndEDMAC( void ) /* Set the EDMAC interrupt priority. */ _IPR( _ETHER_EINT ) = configKERNEL_INTERRUPT_PRIORITY; - /* TODO: Check bit 5 */ /* Enable interrupts of interest only. */ EDMAC.EESIPR.LONG = emacTX_END_INTERRUPT | emacRX_END_INTERRUPT; ETHERC.RFLR.LONG = 1518; /* Ether payload is 1500+ CRC */ @@ -521,7 +526,8 @@ static void prvConfigureEtherCAndEDMAC( void ) EDMAC.TFTR.LONG = 0x00000000; /* Threshold of Tx_FIFO */ EDMAC.FDR.LONG = 0x00000000; /* Transmit fifo & receive fifo is 256 bytes */ EDMAC.RMCR.LONG = 0x00000003; /* Receive function is normal mode(continued) */ - + ETHERC.ECMR.BIT.PRM = 0; /* Ensure promiscuous mode is off. */ + /* Enable the interrupt... */ _IEN( _ETHER_EINT ) = 1; } @@ -532,19 +538,14 @@ void vEMAC_ISR_Handler( void ) { unsigned long ul = EDMAC.EESR.LONG; long lHigherPriorityTaskWoken = pdFALSE; -extern xSemaphoreHandle xEMACSemaphore; -static long ulTxEndInts = 0; +extern xQueueHandle xEMACEventQueue; +const unsigned long ulRxEvent = uipETHERNET_RX_EVENT; /* Has a Tx end occurred? */ if( ul & emacTX_END_INTERRUPT ) { - ++ulTxEndInts; - if( ulTxEndInts >= 2 ) - { - /* Only return the buffer to the pool once both Txes have completed. */ - prvReturnBuffer( ( void * ) xTxDescriptors[ 0 ].buf_p ); - ulTxEndInts = 0; - } + /* Only return the buffer to the pool once both Txes have completed. */ + prvReturnBuffer( ( void * ) xTxDescriptors[ 0 ].buf_p ); EDMAC.EESR.LONG = emacTX_END_INTERRUPT; } @@ -552,7 +553,7 @@ static long ulTxEndInts = 0; if( ul & emacRX_END_INTERRUPT ) { /* Make sure the Ethernet task is not blocked waiting for a packet. */ - xSemaphoreGiveFromISR( xEMACSemaphore, &lHigherPriorityTaskWoken ); + xQueueSendFromISR( xEMACEventQueue, &ulRxEvent, &lHigherPriorityTaskWoken ); portYIELD_FROM_ISR( lHigherPriorityTaskWoken ); EDMAC.EESR.LONG = emacRX_END_INTERRUPT; }