2.4 Ethernet Driver Library

2.4.1 Introduction

The Ethernet Driver library for MCC Melody provides drivers for the ENC28J60 and ENCX24J600 family of controllers. It allows for quick and easy configuration and code generation for applications using SPI in polling mode.

2.4.2 Module Documentation

2.4.2.1 ENC28J60

This header file provides API prototypes and other data types for the ENC28J60 Ethernet Driver.

2.4.2.1.1 Module description

This header file provides API prototypes and other data types for the ENC28J60 Ethernet Driver.

Version: ENC28J60 Ethernet Driver Version 6.1.0
Definitions
  • #define ETH_NCS_HIGH() do{ETH_CS_SetHigh();} while(0)

    Sets Ethernet Chip Select to high.

  • #define ETH_NCS_LOW() do{ETH_CS_SetLow();} while(0)

    Sets Ethernet Chip Select to low.

  • #define ETH_SPI_READ8() SPI1_Host.ByteExchange(0)

    Reads the SPI byte.

  • #define ETH_SPI_WRITE8(a) SPI1_Host.ByteExchange(a)

    Writes the SPI byte.

  • #define ETH_WRITE_IN_PROGRESS (0x0001 << 0)

    Packet write in progress, not ready for transmit.

  • #define ETH_TX_QUEUED (0x0001 << 1)

    Packet complete, in queue for transmit.

  • #define ETH_ALLOCATED (0x0001 << 2)

    Flag for pool management. Set to either free or allocated.

Enumerations
Functions

2.4.2.1.2 Definition Documentation

ETH_ALLOCATED

#define ETH_ALLOCATED (0x0001 << 2)

Flag for pool management. Set to either free or allocated.

ETH_NCS_HIGH

#define ETH_NCS_HIGH( ) do{ETH_CS_SetHigh();} while(0)

Sets Ethernet Chip Select to high.

ETH_NCS_LOW

#define ETH_NCS_LOW( ) do{ETH_CS_SetLow();} while(0)

Sets Ethernet Chip Select to low.

ETH_SPI_READ8

#define ETH_SPI_READ8( ) SPI1_Host.ByteExchange(0)

Reads the SPI byte.

ETH_SPI_WRITE8

#define ETH_SPI_WRITE8( a) SPI1_Host.ByteExchange(a)

Writes the SPI byte.

ETH_TX_QUEUED

#define ETH_TX_QUEUED (0x0001 << 1)

Packet complete, in queue for transmit.

ETH_WRITE_IN_PROGRESS

#define ETH_WRITE_IN_PROGRESS (0x0001 << 0)

Packet write in progress, not ready for transmit.

2.4.2.1.3 Function Documentation

ENC28_BankSel()

static void ENC28_BankSel (enc28j60_registers_t r)[static]

Selects the bank.

Parameters:
r

register

Returns:

None.

ENC28_Bfc()

static void ENC28_Bfc (enc28j60_registers_t a, char bits)[static]

Clears the SFR bit field.

Parameters:
a

register

bits
Returns:

None.

ENC28_Bfs()

static void ENC28_Bfs (enc28j60_registers_t a, char bits)[static]

Sets the SFR bit field.

Parameters:
a

register

bits
Returns:

None.

ENC28_PhyRead()

static uint16_t ENC28_PhyRead (enc28j60_phy_registers_t a)[static]

Reads the Physical Layer (PHY) register.

Parameters:
a

register

Returns:

Register data.

ENC28_PhyWrite()

static void ENC28_PhyWrite (enc28j60_phy_registers_t a, uint16_t d)[static]

Writes the PHY register.

Parameters:
a

register

d

data

Returns:

None.

ENC28_Rcr16()

static uint16_t ENC28_Rcr16 (enc28j60_registers_t a)[static]

Reads two bytes from SFRs.

Parameters:
a

register

Returns:

Two bytes of SFR value.

ENC28_Rcr8()

static uint8_t ENC28_Rcr8 (enc28j60_registers_t a)[static]

Reads one byte from Special Function Register (SFR).

Parameters:
a

register

Returns:

One byte of SFR value.

ENC28_Wcr16()

static void ENC28_Wcr16 (enc28j60_registers_t a, uint16_t v)[static]

Writes two bytes to SFRs.

Parameters:
a

register

v

16-bit value

Returns:

None.

ENC28_Wcr8()

static void ENC28_Wcr8 (enc28j60_registers_t a, uint8_t v)[static]

Writes one byte to SFRs.

Parameters:
a

register

v

8-bit value

Returns:

None.

ETH_CloseSPI()

static void ETH_CloseSPI (void )[static]

Releases the Serial Peripheral Interface (SPI) bus.

Parameters:
None.
Returns:

None.

ETH_ComputeChecksum()

static uint16_t ETH_ComputeChecksum (uint16_t len, uint16_t seed)[static]

Calculates the checksum.

Parameters:
len

length

seed
Returns:

Checksum.

ETH_NewPacket()

txPacket_t * ETH_NewPacket (void )

Allocates a new packet element and links it to the chained list.

Parameters:
None.
Returns:

Packet address.

ETH_OpenSPI()

static void ETH_OpenSPI (void )[static]

Connects the SPI bus.

Parameters:
None.
Returns:

None.

ETH_PacketListReset()

void ETH_PacketListReset (void )

Resets the Ethernet packet list.

Parameters:
None.
Returns:

None.

ETH_RemovePacket()

void ETH_RemovePacket (txPacket_t * pPacket)

Deallocates a packet element and unlinks it from the chained list.

Parameters:
pPacket

packetHandle

Returns:

None.

ETH_SendQueued()

phy_error_msg ETH_SendQueued (void )

Enqueues the latest written packet and starts the transmission of a queued packet.

Parameters:
None.
Return values:
PHY_SUCCESS
PHY_BUFFER_BUSY
ETH_Shift_Tx_Packets()

phy_error_msg ETH_Shift_Tx_Packets (void )

Copies the queued packets to the TX Buffer start address using the DMA setup.

Parameters:
None.
Return values:
PHY_SUCCESS
PHY_DMA_TIMEOUT

2.4.2.1.4 Enumeration Type Documentation

enc28j60_phy_registers_t

enum enc28j60_phy_registers_t

ENC28J60 PHY register addresses.

J60_PHCON1

PHY Control Register 1

J60_PHSTAT1

Physical Layer Status Register 1

J60_PHID1

PHY Identifier

J60_PHID2

PHY Identifier, P/N, and Revision

J60_PHCON2

PHY Control Register 2

J60_PHSTAT2

Physical Layer Status Register 2

J60_PHIE

PHY Interrupt Enable Register

J60_PHIR

PHY Interrupt Request Register

J60_PHLCON

PHY Module LED Control Register

enc28j60_registers_t

enum enc28j60_registers_t

ENC28J60 registers.

J60_ERDPTL

Bank 0: Read Pointer Low Byte

J60_ERDPTH

Bank 0: Read Pointer High Byte

J60_EWRPTL

Bank 0: Write Pointer Low Byte

J60_EWRPTH

Bank 0: Write Pointer High Byte

J60_ETXSTL

Bank 0: TX Start Low Byte

J60_ETXSTH

Bank 0: TX Start High Byte

J60_ETXNDL

Bank 0: TX End Low Byte

J60_ETXNDH

Bank 0: TX End High Byte

J60_ERXSTL

Bank 0: RX Start Low Byte

J60_ERXSTH

Bank 0: RX Start High Byte

J60_ERXNDL

Bank 0: RX End Low Byte

J60_ERXNDH

Bank 0: RX End High Byte

J60_ERXRDPTL

Bank 0: RX RD Pointer Low Byte

J60_ERXRDPTH

Bank 0: RX RD Pointer High Byte

J60_ERXWRPTL

Bank 0: RX WR Pointer Low Byte

J60_ERXWRPTH

Bank 0: RX WR Pointer High Byte

J60_EDMASTL

Bank 0: DMA Start Low Byte

J60_EDMASTH

Bank 0: DMA Start High Byte

J60_EDMANDL

Bank 0: DMA End Low Byte

J60_EDMANDH

Bank 0: DMA End High Byte

J60_EDMADSTL

Bank 0: DMA Destination Low Byte

J60_EDMADSTH

Bank 0: DMA Destination High Byte

J60_EDMACSL

Bank 0: DMA Checksum Low Byte

J60_EDMACSH

Bank 0: DMA Checksum High Byte

RSRV_018

Bank 0: Reserved

RSRV_019

Bank 0: Reserved

RSRV_01A

Bank 0: Reserved

J60_EHT0

Bank 1: Hash Table Byte 0

J60_EHT1

Bank 1: Hash Table Byte 1

J60_EHT2

Bank 1: Hash Table Byte 2

J60_EHT3

Bank 1: Hash Table Byte 3

J60_EHT4

