2 FreeRTOS V7.0.0 - Copyright (C) 2011 Real Time Engineers Ltd.
\r
5 ***************************************************************************
\r
7 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
8 * Complete, revised, and edited pdf reference manuals are also *
\r
11 * Purchasing FreeRTOS documentation will not only help you, by *
\r
12 * ensuring you get running as quickly as possible and with an *
\r
13 * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
14 * the FreeRTOS project to continue with its mission of providing *
\r
15 * professional grade, cross platform, de facto standard solutions *
\r
16 * for microcontrollers - completely free of charge! *
\r
18 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
20 * Thank you for using FreeRTOS, and thank you for your support! *
\r
22 ***************************************************************************
\r
25 This file is part of the FreeRTOS distribution.
\r
27 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
28 the terms of the GNU General Public License (version 2) as published by the
\r
29 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
30 >>>NOTE<<< The modification to the GPL is included to allow you to
\r
31 distribute a combined work that includes FreeRTOS without being obliged to
\r
32 provide the source code for proprietary components outside of the FreeRTOS
\r
33 kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
34 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
35 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
36 more details. You should have received a copy of the GNU General Public
\r
37 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
38 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
39 by writing to Richard Barry, contact details for whom are available on the
\r
44 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
47 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
50 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
51 licensing and training services.
\r
55 /* Task that controls the uIP TCP/IP stack. */
\r
58 /* Standard includes. */
\r
61 /* Scheduler includes. */
\r
62 #include "FreeRTOS.h"
\r
68 #include "uip_arp.h"
\r
71 #include "clock-arch.h"
\r
73 /* Demo includes. */
\r
75 #include "partest.h"
\r
78 /*-----------------------------------------------------------*/
\r
80 /* Shortcut to the header within the Rx buffer. */
\r
81 #define xHeader ((struct uip_eth_hdr *) &uip_buf[ 0 ])
\r
83 /*-----------------------------------------------------------*/
\r
86 * Port functions required by the uIP stack.
\r
88 void clock_init( void );
\r
89 clock_time_t clock_time( void );
\r
90 extern void timer_set(struct timer *t, clock_time_t interval);
\r
91 extern int timer_expired(struct timer *t);
\r
92 extern void timer_reset(struct timer *t);
\r
94 /*-----------------------------------------------------------*/
\r
96 /* The semaphore used by the ISR to wake the uIP task. */
\r
97 extern xSemaphoreHandle xFECSemaphore;
\r
99 /*-----------------------------------------------------------*/
\r
101 void clock_init(void)
\r
103 /* This is done when the scheduler starts. */
\r
105 /*-----------------------------------------------------------*/
\r
107 /* Define clock functions here to avoid header file name clash between uIP
\r
108 and the Luminary Micro driver library. */
\r
109 clock_time_t clock_time( void )
\r
111 return xTaskGetTickCount();
\r
113 /*-----------------------------------------------------------*/
\r
115 void vuIP_Task( void *pvParameters )
\r
118 uip_ipaddr_t xIPAddr;
\r
119 struct timer periodic_timer, arp_timer;
\r
121 /* To prevent compiler warnings. */
\r
122 ( void ) pvParameters;
\r
124 /* Initialise the uIP stack. */
\r
125 timer_set( &periodic_timer, configTICK_RATE_HZ / 2 );
\r
126 timer_set( &arp_timer, configTICK_RATE_HZ * 10 );
\r
128 uip_ipaddr( xIPAddr, configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 );
\r
129 uip_sethostaddr( xIPAddr );
\r
131 /* Initialise the WEB server. */
\r
134 /* Initialise the Ethernet controller peripheral. */
\r
139 /* Is there received data ready to be processed? */
\r
140 uip_len = usFECGetRxedData();
\r
144 /* Standard uIP loop taken from the uIP manual. */
\r
146 if( xHeader->type == htons( UIP_ETHTYPE_IP ) )
\r
151 /* If the above function invocation resulted in data that
\r
152 should be sent out on the network, the global variable
\r
153 uip_len is set to a value > 0. */
\r
161 /* If we are not sending data then let the FEC driver know
\r
162 the buffer is no longer required. */
\r
163 vFECRxProcessingCompleted();
\r
166 else if( xHeader->type == htons( UIP_ETHTYPE_ARP ) )
\r
170 /* If the above function invocation resulted in data that
\r
171 should be sent out on the network, the global variable
\r
172 uip_len is set to a value > 0. */
\r
179 /* If we are not sending data then let the FEC driver know
\r
180 the buffer is no longer required. */
\r
181 vFECRxProcessingCompleted();
\r
186 /* If we are not sending data then let the FEC driver know
\r
187 the buffer is no longer required. */
\r
188 vFECRxProcessingCompleted();
\r
193 if( timer_expired( &periodic_timer ) )
\r
195 timer_reset( &periodic_timer );
\r
196 for( i = 0; i < UIP_CONNS; i++ )
\r
200 /* If the above function invocation resulted in data that
\r
201 should be sent out on the network, the global variable
\r
202 uip_len is set to a value > 0. */
\r
210 /* Call the ARP timer function every 10 seconds. */
\r
211 if( timer_expired( &arp_timer ) )
\r
213 timer_reset( &arp_timer );
\r
219 /* We did not receive a packet, and there was no periodic
\r
220 processing to perform. Block for a fixed period. If a packet
\r
221 is received during this period we will be woken by the ISR
\r
222 giving us the Semaphore. */
\r
223 xSemaphoreTake( xFECSemaphore, configTICK_RATE_HZ / 2 );
\r
228 /*-----------------------------------------------------------*/
\r