]> git.sur5r.net Git - freertos/commitdiff
Tidy up SAM4E NetworkInterface.c. V7.6.0
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sun, 17 Nov 2013 22:19:54 +0000 (22:19 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sun, 17 Nov 2013 22:19:54 +0000 (22:19 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2107 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/portable/NetworkInterface/SAM4E/NetworkInterface.c

index 9d732320edbdb801165435ad4ef7fccd333aae5e..462ffeddd2edbe4099a1aa133b2f97fd9181ca38 100644 (file)
@@ -40,6 +40,7 @@
 \r
 /* Standard includes. */\r
 #include <stdint.h>\r
+#include <limits.h>\r
 \r
 /* FreeRTOS includes. */\r
 #include "FreeRTOS.h"\r
@@ -126,7 +127,7 @@ portBASE_TYPE xReturn = pdFALSE;
                                created. */\r
                                if( xGMACRxEventSemaphore == NULL )\r
                                {\r
-                                       vSemaphoreCreateBinary( xGMACRxEventSemaphore );\r
+                                       xGMACRxEventSemaphore = xSemaphoreCreateCounting( ULONG_MAX, 0 );\r
                                        #if ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS == 1\r
                                        {\r
                                                /* If the trace recorder code is included name the semaphore for\r
@@ -169,7 +170,7 @@ static void prvGMACRxCallback( uint32_t ulStatus )
 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
 \r
        /* Unblock the deferred interrupt handler task if the event was an Rx. */\r
-       if( ulStatus != 0 )\r
+       if( ulStatus == GMAC_RSR_REC )\r
        {\r
                xSemaphoreGiveFromISR( xGMACRxEventSemaphore, &xHigherPriorityTaskWoken );\r
        }\r
@@ -216,7 +217,8 @@ static void prvGMACDeferredInterruptHandlerTask( void *pvParameters )
 {\r
 xNetworkBufferDescriptor_t *pxNetworkBuffer;\r
 xIPStackEvent_t xRxEvent = { eEthernetRxEvent, NULL };\r
-static const portTickType xBufferWaitDelay = 500UL / portTICK_RATE_MS;\r
+static const portTickType xBufferWaitDelay = 1500UL / portTICK_RATE_MS;\r
+uint32_t ulReturned;\r
 \r
        ( void ) pvParameters;\r
        configASSERT( xGMACRxEventSemaphore );\r
@@ -231,14 +233,14 @@ static const portTickType xBufferWaitDelay = 500UL / portTICK_RATE_MS;
                obtained. */\r
                while( xSemaphoreTake( xGMACRxEventSemaphore, portMAX_DELAY ) == pdFALSE );\r
 \r
-               /* The buffer filled by the DMA is going to be passed into the IP\r
-               stack.  Allocate another buffer for the DMA descriptor. */\r
+               /* Allocate a buffer to hold the data. */\r
                pxNetworkBuffer = pxNetworkBufferGet( ipTOTAL_ETHERNET_FRAME_SIZE, xBufferWaitDelay );\r
                \r
                if( pxNetworkBuffer != NULL )\r
                {\r
                        /* At least one packet has been received. */\r
-                       if( gmac_dev_read( &xGMACStruct, pxNetworkBuffer->pucEthernetBuffer, ipTOTAL_ETHERNET_FRAME_SIZE, ( uint32_t * ) &( pxNetworkBuffer->xDataLength ) ) == GMAC_OK )\r
+                       ulReturned = gmac_dev_read( &xGMACStruct, pxNetworkBuffer->pucEthernetBuffer, ipTOTAL_ETHERNET_FRAME_SIZE, ( uint32_t * ) &( pxNetworkBuffer->xDataLength ) );\r
+                       if( ulReturned == GMAC_OK )\r
                        {\r
                                #if ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES == 1\r
                                {\r