Bank 1: Hash Table Byte 4

J60_EHT5

Bank 1: Hash Table Byte 5

J60_EHT6

Bank 1: Hash Table Byte 6

J60_EHT7

Bank 1: Hash Table Byte 7

J60_EPMM0

Bank 1: Pattern Match Mask Byte 0

J60_EPMM1

Bank 1: Pattern Match Mask Byte 1

J60_EPMM2

Bank 1: Pattern Match Mask Byte 2

J60_EPMM3

Bank 1: Pattern Match Mask Byte 3

J60_EPMM4

Bank 1: Pattern Match Mask Byte 4

J60_EPMM5

Bank 1: Pattern Match Mask Byte 5

J60_EPMM6

Bank 1: Pattern Match Mask Byte 6

J60_EPMM7

Bank 1: Pattern Match Mask Byte 7

J60_EPMCSL

Bank 1: Pattern Match Checksum Low Byte

J60_EPMCSH

Bank 1: Pattern Match Checksum High Byte

RSRV_112

Bank 1: Reserved

RSRV_113

Bank 1: Reserved

J60_EPMOL

Bank 1: Pattern Match Offset Low Byte

J60_EPMOH

Bank 1: Pattern Match Offset High Byte

RSRV_116

Bank 1: Reserved

RSRV_117

Bank 1: Reserved

J60_ERXFCON

Bank 1: Ethernet Receive Filter Control Register

J60_EPKTCNT

Bank 1: Ethernet Packet Count

RSRV_11A

Bank 1: Reserved

J60_MACON1

Bank 2: MAC Control Register 1

RSRV_201

Bank 2: Reserved

J60_MACON3

Bank 2: MAC Control Register 3

J60_MACON4

Bank 2: MAC Control Register 4

J60_MABBIPG

Bank 2: Back-to-Back Inter-Packet Gap

RSRV_205

Bank 2: Reserved

J60_MAIPGL

Bank 2: Non-Back-to-Back Inter-Packet Gap Low Byte

J60_MAIPGH

Bank 2: Non-Back-to-Back Inter-Packet Gap High Byte

J60_MACLCON1

Bank 2: Retransmission Maximum

J60_MACLCON2

Bank 2: Collision Window

J60_MAMXFLL

Bank 2: Maximum Frame Length Low Byte

J60_MAMXFLH

Bank 2: Maximum Frame Length High Byte

RSRV_20C

Bank 2: Reserved

RSRV_20D

Bank 2: Reserved

RSRV_20E

Bank 2: Reserved

RSRV_20F

Bank 2: Reserved

RSRV_210

Bank 2: Reserved

RSRV_211

Bank 2: Reserved

J60_MICMD

Bank 2: MII Command Register

RSRV_213

Bank 2: Reserved

J60_MIREGADR

Bank 2: MII Register Address

RSRV_215

Bank 2: Reserved

J60_MIWRL

Bank 2: MII Write Data Low Byte

J60_MIWRH

Bank 2: MII Write Data High Byte

J60_MIRDL

Bank 2: MII Read Data Low Byte

J60_MIRDH

Bank 2: MII Read Data High Byte

RSRV_21A

Bank 2: Reserved

J60_MAADR5

Bank 3: MAC Address Byte 5

J60_MAADR6

Bank 3: MAC Address Byte 6

J60_MAADR3

Bank 3: MAC Address Byte 3

J60_MAADR4

Bank 3: MAC Address Byte 4

J60_MAADR1

Bank 3: MAC Address Byte 1

J60_MAADR2

Bank 3: MAC Address Byte 2

J60_EBSTSD

Bank 3: Built-in Self-Test Fill Seed

J60_EBSTCON

Bank 3: Ethernet Self-Test Control Register

J60_EBSTCSL

Bank 3: Built-in Self-Test Checksum Low Byte

J60_EBSTCSH

Bank 3: Built-in Self-Test Checksum High Byte

J60_MISTAT

Bank 3: MII Status Register

RSRV_30B

Bank 3: Reserved

RSRV_30C

Bank 3: Reserved

RSRV_30D

Bank 3: Reserved

RSRV_30E

Bank 3: Reserved

RSRV_30F

Bank 3: Reserved

RSRV_310

Bank 3: Reserved

RSRV_311

Bank 3: Reserved

J60_EREVID

Bank 3: Ethernet Revision ID

RSRV_313

Bank 3: Reserved

RSRV_314

Bank 3: Reserved

J60_ECOCON

Bank 3: Clock Output Control Register

RSRV_316

Bank 3: Reserved

J60_EFLOCON

Bank 3: Ethernet Flow Control Register

J60_EPAUSL

Bank 3: Pause Timer Value Low Byte

J60_EPAUSH

Bank 3: Pause Timer Value High Byte

RSRV_31A

Bank 3: Reserved

J60_EIE

Common Bank Registers: Ethernet Interrupt Enable Register

J60_EIR

Common Bank Registers: Ethernet Interrupt Request (Flag) Register

J60_ESTAT

Common Bank Registers: Ethernet Status Register

J60_ECON2

Common Bank Registers: Ethernet Control Register 2

J60_ECON1

Common Bank Registers: Ethernet Control Register 1

sfr_bank_t

enum sfr_bank_t

SFR banks.

Special Function Register (SFR) Banks.

sfr_bank0

Bank 0

sfr_bank1

Bank 1

sfr_bank2

Bank 2

sfr_bank3

Bank 3

sfr_common

Common Set of Registers (last five locations of each bank)

sfr_bank0

Bank 0

sfr_bank1

Bank 1

sfr_bank2

Bank 2

sfr_bank3

Bank 3

sfr_common

Common Set of Registers (last five locations of each bank)

spi_inst_t

enum spi_inst_t

SPI instructions.

rcr_inst

Read Control Register

rbm_inst

Read Buffer Memory

wcr_inst

Write Control Register

wbm_inst

Write Buffer Memory

bfs_inst

Bit Field Set

bfc_inst

Bit Field Clear

src_inst

System Reset Command (Soft Reset)

2.4.2.1.5 Variable Documentation

Control_Byte

Control_Byte

ENC28J60 Control Byte.

2.4.2.2 ENCX24J600

This file provides register definitions for the ENCx24J600 controller.

2.4.2.2.1 Module description

This file provides register definitions for the ENCx24J600 controller.

Version: ENCx24J600 Driver Version 6.1.0
Definitions
  • #define ETH_WRITE_IN_PROGRESS (0x0001 << 0)

    Packet write in progress, not ready for transmit.

  • #define ETH_TX_QUEUED (0x0001 << 1)

    Packet in queue for transmit.

  • #define ETH_ALLOCATED (0x0001 << 2)

    Flag for pool management. Set to either free or allocated.

  • #define ETH_NCS_HIGH() do{ETH_CS_SetHigh();} while(0)

    Sets Ethernet Chip Select to high.

  • #define ETH_NCS_LOW() do{ETH_CS_SetLow();} while(0)

    Sets Ethernet Chip Select to low.

  • #define ETH_READ8() SPI1_Host.ByteExchange(0)

    Reads the Serial Peripheral Interface (SPI) byte.

  • #define ETH_WRITE8(a) SPI1_Host.ByteExchange(a)

    Packet write in progress, not ready for transmit.

  • #define TXSTART 0x0000ul

    Transmit buffer start.

  • #define TXEND 0x15FFul

    Transmit buffer end.

  • #define RXSTART 0x1600ul

    Receive buffer start (must be an even memory address).

  • #define RXEND (RAMSIZE_ETH - 2)

    Receive buffer end.

  • #define PHCON1_PSLEEP 0x0800

    Bit mask for PHY Sleep Enable bit. Physical Layer (PHY) power is down.

  • #define PHCON1_PWAKE 0xF7FF

    Bit mask for PHY Wake-Up as a normal operation.

Enumerations
Functions

2.4.2.2.2 Definition Documentation

ETH_ALLOCATED

#define ETH_ALLOCATED (0x0001 << 2)

Flag for pool management. Set to either free or allocated.

ETH_NCS_HIGH

#define ETH_NCS_HIGH( ) do{ETH_CS_SetHigh();} while(0)

Sets Ethernet Chip Select to high.

ETH_NCS_LOW

#define ETH_NCS_LOW( ) do{ETH_CS_SetLow();} while(0)

Sets Ethernet Chip Select to low.

ETH_READ8

#define ETH_READ8( ) SPI1_Host.ByteExchange(0)

Reads the Serial Peripheral Interface (SPI) byte.

ETH_TX_QUEUED

#define ETH_TX_QUEUED (0x0001 << 1)

Packet in queue for transmit.

ETH_WRITE8

#define ETH_WRITE8( a) SPI1_Host.ByteExchange(a)

Packet write in progress, not ready for transmit.

ETH_WRITE_IN_PROGRESS

#define ETH_WRITE_IN_PROGRESS (0x0001 << 0)

Packet write in progress, not ready for transmit.

PHCON1_PSLEEP

#define PHCON1_PSLEEP 0x0800

Bit mask for PHY Sleep Enable bit. Physical Layer (PHY) power is down.

PHCON1_PWAKE

#define PHCON1_PWAKE 0xF7FF

Bit mask for PHY Wake-Up as a normal operation.

RXEND

#define RXEND (RAMSIZE_ETH - 2)

Receive buffer end.

RXSTART

#define RXSTART 0x1600ul

Receive buffer start (must be an even memory address).

TXEND

#define TXEND 0x15FFul

Transmit buffer end.

TXSTART

#define TXSTART 0x0000ul

Transmit buffer start.

2.4.2.2.3 Function Documentation

ENCx24_BankselSPI()

static void ENCx24_BankselSPI (encX24J600_registers_t a)[static]

Selects the SPI bank.

Parameters:
a

register

Returns:

None.

ENCx24_BFC()

void ENCx24_BFC (encX24J600_registers_t a, uint16_t bitMask)

Clears the SFR bit field.

Parameters:
a

register

bitMask
Returns:

None.

ENCx24_BFS()

void ENCx24_BFS (encX24J600_registers_t a, uint16_t bitMask)

Sets the SFR bit field.

Parameters:
a

register

bitMask
Returns:

None.

ENCx24_PhyRead()

uint16_t ENCx24_PhyRead (encX24J600_phy_registers_t a)

Reads the PHY register.

Parameters:
a

register

Returns:

Two bytes of data.

ENCx24_PHYWrite()

void ENCx24_PHYWrite (encX24J600_phy_registers_t a, uint16_t data)

Writes the PHY register.

Parameters:
a

register

data
Returns:

None.

ENCx24_Read()

uint16_t ENCx24_Read (encX24J600_registers_t a)

Reads from Special Function Register (SFR).

Parameters:
a

register

Returns:

Two bytes of SFR value.

ENCx24_Write()

void ENCx24_Write (encX24J600_registers_t a, uint16_t data)

Writes to SFRs.

Parameters:
a

register

data
Returns:

None.

ETH_CloseSPI()

static void ETH_CloseSPI (void )[static]

Releases the Serial Peripheral Interface (SPI) bus.

Parameters:
None.
Returns:

None.

ETH_DMAComputeChecksum()

static uint16_t ETH_DMAComputeChecksum (uint16_t rxPtr, uint16_t len, uint16_t seed)[static]

Calculates the checksum.

Parameters:
rxPtr

RX pointer

len

length

seed
Returns:

Checksum.

ETH_EdataRead()

uint8_t ETH_EdataRead (encX24J600_registers_t a)

Reads the 8-bit data from the ENCx24J600 register (work around for Errata).

Parameters:
a

register

Returns:

One byte of data.

ETH_MACRead8()

uint8_t ETH_MACRead8 (encX24J600_registers_t a)

Reads the 8-bit MAC-related data from ENCx24J600 registers.

Parameters:
a

register

Returns:

One byte of data.

ETH_MACWrite8()

void ETH_MACWrite8 (encX24J600_registers_t a, uint8_t data)

Writes the 8-bit MAC-related data to ENCx24J600 registers.

Parameters:
a

register

data
Returns:

None.

ETH_NewPacket()

txPacket_t* ETH_NewPacket (void )

Allocates a new packet element and links it to the chained list.

Parameters:
None.
Returns:

Packet address.

ETH_OpenSPI()

static void ETH_OpenSPI (void )[static]

Connects the SPI bus.

Parameters:
None.
Returns:

None.

ETH_PacketListReset()

void ETH_PacketListReset (void )

Resets the Ethernet packet list.

Parameters:
None.
Returns:

None.

ETH_readLinkStatus()

inline static uint32_t ETH_readLinkStatus (void )

Checks for the link status.

Parameters:
None.
Return values:
PHY_SUCCESS

link found

PHY_LINK_NOT_FOUND

link is not present

ETH_RemovePacket()

void ETH_RemovePacket (txPacket_t * pPacket)

Deallocates a packet element and unlinks it from the chained list.

Parameters:
*pPacket

packetHandle

Returns:

None.

ETH_SendQueued()

phy_error_msg ETH_SendQueued (void )

Enqueues the latest written packet and starts the transmission of a queued packet.

Parameters:
None.
Return values:
PHY_SUCCESS
PHY_BUFFER_BUSY
ETH_Set_TXRTS()

void ETH_Set_TXRTS (void )

Packet transmission request.

Parameters:
None.
Returns:

None.

ETH_SetPktDec()

void ETH_SetPktDec (void )

Decrements packet count.

Parameters:
None.
Returns:

None.

ETH_SetRXptr()

void ETH_SetRXptr (uint16_t address)

RX packet read pointer.

Parameters:
address
Returns:

None.

ETH_Shift_Tx_Packets()

phy_error_msg ETH_Shift_Tx_Packets (void )

Copies all the queued packets to the TX Buffer start address using the DMA setup.

Parameters:
None.
Return values:
PHY_SUCCESS
PHY_DMA_TIMEOUT
waitForDMA()

inline static void waitForDMA (void )

Waits for the DMA.

Parameters:
None.
Returns:

None.

2.4.2.2.4 Enumeration Type Documentation

encX24J600_1_byte_instructions_t

enum encX24J600_1_byte_instructions_t

SPI single byte instructions.

b0sel_inst

Bank 0 Select

b1sel_inst

Bank 1 Select

b2sel_inst

Bank 2 Select

b3sel_inst

Bank 3 Select

setethrst_inst

System Reset

fcdisable_inst

Flow Control Disable

fcsingle_inst

Flow Control Single

fcmultiple_inst

Flow Control Multiple

fcclear_inst

Flow Control Clear

setpktdec_inst

Decrement Packet Counter

dmastop_inst

DMA Stop

dmacksum_inst

DMA Start Checksum

dmacksums_inst

DMA Start Checksum with Seed

dmacopy_inst

DMA Start Copy

dmacopys_inst

DMA Start Copy and Checksum with Seed

settxrts_inst

Request Packet Transmission

enablerx_inst

Enable RX

disablerx_inst

Disable RX

seteie_inst

Enable Interrupts

clreie_inst

Disable Interrupts

encX24J600_2_byte_instructions_t

enum encX24J600_2_byte_instructions_t

SPI two byte instructions.

rbsel_inst

Read Bank Select

encX24J600_3_byte_instructions_t

enum encX24J600_3_byte_instructions_t

SPI three byte instructions.

rgprdpt_inst

Read EGPRDPT

rrxrdpt_inst

Read ERXRDPT

rgpwrpt_inst

Read EGPWRPT

rrxwrpt_inst

Read ERXRDPT

rudawrpt_inst

Read EUDAWRPT

wgprdpt_inst

Write EGPRDPT

wrxrdpt_inst

Write ERXRDPT

wgpwrpt_inst

Write EGPWRPT

wrxwrpt_inst

Write ERXWRPT

wudawrpt_inst

Write EUDAWRPT

encX24J600_N_byte_instructions_t

enum encX24J600_N_byte_instructions_t

SPI N byte instructions.

rcr_inst

Banked register read

wcr_inst

Banked register write

bfs_inst

Banked bit set

bfc_inst

Banked bit clear

rcru_inst

Unbanked SFR operation

wcru_inst

Unbanked SFR writes

bfsu_inst

Unbanked bit set

bfcu_inst

Unbanked bit clear

rgpdata_inst

SRAM data EGPDATA read

rrxdata_inst

SRAM data RXDATA read

rudadata_inst

SRAM data UDADATA read

wgpdata_inst

SRAM writes

wrxdata_inst

SRAM data write from ERXDATA

wudadata_inst

SRAM data write from EUDADATA

encX24J600_phy_registers_t

enum encX24J600_phy_registers_t

ENCX24J600 PHY registers.

PHCON1

PHY Control Register 1

PHSTAT1

Physical Layer Status Register 1

PHANA

PHY Auto-Negotiation Advertisement Register

PHANLPA

PHY Auto-Negotiation Link Partner Ability Register

PHANE

PHY Auto-Negotiation Expansion Register

PHCON2

PHY Control Register 2

PHSTAT2

Physical Layer Status Register 2

PHSTAT3

Physical Layer Status Register 3

encX24J600_registers_t

enum encX24J600_registers_t

SFR addresses for the ENCx24J600 SPI mode.

XJ600_ETXSTL

TX Start Address

XJ600_ETXLENL

TX Length

XJ600_ERXSTL

RX Buffer Start Address

XJ600_ERXTAILL

RX Tail Pointer

XJ600_ERXHEADL

RX Head Pointer

XJ600_EDMASTL

DMA Start Address

