OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [ColdFire_MCF51CN128_CodeWarrior/] [Sources/] [httpd/] [uIP_Task.c] - Blame information for rev 585

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 jeremybenn
/*
2
    FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd.
3
 
4
    ***************************************************************************
5
    *                                                                         *
6
    * If you are:                                                             *
7
    *                                                                         *
8
    *    + New to FreeRTOS,                                                   *
9
    *    + Wanting to learn FreeRTOS or multitasking in general quickly       *
10
    *    + Looking for basic training,                                        *
11
    *    + Wanting to improve your FreeRTOS skills and productivity           *
12
    *                                                                         *
13
    * then take a look at the FreeRTOS books - available as PDF or paperback  *
14
    *                                                                         *
15
    *        "Using the FreeRTOS Real Time Kernel - a Practical Guide"        *
16
    *                  http://www.FreeRTOS.org/Documentation                  *
17
    *                                                                         *
18
    * A pdf reference manual is also available.  Both are usually delivered   *
19
    * to your inbox within 20 minutes to two hours when purchased between 8am *
20
    * and 8pm GMT (although please allow up to 24 hours in case of            *
21
    * exceptional circumstances).  Thank you for your support!                *
22
    *                                                                         *
23
    ***************************************************************************
24
 
25
    This file is part of the FreeRTOS distribution.
26
 
27
    FreeRTOS is free software; you can redistribute it and/or modify it under
28
    the terms of the GNU General Public License (version 2) as published by the
29
    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
30
    ***NOTE*** The exception to the GPL is included to allow you to distribute
31
    a combined work that includes FreeRTOS without being obliged to provide the
32
    source code for proprietary components outside of the FreeRTOS kernel.
33
    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
34
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
35
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
36
    more details. You should have received a copy of the GNU General Public
37
    License and the FreeRTOS license exception along with FreeRTOS; if not it
38
    can be viewed here: http://www.freertos.org/a00114.html and also obtained
39
    by writing to Richard Barry, contact details for whom are available on the
40
    FreeRTOS WEB site.
41
 
42
    1 tab == 4 spaces!
43
 
44
    http://www.FreeRTOS.org - Documentation, latest information, license and
45
    contact details.
46
 
47
    http://www.SafeRTOS.com - A version that is certified for use in safety
48
    critical systems.
49
 
50
    http://www.OpenRTOS.com - Commercial support, development, porting,
51
    licensing and training services.
52
*/
53
 
54
/* Standard includes. */
55
#include <string.h>
56
 
57
/* Scheduler includes. */
58
#include "FreeRTOS.h"
59
#include "task.h"
60
#include "semphr.h"
61
 
62
/* uip includes. */
63
#include "uip.h"
64
#include "uip_arp.h"
65
#include "httpd.h"
66
#include "timer.h"
67
#include "clock-arch.h"
68
#include "timer.h"
69
 
70
/* Demo includes. */
71
#include "FEC.h"
72
#include "partest.h"
73
 
74
/*-----------------------------------------------------------*/
75
 
76
/* Shortcut to the header within the Rx buffer. */
77
#define xHeader ((struct uip_eth_hdr *) &uip_buf[ 0 ])
78
 
79
/*-----------------------------------------------------------*/
80
 
81
/*
82
 * Port functions required by the uIP stack.
83
 */
84
clock_time_t clock_time( void );
85
 
86
/*-----------------------------------------------------------*/
87
 
88
/* The semaphore used by the ISR to wake the uIP task. */
89
extern xSemaphoreHandle xFECSemaphore;
90
 
91
/*-----------------------------------------------------------*/
92
 
93
clock_time_t clock_time( void )
94
{
95
        return xTaskGetTickCount();
96
}
97
 
98
 
