]> git.sur5r.net Git - freertos/blob - Demo/ARM9_STR91X_IAR/lwip/lwipWebServer/BasicWEB.c
Update Cortex M3 ports to ensure 8 byte alignment.
[freertos] / Demo / ARM9_STR91X_IAR / lwip / lwipWebServer / BasicWEB.c
1 \r
2 /*\r
3     FreeRTOS V6.0.1 - Copyright (C) 2009 Real Time Engineers Ltd.\r
4 \r
5     ***************************************************************************\r
6     *                                                                         *\r
7     * If you are:                                                             *\r
8     *                                                                         *\r
9     *    + New to FreeRTOS,                                                   *\r
10     *    + Wanting to learn FreeRTOS or multitasking in general quickly       *\r
11     *    + Looking for basic training,                                        *\r
12     *    + Wanting to improve your FreeRTOS skills and productivity           *\r
13     *                                                                         *\r
14     * then take a look at the FreeRTOS eBook                                  *\r
15     *                                                                         *\r
16     *        "Using the FreeRTOS Real Time Kernel - a Practical Guide"        *\r
17     *                  http://www.FreeRTOS.org/Documentation                  *\r
18     *                                                                         *\r
19     * A pdf reference manual is also available.  Both are usually delivered   *\r
20     * to your inbox within 20 minutes to two hours when purchased between 8am *\r
21     * and 8pm GMT (although please allow up to 24 hours in case of            *\r
22     * exceptional circumstances).  Thank you for your support!                *\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 exception to the GPL is included to allow you to distribute\r
32     a combined work that includes FreeRTOS without being obliged to provide the\r
33     source code for proprietary components outside of the FreeRTOS kernel.\r
34     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT\r
35     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
36     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     http://www.FreeRTOS.org - Documentation, latest information, license and\r
46     contact details.\r
47 \r
48     http://www.SafeRTOS.com - A version that is certified for use in safety\r
49     critical systems.\r
50 \r
51     http://www.OpenRTOS.com - Commercial support, development, porting,\r
52     licensing and training services.\r
53 */\r
54 \r
55 /*\r
56         Implements a simplistic WEB server.  Every time a connection is made and\r
57         data is received a dynamic page that shows the current TCP/IP statistics\r
58         is generated and returned.  The connection is then closed.\r
59 */\r
60 \r
61 \r
62 /*------------------------------------------------------------------------------*/\r
63 /*                            PROTOTYPES                                        */\r
64 /*------------------------------------------------------------------------------*/\r
65 \r
66 /* Standard includes. */\r
67 #include <stdio.h>\r
68 #include <string.h>\r
69 \r
70 /* Scheduler includes. */\r
71 #include "FreeRTOS.h"\r
72 #include "task.h"\r
73 #include "semphr.h"\r
74 \r
75 /* Demo includes. */\r
76 #include "BasicWEB.h"\r
77 \r
78 /* lwIP includes. */\r
79 #include "lwip/api.h"\r
80 #include "lwip/tcpip.h"\r
81 #include "lwip/memp.h"\r
82 #include "lwip/stats.h"\r
83 #include "netif/loopif.h"\r
84 #include "lcd.h"\r
85 #include "httpd.h"\r
86 \r
87 #define lwipTCP_STACK_SIZE                      600\r
88 \r
89 \r
90 /*------------------------------------------------------------------------------*/\r
91 /*                            GLOBALS                                          */\r
92 /*------------------------------------------------------------------------------*/\r
93 static struct netif EMAC_if;\r
94 \r
95 /*------------------------------------------------------------------------------*/\r
96 /*                            FUNCTIONS                                         */\r
97 /*------------------------------------------------------------------------------*/\r
98 \r
99 \r
100 void vlwIPInit( void )\r
101 {\r
102     /* Initialize lwIP and its interface layer. */\r
103         sys_init();\r
104         mem_init();                                                             \r
105         memp_init();\r
106         pbuf_init();\r
107         netif_init();\r
108         ip_init();\r
109         sys_set_state(( signed char * ) "lwIP", lwipTCP_STACK_SIZE);\r
110         tcpip_init( NULL, NULL );       \r
111         sys_set_default_state();\r
112 }\r
113 /*------------------------------------------------------------*/\r
114 \r
115 void vBasicWEBServer( void *pvParameters )\r
116 {\r
117 struct ip_addr xIpAddr, xNetMast, xGateway;\r
118 extern err_t ethernetif_init( struct netif *netif );\r
119 \r
120     /* Parameters are not used - suppress compiler error. */\r
121     ( void ) pvParameters;\r
122 \r
123     /* Create and configure the EMAC interface. */\r
124     IP4_ADDR( &xIpAddr, emacIPADDR0, emacIPADDR1, emacIPADDR2, emacIPADDR3 );\r
125     IP4_ADDR( &xNetMast, emacNET_MASK0, emacNET_MASK1, emacNET_MASK2, emacNET_MASK3 );\r
126     IP4_ADDR( &xGateway, emacGATEWAY_ADDR0, emacGATEWAY_ADDR1, emacGATEWAY_ADDR2, emacGATEWAY_ADDR3 );\r
127     netif_add( &EMAC_if, &xIpAddr, &xNetMast, &xGateway, NULL, ethernetif_init, tcpip_input );\r
128 \r
129     /* make it the default interface */\r
130     netif_set_default( &EMAC_if );\r
131 \r
132     /* bring it up */\r
133     netif_set_up(&EMAC_if);\r
134 \r
135     /* Initialize HTTP */\r
136     httpd_init();\r
137 \r
138         /* Nothing else to do.  No point hanging around. */\r
139         vTaskDelete( NULL );\r
140 }\r
141 \r
142 \r