XJ600_EDMALENL

DMA Length

XJ600_EDMADSTL

DMA Destination Address

XJ600_EDMACSL

DMA Checksum

XJ600_ETXSTATL

TX Status

XJ600_ETXWIREL

Transmit Byte Count on Wire (including collision bytes)

XJ600_EHT1L

Hash Table Filter 1

XJ600_EHT2L

Hash Table Filter 2

XJ600_EHT3L

Hash Table Filter 3

XJ600_EHT4L

Hash Table Filter 4

XJ600_EPMM1L

Pattern Match Filter Mask 1

XJ600_EPMM2L

Pattern Match Filter Mask 2

XJ600_EPMM3L

Pattern Match Filter Mask 3

XJ600_EPMM4L

Pattern Match Filter Mask 4

XJ600_EPMCSL

Pattern Match Filter Checksum

XJ600_EPMOL

Pattern Match Filter Offset

XJ600_ERXFCONL

Ethernet RX Filter Control Register

XJ600_MACON1L

MAC Control Register 1

XJ600_MACON2L

MAC Control Register 2

XJ600_MABBIPGL

MAC Back-to-Back Inter-Packet Gap

XJ600_MAIPGL

MAC Inter-Packet Gap

XJ600_MACLCONL

MAC Colision Control Register

XJ600_MAMXFLL

MAC Maximum Frame Length

XJ600_MICMDL

MII Management Command

XJ600_MIREGADRL

MII Management Adresses

XJ600_MAADR3L

MAC Address Byte 5

XJ600_MAADR3H

MAC Address Byte 6

XJ600_MAADR2L

MAC Address Byte 3

XJ600_MAADR2H

MAC Address Byte 4

XJ600_MAADR1L

MAC Address Byte 1

XJ600_MAADR1H

MAC Address Byte 2

XJ600_MIWRL

MII Management Write Data

XJ600_MIRDL

MII Management Read Data

XJ600_MISTATL

MII Management Status Register

XJ600_EPAUSL

Pause Timer Value

XJ600_ECON2L

Ethernet Control Register 2

XJ600_ERXWML

Receive Watermark

XJ600_EIEL

Ethernet Interrupt Enable Register

XJ600_EIDLEDL

Ethernet ID Status/LED Control Register

XJ600_EGPDATAL

Use the SRAM Instructions

XJ600_ERXDATAL

Use the SRAM Instructions

XJ600_EUDADATAL

Use the SRAM Instructions

XJ600_EGPRDPTL

General Purpose Data Window Register

XJ600_EGPWRPTL

General Purpose Window Write Pointer

XJ600_ERXRDPTL

RX Window Read Pointer

XJ600_ERXWRPTL

RX Window Write Pointer

XJ600_EUDARDPTL

UDA Window Read Pointer

XJ600_EUDAWRPTL

UDA Window Write Pointer

XJ600_EUDASTL

User-Defined Area Start Pointer

XJ600_EUDANDL

User-Defined Area End Pointer

XJ600_ESTATL

Ethernet Status Register

XJ600_EIRL

Ethernet Interrupt Flag Register 1

XJ600_ECON1L

Ethernet Control Register 1

2.4.2.3 Ethernet Driver 8-Bit Interface

This file includes definitions of public interface for an Ethernet driver. See individual Ethernet drivers for specific implementations of this interface.

2.4.2.3.1 Module description

This file includes definitions of public interface for an Ethernet driver. See individual Ethernet drivers for specific implementations of this interface.

Version: Ethernet Driver 8-Bit Interface Version 6.0.0
Functions
  • void ETH_Init (void)

    Sets up the Ethernet and starts the execution. Initializes the TX/RX buffer, the MAC and the PHY.

  • void ETH_EventHandler (void)

    Manages the MAC events. Can be used for polling or for new events in Interrupt Service Routine (ISR).

  • void ETH_NextPacketUpdate (void)

    Updates the pointers for the next available RX packets. Retrieves information about the last received packet and the address of the next ones.

  • void ETH_ResetReceiver (void)

    Resets the receiver buffer.

  • void ETH_SendSystemReset (void)

    Resets the system software.

  • const mac48Address_t * MAC_getAddress (void)

    Returns the MAC address of type mac48Address_t.

  • uint16_t ETH_ReadBlock (void *buffer, uint16_t length)

    Reads a block of data from the RX buffer MAC.

  • uint8_t ETH_Read8 (void)

    Reads one byte of data from the RX buffer MAC.

  • uint16_t ETH_Read16 (void)

    Reads two bytes of data from the RX buffer and returns them in host order.

  • uint32_t ETH_Read24 (void)

    Reads three bytes of data from the RX buffer and returns them in host order.

  • uint32_t ETH_Read32 (void)

    Reads four bytes of data from the RX buffer and returns them in host order.

  • void ETH_Dump (uint16_t length)

    Drops the N bytes from a packet list when the data is lost. Clears a number of bytes (length) from the RX buffer.

  • void ETH_Flush (void)

    Drops the rest of this packet and release the buffer. Clears all bytes from the RX buffer.

  • uint16_t ETH_GetFreeTxBufferSize (void)

    Returns the available space size in the Ethernet TX buffer.

  • phy_error_msg ETH_WriteStart (const mac48Address_t *dest_mac, uint16_t type)

    Starts a packet if the Ethernet transmitter is idle.

  • uint16_t ETH_WriteString (const char *string)

    Writes a string of data into the MAC.

  • uint16_t ETH_WriteBlock (const char *data, uint16_t length)

    Writes a block of data into the TX buffer MAC.

  • void ETH_Write8 (uint8_t data)

    Writes one byte of data into the TX buffer MAC.

  • void ETH_Write16 (uint16_t data)

    Writes two bytes into the TX buffer MAC in Network order.

  • void ETH_Write24 (uint32_t data)

    Writes three bytes into the TX buffer MAC in Network order.

  • void ETH_Write32 (uint32_t data)

    Writes four bytes into the TX buffer MAC in Network order.

  • void ETH_Insert (char *data, uint16_t len, uint16_t offset)

    Inserts N data bytes into a specific offset in the TX buffer/packet.

  • phy_error_msg ETH_Copy (uint16_t len)

    Copies N bytes from the saved read location (RX buffer) into the current TX location (TX buffer) using the DMA set up. This is used for ICMP ECHO to eliminate the need to extract the arbitrary payload.

  • phy_error_msg ETH_Send (void)

    Sends the TX packet. Starts the transmission of packet or queues the packet that has been created.

  • uint16_t ETH_TxComputeChecksum (uint16_t position, uint16_t length, uint16_t seed)

    Calculates the hardware checksum of length bytes starting with the position.

  • uint16_t ETH_RxComputeChecksum (uint16_t len, uint16_t seed)

    Calculates the RX software checksum.

  • void ETH_GetMAC (uint8_t *macAddr)

    Reads the MAC address.

  • void ETH_SetMAC (uint8_t *macAddr)

    Sets the MAC address.

  • uint16_t ETH_GetWritePtr (void)

    Returns the value of the write pointer.

  • void ETH_SaveRDPT (void)

    Saves the receive pointer for copy.

  • void ETH_ResetReadPtr (void)

    Resets the receive pointer to the Init.

  • uint16_t ETH_GetReadPtr (void)

    Returns the value of the read pointer.

  • void ETH_SetReadPtr (uint16_t rdptr)

    Sets the read pointer to a specific address.

  • uint16_t ETH_GetStatusVectorByteCount (void)

    Returns the Status Vector's byte count.

  • void ETH_SetStatusVectorByteCount (uint16_t bc)

    Sets the Status Vector's byte count.

  • void ETH_ResetByteCount (void)

    Resets the driver's byte count.

  • uint16_t ETH_GetByteCount (void)

    Returns the the driver's byte count.

  • uint16_t ETH_ReadSavedWRPT (void)

    Returns the saved write pointer.

  • void ETH_SaveWRPT (void)

    Saves the write pointer for copy.

  • void ETH_SetRxByteCount (uint16_t count)

    Sets the receiver's byte count.

  • uint16_t ETH_GetRxByteCount (void)

    Returns the receiver's byte count.

  • bool ETH_CheckLinkUp (void)

    Checks for the link.

  • void ETH_TxReset (void)

    Resets the transmitter.

  • void ETH_MoveBackReadPtr (uint16_t offset)

    Moves back the read pointer.

2.4.2.3.2 Function Documentation

ETH_CheckLinkUp()

bool ETH_CheckLinkUp (void )

Checks for the link.

Parameters:
None.
Return values:
True

if the link is present.

False

if the link is not present.

ETH_Copy()

phy_error_msg ETH_Copy (uint16_t len)

Copies N bytes from the saved read location (RX buffer) into the current TX location (TX buffer) using the DMA set up. This is used for ICMP ECHO to eliminate the need to extract the arbitrary payload.

