Component: TCPIP (ENC28J60) (Comms: Networking)

From Flowcode Help
Jump to navigationJump to search


Author Ben Rowland
Version 1.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

SPI Channel

This property is of type Fixed list of ints and can be referenced with the variable name CHANNEL.

SPI peripheral onboard the target microcontroller to use.

Prescale

This property is of type Fixed list of ints and can be referenced with the variable name PR_SCALE.

Rate by which the master oscillator is reduced before clocking the SPI peripheral

Reset Pin

This property is of type Single digital pin and can be referenced with the variable name ResetPin.

No additional information


Chip Select CS

This property is of type Single digital pin and can be referenced with the variable name cs_pin.

No additional information


MOSI (SDO)

This property is of type Single digital pin and can be referenced with the variable name MOSI.

No additional information


MISO (SDI)

This property is of type Single digital pin and can be referenced with the variable name MISO.

No additional information


CLK

This property is of type Single digital pin and can be referenced with the variable name CLK.

No additional information


MOSI Remap

This property is of type Fixed list of ints and can be referenced with the variable name MosiRemap.

No additional information


MISO Remap

This property is of type Fixed list of ints and can be referenced with the variable name MisoRemap.

No additional information


CLK Remap

This property is of type Fixed list of ints and can be referenced with the variable name ClkRemap.

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