2 FreeRTOS.org V5.1.1 - Copyright (C) 2003-2008 Richard Barry.
\r
4 This file is part of the FreeRTOS.org distribution.
\r
6 FreeRTOS.org is free software; you can redistribute it and/or modify
\r
7 it under the terms of the GNU General Public License as published by
\r
8 the Free Software Foundation; either version 2 of the License, or
\r
9 (at your option) any later version.
\r
11 FreeRTOS.org is distributed in the hope that it will be useful,
\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 GNU General Public License for more details.
\r
16 You should have received a copy of the GNU General Public License
\r
17 along with FreeRTOS.org; if not, write to the Free Software
\r
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
20 A special exception to the GPL can be applied should you wish to distribute
\r
21 a combined work that includes FreeRTOS.org, without being obliged to provide
\r
22 the source code for any proprietary components. See the licensing section
\r
23 of http://www.FreeRTOS.org for full details of how and when the exception
\r
26 ***************************************************************************
\r
27 See http://www.FreeRTOS.org for documentation, latest information, license
\r
28 and contact details. Please ensure to read the configuration and relevant
\r
29 port sections of the online documentation.
\r
30 ***************************************************************************
\r
34 /* Task that controls the uIP TCP/IP stack. */
\r
37 /* Standard includes. */
\r
40 /* Scheduler includes. */
\r
41 #include "FreeRTOS.h"
\r
47 #include "uip_arp.h"
\r
50 #include "clock-arch.h"
\r
52 /* Demo includes. */
\r
54 #include "partest.h"
\r
57 /*-----------------------------------------------------------*/
\r
59 /* Shortcut to the header within the Rx buffer. */
\r
60 #define xHeader ((struct uip_eth_hdr *) &uip_buf[ 0 ])
\r
62 /*-----------------------------------------------------------*/
\r
65 * Port functions required by the uIP stack.
\r
67 void clock_init( void );
\r
68 clock_time_t clock_time( void );
\r
69 extern void timer_set(struct timer *t, clock_time_t interval);
\r
70 extern int timer_expired(struct timer *t);
\r
71 extern void timer_reset(struct timer *t);
\r
73 /*-----------------------------------------------------------*/
\r
75 /* The semaphore used by the ISR to wake the uIP task. */
\r
76 extern xSemaphoreHandle xFECSemaphore;
\r
78 /*-----------------------------------------------------------*/
\r
80 void clock_init(void)
\r
82 /* This is done when the scheduler starts. */
\r
84 /*-----------------------------------------------------------*/
\r
86 /* Define clock functions here to avoid header file name clash between uIP
\r
87 and the Luminary Micro driver library. */
\r
88 clock_time_t clock_time( void )
\r
90 return xTaskGetTickCount();
\r
92 /*-----------------------------------------------------------*/
\r
94 void vuIP_Task( void *pvParameters )
\r
97 uip_ipaddr_t xIPAddr;
\r
98 struct timer periodic_timer, arp_timer;
\r
100 /* To prevent compiler warnings. */
\r
101 ( void ) pvParameters;
\r
103 /* Initialise the uIP stack. */
\r
104 timer_set( &periodic_timer, configTICK_RATE_HZ / 2 );
\r
105 timer_set( &arp_timer, configTICK_RATE_HZ * 10 );
\r
107 uip_ipaddr( xIPAddr, configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 );
\r
108 uip_sethostaddr( xIPAddr );
\r
110 /* Initialise the WEB server. */
\r
113 /* Initialise the Ethernet controller peripheral. */
\r
118 /* Is there received data ready to be processed? */
\r
119 uip_len = usFECGetRxedData();
\r
123 /* Standard uIP loop taken from the uIP manual. */
\r
125 if( xHeader->type == htons( UIP_ETHTYPE_IP ) )
\r
130 /* If the above function invocation resulted in data that
\r
131 should be sent out on the network, the global variable
\r
132 uip_len is set to a value > 0. */
\r
140 /* If we are not sending data then let the FEC driver know
\r
141 the buffer is no longer required. */
\r
142 vFECRxProcessingCompleted();
\r
145 else if( xHeader->type == htons( UIP_ETHTYPE_ARP ) )
\r
149 /* If the above function invocation resulted in data that
\r
150 should be sent out on the network, the global variable
\r
151 uip_len is set to a value > 0. */
\r
158 /* If we are not sending data then let the FEC driver know
\r
159 the buffer is no longer required. */
\r
160 vFECRxProcessingCompleted();
\r
165 /* If we are not sending data then let the FEC driver know
\r
166 the buffer is no longer required. */
\r
167 vFECRxProcessingCompleted();
\r
172 if( timer_expired( &periodic_timer ) )
\r
174 timer_reset( &periodic_timer );
\r
175 for( i = 0; i < UIP_CONNS; i++ )
\r
179 /* If the above function invocation resulted in data that
\r
180 should be sent out on the network, the global variable
\r
181 uip_len is set to a value > 0. */
\r
189 /* Call the ARP timer function every 10 seconds. */
\r
190 if( timer_expired( &arp_timer ) )
\r
192 timer_reset( &arp_timer );
\r
198 /* We did not receive a packet, and there was no periodic
\r
199 processing to perform. Block for a fixed period. If a packet
\r
200 is received during this period we will be woken by the ISR
\r
201 giving us the Semaphore. */
\r
202 xSemaphoreTake( xFECSemaphore, configTICK_RATE_HZ / 2 );
\r
207 /*-----------------------------------------------------------*/
\r