mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
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.
This commit is contained in:
parent
290e7bd222
commit
968aa1b199
|
@ -246,23 +246,29 @@ unsigned long ulBytesReceived;
|
||||||
|
|
||||||
if( ulBytesReceived > 0 )
|
if( ulBytesReceived > 0 )
|
||||||
{
|
{
|
||||||
|
/* 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 &= ~( FP1 | FP0 );
|
||||||
pxCurrentRxDesc->status |= ACT;
|
pxCurrentRxDesc->status |= ACT;
|
||||||
|
|
||||||
|
/* Move onto the next buffer in the ring. */
|
||||||
|
pxCurrentRxDesc = pxCurrentRxDesc->next;
|
||||||
|
|
||||||
if( EDMAC.EDRRR.LONG == 0x00000000L )
|
if( EDMAC.EDRRR.LONG == 0x00000000L )
|
||||||
{
|
{
|
||||||
/* Restart Ethernet if it has stopped */
|
/* Restart Ethernet if it has stopped */
|
||||||
EDMAC.EDRRR.LONG = 0x00000001L;
|
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 );
|
|
||||||
|
|
||||||
uip_buf = ( void * ) pxCurrentRxDesc->buf_p;
|
|
||||||
|
|
||||||
/* Move onto the next buffer in the ring. */
|
|
||||||
pxCurrentRxDesc = pxCurrentRxDesc->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ulBytesReceived;
|
return ulBytesReceived;
|
||||||
|
@ -504,7 +510,6 @@ static void prvConfigureEtherCAndEDMAC( void )
|
||||||
/* Set the EDMAC interrupt priority. */
|
/* Set the EDMAC interrupt priority. */
|
||||||
_IPR( _ETHER_EINT ) = configKERNEL_INTERRUPT_PRIORITY;
|
_IPR( _ETHER_EINT ) = configKERNEL_INTERRUPT_PRIORITY;
|
||||||
|
|
||||||
/* TODO: Check bit 5 */
|
|
||||||
/* Enable interrupts of interest only. */
|
/* Enable interrupts of interest only. */
|
||||||
EDMAC.EESIPR.LONG = emacTX_END_INTERRUPT | emacRX_END_INTERRUPT;
|
EDMAC.EESIPR.LONG = emacTX_END_INTERRUPT | emacRX_END_INTERRUPT;
|
||||||
ETHERC.RFLR.LONG = 1518; /* Ether payload is 1500+ CRC */
|
ETHERC.RFLR.LONG = 1518; /* Ether payload is 1500+ CRC */
|
||||||
|
@ -521,6 +526,7 @@ static void prvConfigureEtherCAndEDMAC( void )
|
||||||
EDMAC.TFTR.LONG = 0x00000000; /* Threshold of Tx_FIFO */
|
EDMAC.TFTR.LONG = 0x00000000; /* Threshold of Tx_FIFO */
|
||||||
EDMAC.FDR.LONG = 0x00000000; /* Transmit fifo & receive fifo is 256 bytes */
|
EDMAC.FDR.LONG = 0x00000000; /* Transmit fifo & receive fifo is 256 bytes */
|
||||||
EDMAC.RMCR.LONG = 0x00000003; /* Receive function is normal mode(continued) */
|
EDMAC.RMCR.LONG = 0x00000003; /* Receive function is normal mode(continued) */
|
||||||
|
ETHERC.ECMR.BIT.PRM = 0; /* Ensure promiscuous mode is off. */
|
||||||
|
|
||||||
/* Enable the interrupt... */
|
/* Enable the interrupt... */
|
||||||
_IEN( _ETHER_EINT ) = 1;
|
_IEN( _ETHER_EINT ) = 1;
|
||||||
|
@ -532,19 +538,14 @@ void vEMAC_ISR_Handler( void )
|
||||||
{
|
{
|
||||||
unsigned long ul = EDMAC.EESR.LONG;
|
unsigned long ul = EDMAC.EESR.LONG;
|
||||||
long lHigherPriorityTaskWoken = pdFALSE;
|
long lHigherPriorityTaskWoken = pdFALSE;
|
||||||
extern xSemaphoreHandle xEMACSemaphore;
|
extern xQueueHandle xEMACEventQueue;
|
||||||
static long ulTxEndInts = 0;
|
const unsigned long ulRxEvent = uipETHERNET_RX_EVENT;
|
||||||
|
|
||||||
/* Has a Tx end occurred? */
|
/* Has a Tx end occurred? */
|
||||||
if( ul & emacTX_END_INTERRUPT )
|
if( ul & emacTX_END_INTERRUPT )
|
||||||
{
|
{
|
||||||
++ulTxEndInts;
|
/* Only return the buffer to the pool once both Txes have completed. */
|
||||||
if( ulTxEndInts >= 2 )
|
prvReturnBuffer( ( void * ) xTxDescriptors[ 0 ].buf_p );
|
||||||
{
|
|
||||||
/* Only return the buffer to the pool once both Txes have completed. */
|
|
||||||
prvReturnBuffer( ( void * ) xTxDescriptors[ 0 ].buf_p );
|
|
||||||
ulTxEndInts = 0;
|
|
||||||
}
|
|
||||||
EDMAC.EESR.LONG = emacTX_END_INTERRUPT;
|
EDMAC.EESR.LONG = emacTX_END_INTERRUPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,7 +553,7 @@ static long ulTxEndInts = 0;
|
||||||
if( ul & emacRX_END_INTERRUPT )
|
if( ul & emacRX_END_INTERRUPT )
|
||||||
{
|
{
|
||||||
/* Make sure the Ethernet task is not blocked waiting for a packet. */
|
/* Make sure the Ethernet task is not blocked waiting for a packet. */
|
||||||
xSemaphoreGiveFromISR( xEMACSemaphore, &lHigherPriorityTaskWoken );
|
xQueueSendFromISR( xEMACEventQueue, &ulRxEvent, &lHigherPriorityTaskWoken );
|
||||||
portYIELD_FROM_ISR( lHigherPriorityTaskWoken );
|
portYIELD_FROM_ISR( lHigherPriorityTaskWoken );
|
||||||
EDMAC.EESR.LONG = emacRX_END_INTERRUPT;
|
EDMAC.EESR.LONG = emacRX_END_INTERRUPT;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue