To use the ENC28J60 in your project, include the files ‘ENC28J60.c” and “ENC28J60.h” in your project and uncomment the following macro in HardwareProfile.h:
#define ENC_CS_TRIS xxxxxxxxxxxxxxx
Several macros need to be mapped to registers or register bits when using the ENC28J60. They include:
Macro |
Purpose |
Sample Value |
ENC_CS_IO |
Defines the LAT (or PORT, where applicable) register bit that corresponds to the chip select pin. Defining this macro will also indicate that the stack should use the ENC28J60. |
LATDbits.LATD14 |
ENC_CS_TRIS |
Defines the TRIS bit that corresponds to the chip select pin. |
TRISDbits.TRISD14 |
ENC_RST_IO |
Defines the LAT (or PORT, where applicable) register bit that corresponds to the reset pin. If you leave the reset pin unconnected in your design, comment this macro out. |
LATDbits.LATD15 |
ENC_RST_TRIS |
Defines the TRIS bit that corresponds to the reset pin. |
TRISDbits.TRISD15 |
ENC_SPI_IF |
Points to the interrupt flag for the SPI module connected to the chip. |
IFS0bits.SPI1IF |
ENC_SSPBUF |
Points to the SPI buffer register for the SPI module connected to the chip. |
SPI1BUF |
ENC_SPISTAT |
Points to the SPI status register for the SPI module connected to the chip. |
SPI1STAT |
ENC_SPISTATbits |
Provides bitwise access to the SPI status register for the SPI module connected to the chip. The ____bits registers are typically defined in the processor’s header files. |
SPI1STATbits |
ENC_SPICON1 |
Points to the SPI control register for the SPI module connected to the chip. |
SPI1CON1 |
ENC_SPICON1bits |
Provides bitwise access to the SPI control register for the SPI module connected to the chip (see ENC_SPISTATbits entry). |
SPI1CON1bits |
ENC_SPICON2 |
Points to the second SPI control register for the SPI module connected to the chip. If your device doesn’t have an SPICON2 register (e.g. PIC32) just omit this definition. |
SPI1CON2 |
ENC_SPIBRG |
Points to the SPI Baud Rate Generator register for the SPI module connected to the chip. If your device doesn’t have a BRG-based SPI module, just omit this definition. |
SPI1BRG |