Parameters:
len

length

Return values:
PHY_SUCCESS
PHY_DMA_TIMEOUT
ETH_Dump()

void ETH_Dump (uint16_t length)

Drops the N bytes from a packet list when the data is lost. Clears a number of bytes (length) from the RX buffer.

Parameters:
length
Returns:

None.

ETH_EventHandler()

void ETH_EventHandler (void )

Manages the MAC events. Can be used for polling or for new events in Interrupt Service Routine (ISR).

Parameters:
None.
Returns:

None.

ETH_Flush()

void ETH_Flush (void )

Drops the rest of this packet and release the buffer. Clears all bytes from the RX buffer.

Parameters:
None.
Returns:

None.

ETH_GetByteCount()

uint16_t ETH_GetByteCount (void )

Returns the the driver's byte count.

Parameters:
None.
Returns:

Byte count.

ETH_GetFreeTxBufferSize()

uint16_t ETH_GetFreeTxBufferSize (void )

Returns the available space size in the Ethernet TX buffer.

Parameters:
None.
Returns:

Available space left in the TX buffer.

ETH_GetMAC()

void ETH_GetMAC (uint8_t * macAddr)

Reads the MAC address.

Parameters:
*macAddr
Returns:

None.

ETH_GetReadPtr()

uint16_t ETH_GetReadPtr (void )

Returns the value of the read pointer.

Parameters:
None.
Returns:

Pointer value.

ETH_GetRxByteCount()

uint16_t ETH_GetRxByteCount (void )

Returns the receiver's byte count.

Parameters:
None.
Returns:

Byte count.

ETH_GetStatusVectorByteCount()

uint16_t ETH_GetStatusVectorByteCount (void )

Returns the Status Vector's byte count.

Parameters:
None.
Returns:

Byte count.

ETH_GetWritePtr()

uint16_t ETH_GetWritePtr (void )

Returns the value of the write pointer.

Parameters:
None.
Returns:

Pointer value.

ETH_Init()

void ETH_Init (void )

Sets up the Ethernet and starts the execution. Initializes the TX/RX buffer, the MAC and the PHY.

Parameters:
None.
Returns:

None.

ETH_Insert()

void ETH_Insert (char * data, uint16_t len, uint16_t offset)

Inserts N data bytes into a specific offset in the TX buffer/packet.

Parameters:
*data
len

length

offset
Returns:

None.

ETH_MoveBackReadPtr()

void ETH_MoveBackReadPtr (uint16_t offset)

Moves back the read pointer.

Parameters:
offset
Returns:

None.

ETH_NextPacketUpdate()

void ETH_NextPacketUpdate (void )

Updates the pointers for the next available RX packets. Retrieves information about the last received packet and the address of the next ones.

Parameters:
None.
Returns:

None.

ETH_Read16()

uint16_t ETH_Read16 (void )

Reads two bytes of data from the RX buffer and returns them in host order.

Parameters:
None.
Returns:

Two bytes of data.

ETH_Read24()

uint32_t ETH_Read24 (void )

Reads three bytes of data from the RX buffer and returns them in host order.

Parameters:
None.
Returns:

Three bytes of data.

ETH_Read32()

uint32_t ETH_Read32 (void )

Reads four bytes of data from the RX buffer and returns them in host order.

Parameters:
None.
Returns:

Four bytes of data.

ETH_Read8()

uint8_t ETH_Read8 (void )

Reads one byte of data from the RX buffer MAC.

Parameters:
None.
Returns:

One byte of data.

ETH_ReadBlock()

uint16_t ETH_ReadBlock (void * buffer, uint16_t length)

Reads a block of data from the RX buffer MAC.

Parameters:
*buffer
length
Returns:

Read count.

ETH_ReadSavedWRPT()

uint16_t ETH_ReadSavedWRPT (void )

Returns the saved write pointer.

Parameters:
None.
Returns:

Pointer value.

ETH_ResetByteCount()

void ETH_ResetByteCount (void )

Resets the driver's byte count.

Parameters:
None.
Returns:

None.

ETH_ResetReadPtr()

void ETH_ResetReadPtr (void )

Resets the receive pointer to the Init.

Parameters:
None.
Returns:

None.

ETH_ResetReceiver()

void ETH_ResetReceiver (void )

Resets the receiver buffer.

Parameters:
None.
Returns:

None.

ETH_RxComputeChecksum()

uint16_t ETH_RxComputeChecksum (uint16_t len, uint16_t seed)

Calculates the RX software checksum.

Parameters:
len

length

seed
Returns:

Checksum.

ETH_SaveRDPT()

void ETH_SaveRDPT (void )

Saves the receive pointer for copy.

Parameters:
None.
Returns:

None.

ETH_SaveWRPT()

void ETH_SaveWRPT (void )

Saves the write pointer for copy.

Parameters:
None.
Returns:

None.

ETH_Send()

phy_error_msg ETH_Send (void )

Sends the TX packet. Starts the transmission of packet or queues the packet that has been created.

Parameters:
None.
Return values:
PHY_SUCCESS
PHY_BUFFER_BUSY
PHY_LINK_NOT_FOUND
PHY_TX_QUEUED
PHY_TX_LOGIC_NOT_IDLE
ETH_SendSystemReset()

void ETH_SendSystemReset (void )

Resets the system software.

Parameters:
None.
Returns:

None.

ETH_SetMAC()

void ETH_SetMAC (uint8_t * macAddr)

Sets the MAC address.

Parameters:
*macAddr
Returns:

None.

ETH_SetReadPtr()

void ETH_SetReadPtr (uint16_t rdptr)

Sets the read pointer to a specific address.

Parameters:
rdptr

Read pointer

Returns:

None.

ETH_SetRxByteCount()

void ETH_SetRxByteCount (uint16_t count)

Sets the receiver's byte count.

Parameters:
count

byte count

Returns:

None.

ETH_SetStatusVectorByteCount()

void ETH_SetStatusVectorByteCount (uint16_t bc)

Sets the Status Vector's byte count.

Parameters:
bc

Byte count

Returns:

None.

ETH_TxComputeChecksum()

uint16_t ETH_TxComputeChecksum (uint16_t position, uint16_t length, uint16_t seed)

Calculates the hardware checksum of length bytes starting with the position.

Parameters:
position
length
seed
Returns:

Checksum.

ETH_TxReset()

void ETH_TxReset (void )

Resets the transmitter.

Parameters:
None.
Returns:

None.

ETH_Write16()

void ETH_Write16 (uint16_t data)

Writes two bytes into the TX buffer MAC in Network order.

Parameters:
data
Returns:

None.

ETH_Write24()

void ETH_Write24 (uint32_t data)

Writes three bytes into the TX buffer MAC in Network order.

Parameters:
data
Returns:

None.

ETH_Write32()

void ETH_Write32 (uint32_t data)

Writes four bytes into the TX buffer MAC in Network order.

Parameters:
data
Returns:

None.

ETH_Write8()

void ETH_Write8 (uint8_t data)

Writes one byte of data into the TX buffer MAC.

Parameters:
data
Returns:

None.

ETH_WriteBlock()

uint16_t ETH_WriteBlock (const char * data, uint16_t length)

Writes a block of data into the TX buffer MAC.

Parameters:
*data
length
Returns:

Length.

ETH_WriteStart()

phy_error_msg ETH_WriteStart (const mac48Address_t * dest_mac, uint16_t type)

Starts a packet if the Ethernet transmitter is idle.

Parameters:
*dest_mac
type
Return values:
PHY_SUCCESS

Packet started

PHY_BUFFER_BUSY

Buffer is busy

PHY_TX_LOGIC_NOT_IDLE

Transmitter is busy

ETH_WriteString()

uint16_t ETH_WriteString (const char * string)

Writes a string of data into the MAC.

Parameters:
*string
Returns:

None.

MAC_getAddress()

const mac48Address_t* MAC_getAddress (void )

Returns the MAC address of type mac48Address_t.

Parameters:
None.
Returns:

MAC address.

2.4.2.3.3 Enumeration Type Documentation

phy_error_msg

enum phy_error_msg

PHY status/errors.

PHY_ERROR
PHY_SUCCESS
PHY_LINK_NOT_FOUND
PHY_BUFFER_BUSY
PHY_TX_LOGIC_NOT_IDLE
PHY_TX_QUEUED
PHY_DMA_TIMEOUT

2.4.3 Class Documentation

2.4.3.1 eir_t Union Reference

ENC28J60 EIR register.

2.4.3.1.1 Detailed Description

ENC28J60 EIR register.

#include <enc28j60.h>

2.4.3.1.2 Member Data Documentation

The documentation for this union was generated from the following file:

source/

enc28j60.h

@1

struct { ... }

__pad0__

unsigned __pad0__

__pad1__