99
void vuIP_Task( void *pvParameters )
100
{
101
portBASE_TYPE i;
102
uip_ipaddr_t xIPAddr;
103
struct timer periodic_timer, arp_timer;
104
extern void ( vEMAC_ISR )( void );
105
 
106
        /* Just to get rid of the compiler warning. */
107
        ( void ) pvParameters;
108
 
109
        /* Enable/Reset the Ethernet Controller */
110
 
111
        /* Create the semaphore used by the ISR to wake this task. */
112
        vSemaphoreCreateBinary( xFECSemaphore );
113
 
114
        /* Initialise the uIP stack. */
115
        timer_set( &periodic_timer, configTICK_RATE_HZ / 2 );
116
        timer_set( &arp_timer, configTICK_RATE_HZ * 10 );
117
        uip_init();
118
        uip_ipaddr( xIPAddr, configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 );
119
        uip_sethostaddr( xIPAddr );
120
        uip_ipaddr( xIPAddr, configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 );
121
        uip_setnetmask( xIPAddr );
122
        httpd_init();
123
 
124
        vInitFEC();
125
 
126
        for( ;; )
127
        {
128
                /* Is there received data ready to be processed? */
129
                uip_len = ( unsigned short ) ulFECRx();
130
 
131
                if( ( uip_len > 0 ) && ( uip_buf != NULL ) )
132
                {
133
                        /* Standard uIP loop taken from the uIP manual. */
134
 
135
                        if( xHeader->type == htons( UIP_ETHTYPE_IP ) )
136
                        {
137
                                uip_arp_ipin();
138
                                uip_input();
139
 
140
                                /* If the above function invocation resulted in data that
141
                                should be sent out on the network, the global variable
142
                                uip_len is set to a value > 0. */
143
                                if( uip_len > 0 )
144
                                {
145
                                        uip_arp_out();
146
                                        vFECTx();
147
                                }
148
                        }
149
                        else if( xHeader->type == htons( UIP_ETHTYPE_ARP ) )
150
                        {
151
                                uip_arp_arpin();
152
 
153
                                /* If the above function invocation resulted in data that
154
                                should be sent out on the network, the global variable
155
                                uip_len is set to a value > 0. */
156
                                if( uip_len > 0 )
157
                                {
158
                                        vFECTx();
159
                                }
160
                        }
161
                }
162
                else
163
                {
164
                        if( ( timer_expired( &periodic_timer ) ) && ( uip_buf != NULL ) )
165
                        {
166
                                timer_reset( &periodic_timer );
167
                                for( i = 0; i < UIP_CONNS; i++ )
168
                                {
169
                                        uip_periodic( i );
170
 
171
                                        /* If the above function invocation resulted in data that
172
                                        should be sent out on the network, the global variable
173
                                        uip_len is set to a value > 0. */
174
                                        if( uip_len > 0 )
175
                                        {
176
                                                uip_arp_out();
177
                                                vFECTx();
178
                                        }
179
                                }
180
 
181
                                /* Call the ARP timer function every 10 seconds. */
182
                                if( timer_expired( &arp_timer ) )
183
                                {
184
                                        timer_reset( &arp_timer );
185
                                        uip_arp_timer();
186
                                }
187
                        }
188
                        else
189
                        {
190
                                /* We did not receive a packet, and there was no periodic
191
                                processing to perform.  Block for a fixed period.  If a packet
192
                                is received during this period we will be woken by the ISR
193
                                giving us the Semaphore. */
194
                                xSemaphoreTake( xFECSemaphore, configTICK_RATE_HZ / 2 );
195
                        }
196
                }
197
        }
198
}
199
/*-----------------------------------------------------------*/
200
 
201
void vApplicationProcessFormInput( char *pcInputString, portBASE_TYPE xInputLength )
202
{
203
char *c;
204
 
205
        /* Just to get rid of the compiler warning - other ports/demos use the parameter. */
206
        ( void ) xInputLength;
207
 
208
        /* Process the form input sent by the IO page of the served HTML. */
209
 
210
        c = strstr( pcInputString, "?" );
211
 
212
    if( c )
213
    {
214
                /* Turn LED's on or off in accordance with the check box status. */
215
                if( strstr( c, "LED3=1" ) != NULL )
216
                {
217
                        /* Turn LED 3 on. */
218
                        vParTestSetLED( 3, 1 );
219
                }
220
                else
221
                {
222
                        /* Turn LED 3 off. */
223
                        vParTestSetLED( 3, 0 );
224
                }
225
    }
226
}
227
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.