]> git.sur5r.net Git - freertos/blob - Demo/ARM9_STR91X_IAR/lwip/lwipWebServer/BasicWEB.c
ffb1cfd60094ae7f5e793bb65ce1ba5e38a0aef8
[freertos] / Demo / ARM9_STR91X_IAR / lwip / lwipWebServer / BasicWEB.c
1 \r
2 /*\r
3     FreeRTOS V6.0.0 - Copyright (C) 2009 Real Time Engineers Ltd.\r
4 \r
5     This file is part of the FreeRTOS distribution.\r
6 \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
15     license details.\r
16 \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
20     more details.\r
21 \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
25 \r
26 \r
27     ***************************************************************************\r
28     *                                                                         *\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
32     *                                                                         *\r
33     ***************************************************************************\r
34 \r
35     1 tab == 4 spaces!\r
36 \r
37     Please ensure to read the configuration and relevant port sections of the\r
38     online documentation.\r
39 \r
40     http://www.FreeRTOS.org - Documentation, latest information, license and\r
41     contact details.\r
42 \r
43     http://www.SafeRTOS.com - A version that is certified for use in safety\r
44     critical systems.\r
45 \r
46     http://www.OpenRTOS.com - Commercial support, development, porting,\r
47     licensing and training services.\r
48 */\r
49 \r
50 /*\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
54 */\r
55 \r
56 \r
57 /*------------------------------------------------------------------------------*/\r
58 /*                            PROTOTYPES                                        */\r
59 /*------------------------------------------------------------------------------*/\r
60 \r
61 /* Standard includes. */\r
62 #include <stdio.h>\r
63 #include <string.h>\r
64 \r
65 /* Scheduler includes. */\r
66 #include "FreeRTOS.h"\r
67 #include "task.h"\r
68 #include "semphr.h"\r
69 \r
70 /* Demo includes. */\r
71 #include "BasicWEB.h"\r
72 \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
79 #include "lcd.h"\r
80 #include "httpd.h"\r
81 \r
82 #define lwipTCP_STACK_SIZE                      600\r
83 \r
84 \r
85 /*------------------------------------------------------------------------------*/\r
86 /*                            GLOBALS                                          */\r
87 /*------------------------------------------------------------------------------*/\r
88 static struct netif EMAC_if;\r
89 \r
90 /*------------------------------------------------------------------------------*/\r
91 /*                            FUNCTIONS                                         */\r
92 /*------------------------------------------------------------------------------*/\r
93 \r
94 \r
95 void vlwIPInit( void )\r
96 {\r
97     /* Initialize lwIP and its interface layer. */\r
98         sys_init();\r
99         mem_init();                                                             \r
100         memp_init();\r
101         pbuf_init();\r
102         netif_init();\r
103         ip_init();\r
104         sys_set_state(( signed char * ) "lwIP", lwipTCP_STACK_SIZE);\r
105         tcpip_init( NULL, NULL );       \r
106         sys_set_default_state();\r
107 }\r
108 /*------------------------------------------------------------*/\r
109 \r
110 void vBasicWEBServer( void *pvParameters )\r
111 {\r
112 struct ip_addr xIpAddr, xNetMast, xGateway;\r
113 extern err_t ethernetif_init( struct netif *netif );\r
114 \r
115     /* Parameters are not used - suppress compiler error. */\r
116     ( void ) pvParameters;\r
117 \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
123 \r
124     /* make it the default interface */\r
125     netif_set_default( &EMAC_if );\r
126 \r
127     /* bring it up */\r
128     netif_set_up(&EMAC_if);\r
129 \r
130     /* Initialize HTTP */\r
131     httpd_init();\r
132 \r
133         /* Nothing else to do.  No point hanging around. */\r
134         vTaskDelete( NULL );\r
135 }\r
136 \r
137 \r