unsigned __pad1__

DMAIF

unsigned DMAIF

DMA Interrupt Flag bit

LINKIF

unsigned LINKIF

Link Change Interrupt Flag bit

PKTIF

unsigned PKTIF

Receive Packet Pending Interrupt Flag bit

RXERIF

unsigned RXERIF

Receive Error Interrupt Flag bit

TXERIF

unsigned TXERIF

Transmit Error Interrupt Flag bit

TXIF

unsigned TXIF

Transmit Interrupt Flag bit

val

char val

2.4.3.2 ethernetDriver_t Struct Reference

#include <physical_layer_interface.h>

2.4.3.2.2 Member Data Documentation

The documentation for this struct was generated from the following file:

source/

physical_layer_interface.h

__pad0__

unsigned __pad0__

bufferBusy

unsigned bufferBusy

error

unsigned error

idle

unsigned idle

linkChange

unsigned linkChange

pktReady

unsigned pktReady

saveRDPT

uint16_t saveRDPT

saveWRPT

uint16_t saveWRPT

up

unsigned up

2.4.3.3 mac48Address_t Union Reference

MAC Address (48-bits).

2.4.3.3.1 Detailed Description

MAC Address (48-bits).

#include <physical_layer_interface.h>

2.4.3.3.2 Member Data Documentation

The documentation for this union was generated from the following file:

source/

physical_layer_interface.h

byte1

uint8_t byte1

byte2

uint8_t byte2

byte3

uint8_t byte3

byte4

uint8_t byte4

byte5

uint8_t byte5

byte6

uint8_t byte6

mac_array

uint8_t mac_array[6]

s

struct { ... } s

2.4.3.4 mac64Address_t Union Reference

MAC Address (64-bits).

2.4.3.4.1 Detailed Description

MAC Address (64-bits).

#include <physical_layer_interface.h>

2.4.3.4.2 Member Data Documentation

The documentation for this union was generated from the following file:

source/

physical_layer_interface.h

byte1

uint8_t byte1

byte2

uint8_t byte2

byte3

uint8_t byte3

byte4

uint8_t byte4

byte5

uint8_t byte5

byte6

uint8_t byte6

byte7

uint8_t byte7

byte8

uint8_t byte8

mac_array

uint8_t mac_array[8]

s

struct { ... } s

2.4.3.5 phstat2_t Union Reference

ENC28J60 PHSTAT2 register.

2.4.3.5.2 Member Data Documentation

The documentation for this union was generated from the following file:

source/

enc28j60.h

@3

struct { ... }

__pad0__

unsigned __pad0__

__pad1__

unsigned __pad1__

__pad2__

unsigned __pad2__

COLSTAT

unsigned COLSTAT

PHY Collision Status bit

DPXSTAT

unsigned DPXSTAT

PHY Duplex Status bit

LSTAT

unsigned LSTAT

PHY Link Status bit (non-latching)

PLRITY

unsigned PLRITY

Polarity Status bit

RXSTAT

unsigned RXSTAT

PHY Receive Status bit

TXSTAT

unsigned TXSTAT

PHY Transmit Status bit

val

unsigned int val

2.4.3.6 receiveStatusVector_t Union Reference

ENC28J60 receive status vector.

2.4.3.6.1 Detailed Description

ENC28J60 receive status vector.

Receive status vector.

#include <enc28j60.h>

Public Attributes

2.4.3.6.2 Member Data Documentation

The documentation for this union was generated from the following files:

source/

enc28j60.h

source/

encx24j600_spi.h

@5

struct { ... }

@7

struct { ... }

__pad0__

unsigned __pad0__

__pad1__

unsigned __pad1__

Broadcast

unsigned Broadcast

Receive Broadcast Packet

BroadcastMatch

unsigned BroadcastMatch

Broadcast Filter Match

byteCount

uint16_t byteCount

Received Byte Count

CarrierPreviouslySeen

unsigned CarrierPreviouslySeen

Carrier Event Previously Seen

CodeViolation

unsigned CodeViolation

Code Violation

ControlFrame

unsigned ControlFrame

Receive Control Frame

controlFrame

unsigned controlFrame

Receive Control Frame

CRCError

unsigned CRCError

CRC Error

crcError

unsigned crcError

CRC Error

DribbleNibble

unsigned DribbleNibble

Dribble Nibble

dribbleNibble

unsigned dribbleNibble

Dribble Nibble

excessCarrierEvent

unsigned excessCarrierEvent

Carrier Event Previously Seen

filler

unsigned filler

Not-Me Filter Match

HashMatch

unsigned HashMatch

Hash Filter Match

LengthCheckError

unsigned LengthCheckError

Length Check Error

lengthCheckError

unsigned lengthCheckError

Length Check Error

lengthLongError

unsigned lengthLongError

Length Out of Range

LengthOutOfRange

unsigned LengthOutOfRange

Length Out of Range

long_drop_event

unsigned long_drop_event

Long Event/Drop Event

MagicPacketMatch

unsigned MagicPacketMatch

Magic Packet(TM) Filter Match

Multicast

unsigned Multicast

Receive Multicast Packet

MulticastMatch

unsigned MulticastMatch

Multicast Filter Match

PatternMatch

unsigned PatternMatch

Pattern Match Filter Match

PauseControlFrame

unsigned PauseControlFrame

Receive Pause Control Frame

pauseControlFrame

unsigned pauseControlFrame

Receive Pause Control Frame

PreviouslyIgnored

unsigned PreviouslyIgnored

Packet Previously Ignored

ReceiveOk

unsigned ReceiveOk

Received Ok

RuntMatch

unsigned RuntMatch

Runt Filter Match

rxBroadcast

unsigned rxBroadcast

Receive Broadcast Packet

RXDCPreviouslySeen

unsigned RXDCPreviouslySeen

RXDC Previously Seen

rxMulticast

unsigned rxMulticast

Receive Multicast Packet

rxOK

unsigned rxOK

Received Ok

UnicastMatch

unsigned UnicastMatch

Unicast Filter Match

unknownContrlFrame

unsigned unknownContrlFrame

Receive Unknown Opcode

UnsupportedOpcode

unsigned UnsupportedOpcode

Receive Unknown Opcode

v

uint8_t v

vlanTagPresent

unsigned vlanTagPresent

Receive VLAN Type Detected

VLANType

unsigned VLANType

Receive VLAN Type Detected

Zero

unsigned char Zero

zero

unsigned zero

Zero

ZeroH

unsigned ZeroH

Zero

2.4.3.7 txPacket_t Struct Reference

#include <physical_layer_interface.h>

2.4.3.7.2 Member Data Documentation

The documentation for this struct was generated from the following file:

source/

physical_layer_interface.h

flags

uint16_t flags

nextPacket

void* nextPacket

packetEnd

uint16_t packetEnd

packetStart

uint16_t packetStart

prevPacket

void* prevPacket

2.4.4 File Documentation

2.4.4.1 source/enc28j60.c File Reference

This file provides the Ethernet driver API implementation for the ENC28J60 device.

#include <xc.h>
#include <stdint.h>
#include <stddef.h>
#include "../enc28j60.h"
#include "../../system/system.h"
#include "../physical_layer_interface.h"
#include "../../spi/spi_interface.h"
#include "../../timer/delay.h"

2.4.4.1.1 Functions

2.4.4.1.2 Macros

2.4.4.1.4 Detailed Description

This file provides the Ethernet driver API implementation for the ENC28J60 device.

ENC28J60 Ethernet Driver Source File

Version: ENC28J60 Ethernet Driver Version 6.1.0

2.4.4.1.5 Macro Definition Documentation

BROADCAST_MAC

#define BROADCAST_MAC {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}

CheckBit

#define CheckBit( bitField, bitMask) (bool)(bitField & bitMask)

ClearBit

#define ClearBit( bitField, bitMask) do{ bitField = bitField & (~bitMask); } while(0)

MAC_ADDRESS

#define MAC_ADDRESS {0x02, 0x00, 0x00, 0x00, 0x00, 0x01}

MAX_TX_PACKET_SIZE

#define MAX_TX_PACKET_SIZE (1518)

MAX_TX_PACKETS

#define MAX_TX_PACKETS (20)

MIN_TX_PACKET

#define MIN_TX_PACKET (MIN_TX_PACKET_SIZE + TX_STATUS_VECTOR_SIZE)

MIN_TX_PACKET_SIZE

#define MIN_TX_PACKET_SIZE (64)

RAMSIZE_ETH

#define RAMSIZE_ETH (0x1FFF)

RXEND

#define RXEND (TXSTART - 2)

RXSTART

#define RXSTART (0)

SetBit

#define SetBit( bitField, bitMask) do{ bitField = bitField | bitMask; } while(0)

TX_BUFFER_MID

#define TX_BUFFER_MID ((TXSTART) + ((TX_BUFFER_SIZE) >> 1))

