]> git.sur5r.net Git - freertos/blob - Demo/ARM9_STR91X_IAR/lwip/lwipWebServer/BasicWEB.c
Update to V4.7.0.
[freertos] / Demo / ARM9_STR91X_IAR / lwip / lwipWebServer / BasicWEB.c
1 \r
2 /*\r
3         FreeRTOS.org V4.7.0 - copyright (C) 2003-2006 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\r
8         it under the terms of the GNU General Public License as published by\r
9         the Free Software Foundation; either version 2 of the License, or\r
10         (at your option) any later version.\r
11 \r
12         FreeRTOS.org is distributed in the hope that it will be useful,\r
13         but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15         GNU General Public License for more details.\r
16 \r
17         You should have received a copy of the GNU General Public License\r
18         along with FreeRTOS.org; if not, write to the Free Software\r
19         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
20 \r
21         A special exception to the GPL can be applied should you wish to distribute\r
22         a combined work that includes FreeRTOS.org, without being obliged to provide\r
23         the source code for any proprietary components.  See the licensing section\r
24         of http://www.FreeRTOS.org for full details of how and when the exception\r
25         can be applied.\r
26 \r
27         ***************************************************************************\r
28         See http://www.FreeRTOS.org for documentation, latest information, license\r
29         and contact details.  Please ensure to read the configuration and relevant\r
30         port sections of the online documentation.\r
31         ***************************************************************************\r
32 */\r
33 \r
34 /*\r
35         Implements a simplistic WEB server.  Every time a connection is made and\r
36         data is received a dynamic page that shows the current TCP/IP statistics\r
37         is generated and returned.  The connection is then closed.\r
38 */\r
39 \r
40 \r
41 /*------------------------------------------------------------------------------*/\r
42 /*                            PROTOTYPES                                        */\r
43 /*------------------------------------------------------------------------------*/\r
44 \r
45 /* Standard includes. */\r
46 #include <stdio.h>\r
47 #include <string.h>\r
48 \r
49 /* Scheduler includes. */\r
50 #include "FreeRTOS.h"\r
51 #include "task.h"\r
52 #include "semphr.h"\r
53 \r
54 /* Demo includes. */\r
55 #include "BasicWEB.h"\r
56 \r
57 /* lwIP includes. */\r
58 #include "lwip/api.h"\r
59 #include "lwip/tcpip.h"\r
60 #include "lwip/memp.h"\r
61 #include "lwip/stats.h"\r
62 #include "netif/loopif.h"\r
63 #include "lcd.h"\r
64 #include "httpd.h"\r
65 \r
66 #define lwipTCP_STACK_SIZE                      600\r
67 \r
68 \r
69 /*------------------------------------------------------------------------------*/\r
70 /*                            GLOBALS                                          */\r
71 /*------------------------------------------------------------------------------*/\r
72 static struct netif EMAC_if;\r
73 \r
74 /*------------------------------------------------------------------------------*/\r
75 /*                            FUNCTIONS                                         */\r
76 /*------------------------------------------------------------------------------*/\r
77 \r
78 \r
79 void vlwIPInit( void )\r
80 {\r
81     /* Initialize lwIP and its interface layer. */\r
82         sys_init();\r
83         mem_init();                                                             \r
84         memp_init();\r
85         pbuf_init();\r
86         netif_init();\r
87         ip_init();\r
88         sys_set_state(( signed portCHAR * ) "lwIP", lwipTCP_STACK_SIZE);\r
89         tcpip_init( NULL, NULL );       \r
90         sys_set_default_state();\r
91 }\r
92 /*------------------------------------------------------------*/\r
93 \r
94 void vBasicWEBServer( void *pvParameters )\r
95 {\r
96 struct ip_addr xIpAddr, xNetMast, xGateway;\r
97 extern err_t ethernetif_init( struct netif *netif );\r
98 \r
99     /* Parameters are not used - suppress compiler error. */\r
100     ( void ) pvParameters;\r
101 \r
102     /* Create and configure the EMAC interface. */\r
103     IP4_ADDR( &xIpAddr, emacIPADDR0, emacIPADDR1, emacIPADDR2, emacIPADDR3 );\r
104     IP4_ADDR( &xNetMast, emacNET_MASK0, emacNET_MASK1, emacNET_MASK2, emacNET_MASK3 );\r
105     IP4_ADDR( &xGateway, emacGATEWAY_ADDR0, emacGATEWAY_ADDR1, emacGATEWAY_ADDR2, emacGATEWAY_ADDR3 );\r
106     netif_add( &EMAC_if, &xIpAddr, &xNetMast, &xGateway, NULL, ethernetif_init, tcpip_input );\r
107 \r
108     /* make it the default interface */\r
109     netif_set_default( &EMAC_if );\r
110 \r
111     /* bring it up */\r
112     netif_set_up(&EMAC_if);\r
113 \r
114     /* Initialize HTTP */\r
115     httpd_init();\r
116 \r
117         /* Nothing else to do.  No point hanging around. */\r
118         vTaskDelete( NULL );\r
119 }\r
120 \r
121 \r