]> git.sur5r.net Git - freertos/commitdiff
Make SAM4E network driver a little more robust.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sun, 17 Nov 2013 15:42:08 +0000 (15:42 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sun, 17 Nov 2013 15:42:08 +0000 (15:42 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2104 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

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

index 3da074ab2619ea5f4535bea84a55eca660f3cc19..9d732320edbdb801165435ad4ef7fccd333aae5e 100644 (file)
@@ -216,6 +216,7 @@ 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
 \r
        ( void ) pvParameters;\r
        configASSERT( xGMACRxEventSemaphore );\r
@@ -232,7 +233,7 @@ xIPStackEvent_t xRxEvent = { eEthernetRxEvent, NULL };
 \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
-               pxNetworkBuffer = pxNetworkBufferGet( ipTOTAL_ETHERNET_FRAME_SIZE, portMAX_DELAY );\r
+               pxNetworkBuffer = pxNetworkBufferGet( ipTOTAL_ETHERNET_FRAME_SIZE, xBufferWaitDelay );\r
                \r
                if( pxNetworkBuffer != NULL )\r
                {\r
@@ -287,9 +288,15 @@ xIPStackEvent_t xRxEvent = { eEthernetRxEvent, NULL };
                        }\r
                        else\r
                        {\r
+                               vNetworkBufferRelease( pxNetworkBuffer );\r
                                iptraceETHERNET_RX_EVENT_LOST();\r
                        }\r
                }\r
+               else\r
+               {\r
+                       /* Left a frame in the driver as a buffer was not available. */\r
+                       gmac_dev_reset( &xGMACStruct );\r
+               }\r
        }\r
 }\r
 /*-----------------------------------------------------------*/\r