]> git.sur5r.net Git - freertos/blobdiff - Demo/CORTEX_A2F200_IAR_and_Keil/uIP_Task.c
New MicroBlaze port: Added a FreeRTOS exception handler, and installed it in each...
[freertos] / Demo / CORTEX_A2F200_IAR_and_Keil / uIP_Task.c
index 5f35cf5324544c0efb7aa088182473ea44581fed..58e0ca9a9f0cabad1fca317240d1f6eb798d8fd3 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V7.0.0 - Copyright (C) 2011 Real Time Engineers Ltd.\r
+    FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.\r
        \r
 \r
     ***************************************************************************\r
@@ -159,8 +159,8 @@ clock_time_t clock_time( void )
 void vuIP_Task( void *pvParameters )\r
 {\r
 portBASE_TYPE i;\r
-unsigned long ulNewEvent = 0UL;\r
-unsigned long ulUIP_Events = 0UL;\r
+unsigned long ulNewEvent = 0UL, ulUIP_Events = 0UL;\r
+long lPacketLength;\r
 \r
        /* Just to prevent compiler warnings about the unused parameter. */\r
        ( void ) pvParameters;\r
@@ -174,11 +174,13 @@ unsigned long ulUIP_Events = 0UL;
        for( ;; )\r
        {\r
                /* Is there received data ready to be processed? */\r
-               uip_len = MSS_MAC_rx_packet();\r
+               lPacketLength = MSS_MAC_rx_packet();\r
 \r
                /* Statements to be executed if data has been received on the Ethernet. */\r
-               if( ( uip_len > 0 ) && ( uip_buf != NULL ) )\r
+               if( ( lPacketLength > 0 ) && ( uip_buf != NULL ) )\r
                {\r
+                       uip_len = ( u16_t ) lPacketLength;\r
+                       \r
                        /* Standard uIP loop taken from the uIP manual. */\r
                        if( xHeader->type == htons( UIP_ETHTYPE_IP ) )\r
                        {\r
@@ -269,49 +271,6 @@ struct uip_eth_addr xAddr;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vApplicationProcessFormInput( char *pcInputString )\r
-{\r
-char *c;\r
-\r
-       /* Only interested in processing form input if this is the IO page. */\r
-       c = strstr( pcInputString, "io.shtml" );\r
-       \r
-       if( c )\r
-       {\r
-               /* Is there a command in the string? */\r
-               c = strstr( pcInputString, "?" );\r
-           if( c )\r
-           {\r
-                       /* Turn the LED's on or off in accordance with the check box status. */\r
-                       if( strstr( c, "LED0=1" ) != NULL )\r
-                       {\r
-                               /* Turn the LEDs on. */\r
-                               vParTestSetLED( 7, 1 );\r
-                               vParTestSetLED( 8, 1 );\r
-                               vParTestSetLED( 9, 1 );\r
-                               vParTestSetLED( 10, 1 );\r
-                       }\r
-                       else\r
-                       {\r
-                               /* Turn the LEDs off. */\r
-                               vParTestSetLED( 7, 0 );\r
-                               vParTestSetLED( 8, 0 );\r
-                               vParTestSetLED( 9, 0 );\r
-                               vParTestSetLED( 10, 0 );\r
-                       }\r
-           }\r
-               else\r
-               {\r
-                       /* Commands to turn LEDs off are not always explicit. */\r
-                       vParTestSetLED( 7, 0 );\r
-                       vParTestSetLED( 8, 0 );\r
-                       vParTestSetLED( 9, 0 );\r
-                       vParTestSetLED( 10, 0 );\r
-               }\r
-       }\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
 static void prvInitialise_uIP( void )\r
 {\r
 uip_ipaddr_t xIPAddr;\r
@@ -329,14 +288,14 @@ xTimerHandle xARPTimer, xPeriodicTimer;
        xEMACEventQueue = xQueueCreate( uipEVENT_QUEUE_LENGTH, sizeof( unsigned long ) );\r
 \r
        /* Create and start the uIP timers. */\r
-       xARPTimer = xTimerCreate(       ( const signed char * const ) "ARPTimer", /* Just a name that is helpful for debugging, not used by the kernel. */\r
+       xARPTimer = xTimerCreate(       ( signed char * ) "ARPTimer", /* Just a name that is helpful for debugging, not used by the kernel. */\r
                                                                ( 10000UL / portTICK_RATE_MS ), /* Timer period. */\r
                                                                pdTRUE, /* Autor-reload. */\r
                                                                ( void * ) uipARP_TIMER,\r
                                                                prvUIPTimerCallback\r
                                                        );\r
 \r
-       xPeriodicTimer = xTimerCreate(  ( const signed char * const ) "PeriodicTimer",\r
+       xPeriodicTimer = xTimerCreate(  ( signed char * ) "PeriodicTimer",\r
                                                                        ( 500UL / portTICK_RATE_MS ),\r
                                                                        pdTRUE, /* Autor-reload. */\r
                                                                        ( void * ) uipPERIODIC_TIMER,\r
@@ -357,7 +316,7 @@ xTimerHandle xARPTimer, xPeriodicTimer;
 static void prvEMACEventListener( unsigned long ulISREvents )\r
 {\r
 long lHigherPriorityTaskWoken = pdFALSE;\r
-unsigned long ulUIPEvents = 0UL;\r
+const unsigned long ulRxEvent = uipETHERNET_RX_EVENT;\r
 \r
        /* Sanity check that the event queue was indeed created. */\r
        configASSERT( xEMACEventQueue );\r
@@ -365,20 +324,13 @@ unsigned long ulUIPEvents = 0UL;
        if( ( ulISREvents & MSS_MAC_EVENT_PACKET_SEND ) != 0UL )\r
        {\r
                /* An Ethernet Tx event has occurred. */\r
-               MSS_MAC_CheckTxBufferStatus();\r
+               MSS_MAC_FreeTxBuffers();\r
        }\r
 \r
        if( ( ulISREvents & MSS_MAC_EVENT_PACKET_RECEIVED ) != 0UL )\r
        {\r
                /* An Ethernet Rx event has occurred. */\r
-               ulUIPEvents |= uipETHERNET_RX_EVENT;\r
-       }\r
-\r
-       if( ulUIPEvents != 0UL )\r
-       {\r
-               /* Send any events that have occurred to the uIP stack (the uIP task in\r
-               this case). */\r
-               xQueueSendFromISR( xEMACEventQueue, &ulUIPEvents, &lHigherPriorityTaskWoken );\r
+               xQueueSendFromISR( xEMACEventQueue, &ulRxEvent, &lHigherPriorityTaskWoken );\r
        }\r
 \r
        portEND_SWITCHING_ISR( lHigherPriorityTaskWoken );\r
@@ -406,7 +358,7 @@ void vEMACWrite( void )
 {\r
 const long lMaxAttempts = 10;\r
 long lAttempt;\r
-const portTickType xShortDelay = ( 10 / portTICK_RATE_MS );\r
+const portTickType xShortDelay = ( 5 / portTICK_RATE_MS );\r
 \r
        /* Try to send data to the Ethernet.  Keep trying for a while if data cannot\r
        be sent immediately.  Note that this will actually cause the data to be sent\r
@@ -447,3 +399,40 @@ static const unsigned long ulPeriodicTimerExpired = uipPERIODIC_TIMER_EVENT;
        }\r
 }\r
 /*-----------------------------------------------------------*/\r
+\r
+void vApplicationProcessFormInput( char *pcInputString )\r
+{\r
+char *c;\r
+\r
+       /* Only interested in processing form input if this is the IO page. */\r
+       c = strstr( pcInputString, "io.shtml" );\r
+       \r
+       if( c )\r
+       {\r
+               /* Is there a command in the string? */\r
+               c = strstr( pcInputString, "?" );\r
+           if( c )\r
+           {\r
+                       /* Turn the LED's on or off in accordance with the check box status. */\r
+                       if( strstr( c, "LED0=1" ) != NULL )\r
+                       {\r
+                               /* Turn the LEDs on. */\r
+                               vParTestSetLED( 3, 1 );\r
+                               vParTestSetLED( 4, 1 );\r
+                       }\r
+                       else\r
+                       {\r
+                               /* Turn the LEDs off. */\r
+                               vParTestSetLED( 3, 0 );\r
+                               vParTestSetLED( 4, 0 );\r
+                       }\r
+           }\r
+               else\r
+               {\r
+                       /* Commands to turn LEDs off are not always explicit. */\r
+                       vParTestSetLED( 3, 0 );\r
+                       vParTestSetLED( 4, 0 );\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r