Component: TCPIP (ENC28J60) (Comms: Networking)
Author | Matrix TSL |
Version | 2.0 (Release) |
Category | Comms: Networking |
Contents
- 1 TCPIP (ENC28J60) component
- 2 Examples
- 3 Downloadable macro reference
- 3.1 PacketSend
- 3.2 MakeTcpSynackFromSyn
- 3.3 MakeArpRequest
- 3.4 InitialiseDataLengthInfo
- 3.5 MakeTcpAckFromAny
- 3.6 PacketReceive
- 3.7 CheckForTCPType
- 3.8 CheckArpPacketIsMyreplyArp
- 3.9 CheckForIp
- 3.10 CheckForTCPPort
- 3.11 CheckForPing
- 3.12 GetModuleRevision
- 3.13 MakeTcpAckWithData
- 3.14 MakeArpAnswerFromRequest
- 3.15 ReadRegister
- 3.16 CheckForARP
- 3.17 ClientSendPacket
- 3.18 MakeEchoReplyFromRequest
- 3.19 ControlLEDs
- 3.20 GetDataLength
- 3.21 GetTcpDataPointer
- 3.22 WriteRegister
- 3.23 FillTcpData
- 3.24 ReadStringFromBuffer
- 3.25 GetSendersMAC
- 3.26 Initialise
- 4 Simulation macro reference
- 5 Property reference
TCPIP (ENC28J60) component
A set of routines used to control a ENC28J60 TCP/IP Module. Required connections VCC, Reset, GND, SCK, MISO, MOSI, CS. Leave these pins disconnected CLKOUT, ENC_WOL, ENC_INT
Examples
Here is a simple example to help get started with the ENC28J60 module.
The example program creates a web page server on the network and will also respond to ping requests.
The HTML to drive the web pages is included in the flowchart near the bottom of the main program loop. ENC28J60 Example Additional examples can be found in the “Apps and Bundles” section of this Wiki:
Wireless LAN Application Guide
Downloadable macro reference
PacketSend
Attempts to transmit a data packet to the ENC28J60 module.
Parameters
- UINT Length
Return value
- This call does not return a value
MakeTcpSynackFromSyn
No additional information
Parameters
- UINT Port
Return value
- This call does not return a value
MakeArpRequest
No additional information
Parameters
- <- BYTE ServerIP
- This parameter may be returned back to the caller
Return value
- This call does not return a value
InitialiseDataLengthInfo
Initialises the data pointers to allow us to craft a response containing data
Parameters
- This macro has no parameters
Return value
- This call does not return a value
MakeTcpAckFromAny
No additional information
Parameters
- UINT Port
Return value
- This call does not return a value
PacketReceive
Attempts to receive a data packet from the ENC28J60 module.
Returns the number of bytes received.
Parameters
- This macro has no parameters
Return value
CheckForTCPType
Checks to what kind of TCP type the received data is requesting.
Returns a bit field specifying the type of request.
0x01 = Ack Requires, 0x02 = Synchronise
0x10 = Ack
Parameters
- This macro has no parameters
Return value
CheckArpPacketIsMyreplyArp
No additional information
Parameters
- This macro has no parameters
Return value
CheckForIp
Checks to see if the received data is an IP request with my IP address.
Parameters
- UINT Length
Return value
CheckForTCPPort
Checks to see if the received data is requesting the server port
Parameters
- UINT Port
Return value
CheckForPing
Checks to see if the received data is a Ping request
Parameters
- This macro has no parameters
Return value
GetModuleRevision
Requets the module revision number and returns the value supplied by the module's firmware.
Parameters
- This macro has no parameters
Return value
MakeTcpAckWithData
No additional information
Parameters
- UINT DataLength
Return value
- This call does not return a value
MakeArpAnswerFromRequest
No additional information
Parameters
- This macro has no parameters
Return value
- This call does not return a value
ReadRegister
Reads the value from a single register onboard the ENC28J60 module.
Parameters
- BYTE Address
Return value
CheckForARP
Checks to see if the received data is an ARP request with my IP address.
Parameters
- UINT Length
Return value
ClientSendPacket
No additional information
Parameters
- UINT DestPort
- UINT SourcePort
- BYTE Flags
- BYTE MaxSegmentSize
- BYTE ClearSeqAck
- UINT NextAckNum
- UINT DataLength
- BYTE DestMac
- BYTE DestIp
Return value
- This call does not return a value
MakeEchoReplyFromRequest
No additional information
Parameters
- UINT Length
Return value
- This call does not return a value
ControlLEDs
Allows both the LEDs on the Ethernet socket to be controlled.
Useful for checking if the SPI communications are functioning correctly.
Parameters
- BYTE Mode
- 0=Off, 1=On, 2=Auto
Return value
- This call does not return a value
GetDataLength
Returns the number of received data bytes after the headers
Parameters
- This macro has no parameters
Return value
GetTcpDataPointer
No additional information
Parameters
- This macro has no parameters
Return value
WriteRegister
Writes a value to a single register onboard the ENC28J60 module.
Parameters
- BYTE Address
- BYTE Data
Return value
- This call does not return a value
FillTcpData
No additional information
Parameters
- UINT Position
- <- STRING Data
- This parameter may be returned back to the caller
Return value
ReadStringFromBuffer
Reads a string from the buffer at location specified for the number of bytes specified.
If a space character is encountered then the macro will return straight away without the space character in the string.
Parameters
- UINT BufferLocation
- BYTE NumberOfBytes
- Number of bytes to read from the buffer and store into string
Return value
GetSendersMAC
Gets the MAC address from locations 6-11 of the IP Header
Parameters
- BYTE MAC
- 6-byte Array to store the MAC address
Return value
- This call does not return a value
Initialise
Initialises the SPI connection to the TCPIP module and sets up some initial values.
Flashes the LEDs on and off twice to confirm SPI comms are active.
LEDs are then configured to auto functionality.
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Simulation macro reference
This component does not contain any simulation macros
Property reference
Server Port
This property is of type Unsigned integer and can be referenced with the variable name Port.
Sets the server's TCP/IP port address which is used to filter incoming TCP packets.
Buffer Size
This property is of type Unsigned integer and can be referenced with the variable name BufferSize.
Number of bytes to use for the transmit and receive buffer, we actually use this +1 to allow for a null termination.
8-bit PICs should set this to 255 to allow compilation to succeed.
Other devices can have larger buffers.
Default = 500
Channel
This property is of type Fixed list of ints and can be referenced with the variable name cal_spi::CHANNEL.
SPI Channel selector
Prescale
This property is of type Fixed list of ints and can be referenced with the variable name cal_spi::PR_SCALE.
Prescale option selector
MOSI
This property is of type Single digital pin and can be referenced with the variable name cal_spi::MOSI.
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.
MISO
This property is of type Single digital pin and can be referenced with the variable name cal_spi::MISO.
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.
CLK
This property is of type Single digital pin and can be referenced with the variable name cal_spi::CLK.
SPI Clock Pin CLK - The Clock signal is driven by the SPI master.
CS / SS
This property is of type Single digital pin and can be referenced with the variable name cal_spi::SS.
Chip Select / Slave Select Pin
Master Mode: General purpose output pin used to select the remote SPI device.
Slave Mode: Hardware chip select pin input used to select the SPI device.
Reset Pin
This property is of type Single digital pin and can be referenced with the variable name ResetPin.
No additional information
MAC0
This property is of type Unsigned integer and can be referenced with the variable name MAC0.
No additional information
MAC1
This property is of type Unsigned integer and can be referenced with the variable name MAC1.
No additional information
MAC2
This property is of type Unsigned integer and can be referenced with the variable name MAC2.
No additional information
MAC3
This property is of type Unsigned integer and can be referenced with the variable name MAC3.
No additional information
MAC4
This property is of type Unsigned integer and can be referenced with the variable name MAC4.
No additional information
MAC5
This property is of type Unsigned integer and can be referenced with the variable name MAC5.
No additional information
IP0
This property is of type Unsigned integer and can be referenced with the variable name IP0.
No additional information
IP1
This property is of type Unsigned integer and can be referenced with the variable name IP1.
No additional information
IP2
This property is of type Unsigned integer and can be referenced with the variable name IP2.
No additional information
IP3
This property is of type Unsigned integer and can be referenced with the variable name IP3.
No additional information
Label
This property is of type Line of text and can be referenced with the variable name label.
No additional information
Sim Type
This property is of type Fixed list of ints and can be referenced with the variable name SimType.
Decides how to perform the simulation of the component.
TCP IP - Communicates using the Windows TCP IP communications DLL
SPI / Injector - Communicates using the CAL SPI to allow the communications to be analysed and debugged.
Scope Traces
This property is of type True or false and can be referenced with the variable name cal_spi::ScopeTraces.
Selects if the scope traces are automatically generated or not
Console Data
This property is of type True or false and can be referenced with the variable name cal_spi::ConsoleData.
Selects if the console data is automatically generated or not
Injector
This property is of type Fixed list of ints and can be referenced with the variable name cal_spi::Injector.
No additional information
Network Interface
This property is of type Fixed list of ints and can be referenced with the variable name TCP_Base1::interface.
List of network interfaces connected to the PC.
Sets which interface we are communicating via.