Wired Ethernet Interface Setup
Including TCP-IP Stack Source Code
Include the following files in your project tree from the µC/TCP-IP source code distribution, as indicated in Figure - µC/TCP-IP Source Code. In this figure, the IP folder only show the sub-folder IPv4 as an example. If you are running with IPv6, please add the IPv6 folder instead or add both IPv4 and IPv6 folders if you want your project to support both IP version.
As indicated in the Figure - µC/TCP-IP Source Code, all the files in the Source folder must be added to your project tree. Furthermore, if a TCP-IP port exists for your CPU architecture inside the "Ports" folder, you can also include it to your project files.
Second, add the following include paths to your project’s C compiler settings:
\Micrium\Software\uC-TCPIP
\Micrium\Software\uC-TCPIP\Dev\Ether\<device_name>
\Micrium\Software\uC-TCPIP\Dev\Ether\PHY\<phy_device_name>
Modify the Interface Device Configuration
Modify Ethernet Device Configuration
Inside the net_dev_cfg.c file, there are different device configuration templates. Since that, in this section, the example project we want to run is with a Ethernet wired device, the configuration that interests us is beneath the section "EXAMPLE ETHERNET DEVICE CONFIGURATION".
Next you need to modify the Ethernet device configuration template as needed by your application. Refer to section Memory Configuration and Ethernet Interface Configuration for all the details on the parameters to configure.
Modify PHY Configuration
Under the Ethernet device configuration, you will also found the PHY device configuration. This configuration will also need to be adjusted according to your PHY setup on the development board. Refer to section Ethernet Interface Configuration for all the details on the PHY configuration.
Modify Static Configurations
As previously mentioned, the µC/TCP-IP static configurations are located in the net_cfg.h
file. For this getting started guide, the template file without modification should be enough to get you started. Depending on your Interface device configuration, it is possible that you would need to adjust the µC/TCP-IP queues' configurations as listed in Listing µC/TCP-IP Static Configuration Modifications. Refer to section Task Queue Configuration for more details on the TCP-IP queues' configurations.
#define NET_CFG_IF_RX_Q_SIZE 50
#define NET_CFG_IF_TX_DEALLOC_Q_SIZE 50
Tasks Priority
The net_cfg.c
file includes the three network task configurations. You will need to defined the priority of each of those tasks. The priorities will depend on the other tasks already present in your application. Refer to section Network Tasks Configuration for all the details on configuring the network tasks and their priority.
Example Project Setup
The purpose of this example project is to setup a network host on the target board to allow it to communicate with other hosts on the network. Figure - Example Application Setup shows the project test setup for a Ethernet wired interface. The target board is wire-connected to an Ethernet switch or via an Ethernet cross-over cable to a Windows-based PC. The PC’s IP address is set to 10.10.10.111 and the target’s addresses will be configure to 10.10.10.64 as it will be shown in the next section Adding µC/TCP-IP application function.
This example project contains enough code to be able to ping the board. Therefore, after successfully running the project, You will be able to issue the following command form a command-prompt:
ping 10.10.10.64
Ping (on the PC) should reply back with the ping time to the target. µC/TCP-IP target projects connected to the test PC on the same Ethernet switch or Ethernet cross-over cable achieve ping times of less than 2 milliseconds.
After you have successfully completed and run the example project, you can use it as a starting point to run other µC/TCP-IP demos you may have purchased.
Adding Additional includes
Since the µC/TCP-IP module was added to the example project, the following include must be added to the app.c file :
#include <KAL/kal.h>
#include <Source/net.h>
#include <net_dev_????.h>
#include <net_phy_????.h>
#include <net_dev_cfg.h>
#include <net_bsp.h>
Adding µC/TCP-IP Application Function
Before running the example application, you will need to add the new funtion, AppInit_TCPIP()
, in your app.c file to initialize and setup the µC/TCP-IP stack. Section Tasks and Objects Initialization gives an example of the main application task inside which the AppInit_TCPIP()
function will be called. Section Ethernet Sample Application gives an AppInit_TCPIP()
example for a wired Ethernet interface.
Those code examples will need to be modified in accordance with your project setup. For example, when adding an interface, your network device configuration object name (inside net_dev_cfg.c
) will need to be specify and the IP address used in the example could need to be change to match your network.
Once the source code is built and loaded into the target, the target will respond to ICMP Echo (ping) requests.