1.2.5.3 ENCx24J600 Driver Library
The ENCx24J600 External MAC is an external module to the PIC32 that is connected through a SPI or PSP interface. 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/100 Ethernet
Full-Duplex and Half-Duplex operation
Broadcast, Multicast and Unicast packets
Manual and automatic flow control
Supports Auto-MDIX
Fully configurable interrupts
Configurable receive packet filtering using:
64-bit Hash Table
64-byte Pattern Match
Magic Packet™ Filtering
Runt Packet Detection and Filtering
Supports Packet Payload Checksum calculation
CRC Check
Supports SPI interface
Abstraction Model
The ENCx24J600 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 ENCx24J600 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 ENC hardware requires a specific configuration of the SPI driver to work correctly. Inside the MHC SPI Driver configuration be sure to select:
SPI clock rate of 14000000 or less. With a PB clock of 80 MHz, 13333333 is the clock rate.
Clock mode of DRV_SPI_CLOCK_MODE_IDLE_LOW_EDGE_FALL
Input phase of SPI_INPUT_SAMPLING_PHASE_AT_END
Recommended Settings
Interrupt Driver mode
Enhanced Buffer mode
DMA mode enabled:
DMA block transfer size of at least 1600 bytes
Size of DMA buffer for dummy data of at least 1600 bytes
Ensure when setting up DMA in interrupt mode that the DMA interrupts are a higher priority than the SPI Driver interrupt
Library Interface
Name | Description |
---|---|
System Interaction FunctionsFunctions | |
DRV_ENCX24J600_Deinitialize | Deinitializes the ENCx24J600 Driver Instance. |
DRV_ENCX24J600_Initialize | Initializes the ENCx24J600 Driver Instance, with the configuration data. |
DRV_ENCX24J600_Reinitialize | Reinitializes the instance of the ENCX24J600 driver. |
DRV_ENCX24J600_Tasks | Main task function for the driver. |
DRV_ENCX24J600_SetMacCtrlInfo | This function sets the MAC control information for the driver. |
DRV_ENCX24J600_StackInitialize | This function initializes the driver with a TCPIP_MAC_INIT object. |
DRV_ENCX24J600_Process | Additional processing that happens outside the tasks function. |
Client Level FunctionsFunctions | |
DRV_ENCX24J600_Close | Closes a client handle to the driver. |
DRV_ENCX24J600_ConfigGet | Gets the current configuration. |
DRV_ENCX24J600_LinkCheck | This function returns the status of the link. |
DRV_ENCX24J600_Open | This function is called by the client to open a handle to a driver instance. |
DRV_ENCX24J600_ParametersGet | Get the parameters of the device. |
DRV_ENCX24J600_PowerMode | This function sets the power mode of the device. |
DRV_ENCX24J600_RegisterStatisticsGet | Get the register statistics. |
DRV_ENCX24J600_StatisticsGet | Retrieve the devices statistics. |
DRV_ENCX24J600_Status | Gets the current status of the driver. |
Receive FunctionsFunctions | |
DRV_ENCX24J600_PacketRx | Receive a packet from the driver. |
DRV_ENCX24J600_RxFilterHashTableEntrySet | This function adds an entry to the hash table. |
Transmit FunctionsFunctions | |
DRV_ENCX24J600_PacketTx | This function queues a packet for transmission. |
Event FunctionsFunctions | |
DRV_ENCX24J600_EventAcknowledge | Acknowledges an event. |
DRV_ENCX24J600_EventMaskSet | Sets the event mask. |
DRV_ENCX24J600_EventPendingGet | Gets the current events. |
Data Types and ConstantsTypes | |
DRV_ENCX24J600_Configuration | Defines the data required to initialize or reinitialize the ENCX24J600 Driver. |
DRV_ENCX24J600_MDIX_TYPE | Defines the enumeration for controlling the MDIX select. |