]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/ARM9_STR91X_IAR/lwip/lwipWebServer/BasicWEB.c
c42363911c99325ebd4077ffe79a2de99fc34062
[freertos] / FreeRTOS / Demo / ARM9_STR91X_IAR / lwip / lwipWebServer / BasicWEB.c
1 \r
2 /*\r
3     FreeRTOS V7.4.0 - Copyright (C) 2013 Real Time Engineers Ltd.\r
4 \r
5     FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT\r
6     http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
7 \r
8     ***************************************************************************\r
9      *                                                                       *\r
10      *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
11      *    Complete, revised, and edited pdf reference manuals are also       *\r
12      *    available.                                                         *\r
13      *                                                                       *\r
14      *    Purchasing FreeRTOS documentation will not only help you, by       *\r
15      *    ensuring you get running as quickly as possible and with an        *\r
16      *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
17      *    the FreeRTOS project to continue with its mission of providing     *\r
18      *    professional grade, cross platform, de facto standard solutions    *\r
19      *    for microcontrollers - completely free of charge!                  *\r
20      *                                                                       *\r
21      *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
22      *                                                                       *\r
23      *    Thank you for using FreeRTOS, and thank you for your support!      *\r
24      *                                                                       *\r
25     ***************************************************************************\r
26 \r
27 \r
28     This file is part of the FreeRTOS distribution.\r
29 \r
30     FreeRTOS is free software; you can redistribute it and/or modify it under\r
31     the terms of the GNU General Public License (version 2) as published by the\r
32     Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
33 \r
34     >>>>>>NOTE<<<<<< The modification to the GPL is included to allow you to\r
35     distribute a combined work that includes FreeRTOS without being obliged to\r
36     provide the source code for proprietary components outside of the FreeRTOS\r
37     kernel.\r
38 \r
39     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
40     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
41     FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more\r
42     details. You should have received a copy of the GNU General Public License\r
43     and the FreeRTOS license exception along with FreeRTOS; if not itcan be\r
44     viewed here: http://www.freertos.org/a00114.html and also obtained by\r
45     writing to Real Time Engineers Ltd., contact details for whom are available\r
46     on the FreeRTOS WEB site.\r
47 \r
48     1 tab == 4 spaces!\r
49 \r
50     ***************************************************************************\r
51      *                                                                       *\r
52      *    Having a problem?  Start by reading the FAQ "My application does   *\r
53      *    not run, what could be wrong?"                                     *\r
54      *                                                                       *\r
55      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
56      *                                                                       *\r
57     ***************************************************************************\r
58 \r
59 \r
60     http://www.FreeRTOS.org - Documentation, books, training, latest versions, \r
61     license and Real Time Engineers Ltd. contact details.\r
62 \r
63     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
64     including FreeRTOS+Trace - an indispensable productivity tool, and our new\r
65     fully thread aware and reentrant UDP/IP stack.\r
66 \r
67     http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High \r
68     Integrity Systems, who sell the code with commercial support, \r
69     indemnification and middleware, under the OpenRTOS brand.\r
70     \r
71     http://www.SafeRTOS.com - High Integrity Systems also provide a safety \r
72     engineered and independently SIL3 certified version for use in safety and \r
73     mission critical applications that require provable dependability.\r
74 */\r
75 \r
76 /*\r
77         Implements a simplistic WEB server.  Every time a connection is made and\r
78         data is received a dynamic page that shows the current TCP/IP statistics\r
79         is generated and returned.  The connection is then closed.\r
80 */\r
81 \r
82 \r
83 /*------------------------------------------------------------------------------*/\r
84 /*                            PROTOTYPES                                        */\r
85 /*------------------------------------------------------------------------------*/\r
86 \r
87 /* Standard includes. */\r
88 #include <stdio.h>\r
89 #include <string.h>\r
90 \r
91 /* Scheduler includes. */\r
92 #include "FreeRTOS.h"\r
93 #include "task.h"\r
94 #include "semphr.h"\r
95 \r
96 /* Demo includes. */\r
97 #include "BasicWEB.h"\r
98 \r
99 /* lwIP includes. */\r
100 #include "lwip/api.h"\r
101 #include "lwip/tcpip.h"\r
102 #include "lwip/memp.h"\r
103 #include "lwip/stats.h"\r
104 #include "netif/loopif.h"\r
105 #include "lcd.h"\r
106 #include "httpd.h"\r
107 \r
108 #define lwipTCP_STACK_SIZE                      600\r
109 \r
110 \r
111 /*------------------------------------------------------------------------------*/\r
112 /*                            GLOBALS                                          */\r
113 /*------------------------------------------------------------------------------*/\r
114 static struct netif EMAC_if;\r
115 \r
116 /*------------------------------------------------------------------------------*/\r
117 /*                            FUNCTIONS                                         */\r
118 /*------------------------------------------------------------------------------*/\r
119 \r
120 \r
121 void vlwIPInit( void )\r
122 {\r
123     /* Initialize lwIP and its interface layer. */\r
124         sys_init();\r
125         mem_init();                                                             \r
126         memp_init();\r
127         pbuf_init();\r
128         netif_init();\r
129         ip_init();\r
130         sys_set_state(( signed char * ) "lwIP", lwipTCP_STACK_SIZE);\r
131         tcpip_init( NULL, NULL );       \r
132         sys_set_default_state();\r
133 }\r
134 /*------------------------------------------------------------*/\r
135 \r
136 void vBasicWEBServer( void *pvParameters )\r
137 {\r
138 struct ip_addr xIpAddr, xNetMast, xGateway;\r
139 extern err_t ethernetif_init( struct netif *netif );\r
140 \r
141     /* Parameters are not used - suppress compiler error. */\r
142     ( void ) pvParameters;\r
143 \r
144     /* Create and configure the EMAC interface. */\r
145     IP4_ADDR( &xIpAddr, emacIPADDR0, emacIPADDR1, emacIPADDR2, emacIPADDR3 );\r
146     IP4_ADDR( &xNetMast, emacNET_MASK0, emacNET_MASK1, emacNET_MASK2, emacNET_MASK3 );\r
147     IP4_ADDR( &xGateway, emacGATEWAY_ADDR0, emacGATEWAY_ADDR1, emacGATEWAY_ADDR2, emacGATEWAY_ADDR3 );\r
148     netif_add( &EMAC_if, &xIpAddr, &xNetMast, &xGateway, NULL, ethernetif_init, tcpip_input );\r
149 \r
150     /* make it the default interface */\r
151     netif_set_default( &EMAC_if );\r
152 \r
153     /* bring it up */\r
154     netif_set_up(&EMAC_if);\r
155 \r
156     /* Initialize HTTP */\r
157     httpd_init();\r
158 \r
159         /* Nothing else to do.  No point hanging around. */\r
160         vTaskDelete( NULL );\r
161 }\r
162 \r
163 \r