Difference between revisions of "Component: TCPIP (ENC28J60) (Comms: Networking)"
(XML import) |
(XML import BR) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 21: | Line 21: | ||
==Examples== | ==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. | ||
+ | {{Fcfile|ENC28J60_Example.fcfx|ENC28J60 Example}} | ||
+ | Additional examples can be found in the “Apps and Bundles” section of this Wiki: | ||
+ | |||
+ | [[Internet_Application_Guide | Internet Application Guide]] | ||
+ | |||
+ | [[Wireless_LAN_Application_Guide | Wireless LAN Application Guide]] | ||
==Downloadable macro reference== | ==Downloadable macro reference== |
Latest revision as of 15:46, 16 February 2017
Author | Ben Rowland |
Version | 1.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
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