From: richardbarry Date: Sun, 17 Nov 2013 22:19:54 +0000 (+0000) Subject: Tidy up SAM4E NetworkInterface.c. X-Git-Tag: V7.6.0 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5c6c8358e24d87851904d80d4f5c2ba15b4839a5;p=freertos Tidy up SAM4E NetworkInterface.c. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2107 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/portable/NetworkInterface/SAM4E/NetworkInterface.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/portable/NetworkInterface/SAM4E/NetworkInterface.c index 9d732320e..462ffeddd 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/portable/NetworkInterface/SAM4E/NetworkInterface.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/portable/NetworkInterface/SAM4E/NetworkInterface.c @@ -40,6 +40,7 @@ /* Standard includes. */ #include +#include /* FreeRTOS includes. */ #include "FreeRTOS.h" @@ -126,7 +127,7 @@ portBASE_TYPE xReturn = pdFALSE; created. */ if( xGMACRxEventSemaphore == NULL ) { - vSemaphoreCreateBinary( xGMACRxEventSemaphore ); + xGMACRxEventSemaphore = xSemaphoreCreateCounting( ULONG_MAX, 0 ); #if ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS == 1 { /* If the trace recorder code is included name the semaphore for @@ -169,7 +170,7 @@ static void prvGMACRxCallback( uint32_t ulStatus ) portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* Unblock the deferred interrupt handler task if the event was an Rx. */ - if( ulStatus != 0 ) + if( ulStatus == GMAC_RSR_REC ) { xSemaphoreGiveFromISR( xGMACRxEventSemaphore, &xHigherPriorityTaskWoken ); } @@ -216,7 +217,8 @@ static void prvGMACDeferredInterruptHandlerTask( void *pvParameters ) { xNetworkBufferDescriptor_t *pxNetworkBuffer; xIPStackEvent_t xRxEvent = { eEthernetRxEvent, NULL }; -static const portTickType xBufferWaitDelay = 500UL / portTICK_RATE_MS; +static const portTickType xBufferWaitDelay = 1500UL / portTICK_RATE_MS; +uint32_t ulReturned; ( void ) pvParameters; configASSERT( xGMACRxEventSemaphore ); @@ -231,14 +233,14 @@ static const portTickType xBufferWaitDelay = 500UL / portTICK_RATE_MS; obtained. */ while( xSemaphoreTake( xGMACRxEventSemaphore, portMAX_DELAY ) == pdFALSE ); - /* The buffer filled by the DMA is going to be passed into the IP - stack. Allocate another buffer for the DMA descriptor. */ + /* Allocate a buffer to hold the data. */ pxNetworkBuffer = pxNetworkBufferGet( ipTOTAL_ETHERNET_FRAME_SIZE, xBufferWaitDelay ); if( pxNetworkBuffer != NULL ) { /* At least one packet has been received. */ - if( gmac_dev_read( &xGMACStruct, pxNetworkBuffer->pucEthernetBuffer, ipTOTAL_ETHERNET_FRAME_SIZE, ( uint32_t * ) &( pxNetworkBuffer->xDataLength ) ) == GMAC_OK ) + ulReturned = gmac_dev_read( &xGMACStruct, pxNetworkBuffer->pucEthernetBuffer, ipTOTAL_ETHERNET_FRAME_SIZE, ( uint32_t * ) &( pxNetworkBuffer->xDataLength ) ); + if( ulReturned == GMAC_OK ) { #if ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES == 1 {