Web

Source code can be downloaded from source:/Examples/Web

Description
This demo example implements a very simple dynamic HTTP-server. It waits until connected, then sends a HTTP-header and the HTML-code stored in memory. The web page can be viewed in Web-browser as the result.

From the main.c source file:

Initialization
1     SystemInit();
This demo can be larger than 16k (bootloader initializes only A[13..0]), so initialize memory before clock setup
1     MemoryPinInit();
2     EMCFlashInit();
3
4     CGU_Init();
Enable 32 kHz & 1 kHz on osc32k
1     CGU_EnableEntity(CGU_CLKSRC_32KHZ_OSC, ENABLE);            
2
3     CGU_EnableEntity(CGU_CLKSRC_ENET_RX_CLK, ENABLE);
4     CGU_EnableEntity(CGU_CLKSRC_ENET_TX_CLK, ENABLE);
5
6     CGU_EntityConnect(CGU_CLKSRC_ENET_TX_CLK, CGU_BASE_PHY_TX);
7     CGU_EntityConnect(CGU_CLKSRC_ENET_RX_CLK, CGU_BASE_PHY_RX);
Generate interrupt every 10 ms
1     SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE)/100);
2
3     TCPLowLevelInit();
Clear HTTP-server’s flag register
1     HTTPStatus = 0;
Set port we want to listen to
1     TCPLocalPort = TCP_PORT_HTTP;
Execution
 1     while (1)
 2     {
 3         // listen for incoming TCP-connection
 4         if (!(SocketStatus & SOCK_ACTIVE)) TCPPassiveOpen();
 5         // handle network and easyWEB-stack
 6         DoNetworkStuff();
 7         // events
 8         HTTPServer();
 9     }

Undefined