]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/ARM9_STR91X_IAR/lwip/lwipWebServer/BasicWEB.c
e5877573362ed2b2d26ed26b2eea57b91c06f7b9
[freertos] / FreeRTOS / Demo / ARM9_STR91X_IAR / lwip / lwipWebServer / BasicWEB.c
1 \r
2 /*\r
3  * FreeRTOS Kernel V10.2.1\r
4  * Copyright (C) 2019 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.\r
15  *\r
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
22  *\r
23  * http://www.FreeRTOS.org\r
24  * http://aws.amazon.com/freertos\r
25  *\r
26  * 1 tab == 4 spaces!\r
27  */\r
28 \r
29 /*\r
30         Implements a simplistic WEB server.  Every time a connection is made and\r
31         data is received a dynamic page that shows the current TCP/IP statistics\r
32         is generated and returned.  The connection is then closed.\r
33 */\r
34 \r
35 \r
36 /*------------------------------------------------------------------------------*/\r
37 /*                            PROTOTYPES                                        */\r
38 /*------------------------------------------------------------------------------*/\r
39 \r
40 /* Standard includes. */\r
41 #include <stdio.h>\r
42 #include <string.h>\r
43 \r
44 /* Scheduler includes. */\r
45 #include "FreeRTOS.h"\r
46 #include "task.h"\r
47 #include "semphr.h"\r
48 \r
49 /* Demo includes. */\r
50 #include "BasicWEB.h"\r
51 \r
52 /* lwIP includes. */\r
53 #include "lwip/api.h"\r
54 #include "lwip/tcpip.h"\r
55 #include "lwip/memp.h"\r
56 #include "lwip/stats.h"\r
57 #include "netif/loopif.h"\r
58 #include "lcd.h"\r
59 #include "httpd.h"\r
60 \r
61 #define lwipTCP_STACK_SIZE                      600\r
62 \r
63 \r
64 /*------------------------------------------------------------------------------*/\r
65 /*                            GLOBALS                                          */\r
66 /*------------------------------------------------------------------------------*/\r
67 static struct netif EMAC_if;\r
68 \r
69 /*------------------------------------------------------------------------------*/\r
70 /*                            FUNCTIONS                                         */\r
71 /*------------------------------------------------------------------------------*/\r
72 \r
73 \r
74 void vlwIPInit( void )\r
75 {\r
76     /* Initialize lwIP and its interface layer. */\r
77         sys_init();\r
78         mem_init();                                                             \r
79         memp_init();\r
80         pbuf_init();\r
81         netif_init();\r
82         ip_init();\r
83         sys_set_state(( signed char * ) "lwIP", lwipTCP_STACK_SIZE);\r
84         tcpip_init( NULL, NULL );       \r
85         sys_set_default_state();\r
86 }\r
87 /*------------------------------------------------------------*/\r
88 \r
89 void vBasicWEBServer( void *pvParameters )\r
90 {\r
91 struct ip_addr xIpAddr, xNetMast, xGateway;\r
92 extern err_t ethernetif_init( struct netif *netif );\r
93 \r
94     /* Parameters are not used - suppress compiler error. */\r
95     ( void ) pvParameters;\r
96 \r
97     /* Create and configure the EMAC interface. */\r
98     IP4_ADDR( &xIpAddr, emacIPADDR0, emacIPADDR1, emacIPADDR2, emacIPADDR3 );\r
99     IP4_ADDR( &xNetMast, emacNET_MASK0, emacNET_MASK1, emacNET_MASK2, emacNET_MASK3 );\r
100     IP4_ADDR( &xGateway, emacGATEWAY_ADDR0, emacGATEWAY_ADDR1, emacGATEWAY_ADDR2, emacGATEWAY_ADDR3 );\r
101     netif_add( &EMAC_if, &xIpAddr, &xNetMast, &xGateway, NULL, ethernetif_init, tcpip_input );\r
102 \r
103     /* make it the default interface */\r
104     netif_set_default( &EMAC_if );\r
105 \r
106     /* bring it up */\r
107     netif_set_up(&EMAC_if);\r
108 \r
109     /* Initialize HTTP */\r
110     httpd_init();\r
111 \r
112         /* Nothing else to do.  No point hanging around. */\r
113         vTaskDelete( NULL );\r
114 }\r
115 \r
116 \r