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