|
|
Line 16: |
Line 16: |
| | | |
| ==Detailed description== | | ==Detailed description== |
| + | |
| + | |
| | | |
| ''No detailed description exists yet for this component'' | | ''No detailed description exists yet for this component'' |
| | | |
| ==Examples== | | ==Examples== |
| + | |
| + | |
| | | |
| | | |
Revision as of 10:40, 17 November 2021
Author
|
Matrix TSL
|
Version
|
2.2
|
Category
|
Comms: Networking
|
TCP/IP 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
Detailed description
No detailed description exists yet for this component
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:
Internet Application Guide
Wireless LAN Application Guide
Downloadable macro reference
|
SetMyIPAddress
|
Allows the IP Address specified in the component properties to be overridden. The IP Address will revert back to the IP specified in the component properties as part of the initialise macro.
|
- BYTE
|
IP0
|
IP Address Parameter - e.g. 192
|
- BYTE
|
IP1
|
IP Address Parameter - e.g. 168
|
- BYTE
|
IP2
|
IP Address Parameter - e.g. 1
|
- BYTE
|
IP3
|
IP Address Parameter - e.g. 250
|
- VOID
|
Return
|
|
PacketSend
|
Attempts to transmit a data packet to the ENC28J60 module.
|
- UINT
|
Length
|
|
- VOID
|
Return
|
|
MakeTcpSynackFromSyn
|
|
- UINT
|
Port
|
|
- VOID
|
Return
|
|
MakeArpRequest
|
|
[[File:]] -
|
ServerIP
|
|
- VOID
|
Return
|
|
InitialiseDataLengthInfo
|
Initialises the data pointers to allow us to craft a response containing data
|
- VOID
|
Return
|
|
MakeTcpAckFromAny
|
|
- UINT
|
Port
|
|
- VOID
|
Return
|
|
PacketReceive
|
Attempts to receive a data packet from the ENC28J60 module. Returns the number of bytes received.
|
- UINT
|
Return
|
|
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
|
- BYTE
|
Return
|
|
CheckArpPacketIsMyreplyArp
|
|
- BYTE
|
Return
|
|
CheckForIp
|
Checks to see if the received data is an IP request with my IP address.
|
- UINT
|
Length
|
|
- BYTE
|
Return
|
|
CheckForTCPPort
|
Checks to see if the received data is requesting the server port
|
- UINT
|
Port
|
|
- BYTE
|
Return
|
|
CheckForPing
|
Checks to see if the received data is a Ping request
|
- BYTE
|
Return
|
|
GetModuleRevision
|
Requets the module revision number and returns the value supplied by the module's firmware.
|
- BYTE
|
Return
|
|
MakeTcpAckWithData
|
|
- UINT
|
DataLength
|
|
- VOID
|
Return
|
|
SetMyMACAddress
|
Allows the MAC Address specified in the component properties to be overridden. The MAC Address will revert back to the MAC specified in the component properties as part of the initialise macro.
|
- BYTE
|
MAC0
|
MAC Address Parameter
|
- BYTE
|
MAC1
|
MAC Address Parameter
|
- BYTE
|
MAC2
|
MAC Address Parameter
|
- BYTE
|
MAC3
|
MAC Address Parameter
|
- BYTE
|
MAC4
|
MAC Address Parameter
|
- BYTE
|
MAC5
|
MAC Address Parameter
|
- VOID
|
Return
|
|
MakeArpAnswerFromRequest
|
|
- VOID
|
Return
|
|
ReadArrayFromBuffer
|
Reads an array of bytes 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.
|
- UINT
|
BufferLocation
|
|
- BYTE
|
NumberOfBytes
|
Number of bytes to read from the buffer and store into string
|
- BYTE
|
Data
|
|
- VOID
|
Return
|
|
ReadRegister
|
Reads the value from a single register onboard the ENC28J60 module.
|
- BYTE
|
Address
|
|
- BYTE
|
Return
|
|
CheckForARP
|
Checks to see if the received data is an ARP request with my IP address.
|
- UINT
|
Length
|
|
- BYTE
|
Return
|
|
ClientSendPacket
|
|
- UINT
|
DestPort
|
|
- UINT
|
SourcePort
|
|
- BYTE
|
Flags
|
|
- BYTE
|
MaxSegmentSize
|
|
- BYTE
|
ClearSeqAck
|
|
- UINT
|
NextAckNum
|
|
- UINT
|
DataLength
|
|
- BYTE
|
DestMac
|
|
- BYTE
|
DestIp
|
|
- VOID
|
Return
|
|
MakeEchoReplyFromRequest
|
|
- UINT
|
Length
|
|
- VOID
|
Return
|
|
ControlLEDs
|
Allows both the LEDs on the Ethernet socket to be controlled. Useful for checking if the SPI communications are functioning correctly.
|
- BYTE
|
Mode
|
0=Off, 1=On, 2=Auto
|
- VOID
|
Return
|
|
GetDataLength
|
Returns the number of received data bytes after the headers
|
- UINT
|
Return
|
|
GetTcpDataPointer
|
|
- UINT
|
Return
|
|
WriteRegister
|
Writes a value to a single register onboard the ENC28J60 module.
|
- BYTE
|
Address
|
|
- BYTE
|
Data
|
|
- VOID
|
Return
|
|
FillTcpData
|
|
- UINT
|
Position
|
|
- STRING
|
Data
|
|
- UINT
|
Return
|
|
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.
|
- UINT
|
BufferLocation
|
|
- BYTE
|
NumberOfBytes
|
Number of bytes to read from the buffer and store into string
|
- STRING
|
Return
|
|
GetSendersMAC
|
Gets the MAC address from locations 6-11 of the IP Header
|
- BYTE
|
MAC
|
6-byte Array to store the MAC address
|
- VOID
|
Return
|
|
FillTcpArray
|
|
- UINT
|
Position
|
|
- UINT
|
Count
|
|
- BYTE
|
Data
|
|
- VOID
|
Return
|
|
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.
|
- VOID
|
Return
|
|
RxFlushData_Sim
|
Once data reception has been completed, this macro should be called to discard the data packet and allow other data packets to be read.
|
- BYTE
|
Channel
|
Specifies the communications channel 0-3
|
- VOID
|
Return
|
|
RxDataSize
|
This macro is used to detect the size of data collected by the Rx_data_available macro.
|
- BYTE
|
Channel
|
Specifies the communications channel 0-3
|
- UINT
|
Return
|
|
CreateMACSocket
|
This macro creates a socket for sending and receiving Ethernet data using raw data.
|
- BYTE
|
Promiscuous
|
Receive everything (1) or just data bound for your MAC (0)
|
- BYTE
|
Broadcast
|
Allows broadcast messages to be accepted (1) or rejected (0)
|
- BYTE
|
Error
|
Allowsmessages with errors to be accepted (1) or rejected (0)
|
- BYTE
|
Return
|
|
CreateUDPSocket_Sim
|
This macro creates a socket for sending and receiving UDP data.
|
- BYTE
|
Channel
|
Specifies the communications channel 0-3
|
- UINT
|
Src_Port
|
Port Number
|
- BYTE
|
Return
|
|
TxSendMyMAC
|
This macro fills the specified channel's transmit buffer with 6 bytes of data representing this Internet E-Block's MAC address as specified in the component's property page.
|
- BYTE
|
Channel
|
Specifies the communications channel 0-3
|
- VOID
|
Return
|
|
SetMACAddress
|
This macro sets up the Internet E-Block's MAC address. In most circumstances, this macro will not be required as the MAC address setting in the component property page will remain constant throughout your application.
|
- BYTE
|
MAC0
|
First Byte of address
|
- BYTE
|
MAC1
|
Second Byte of address
|
- BYTE
|
MAC2
|
Third Byte of address
|
- BYTE
|
MAC3
|
Fourth Byte of address
|
- BYTE
|
MAC4
|
Fourth Byte of address
|
- BYTE
|
MAC5
|
Fifth Byte of address
|
- VOID
|
Return
|
|
RxMatch_4_Bytes_Sim
|
This macro returns a non-zero value when the next 4 bytes of data in the specified channel's reception buffer are the same as those passed as parameters. There are similar functions that check for 2 bytes and 6 bytes.
|
- BYTE
|
Channel
|
Specifies the communications channel 0-3
|
- BYTE
|
Byte1
|
Specifies the value of the first byte
|
- BYTE
|
Byte2
|
Specifies the value of the second byte
|
- BYTE
|
Byte3
|
Specifies the value of the third byte
|
- BYTE
|
Byte4
|
Specifies the value of the fourth byte
|
- BYTE
|
Return
|
|
RxDataSize_Sim
|
This macro is used to detect the size of data collected by the Rx_data_available macro.
|
- BYTE
|
Channel
|
Specifies the communications channel 0-3
|
- BYTE
|
Return
|
|
SetSubnetMask
|
This macro sets up the Internet E-Block's Subnet Mask. In most circumstances, this macro will not be required as the subnet mask setting in the component property page will remain constant throughout your application.
|
- BYTE
|
IP0
|
First Byte of IP address
|
- BYTE
|
IP1
|
Second Byte of IP address
|
- BYTE
|
IP2
|
Third Byte of IP address
|
- BYTE
|
IP3
|
Fourth Byte of IP address
|
- VOID
|
Return
|
|
RxMatch_2_Bytes_Sim
|
This macro returns a non-zero value when the next 2 bytes of data in the specified channel's reception buffer are the same as those passed as parameters. There are similar functions that check for 4 bytes and 6 bytes.
|
- BYTE
|
Channel
|
Specifies the communications channel 0-3
|
- BYTE
|
Byte1
|
Specifies the value of the first byte
|
- BYTE
|
Byte2
|
Specifies the value of the second byte
|
- BYTE
|
Return
|
|
RxMatchMyMAC_Sim
|
This macro returns a non-zero value when the next 4 bytes of data in the specified channel's reception buffer are the same as the Internet E-block's IP address.
|
- BYTE
|
Channel
|
Specifies the communications channel 0-3
|
- BYTE
|
Return
|
|
TCPClose
|
When an established TCP connection has finished transmission of data, either the local application (i.e. your code) or the remote application (i.e. the application at the other end of the connection) can initiate closure of the socket.
|
- BYTE
|
Channel
|
Specifies the communications channel 0-3
|
- VOID
|
Return
|
|
GetSocketStatus
|
This returns the state of the requested channel's socket.
|
- BYTE
|
Channel
|
Specifies the communications channel 0-3
|
- BYTE
|
Return
|
|
Initialise
|
Resets and initialises the Internet E-Block. It sets up the gateway address, subnet mask, device IP address and device MAC address as defined in the properties of the Flowcode component. This macro must be called before any other TCP_IP component macros
|
- BYTE
|
Return
|
|
SetGateway
|
This macro sets up the Internet E-Block's Gateway address. In most circumstances, this macro will not be required as the gateway address setting in the component property page will remain constant throughout your application.
|
- BYTE
|
IP0
|
First Byte of IP address
|
- BYTE
|
IP1
|
Second Byte of IP address
|
- BYTE
|
IP2
|
Third Byte of IP address
|
- BYTE
|
IP3
|
Fourth Byte of IP address
|
- VOID
|
Return
|
|
RxDataSize
|
This macro is used to detect the size of data collected by the Rx_data_available macro.
|
- BYTE
|
Channel
|
Specifies the communications channel 0-3
|
- BYTE
|
Return
|
|
TxSendMyMAC
|
This macro fills the specified channel's transmit buffer with 6 bytes of data representing this Internet E-Block's MAC address as specified in the component's property page.
|
- BYTE
|
Channel
|
Specifies the communications channel 0-3
|
- VOID
|
Return
|
|
CreateMACSocket
|
This macro creates a socket for sending and receiving Ethernet data using raw data.
|
- BYTE
|
Promiscuous
|
Receive everything (1) or just data bound for your MAC (0)
|
- BYTE
|
Broadcast
|
Allows broadcast messages to be accepted (1) or rejected (0)
|
- BYTE
|
Error
|
Allowsmessages with errors to be accepted (1) or rejected (0)
|
- BYTE
|
Return
|
|
GetSocketStatus
|
This returns the state of the requested channel's socket.
|
- BYTE
|
Channel
|
Specifies the communications channel 0-3
|
- BYTE
|
Return
|
|
Initialise
|
Resets and initialises the Internet E-Block. It sets up the gateway address, subnet mask, device IP address and device MAC address as defined in the properties of the Flowcode component. This macro must be called before any other TCP_IP component macros
|
- VOID
|
Return
|
|
TCPClose
|
When an established TCP connection has finished transmission of data, either the local application (i.e. your code) or the remote application (i.e. the application at the other end of the connection) can initiate closure of the socket.
|
- BYTE
|
Channel
|
Specifies the communications channel 0-3
|
- VOID
|
Return
|
|
RxMatchMyMAC
|
This macro returns a non-zero value when the next 6 bytes of data in the specified channel's reception buffer are the same as the Internet E-block's MAC address entered in the component's property page.
|
- BYTE
|
Channel
|
Specifies the communications channel 0-3
|
- BYTE
|
Return
|
|
RxDataSize
|
This macro is used to detect the size of data collected by the Rx_data_available macro.
|
- BYTE
|
Channel
|
Specifies the communications channel 0-3
|
- UINT
|
Return
|
|
ControlLEDs
|
Allows both the LEDs on the Ethernet socket to be controlled. Useful for checking if the SPI communications are functioning correctly.
|
- BYTE
|
Mode
|
0=Off, 1=On, 2=Auto
|
- VOID
|
Return
|
|
GetDataLength
|
Returns the number of received data bytes after the headers
|
- UINT
|
Return
|
|
TxSendMyMAC
|
This macro fills the specified channel's transmit buffer with 6 bytes of data representing this Internet E-Block's MAC address as specified in the component's property page.
|
- BYTE
|
Channel
|
Specifies the communications channel 0-3
|
- VOID
|
Return
|
|
CreateMACSocket
|
This macro creates a socket for sending and receiving Ethernet data using raw data.
|
- BYTE
|
Promiscuous
|
Receive everything (1) or just data bound for your MAC (0)
|
- BYTE
|
Broadcast
|
Allows broadcast messages to be accepted (1) or rejected (0)
|
- BYTE
|
Error
|
Allowsmessages with errors to be accepted (1) or rejected (0)
|
- BYTE
|
Return
|
|
SetMACAddress
|
Allows the MAC Address specified in the component properties to be overridden. The MAC Address will revert back to the MAC specified in the component properties as part of the initialise macro.
|
- BYTE
|
MAC0
|
MAC Address Parameter
|
- BYTE
|
MAC1
|
MAC Address Parameter
|
- BYTE
|
MAC2
|
MAC Address Parameter
|
- BYTE
|
MAC3
|
MAC Address Parameter
|
- BYTE
|
MAC4
|
MAC Address Parameter
|
- BYTE
|
MAC5
|
MAC Address Parameter
|
- VOID
|
Return
|
|
GetTcpDataPointer
|
|
- UINT
|
Return
|
|
SetSubnetMask
|
This macro sets up the Internet E-Block's Subnet Mask. In most circumstances, this macro will not be required as the subnet mask setting in the component property page will remain constant throughout your application.
|
- BYTE
|
IP0
|
First Byte of IP address
|
- BYTE
|
IP1
|
Second Byte of IP address
|
- BYTE
|
IP2
|
Third Byte of IP address
|
- BYTE
|
IP3
|
Fourth Byte of IP address
|
- VOID
|
Return
|
|
WriteRegister
|
Writes a value to a single register onboard the ENC28J60 module.
|
- BYTE
|
Address
|
|
- BYTE
|
Data
|
|
- VOID
|
Return
|
|
FillTcpData
|
|
- UINT
|
Position
|
|
- STRING
|
Data
|
|
- UINT
|
Return
|
|
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.
|
- UINT
|
BufferLocation
|
|
- BYTE
|
NumberOfBytes
|
Number of bytes to read from the buffer and store into string
|
- STRING
|
Return
|
|
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.
|
- VOID
|
Return
|
|
SetGateway
|
This macro sets up the Internet E-Block's Gateway address. In most circumstances, this macro will not be required as the gateway address setting in the component property page will remain constant throughout your application.
|
- BYTE
|
IP0
|
First Byte of IP address
|
- BYTE
|
IP1
|
Second Byte of IP address
|
- BYTE
|
IP2
|
Third Byte of IP address
|
- BYTE
|
IP3
|
Fourth Byte of IP address
|
- VOID
|
Return
|
Property reference
|
Properties
|
|
Server Port
|
Sets the server's TCP/IP port address which is used to filter incoming TCP packets.
|
|
Buffer Size
|
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
|
SPI Channel selector
|
|
Prescale
|
Prescale option selector
|
|
MOSI
|
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.
|
|
MISO
|
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.
|
|
CLK
|
SPI Clock Pin CLK - The Clock signal is driven by the SPI master.
|
|
CS / 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
|
|
|
MAC0
|
|
|
MAC1
|
|
|
MAC2
|
|
|
MAC3
|
|
|
MAC4
|
|
|
MAC5
|
|
|
IP0
|
|
|
IP1
|
|
|
IP2
|
|
|
IP3
|
|
|
Scope Traces
|
Selects if the scope traces are automatically generated or not
|
|
Console Data
|
Selects if the console data is automatically generated or not
|
|
API
|
|
|
Network Interface
|
List of network interfaces connected to the PC. Sets which interface we are communicating via.
|
|
Connections
|
|
Simulations
|
|
Label
|
|
|
Sim Type
|
Decides how to perform the simulation of the component. TCP IP - Communicates using the Windows TCP IP communications DLL SPI / API - Communicates using the CAL SPI to allow the communications to be analysed and debugged.
|