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.
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
Library Interface
Name | Description |
---|---|
System Interaction Functions | |
DRV_ENC28J60_Deinitialize | Deinitializes the ENC28J60 Driver Instance. |
DRV_ENC28J60_Initialize | Initializes the ENC28J60 Driver Instance, with the configuration data. |
DRV_ENC28J60_Process | Additional processing that happens outside the tasks function. |
DRV_ENC28J60_Reinitialize | Reinitializes the instance of the ENC28J60 driver. |
DRV_ENC28J60_SetMacCtrlInfo | This function sets the MAC control information for the driver. |
DRV_ENC28J60_StackInitialize | This function initializes the driver with a TCPIP_MAC_INIT object. |
DRV_ENC28J60_Tasks | Main task function for the driver. |
Client Level Functions | |
DRV_ENC28J60_Close | Closes a client handle to the driver. |
DRV_ENC28J60_ConfigGet | Gets the current configuration. |
DRV_ENC28J60_LinkCheck | This function returns the status of the link. |
DRV_ENC28J60_Open | This function is called by the client to open a handle to a driver instance. |
DRV_ENC28J60_ParametersGet | Get the parameters of the device. |
DRV_ENC28J60_PowerMode | This function sets the power mode of the device. |
DRV_ENC28J60_RegisterStatisticsGet | Get the register statistics. |
DRV_ENC28J60_StatisticsGet | Retrieve the devices statistics. |
DRV_ENC28J60_Status | Gets the current status of the driver. |
Receive Functions | |
DRV_ENC28J60_PacketRx | Receive a packet from the driver. |
DRV_ENC28J60_RxFilterHashTableEntrySet | This function adds an entry to the hash table. |
Transmit Functions | |
DRV_ENC28J60_PacketTx | This function queues a packet for transmission. |
Event Functions | |
DRV_ENC28J60_EventAcknowledge | Acknowledges an event. |
DRV_ENC28J60_EventMaskSet | Sets the event mask. |
DRV_ENC28J60_EventPendingGet | Gets the current events. |
Data Types and Constants | |
DRV_ENC28J60_Configuration | Defines the data required to initialize or reinitialize the ENC28J60 Driver. |
DRV_ENC28J60_MDIX_TYPE | Defines the enumeration for controlling the MDIX select. |
DRV_ENC28J60_MACObject | This is variable DRV_ENC28J60_MACObject. |