]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/ARM9_STR91X_IAR/lwip/lwipWebServer/BasicWEB.c
Update version numbers in preparation for new release.
[freertos] / FreeRTOS / Demo / ARM9_STR91X_IAR / lwip / lwipWebServer / BasicWEB.c
1 \r
2 /*\r
3     FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
4     All rights reserved\r
5 \r
6     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
7 \r
8     This file is part of the FreeRTOS distribution.\r
9 \r
10     FreeRTOS is free software; you can redistribute it and/or modify it under\r
11     the terms of the GNU General Public License (version 2) as published by the\r
12     Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
13 \r
14     ***************************************************************************\r
15     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
16     >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
17     >>!   obliged to provide the source code for proprietary components     !<<\r
18     >>!   outside of the FreeRTOS kernel.                                   !<<\r
19     ***************************************************************************\r
20 \r
21     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
22     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
23     FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
24     link: http://www.freertos.org/a00114.html\r
25 \r
26     ***************************************************************************\r
27      *                                                                       *\r
28      *    FreeRTOS provides completely free yet professionally developed,    *\r
29      *    robust, strictly quality controlled, supported, and cross          *\r
30      *    platform software that is more than just the market leader, it     *\r
31      *    is the industry's de facto standard.                               *\r
32      *                                                                       *\r
33      *    Help yourself get started quickly while simultaneously helping     *\r
34      *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
35      *    tutorial book, reference manual, or both:                          *\r
36      *    http://www.FreeRTOS.org/Documentation                              *\r
37      *                                                                       *\r
38     ***************************************************************************\r
39 \r
40     http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
41     the FAQ page "My application does not run, what could be wrong?".  Have you\r
42     defined configASSERT()?\r
43 \r
44     http://www.FreeRTOS.org/support - In return for receiving this top quality\r
45     embedded software for free we request you assist our global community by\r
46     participating in the support forum.\r
47 \r
48     http://www.FreeRTOS.org/training - Investing in training allows your team to\r
49     be as productive as possible as early as possible.  Now you can receive\r
50     FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
51     Ltd, and the world's leading authority on the world's leading RTOS.\r
52 \r
53     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
54     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
55     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
56 \r
57     http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
58     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
59 \r
60     http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
61     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
62     licenses offer ticketed support, indemnification and commercial middleware.\r
63 \r
64     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
65     engineered and independently SIL3 certified version for use in safety and\r
66     mission critical applications that require provable dependability.\r
67 \r
68     1 tab == 4 spaces!\r
69 */\r
70 \r
71 /*\r
72         Implements a simplistic WEB server.  Every time a connection is made and\r
73         data is received a dynamic page that shows the current TCP/IP statistics\r
74         is generated and returned.  The connection is then closed.\r
75 */\r
76 \r
77 \r
78 /*------------------------------------------------------------------------------*/\r
79 /*                            PROTOTYPES                                        */\r
80 /*------------------------------------------------------------------------------*/\r
81 \r
82 /* Standard includes. */\r
83 #include <stdio.h>\r
84 #include <string.h>\r
85 \r
86 /* Scheduler includes. */\r
87 #include "FreeRTOS.h"\r
88 #include "task.h"\r
89 #include "semphr.h"\r
90 \r
91 /* Demo includes. */\r
92 #include "BasicWEB.h"\r
93 \r
94 /* lwIP includes. */\r
95 #include "lwip/api.h"\r
96 #include "lwip/tcpip.h"\r
97 #include "lwip/memp.h"\r
98 #include "lwip/stats.h"\r
99 #include "netif/loopif.h"\r
100 #include "lcd.h"\r
101 #include "httpd.h"\r
102 \r
103 #define lwipTCP_STACK_SIZE                      600\r
104 \r
105 \r
106 /*------------------------------------------------------------------------------*/\r
107 /*                            GLOBALS                                          */\r
108 /*------------------------------------------------------------------------------*/\r
109 static struct netif EMAC_if;\r
110 \r
111 /*------------------------------------------------------------------------------*/\r
112 /*                            FUNCTIONS                                         */\r
113 /*------------------------------------------------------------------------------*/\r
114 \r
115 \r
116 void vlwIPInit( void )\r
117 {\r
118     /* Initialize lwIP and its interface layer. */\r
119         sys_init();\r
120         mem_init();                                                             \r
121         memp_init();\r
122         pbuf_init();\r
123         netif_init();\r
124         ip_init();\r
125         sys_set_state(( signed char * ) "lwIP", lwipTCP_STACK_SIZE);\r
126         tcpip_init( NULL, NULL );       \r
127         sys_set_default_state();\r
128 }\r
129 /*------------------------------------------------------------*/\r
130 \r
131 void vBasicWEBServer( void *pvParameters )\r
132 {\r
133 struct ip_addr xIpAddr, xNetMast, xGateway;\r
134 extern err_t ethernetif_init( struct netif *netif );\r
135 \r
136     /* Parameters are not used - suppress compiler error. */\r
137     ( void ) pvParameters;\r
138 \r
139     /* Create and configure the EMAC interface. */\r
140     IP4_ADDR( &xIpAddr, emacIPADDR0, emacIPADDR1, emacIPADDR2, emacIPADDR3 );\r
141     IP4_ADDR( &xNetMast, emacNET_MASK0, emacNET_MASK1, emacNET_MASK2, emacNET_MASK3 );\r
142     IP4_ADDR( &xGateway, emacGATEWAY_ADDR0, emacGATEWAY_ADDR1, emacGATEWAY_ADDR2, emacGATEWAY_ADDR3 );\r
143     netif_add( &EMAC_if, &xIpAddr, &xNetMast, &xGateway, NULL, ethernetif_init, tcpip_input );\r
144 \r
145     /* make it the default interface */\r
146     netif_set_default( &EMAC_if );\r
147 \r
148     /* bring it up */\r
149     netif_set_up(&EMAC_if);\r
150 \r
151     /* Initialize HTTP */\r
152     httpd_init();\r
153 \r
154         /* Nothing else to do.  No point hanging around. */\r
155         vTaskDelete( NULL );\r
156 }\r
157 \r
158 \r