The startup sequence

There are four tasks that implement all network services of this demo:

  • httpd is the web server.
  • n_calc is a server application. It process all remote requests coming from a TCP connection on the port 52012.
  • tcp/ip is the lwIP stack.
  • ETH_INT is a driver task. It manages the ENET peripheral of the MCU.

Figure 1 - sequence diagram.

The above picture shows the sequence diagram of the tasks creation process.

When the system startups the function vStartEthertTasks is in charge of creating all network tasks. First of all it initializes the tcp/ip stack - tcpip_init. The tcpip_init function initializes all data structures needed by lwIP - lwip_init - and then it creates the tcp/ip task. At this page the control flow comes back to the vStartEthernetTasks function that creates the two network application tasks: the web server (httpd) and network calculator (n_calc).
When the scheduler is started - vTaskStartScheduler - and the tcp/ip task is in running state, it completes the lwIP initialization and, before entering in the main loop, it creates the ETH_INT task by calling the tcpip_init_done (a pointer to the prvEthernetConfigureInterface) function.

Now the ethernet subsystem is up and running!

The ETH_INT task is synchronized with the ENET IRQ, and each time a new incoming frame is received by the peripheral, it send the frame to the tcp/ip stack that process the frame.