/* FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. *************************************************************************** * * * FreeRTOS tutorial books are available in pdf and paperback. * * Complete, revised, and edited pdf reference manuals are also * * available. * * * * Purchasing FreeRTOS documentation will not only help you, by * * ensuring you get running as quickly as possible and with an * * in-depth knowledge of how to use FreeRTOS, it will also help * * the FreeRTOS project to continue with its mission of providing * * professional grade, cross platform, de facto standard solutions * * for microcontrollers - completely free of charge! * * * * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * * * * Thank you for using FreeRTOS, and thank you for your support! * * * *************************************************************************** This file is part of the FreeRTOS distribution. FreeRTOS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (version 2) as published by the Free Software Foundation AND MODIFIED BY the FreeRTOS exception. >>>NOTE<<< The modification to the GPL is included to allow you to distribute a combined work that includes FreeRTOS without being obliged to provide the source code for proprietary components outside of the FreeRTOS kernel. FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License and the FreeRTOS license exception along with FreeRTOS; if not it can be viewed here: http://www.freertos.org/a00114.html and also obtained by writing to Richard Barry, contact details for whom are available on the FreeRTOS WEB site. 1 tab == 4 spaces! */ ***Most of the code has been snipped out, to just leave the code that runs the ***uIP stack. This code also only acts as a server. void vuIP_Task( void *pvParameters ) { portBASE_TYPE i; unsigned long ulNewEvent = 0UL; unsigned long ulUIP_Events = 0UL; ( void ) pvParameters; /* Initialise the uIP stack. */ prvInitialise_uIP(); /* Initialise the MAC. */ vInitEmac(); for( ;; ) { /* Check to see if the message that woke this task contains an Rx event. */ if( ( ulUIP_Events & uipETHERNET_RX_EVENT ) != 0UL ) { /* Is there received data ready to be processed? */ uip_len = ( unsigned short ) ulEMACRead(); if( ( uip_len > 0 ) && ( uip_buf != NULL ) ) { if( xHeader->type == htons( UIP_ETHTYPE_IP ) ) { uip_arp_ipin(); uip_input(); /* If the above function invocation resulted in data that should be sent out on the network, the global variable uip_len is set to a value > 0. */ if( uip_len > 0 ) { uip_arp_out(); vEMACWrite(); } } else if( xHeader->type == htons( UIP_ETHTYPE_ARP ) ) { uip_arp_arpin(); /* If the above function invocation resulted in data that should be sent out on the network, the global variable uip_len is set to a value > 0. */ if( uip_len > 0 ) { vEMACWrite(); } } } else { /* Clear the Rx event flag. */ ulUIP_Events &= ~uipETHERNET_RX_EVENT; } } /* Check to see if the message that woke this task contains an periodic event. */ if( ( ulUIP_Events & uipPERIODIC_TIMER_EVENT ) != 0UL ) { /* Clear the periodic event flag. */ ulUIP_Events &= ~uipPERIODIC_TIMER_EVENT; for( i = 0; i < UIP_CONNS; i++ ) { uip_periodic( i ); /* If the above function invocation resulted in data that should be sent out on the network, the global variable uip_len is set to a value > 0. */ if( uip_len > 0 ) { uip_arp_out(); vEMACWrite(); } } } /* Check to see if the message that woke this task contains an ARP timer event. */ if( ( ulUIP_Events & uipARP_TIMER_EVENT ) != 0 ) { /* Clear the ARP timer event. */ ulUIP_Events &= ~uipARP_TIMER_EVENT; uip_arp_timer(); } /* Are any events pending still? There should not be. */ if( ulUIP_Events == pdFALSE ) { /* Block indefinitely until a message arives. The message will contain the next event that needs processing. */ xQueueReceive( xEMACEventQueue, &ulNewEvent, portMAX_DELAY ); ulUIP_Events |= ulNewEvent; } } }