TX_BUFFER_SIZE

#define TX_BUFFER_SIZE ((MAX_TX_PACKET_SIZE + TX_STATUS_VECTOR_SIZE) << 1)

TX_STATUS_VECTOR_SIZE

#define TX_STATUS_VECTOR_SIZE (7)

TXEND

#define TXEND (RAMSIZE_ETH)

TXSTART

#define TXSTART (RAMSIZE_ETH - TX_BUFFER_SIZE)

2.4.4.1.6 Variable Documentation

broadcastMAC

const mac48Address_t broadcastMAC = {BROADCAST_MAC}

eth_MAC

const mac48Address_t* eth_MAC

ethData

volatile ethernetDriver_t ethData

ethListSize

uint8_t ethListSize

lastBank

sfr_bank_t lastBank

macAddress

mac48Address_t macAddress = {MAC_ADDRESS}

nextPacketPointer

uint16_t nextPacketPointer[static]

pHead

txPacket_t* pHead[static]

pTail

txPacket_t* pTail[static]

rxPacketStatusVector

receiveStatusVector_t rxPacketStatusVector[static]

txData

txPacket_t txData[MAX_TX_PACKETS][static]

TXPacketSize

uint16_t TXPacketSize

2.4.4.2 source/enc28j60.h File Reference

2.4.4.2.2 Macros

2.4.4.2.3 Enumerations

2.4.4.2.4 Variables

2.4.4.2.5 Detailed Description

ENC28J60 Ethernet Driver Header File

2.4.4.2.6 Macro Definition Documentation

BANK_MASK

#define BANK_MASK 0xE0

byteReverse24

#define byteReverse24( a) (((((uint32_t)a & (uint32_t)0x00FF00) >> 8) | (((uint32_t)a & (uint32_t)0x0000FF) << 8)) << 8 | (uint32_t)a >> 0x10)

byteReverse32

#define byteReverse32( a)

Value:

((((uint32_t)a & (uint32_t)0xff000000) >> 24) | \
                          (((uint32_t)a & (uint32_t)0x00ff0000) >> 8)  | \
                          (((uint32_t)a & (uint32_t)0x0000ff00) << 8)  | \
                          (((uint32_t)a & (uint32_t)0x000000ff) << 24))
byteSwap16

#define byteSwap16( a) ((((uint16_t)a & (uint16_t)0xFF00) >> 8) | (((uint16_t)a & (uint16_t)0x00FF) << 8))

convert_hton24

#define convert_hton24( a) byteReverse24(a)

htonl

#define htonl( a) byteReverse32(a)

htons

#define htons( a) byteSwap16(a)

ntohl

#define ntohl( a) byteReverse32(a)

ntohs

#define ntohs( a) byteSwap16(a)

SFR_BANK0

#define SFR_BANK0 0x00

SFR_BANK1

#define SFR_BANK1 0x40

SFR_BANK2

#define SFR_BANK2 0x80

SFR_BANK3

#define SFR_BANK3 0xC0

SFR_COMMON

#define SFR_COMMON 0xE0

SFR_MASK

#define SFR_MASK 0x1F

2.4.4.3 source/encx24j600_driver.c File Reference

This file provides the Ethernet driver API implementation for the ENCx24J600 family devices.

#include <xc.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include "../../system/system.h"
#include "../physical_layer_interface.h"
#include "../encx24j600_spi.h"
#include "../../spi/spi_interface.h"
#include "../../timer/delay.h"

2.4.4.3.1 Functions

2.4.4.3.2 Macros

2.4.4.3.4 Detailed Description

This file provides the Ethernet driver API implementation for the ENCx24J600 family devices.

ENCx24J600 Ethernet Driver source file

Version: ENCx24J600 Driver Version 6.1.0

2.4.4.3.5 Macro Definition Documentation

BROADCAST_MAC

#define BROADCAST_MAC {0xff,0xff,0xff,0xff,0xff,0xff}

CheckBit

#define CheckBit( bitField, bitMask) (bool)(bitField & bitMask)

ClearBit

#define ClearBit( bitField, bitMask) do{bitField = bitField & (~bitMask); } while(0)

MAC_ADDRESS

#define MAC_ADDRESS {0x02, 0x00, 0x00, 0x00, 0x00, 0x01}

MAX_TX_PACKET_SIZE

#define MAX_TX_PACKET_SIZE (1518)

MAX_TX_PACKETS

#define MAX_TX_PACKETS (20)

MIN_TX_PACKET

#define MIN_TX_PACKET (MIN_TX_PACKET_SIZE)

MIN_TX_PACKET_SIZE

#define MIN_TX_PACKET_SIZE (64)

SetBit

#define SetBit( bitField, bitMask) do{bitField = bitField | bitMask; } while(0)

TX_BUFFER_MID

#define TX_BUFFER_MID ((TXSTART + TXEND) >> 1)

TX_BUFFER_SIZE

#define TX_BUFFER_SIZE (TXEND - TXSTART)

2.4.4.3.6 Variable Documentation

broadcastMAC

const mac48Address_t broadcastMAC = {BROADCAST_MAC}

ethData

volatile ethernetDriver_t ethData

ethListSize

uint8_t ethListSize

ethMAC

mac48Address_t ethMAC

macAddress

mac48Address_t macAddress = {MAC_ADDRESS}

nextPacketPointer

uint16_t nextPacketPointer[static]

pHead

txPacket_t* pHead[static]

pTail

txPacket_t* pTail[static]

txData

txPacket_t txData[MAX_TX_PACKETS][static]

2.4.4.4 source/encx24j600_spi.c File Reference

This file provides the SPI Interface Ethernet driver API implementation for the ENCx24J600 family devices.

#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include "../../system/system.h"
#include "../encx24j600_spi.h"
#include "../physical_layer_interface.h"

2.4.4.4.1 Functions

2.4.4.4.3 Detailed Description

This file provides the SPI Interface Ethernet driver API implementation for the ENCx24J600 family devices.

ENCx24J600 SPI Driver File

Version: ENCx24J600 Driver Version 6.1.0

2.4.4.4.4 Variable Documentation

last_bank

sfr_bank_t last_bank

rxPacketStatusVector

receiveStatusVector_t rxPacketStatusVector = {{0, 0, 0, 0, 0, 0}}

TXPacketSize

uint16_t TXPacketSize

2.4.4.5 source/encx24j600_spi.h File Reference

This header file provides the serial interface API for the ENCx24J600 devices.

#include "encx24j600_types.h"
#include "../system/system.h"
#include "../spi/spi_interface.h"

2.4.4.5.2 Functions

2.4.4.5.3 Macros

2.4.4.5.4 Enumerations

2.4.4.5.6 Detailed Description

This header file provides the serial interface API for the ENCx24J600 devices.

ENCx24J600 spi Header File

Version: ENCx24J600 Driver Version 6.1.0

2.4.4.5.7 Macro Definition Documentation

BANK_MASK

#define BANK_MASK 0xE0

byteReverse24

#define byteReverse24( a) (((((uint32_t)a & (uint32_t)0x00FF00) >> 8) | (((uint32_t)a & (uint32_t)0x0000FF) << 8)) << 8 | (uint32_t)a >> 0x10)

byteReverse32

#define byteReverse32( a)

Value:

((((uint32_t)a & (uint32_t)0xff000000) >> 24) | \
                          (((uint32_t)a & (uint32_t)0x00ff0000) >> 8)  | \
                          (((uint32_t)a & (uint32_t)0x0000ff00) << 8)  | \
                          (((uint32_t)a & (uint32_t)0x000000ff) << 24))
byteSwap16

#define byteSwap16( a) ((((uint16_t)a & (uint16_t)0xFF00) >> 8) | (((uint16_t)a & (uint16_t)0x00FF) << 8))

convert_hton24

#define convert_hton24( a) byteReverse24(a)

htonl

#define htonl( a) byteReverse32(a)

htons

#define htons( a) byteSwap16(a)

ntohl

#define ntohl( a) byteReverse32(a)

ntohs

#define ntohs( a) byteSwap16(a)

SFR_BANK0

#define SFR_BANK0 0x00

SFR_BANK1

#define SFR_BANK1 0x20

SFR_BANK2

#define SFR_BANK2 0x40

SFR_BANK3

#define SFR_BANK3 0x60

SFR_COMMON

#define SFR_COMMON 0xE0

SFR_MASK

#define SFR_MASK 0x1F

UNBANKED

#define UNBANKED 0X80

2.4.4.5.8 Enumeration Type Documentation

sfr_bank_t

enum sfr_bank_t

sfr_bank0

Bank 0

sfr_bank1

Bank 1

sfr_bank2

Bank 2

sfr_bank3

Bank 3

sfr_common

Common Set of Registers (last five locations of each bank)

sfr_bank0

