]> git.sur5r.net Git - freertos/blob - Demo/ARM9_STR91X_IAR/lwip/lwipWebServer/BasicWEB.c
Update version number.
[freertos] / Demo / ARM9_STR91X_IAR / lwip / lwipWebServer / BasicWEB.c
1 \r
2 /*\r
3         FreeRTOS.org V5.4.0 - Copyright (C) 2003-2009 Richard Barry.\r
4 \r
5         This file is part of the FreeRTOS.org distribution.\r
6 \r
7         FreeRTOS.org is free software; you can redistribute it and/or modify it\r
8         under the terms of the GNU General Public License (version 2) as published\r
9         by the 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.org without being obliged to provide\r
12         the source code for any proprietary components.  Alternative commercial\r
13         license and support terms are also available upon request.  See the \r
14         licensing section of http://www.FreeRTOS.org for full details.\r
15 \r
16         FreeRTOS.org is distributed in the hope that it will be useful, but WITHOUT\r
17         ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
18         FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
19         more details.\r
20 \r
21         You should have received a copy of the GNU General Public License along\r
22         with FreeRTOS.org; if not, write to the Free Software Foundation, Inc., 59\r
23         Temple Place, Suite 330, Boston, MA  02111-1307  USA.\r
24 \r
25 \r
26         ***************************************************************************\r
27         *                                                                         *\r
28         * Get the FreeRTOS eBook!  See http://www.FreeRTOS.org/Documentation      *\r
29         *                                                                         *\r
30         * This is a concise, step by step, 'hands on' guide that describes both   *\r
31         * general multitasking concepts and FreeRTOS specifics. It presents and   *\r
32         * explains numerous examples that are written using the FreeRTOS API.     *\r
33         * Full source code for all the examples is provided in an accompanying    *\r
34         * .zip file.                                                              *\r
35         *                                                                         *\r
36         ***************************************************************************\r
37 \r
38         1 tab == 4 spaces!\r
39 \r
40         Please ensure to read the configuration and relevant port sections of the\r
41         online documentation.\r
42 \r
43         http://www.FreeRTOS.org - Documentation, latest information, license and\r
44         contact details.\r
45 \r
46         http://www.SafeRTOS.com - A version that is certified for use in safety\r
47         critical systems.\r
48 \r
49         http://www.OpenRTOS.com - Commercial support, development, porting,\r
50         licensing and training services.\r
51 */\r
52 \r
53 /*\r
54         Implements a simplistic WEB server.  Every time a connection is made and\r
55         data is received a dynamic page that shows the current TCP/IP statistics\r
56         is generated and returned.  The connection is then closed.\r
57 */\r
58 \r
59 \r
60 /*------------------------------------------------------------------------------*/\r
61 /*                            PROTOTYPES                                        */\r
62 /*------------------------------------------------------------------------------*/\r
63 \r
64 /* Standard includes. */\r
65 #include <stdio.h>\r
66 #include <string.h>\r
67 \r
68 /* Scheduler includes. */\r
69 #include "FreeRTOS.h"\r
70 #include "task.h"\r
71 #include "semphr.h"\r
72 \r
73 /* Demo includes. */\r
74 #include "BasicWEB.h"\r
75 \r
76 /* lwIP includes. */\r
77 #include "lwip/api.h"\r
78 #include "lwip/tcpip.h"\r
79 #include "lwip/memp.h"\r
80 #include "lwip/stats.h"\r
81 #include "netif/loopif.h"\r
82 #include "lcd.h"\r
83 #include "httpd.h"\r
84 \r
85 #define lwipTCP_STACK_SIZE                      600\r
86 \r
87 \r
88 /*------------------------------------------------------------------------------*/\r
89 /*                            GLOBALS                                          */\r
90 /*------------------------------------------------------------------------------*/\r
91 static struct netif EMAC_if;\r
92 \r
93 /*------------------------------------------------------------------------------*/\r
94 /*                            FUNCTIONS                                         */\r
95 /*------------------------------------------------------------------------------*/\r
96 \r
97 \r
98 void vlwIPInit( void )\r
99 {\r
100     /* Initialize lwIP and its interface layer. */\r
101         sys_init();\r
102         mem_init();                                                             \r
103         memp_init();\r
104         pbuf_init();\r
105         netif_init();\r
106         ip_init();\r
107         sys_set_state(( signed portCHAR * ) "lwIP", lwipTCP_STACK_SIZE);\r
108         tcpip_init( NULL, NULL );       \r
109         sys_set_default_state();\r
110 }\r
111 /*------------------------------------------------------------*/\r
112 \r
113 void vBasicWEBServer( void *pvParameters )\r
114 {\r
115 struct ip_addr xIpAddr, xNetMast, xGateway;\r
116 extern err_t ethernetif_init( struct netif *netif );\r
117 \r
118     /* Parameters are not used - suppress compiler error. */\r
119     ( void ) pvParameters;\r
120 \r
121     /* Create and configure the EMAC interface. */\r
122     IP4_ADDR( &xIpAddr, emacIPADDR0, emacIPADDR1, emacIPADDR2, emacIPADDR3 );\r
123     IP4_ADDR( &xNetMast, emacNET_MASK0, emacNET_MASK1, emacNET_MASK2, emacNET_MASK3 );\r
124     IP4_ADDR( &xGateway, emacGATEWAY_ADDR0, emacGATEWAY_ADDR1, emacGATEWAY_ADDR2, emacGATEWAY_ADDR3 );\r
125     netif_add( &EMAC_if, &xIpAddr, &xNetMast, &xGateway, NULL, ethernetif_init, tcpip_input );\r
126 \r
127     /* make it the default interface */\r
128     netif_set_default( &EMAC_if );\r
129 \r
130     /* bring it up */\r
131     netif_set_up(&EMAC_if);\r
132 \r
133     /* Initialize HTTP */\r
134     httpd_init();\r
135 \r
136         /* Nothing else to do.  No point hanging around. */\r
137         vTaskDelete( NULL );\r
138 }\r
139 \r
140 \r