1.2.5.2 ENC28J60 Driver Library

The ENC28J60 External MAC and PHY is an external module connected through a Serial Peripheral Interface (SPI) to host microcontroller. This driver interfaces with the SPI driver to communicate with the external device to implement a complete Ethernet node in a system.

The following are some of the key features of this module:

  • Supports 10 Mbps physical-to-physical layer Ethernet data transfer

  • Full-Duplex and Half-Duplex operation

  • Broadcast, Multicast and Unicast packets

  • Hardware flow control for both Full and Half-Duplex mode

  • Fully configurable interrupts

  • Configurable receive packet filtering using:

  • 64-bit Hash Table

  • 64-byte Pattern Match

  • Magic Packet™ Filtering

  • Supports Packet Payload Checksum calculation

  • CRC Check

  • Supports SPI interface

Abstraction Model

The ENC28J60 Driver library has several different layers to it, as illustrated in the following figure. The interface layer has two main sections that are used the most often: The Tasks function, and the TCP/IP Send and Receive functions.

The Tasks function manages the internal state machine which detects, resets, and then configures the ENC28J60 External MAC. It also handles the monitoring of the hardware status, sending and receiving packets.

The TCP/IP Send and Receive functions interact with the RAM-based queue of packets that are queued to send and packets that have been queued waiting for pick-up by the stack.

The main state machine does not interface directly to the SPI bus, but instead, interfaces to a virtual bus abstraction layer that allows for the replacement of the specific underlying bus implementation.

DRV ENC28J60 Abstraction Model

Configuring the SPI Driver

The ENC2J60 hardware requires a specific configuration of the SPI driver to work correctly. Inside the MHC SPI Driver configuration be sure to select:

  • Run the SPI at frequencies of at least 8 MHz

  • Clock mode of DRV_SPI_CLOCK_MODE_IDLE_LOW_EDGE_FALL

  • Input phase of SPI_INPUT_SAMPLING_PHASE_AT_END

SPI Configuration

Library Interface

NameDescription
System Interaction Functions
DRV_ENC28J60_DeinitializeDeinitializes the ENC28J60 Driver Instance.
DRV_ENC28J60_InitializeInitializes the ENC28J60 Driver Instance, with the configuration data.
DRV_ENC28J60_ProcessAdditional processing that happens outside the tasks function.
DRV_ENC28J60_ReinitializeReinitializes the instance of the ENC28J60 driver.
DRV_ENC28J60_SetMacCtrlInfoThis function sets the MAC control information for the driver.
DRV_ENC28J60_StackInitializeThis function initializes the driver with a TCPIP_MAC_INIT object.
DRV_ENC28J60_TasksMain task function for the driver.
Client Level Functions
DRV_ENC28J60_CloseCloses a client handle to the driver.
DRV_ENC28J60_ConfigGetGets the current configuration.
DRV_ENC28J60_LinkCheckThis function returns the status of the link.
DRV_ENC28J60_OpenThis function is called by the client to open a handle to a driver instance.
DRV_ENC28J60_ParametersGetGet the parameters of the device.
DRV_ENC28J60_PowerModeThis function sets the power mode of the device.
DRV_ENC28J60_RegisterStatisticsGetGet the register statistics.
DRV_ENC28J60_StatisticsGetRetrieve the devices statistics.
DRV_ENC28J60_StatusGets the current status of the driver.
Receive Functions
DRV_ENC28J60_PacketRxReceive a packet from the driver.
DRV_ENC28J60_RxFilterHashTableEntrySetThis function adds an entry to the hash table.
Transmit Functions
DRV_ENC28J60_PacketTxThis function queues a packet for transmission.
Event Functions
DRV_ENC28J60_EventAcknowledgeAcknowledges an event.
DRV_ENC28J60_EventMaskSetSets the event mask.
DRV_ENC28J60_EventPendingGetGets the current events.
Data Types and Constants
DRV_ENC28J60_ConfigurationDefines the data required to initialize or reinitialize the ENC28J60 Driver.
DRV_ENC28J60_MDIX_TYPEDefines the enumeration for controlling the MDIX select.
DRV_ENC28J60_MACObjectThis is variable DRV_ENC28J60_MACObject.