CAN-Engine
Chapter 4: Software
4-17
4.6
I2CHIP TCP/IP MODULE
4.6.1
Background
The I2CHIP TCP/IP module from Wiznet provides a hardware implementation of the TCP/UDP IP
protocol stack. The module allows for vastly improved network performance by offloading time-consuming
network management code to hardware. Detailed documentation for the module is available from Wiznet or
on your TERN development CD.
The I2CHIP module is mapped directly into processor memory space for better performance. The direct
mapping location, as well as the size of the mapped space can differ from controller to controller. When
working with different TERN controllers enabled with the I2CHIP module, you must select the proper
#define statements to describe your hardware configuration. See section 4.6.5 below for more details.
4.6.2
I2Chip Summary
The I2CHIP module allows a total of 4 simultaneous sockets. Each socket can be configured for TCP,
UDP, as well as lower-level raw IP packet modes. The sockets can also be configured for a 'listen' server
socket, or as a client socket. The module allows for a total of 8 KB of packet RECEIVE memory buffer,
and 8 KB of packet TRANSMIT buffer across all 4 sockets.
The buffers are mapped directly into the processor's memory, meaning they can be accessed directly from a
pointer. The existing driver code sits on top of the memory layer and provides easier interfaces to this
underlying data.
The user application has full ability to set most (all?) meaningful TCP/UDP/IP flags, ranging from the
obvious (port/address), to the less obvious (timeout options). The provided drivers should work correctly
under both small AND large memory model compilations.
The module is interrupt-driven, and updates each socket as needed when the state of the connection
changes. Available socket states include all TCP states (
CLOSED, SYNSENT, SYNACK, SYNRECV,
CLOSE_WAIT1, CLOSE_WAIT2
, etc...).
4.6.3
Network Initialization
The first step is to configure your board with the proper network settings.
1.
You will need to connect a standard Ethernet cable with RJ45 connector to your local area
network.
2.
Determine your network settings. Ask your network administrator, or, on a Windows PC
connected to the same local area network (through a hub or switch), and run 'ipconfig' inside a
DOS window.
The results will show three sets of values (sample vals shown here):
IP Address ... : 192.168.2.50
Subnet Mask ... : 255.255.255.0
Default gateway : 192.168.2.1
3.
Your C-Eye controller should be set to use the subnet mask and default gateway shown here.
In the sample code, these values are in these two statically-defined arrays:
u_char GatewayAddress[] = {192, 168, 2, 1};
u_char SubMask[] = {255, 255, 255, 0};