2 FreeRTOS.org V5.1.0 - 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
32 /* Standard includes. */
\r
35 /* Scheduler includes. */
\r
36 #include "FreeRTOS.h"
\r
42 #include "uip_arp.h"
\r
45 #include "clock-arch.h"
\r
47 /* Demo includes. */
\r
49 #include "partest.h"
\r
52 // clock_time_t start;
\r
53 // clock_time_t interval;
\r
57 /*-----------------------------------------------------------*/
\r
59 /* How long to wait before attempting to connect the MAC again. */
\r
60 #define uipINIT_WAIT 100
\r
62 /* Shortcut to the header within the Rx buffer. */
\r
63 #define xHeader ((struct uip_eth_hdr *) &uip_buf[ 0 ])
\r
65 /* Standard constant. */
\r
66 #define uipTOTAL_FRAME_HEADER_SIZE 54
\r
68 /*-----------------------------------------------------------*/
\r
71 * Port functions required by the uIP stack.
\r
73 void clock_init( void );
\r
74 clock_time_t clock_time( void );
\r
76 /*-----------------------------------------------------------*/
\r
78 /* The semaphore used by the ISR to wake the uIP task. */
\r
79 extern xSemaphoreHandle xFECSemaphore;
\r
81 /*-----------------------------------------------------------*/
\r
83 void clock_init(void)
\r
85 /* This is done when the scheduler starts. */
\r
87 /*-----------------------------------------------------------*/
\r
89 /* Define clock functions here to avoid header file name clash between uIP
\r
90 and the Luminary Micro driver library. */
\r
91 clock_time_t clock_time( void )
\r
93 return xTaskGetTickCount();
\r
95 extern void timer_set(struct timer *t, clock_time_t interval);
\r
96 extern int timer_expired(struct timer *t);
\r
97 extern void timer_reset(struct timer *t);
\r
102 void vuIP_Task( void *pvParameters )
\r
105 uip_ipaddr_t xIPAddr;
\r
106 struct timer periodic_timer, arp_timer;
\r
107 extern void ( vEMAC_ISR )( void );
\r
109 /* To prevent compiler warnings. */
\r
110 ( void ) pvParameters;
\r
112 /* Initialise the uIP stack. */
\r
113 timer_set( &periodic_timer, configTICK_RATE_HZ / 2 );
\r
114 timer_set( &arp_timer, configTICK_RATE_HZ * 10 );
\r
116 uip_ipaddr( xIPAddr, configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 );
\r
117 uip_sethostaddr( xIPAddr );
\r
124 /* Is there received data ready to be processed? */
\r
125 uip_len = usGetFECRxData();
\r
129 /* Standard uIP loop taken from the uIP manual. */
\r
131 if( xHeader->type == htons( UIP_ETHTYPE_IP ) )
\r
136 /* If the above function invocation resulted in data that
\r
137 should be sent out on the network, the global variable
\r
138 uip_len is set to a value > 0. */
\r
142 vSendBufferToFEC();
\r
149 else if( xHeader->type == htons( UIP_ETHTYPE_ARP ) )
\r
153 /* If the above function invocation resulted in data that
\r
154 should be sent out on the network, the global variable
\r
155 uip_len is set to a value > 0. */
\r
158 vSendBufferToFEC();
\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
185 vSendBufferToFEC();
\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
209 void vApplicationProcessFormInput( portCHAR *pcInputString )
\r
211 char *c = pcInputString;
\r
213 /* Process the form input sent by the IO page of the served HTML. */
\r
214 while( ( *c != '?' ) && ( *c != 0x00 ) )
\r
222 if( strcmp( c, "LED0=1" ) == 0 )
\r
224 vParTestSetLED( 3, 1 );
\r
228 vParTestSetLED( 3, 0 );
\r