]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/ARM9_STR91X_IAR/lwip/lwipWebServer/BasicWEB.c
Update to MIT licensed FreeRTOS V10.0.0 - see https://www.freertos.org/History.txt
[freertos] / FreeRTOS / Demo / ARM9_STR91X_IAR / lwip / lwipWebServer / BasicWEB.c
1 \r
2 /*\r
3  * FreeRTOS Kernel V10.0.0\r
4  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
5  *\r
6  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
7  * this software and associated documentation files (the "Software"), to deal in\r
8  * the Software without restriction, including without limitation the rights to\r
9  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
10  * the Software, and to permit persons to whom the Software is furnished to do so,\r
11  * subject to the following conditions:\r
12  *\r
13  * The above copyright notice and this permission notice shall be included in all\r
14  * copies or substantial portions of the Software. If you wish to use our Amazon\r
15  * FreeRTOS name, please do so in a fair use way that does not cause confusion.\r
16  *\r
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
19  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
20  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
21  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
23  *\r
24  * http://www.FreeRTOS.org\r
25  * http://aws.amazon.com/freertos\r
26  *\r
27  * 1 tab == 4 spaces!\r
28  */\r
29 \r
30 /*\r
31         Implements a simplistic WEB server.  Every time a connection is made and\r
32         data is received a dynamic page that shows the current TCP/IP statistics\r
33         is generated and returned.  The connection is then closed.\r
34 */\r
35 \r
36 \r
37 /*------------------------------------------------------------------------------*/\r
38 /*                            PROTOTYPES                                        */\r
39 /*------------------------------------------------------------------------------*/\r
40 \r
41 /* Standard includes. */\r
42 #include <stdio.h>\r
43 #include <string.h>\r
44 \r
45 /* Scheduler includes. */\r
46 #include "FreeRTOS.h"\r
47 #include "task.h"\r
48 #include "semphr.h"\r
49 \r
50 /* Demo includes. */\r
51 #include "BasicWEB.h"\r
52 \r
53 /* lwIP includes. */\r
54 #include "lwip/api.h"\r
55 #include "lwip/tcpip.h"\r
56 #include "lwip/memp.h"\r
57 #include "lwip/stats.h"\r
58 #include "netif/loopif.h"\r
59 #include "lcd.h"\r
60 #include "httpd.h"\r
61 \r
62 #define lwipTCP_STACK_SIZE                      600\r
63 \r
64 \r
65 /*------------------------------------------------------------------------------*/\r
66 /*                            GLOBALS                                          */\r
67 /*------------------------------------------------------------------------------*/\r
68 static struct netif EMAC_if;\r
69 \r
70 /*------------------------------------------------------------------------------*/\r
71 /*                            FUNCTIONS                                         */\r
72 /*------------------------------------------------------------------------------*/\r
73 \r
74 \r
75 void vlwIPInit( void )\r
76 {\r
77     /* Initialize lwIP and its interface layer. */\r
78         sys_init();\r
79         mem_init();                                                             \r
80         memp_init();\r
81         pbuf_init();\r
82         netif_init();\r
83         ip_init();\r
84         sys_set_state(( signed char * ) "lwIP", lwipTCP_STACK_SIZE);\r
85         tcpip_init( NULL, NULL );       \r
86         sys_set_default_state();\r
87 }\r
88 /*------------------------------------------------------------*/\r
89 \r
90 void vBasicWEBServer( void *pvParameters )\r
91 {\r
92 struct ip_addr xIpAddr, xNetMast, xGateway;\r
93 extern err_t ethernetif_init( struct netif *netif );\r
94 \r
95     /* Parameters are not used - suppress compiler error. */\r
96     ( void ) pvParameters;\r
97 \r
98     /* Create and configure the EMAC interface. */\r
99     IP4_ADDR( &xIpAddr, emacIPADDR0, emacIPADDR1, emacIPADDR2, emacIPADDR3 );\r
100     IP4_ADDR( &xNetMast, emacNET_MASK0, emacNET_MASK1, emacNET_MASK2, emacNET_MASK3 );\r
101     IP4_ADDR( &xGateway, emacGATEWAY_ADDR0, emacGATEWAY_ADDR1, emacGATEWAY_ADDR2, emacGATEWAY_ADDR3 );\r
102     netif_add( &EMAC_if, &xIpAddr, &xNetMast, &xGateway, NULL, ethernetif_init, tcpip_input );\r
103 \r
104     /* make it the default interface */\r
105     netif_set_default( &EMAC_if );\r
106 \r
107     /* bring it up */\r
108     netif_set_up(&EMAC_if);\r
109 \r
110     /* Initialize HTTP */\r
111     httpd_init();\r
112 \r
113         /* Nothing else to do.  No point hanging around. */\r
114         vTaskDelete( NULL );\r
115 }\r
116 \r
117 \r