3 FreeRTOS V6.0.0 - Copyright (C) 2009 Real Time Engineers Ltd.
\r
5 This file is part of the FreeRTOS distribution.
\r
7 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
8 the terms of the GNU General Public License (version 2) as published by the
\r
9 Free Software Foundation and modified by the FreeRTOS exception.
\r
10 **NOTE** The exception to the GPL is included to allow you to distribute a
\r
11 combined work that includes FreeRTOS without being obliged to provide the
\r
12 source code for proprietary components outside of the FreeRTOS kernel.
\r
13 Alternative commercial license and support terms are also available upon
\r
14 request. See the licensing section of http://www.FreeRTOS.org for full
\r
17 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
\r
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
\r
19 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
22 You should have received a copy of the GNU General Public License along
\r
23 with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
\r
24 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
\r
27 ***************************************************************************
\r
29 * The FreeRTOS eBook and reference manual are available to purchase for a *
\r
30 * small fee. Help yourself get started quickly while also helping the *
\r
31 * FreeRTOS project! See http://www.FreeRTOS.org/Documentation for details *
\r
33 ***************************************************************************
\r
37 Please ensure to read the configuration and relevant port sections of the
\r
38 online documentation.
\r
40 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
43 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
46 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
47 licensing and training services.
\r
51 Implements a simplistic WEB server. Every time a connection is made and
\r
52 data is received a dynamic page that shows the current TCP/IP statistics
\r
53 is generated and returned. The connection is then closed.
\r
57 /*------------------------------------------------------------------------------*/
\r
59 /*------------------------------------------------------------------------------*/
\r
61 /* Standard includes. */
\r
65 /* Scheduler includes. */
\r
66 #include "FreeRTOS.h"
\r
70 /* Demo includes. */
\r
71 #include "BasicWEB.h"
\r
73 /* lwIP includes. */
\r
74 #include "lwip/api.h"
\r
75 #include "lwip/tcpip.h"
\r
76 #include "lwip/memp.h"
\r
77 #include "lwip/stats.h"
\r
78 #include "netif/loopif.h"
\r
82 #define lwipTCP_STACK_SIZE 600
\r
85 /*------------------------------------------------------------------------------*/
\r
87 /*------------------------------------------------------------------------------*/
\r
88 static struct netif EMAC_if;
\r
90 /*------------------------------------------------------------------------------*/
\r
92 /*------------------------------------------------------------------------------*/
\r
95 void vlwIPInit( void )
\r
97 /* Initialize lwIP and its interface layer. */
\r
104 sys_set_state(( signed char * ) "lwIP", lwipTCP_STACK_SIZE);
\r
105 tcpip_init( NULL, NULL );
\r
106 sys_set_default_state();
\r
108 /*------------------------------------------------------------*/
\r
110 void vBasicWEBServer( void *pvParameters )
\r
112 struct ip_addr xIpAddr, xNetMast, xGateway;
\r
113 extern err_t ethernetif_init( struct netif *netif );
\r
115 /* Parameters are not used - suppress compiler error. */
\r
116 ( void ) pvParameters;
\r
118 /* Create and configure the EMAC interface. */
\r
119 IP4_ADDR( &xIpAddr, emacIPADDR0, emacIPADDR1, emacIPADDR2, emacIPADDR3 );
\r
120 IP4_ADDR( &xNetMast, emacNET_MASK0, emacNET_MASK1, emacNET_MASK2, emacNET_MASK3 );
\r
121 IP4_ADDR( &xGateway, emacGATEWAY_ADDR0, emacGATEWAY_ADDR1, emacGATEWAY_ADDR2, emacGATEWAY_ADDR3 );
\r
122 netif_add( &EMAC_if, &xIpAddr, &xNetMast, &xGateway, NULL, ethernetif_init, tcpip_input );
\r
124 /* make it the default interface */
\r
125 netif_set_default( &EMAC_if );
\r
128 netif_set_up(&EMAC_if);
\r
130 /* Initialize HTTP */
\r
133 /* Nothing else to do. No point hanging around. */
\r
134 vTaskDelete( NULL );
\r