Bank 0

sfr_bank1

Bank 1

sfr_bank2

Bank 2

sfr_bank3

Bank 3

sfr_common

Common Set of Registers (last five locations of each bank)

2.4.4.5.9 Variable Documentation

rxPacketStatusVector

receiveStatusVector_t rxPacketStatusVector

TXPacketSize

uint16_t TXPacketSize

2.4.4.6 source/encx24j600_types.h File Reference

2.4.4.6.1 Macros

2.4.4.6.3 Detailed Description

ENCx24J600 Ethernet Controller Header File

2.4.4.6.4 Macro Definition Documentation

ECON1_AESST

#define ECON1_AESST 0x0800

ECON1_DMACPY

#define ECON1_DMACPY 0x0010

ECON1_DMACSSD

#define ECON1_DMACSSD 0x0008

ECON1_DMANOCS

#define ECON1_DMANOCS 0x0004

ECON1_DMAST

#define ECON1_DMAST 0x0020

ECON1_HASHEN

#define ECON1_HASHEN 0x4000

ECON1_HASHLST

#define ECON1_HASHLST 0x1000

ECON1_HASHOP

#define ECON1_HASHOP 0x2000

ECON1_MODEXST

#define ECON1_MODEXST 0x8000

ECON1_PKTDEC

#define ECON1_PKTDEC 0x0100

ECON1_RXEN

#define ECON1_RXEN 0x0001

ECON1_TXRTS

#define ECON1_TXRTS 0x0002

ECON2_AUTOFC

#define ECON2_AUTOFC 0x0080

ECON2_ETHEN

#define ECON2_ETHEN 0x8000

ECON2_ETHRST

#define ECON2_ETHRST 0x0010

ECON2_RXRST

#define ECON2_RXRST 0x0020

ECON2_STRCH

#define ECON2_STRCH 0x4000

EIR_CRYPTEN

#define EIR_CRYPTEN 0x8000

EIR_LINKIF

#define EIR_LINKIF 0x0800

EIR_PCFULIF

#define EIR_PCFULIF 0x0001

EIR_PKTIF

#define EIR_PKTIF 0x0040

EIR_RXABTIF

#define EIR_RXABTIF 0x0002

EIR_TXIF

#define EIR_TXIF 0x0008

ESTAT_CLKRDY

#define ESTAT_CLKRDY 0x1000

ESTAT_PHYDPX

#define ESTAT_PHYDPX 0x0400

ESTAT_PHYLINK

#define ESTAT_PHYLINK 0x0100

ESTAT_PHYRDY

#define ESTAT_PHYRDY 0x0200

ESTAT_PKTCNT

#define ESTAT_PKTCNT 0x00FF

ESTAT_RSTDONE

#define ESTAT_RSTDONE 0x0800

ESTAT_RXBUSY

#define ESTAT_RXBUSY 0x2000

ETH_HEADER_SIZE

#define ETH_HEADER_SIZE 14

IP_PROTOCOL_POS

#define IP_PROTOCOL_POS 23

MACON2_FULDPX_OFF

#define MACON2_FULDPX_OFF 0xFFFE

MACON2_FULDPX_ON

#define MACON2_FULDPX_ON 0x0001

RAMSIZE_ETH

#define RAMSIZE_ETH 0x6000ul

2.4.4.7 source/physical_layer_interface.h File Reference

#include <stdbool.h>
#include <stdint.h>

2.4.4.7.2 Functions

  • void ETH_Init (void)

    Sets up the Ethernet and starts the execution. Initializes the TX/RX buffer, the MAC and the PHY.

  • void ETH_EventHandler (void)

    Manages the MAC events. Can be used for polling or for new events in Interrupt Service Routine (ISR).

  • void ETH_NextPacketUpdate (void)

    Updates the pointers for the next available RX packets. Retrieves information about the last received packet and the address of the next ones.

  • void ETH_ResetReceiver (void)

    Resets the receiver buffer.

  • void ETH_SendSystemReset (void)

    Resets the system software.

  • const mac48Address_t * MAC_getAddress (void)

    Returns the MAC address of type mac48Address_t.

  • uint16_t ETH_ReadBlock (void *buffer, uint16_t length)

    Reads a block of data from the RX buffer MAC.

  • uint8_t ETH_Read8 (void)

    Reads one byte of data from the RX buffer MAC.

  • uint16_t ETH_Read16 (void)

    Reads two bytes of data from the RX buffer and returns them in host order.

  • uint32_t ETH_Read24 (void)

    Reads three bytes of data from the RX buffer and returns them in host order.

  • uint32_t ETH_Read32 (void)

    Reads four bytes of data from the RX buffer and returns them in host order.

  • void ETH_Dump (uint16_t length)

    Drops the N bytes from a packet list when the data is lost. Clears a number of bytes (length) from the RX buffer.

  • void ETH_Flush (void)

    Drops the rest of this packet and release the buffer. Clears all bytes from the RX buffer.

  • uint16_t ETH_GetFreeTxBufferSize (void)

    Returns the available space size in the Ethernet TX buffer.

  • phy_error_msg ETH_WriteStart (const mac48Address_t *dest_mac, uint16_t type)

    Starts a packet if the Ethernet transmitter is idle.

  • uint16_t ETH_WriteString (const char *string)

    Writes a string of data into the MAC.

  • uint16_t ETH_WriteBlock (const char *data, uint16_t length)

    Writes a block of data into the TX buffer MAC.

  • void ETH_Write8 (uint8_t data)

    Writes one byte of data into the TX buffer MAC.

  • void ETH_Write16 (uint16_t data)

    Writes two bytes into the TX buffer MAC in Network order.

  • void ETH_Write24 (uint32_t data)

    Writes three bytes into the TX buffer MAC in Network order.

  • void ETH_Write32 (uint32_t data)

    Writes four bytes into the TX buffer MAC in Network order.

  • void ETH_Insert (char *data, uint16_t len, uint16_t offset)

    Inserts N data bytes into a specific offset in the TX buffer/packet.

  • phy_error_msg ETH_Copy (uint16_t len)

    Copies N bytes from the saved read location (RX buffer) into the current TX location (TX buffer) using the DMA set up. This is used for ICMP ECHO to eliminate the need to extract the arbitrary payload.

  • phy_error_msg ETH_Send (void)

    Sends the TX packet. Starts the transmission of packet or queues the packet that has been created.

  • uint16_t ETH_TxComputeChecksum (uint16_t position, uint16_t length, uint16_t seed)

    Calculates the hardware checksum of length bytes starting with the position.

  • uint16_t ETH_RxComputeChecksum (uint16_t len, uint16_t seed)

    Calculates the RX software checksum.

  • void ETH_GetMAC (uint8_t *macAddr)

    Reads the MAC address.

  • void ETH_SetMAC (uint8_t *macAddr)

    Sets the MAC address.

  • uint16_t ETH_GetWritePtr (void)

    Returns the value of the write pointer.

  • void ETH_SaveRDPT (void)

    Saves the receive pointer for copy.

  • void ETH_ResetReadPtr (void)

    Resets the receive pointer to the Init.

  • uint16_t ETH_GetReadPtr (void)

    Returns the value of the read pointer.

  • void ETH_SetReadPtr (uint16_t rdptr)

    Sets the read pointer to a specific address.

  • uint16_t ETH_GetStatusVectorByteCount (void)

    Returns the Status Vector's byte count.

  • void ETH_SetStatusVectorByteCount (uint16_t bc)

    Sets the Status Vector's byte count.

  • void ETH_ResetByteCount (void)

    Resets the driver's byte count.

  • uint16_t ETH_GetByteCount (void)

    Returns the the driver's byte count.

  • uint16_t ETH_ReadSavedWRPT (void)

    Returns the saved write pointer.

  • void ETH_SaveWRPT (void)

    Saves the write pointer for copy.

  • void ETH_SetRxByteCount (uint16_t count)

    Sets the receiver's byte count.

  • uint16_t ETH_GetRxByteCount (void)

    Returns the receiver's byte count.

  • bool ETH_CheckLinkUp (void)

    Checks for the link.

  • void ETH_TxReset (void)

    Resets the transmitter.

  • void ETH_MoveBackReadPtr (uint16_t offset)

    Moves back the read pointer.

2.4.4.7.6 Detailed Description

Physical Layer Interface Header File

2.4.4.7.7 Macro Definition Documentation

ETH_linkChanged

#define ETH_linkChanged( ) ethData.linkChange

ETH_linkCheck

#define ETH_linkCheck( ) ethData.up

ETH_packetReady

#define ETH_packetReady( ) ethData.pktReady

2.4.4.7.8 Variable Documentation

broadcastMAC

const mac48Address_t broadcastMAC

ethData

volatile ethernetDriver_t ethData

hostMacAddress

mac48Address_t hostMacAddress