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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [ColdFire_MCF52233_Eclipse/] [RTOSDemo/] [webserver/] [uIP_Task.c] - Blame information for rev 578

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
 
55
/* Task that controls the uIP TCP/IP stack. */
56
 
57
 
58
/* Standard includes. */
59
#include <string.h>
60
 
61
/* Scheduler includes. */
62
#include "FreeRTOS.h"
63
#include "task.h"
64
#include "semphr.h"
65
 
66
/* uip includes. */
67
#include "uip.h"
68
#include "uip_arp.h"
69
#include "httpd.h"
70
#include "timer.h"
71
#include "clock-arch.h"
72
 
73
/* Demo includes. */
74
#include "FEC.h"
75
#include "partest.h"
76
 
77
 
78
/*-----------------------------------------------------------*/
79
 
80
/* Shortcut to the header within the Rx buffer. */
81
#define xHeader ((struct uip_eth_hdr *) &uip_buf[ 0 ])
82
 
83
/*-----------------------------------------------------------*/
84
 
85
/*
86
 * Port functions required by the uIP stack.
87
 */
88
void clock_init( void );
89
clock_time_t clock_time( void );
90
extern void timer_set(struct timer *t, clock_time_t interval);
91
extern int timer_expired(struct timer *t);
92
extern void timer_reset(struct timer *t);
93
 
94
/*-----------------------------------------------------------*/
95
 
96
/* The semaphore used by the ISR to wake the uIP task. */
97
extern xSemaphoreHandle xFECSemaphore;
98
 
99
/*-----------------------------------------------------------*/
100
 
101
void clock_init(void)
102
{
103
        /* This is done when the scheduler starts. */
104
}
105
/*-----------------------------------------------------------*/
106
 
107
/* Define clock functions here to avoid header file name clash between uIP
108
and the Luminary Micro driver library. */
109
clock_time_t clock_time( void )
110
{
111
        return xTaskGetTickCount();
112
}
113
/*-----------------------------------------------------------*/
114
 
115
void vuIP_Task( void *pvParameters )
116
{
117
portBASE_TYPE i;
118
uip_ipaddr_t xIPAddr;
119
struct timer periodic_timer, arp_timer;
120
 
121
        /* To prevent compiler warnings. */
122
        ( void ) pvParameters;
123
 
124
        /* Initialise the uIP stack. */
125
        timer_set( &periodic_timer, configTICK_RATE_HZ / 2 );
126
        timer_set( &arp_timer, configTICK_RATE_HZ * 10 );
127
        uip_init();
128
        uip_ipaddr( xIPAddr, configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 );
129
        uip_sethostaddr( xIPAddr );
130
 
131
        /* Initialise the WEB server. */
132
        httpd_init();
133
 
134
        /* Initialise the Ethernet controller peripheral. */
135
        vFECInit();
136
 
137
        for( ;; )
138
        {
139
                /* Is there received data ready to be processed? */
140
                uip_len = usFECGetRxedData();
141
 
142
                if( uip_len > 0 )
143
                {
144
                        /* Standard uIP loop taken from the uIP manual. */
145
 
146
                        if( xHeader->type == htons( UIP_ETHTYPE_IP ) )
147
                        {
148
                                uip_arp_ipin();
149
                                uip_input();
150
 
151
                                /* If the above function invocation resulted in data that
152
                                should be sent out on the network, the global variable
153
                                uip_len is set to a value > 0. */
154
                                if( uip_len > 0 )
155
                                {
156
                                        uip_arp_out();
157
                                        vFECSendData();
158
                                }
159
                                else
160
                                {
161
                                        /* If we are not sending data then let the FEC driver know
162
                                        the buffer is no longer required. */
163
                                        vFECRxProcessingCompleted();
164
                                }
165
                        }
166
                        else if( xHeader->type == htons( UIP_ETHTYPE_ARP ) )
167
                        {
168
                                uip_arp_arpin();
169
 
170
                                /* If the above function invocation resulted in data that
171
                                should be sent out on the network, the global variable
172
                                uip_len is set to a value > 0. */
173
                                if( uip_len > 0 )
174
                                {
175
                                        vFECSendData();
176
                                }
177
                                else
178
                                {
179
                                        /* If we are not sending data then let the FEC driver know
180
                                        the buffer is no longer required. */
181
                                        vFECRxProcessingCompleted();
182
                                }
183
                        }
184
                        else
185
                        {
186
                                /* If we are not sending data then let the FEC driver know
187
                                the buffer is no longer required. */
188
                                vFECRxProcessingCompleted();
189
                        }
190
                }
191
                else
192
                {
193
                        if( timer_expired( &periodic_timer ) )
194
                        {
195
                                timer_reset( &periodic_timer );
196
                                for( i = 0; i < UIP_CONNS; i++ )
197
                                {
198
                                        uip_periodic( i );
199
 
200
                                        /* If the above function invocation resulted in data that
201
                                        should be sent out on the network, the global variable
202
                                        uip_len is set to a value > 0. */
203
                                        if( uip_len > 0 )
204
                                        {
205
                                                uip_arp_out();
206
                                                vFECSendData();
207
                                        }
208
                                }
209
 
210
                                /* Call the ARP timer function every 10 seconds. */
211
                                if( timer_expired( &arp_timer ) )
212
                                {
213
                                        timer_reset( &arp_timer );
214
                                        uip_arp_timer();
215
                                }
216
                        }
217
                        else
218
                        {
219
                                /* We did not receive a packet, and there was no periodic
220
                                processing to perform.  Block for a fixed period.  If a packet
221
                                is received during this period we will be woken by the ISR
222
                                giving us the Semaphore. */
223
                                xSemaphoreTake( xFECSemaphore, configTICK_RATE_HZ / 2 );
224
                        }
225
                }
226
        }
227
}
228
/*-----------------------------------------------------------*/
229
 
230
 
231
 

powered by: WebSVN 2.1.0

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