Component: TCPIP (ENC28J60) (Comms: Networking)

From Flowcode Help
Jump to navigationJump to search


Author Matrix TSL
Version 2.0 (Release)
Category Comms: Networking


Image 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. FC6 Icon.png ENC28J60 Example Additional examples can be found in the “Apps and Bundles” section of this Wiki:

Internet Application Guide

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

UINT


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

BYTE


CheckArpPacketIsMyreplyArp

No additional information


Parameters

This macro has no parameters


Return value

BYTE


CheckForIp

Checks to see if the received data is an IP request with my IP address.

Parameters

UINT Length


Return value

BYTE


CheckForTCPPort

Checks to see if the received data is requesting the server port

Parameters

UINT Port


Return value

BYTE


CheckForPing

Checks to see if the received data is a Ping request

Parameters

This macro has no parameters


Return value

BYTE


GetModuleRevision

Requets the module revision number and returns the value supplied by the module's firmware.

Parameters

This macro has no parameters


Return value

BYTE


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

BYTE


CheckForARP

Checks to see if the received data is an ARP request with my IP address.

Parameters

UINT Length


Return value

BYTE


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

UINT


GetTcpDataPointer

No additional information


Parameters

This macro has no parameters


Return value

UINT


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

UINT


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

STRING


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.