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.
Data structures
union eir_t
ENC28J60 EIR register.
union phstat2_t
ENC28J60 PHSTAT2 register.
union receiveStatusVector_t
ENC28J60 receive status vector.
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
enum spi_inst_t { rcr_inst = 0x00, rbm_inst = 0x3A, wcr_inst = 0x40, wbm_inst = 0x7A, bfs_inst = 0x80, bfc_inst = 0xa0, src_inst = 0xFF }
SPI instructions.
enum sfr_bank_t { sfr_bank0 = SFR_BANK0, sfr_bank1 = SFR_BANK1, sfr_bank2 = SFR_BANK2, sfr_bank3 = SFR_BANK3, sfr_common = SFR_COMMON, sfr_bank0 = SFR_BANK0, sfr_bank1 = SFR_BANK1, sfr_bank2 = SFR_BANK2, sfr_bank3 = SFR_BANK3, sfr_common = SFR_COMMON }
SFR banks.
enum enc28j60_registers_t { J60_ERDPTL = (SFR_BANK0 | 0x00), J60_ERDPTH = (SFR_BANK0 | 0x01), J60_EWRPTL = (SFR_BANK0 | 0x02), J60_EWRPTH = (SFR_BANK0 | 0x03), J60_ETXSTL = (SFR_BANK0 | 0x04), J60_ETXSTH = (SFR_BANK0 | 0x05), J60_ETXNDL = (SFR_BANK0 | 0x06), J60_ETXNDH = (SFR_BANK0 | 0x07), J60_ERXSTL = (SFR_BANK0 | 0x08), J60_ERXSTH = (SFR_BANK0 | 0x09), J60_ERXNDL = (SFR_BANK0 | 0x0A), J60_ERXNDH = (SFR_BANK0 | 0x0B), J60_ERXRDPTL = (SFR_BANK0 | 0x0C), J60_ERXRDPTH = (SFR_BANK0 | 0x0D), J60_ERXWRPTL = (SFR_BANK0 | 0x0E), J60_ERXWRPTH = (SFR_BANK0 | 0x0F), J60_EDMASTL = (SFR_BANK0 | 0x10), J60_EDMASTH = (SFR_BANK0 | 0x11), J60_EDMANDL = (SFR_BANK0 | 0x12), J60_EDMANDH = (SFR_BANK0 | 0x13), J60_EDMADSTL = (SFR_BANK0 | 0x14), J60_EDMADSTH = (SFR_BANK0 | 0x15), J60_EDMACSL = (SFR_BANK0 | 0x16), J60_EDMACSH = (SFR_BANK0 | 0x17), RSRV_018 = (SFR_BANK0 | 0x18), RSRV_019 = (SFR_BANK0 | 0x19), RSRV_01A = (SFR_BANK0 | 0x1A), J60_EHT0 = (SFR_BANK1 | 0x00), J60_EHT1 = (SFR_BANK1 | 0x01), J60_EHT2 = (SFR_BANK1 | 0x02), J60_EHT3 = (SFR_BANK1 | 0x03), J60_EHT4 = (SFR_BANK1 | 0x04), J60_EHT5 = (SFR_BANK1 | 0x05), J60_EHT6 = (SFR_BANK1 | 0x06), J60_EHT7 = (SFR_BANK1 | 0x07), J60_EPMM0 = (SFR_BANK1 | 0x08), J60_EPMM1 = (SFR_BANK1 | 0x09), J60_EPMM2 = (SFR_BANK1 | 0x0A), J60_EPMM3 = (SFR_BANK1 | 0x0B), J60_EPMM4 = (SFR_BANK1 | 0x0C), J60_EPMM5 = (SFR_BANK1 | 0x0D), J60_EPMM6 = (SFR_BANK1 | 0x0E), J60_EPMM7 = (SFR_BANK1 | 0x0F), J60_EPMCSL = (SFR_BANK1 | 0x10), J60_EPMCSH = (SFR_BANK1 | 0x11), RSRV_112 = (SFR_BANK1 | 0x12), RSRV_113 = (SFR_BANK1 | 0x13), J60_EPMOL = (SFR_BANK1 | 0x14), J60_EPMOH = (SFR_BANK1 | 0x15), RSRV_116 = (SFR_BANK1 | 0x16), RSRV_117 = (SFR_BANK1 | 0x17), J60_ERXFCON = (SFR_BANK1 | 0x18), J60_EPKTCNT = (SFR_BANK1 | 0x19), RSRV_11A = (SFR_BANK1 | 0x1A), J60_MACON1 = (SFR_BANK2 | 0x00), RSRV_201 = (SFR_BANK2 | 0x01), J60_MACON3 = (SFR_BANK2 | 0x02), J60_MACON4 = (SFR_BANK2 | 0x03), J60_MABBIPG = (SFR_BANK2 | 0x04), RSRV_205 = (SFR_BANK2 | 0x05), J60_MAIPGL = (SFR_BANK2 | 0x06), J60_MAIPGH = (SFR_BANK2 | 0x07), J60_MACLCON1 = (SFR_BANK2 | 0x08), J60_MACLCON2 = (SFR_BANK2 | 0x09), J60_MAMXFLL = (SFR_BANK2 | 0x0A), J60_MAMXFLH = (SFR_BANK2 | 0x0B), RSRV_20C = (SFR_BANK2 | 0x0C), RSRV_20D = (SFR_BANK2 | 0x0D), RSRV_20E = (SFR_BANK2 | 0x0E), RSRV_20F = (SFR_BANK2 | 0x0F), RSRV_210 = (SFR_BANK2 | 0x10), RSRV_211 = (SFR_BANK2 | 0x11), J60_MICMD = (SFR_BANK2 | 0x12), RSRV_213 = (SFR_BANK2 | 0x13), J60_MIREGADR = (SFR_BANK2 | 0x14), RSRV_215 = (SFR_BANK2 | 0x15), J60_MIWRL = (SFR_BANK2 | 0x16), J60_MIWRH = (SFR_BANK2 | 0x17), J60_MIRDL = (SFR_BANK2 | 0x18), J60_MIRDH = (SFR_BANK2 | 0x19), RSRV_21A = (SFR_BANK2 | 0x1A), J60_MAADR5 = (SFR_BANK3 | 0x00), J60_MAADR6 = (SFR_BANK3 | 0x01), J60_MAADR3 = (SFR_BANK3 | 0x02), J60_MAADR4 = (SFR_BANK3 | 0x03), J60_MAADR1 = (SFR_BANK3 | 0x04), J60_MAADR2 = (SFR_BANK3 | 0x05), J60_EBSTSD = (SFR_BANK3 | 0x06), J60_EBSTCON = (SFR_BANK3 | 0x07), J60_EBSTCSL = (SFR_BANK3 | 0x08), J60_EBSTCSH = (SFR_BANK3 | 0x09), J60_MISTAT = (SFR_BANK3 | 0x0A), RSRV_30B = (SFR_BANK3 | 0x0B), RSRV_30C = (SFR_BANK3 | 0x0C), RSRV_30D = (SFR_BANK3 | 0x0D), RSRV_30E = (SFR_BANK3 | 0x0E), RSRV_30F = (SFR_BANK3 | 0x0F), RSRV_310 = (SFR_BANK3 | 0x10), RSRV_311 = (SFR_BANK3 | 0x11), J60_EREVID = (SFR_BANK3 | 0x12), RSRV_313 = (SFR_BANK3 | 0x13), RSRV_314 = (SFR_BANK3 | 0x14), J60_ECOCON = (SFR_BANK3 | 0x15), RSRV_316 = (SFR_BANK3 | 0x16), J60_EFLOCON = (SFR_BANK3 | 0x17), J60_EPAUSL = (SFR_BANK3 | 0x18), J60_EPAUSH = (SFR_BANK3 | 0x19), RSRV_31A = (SFR_BANK3 | 0x1A), J60_EIE = (SFR_COMMON | 0x1B), J60_EIR = (SFR_COMMON | 0x1C), J60_ESTAT = (SFR_COMMON | 0x1D), J60_ECON2 = (SFR_COMMON | 0x1E), J60_ECON1 = (SFR_COMMON | 0x1F) }
ENC28J60 registers.
enum enc28j60_phy_registers_t { J60_PHCON1 = 0x00, J60_PHSTAT1 = 0x01, J60_PHID1 = 0x02, J60_PHID2 = 0x03, J60_PHCON2 = 0x10, J60_PHSTAT2 = 0x11, J60_PHIE = 0x12, J60_PHIR = 0x13, J60_PHLCON = 0x14 }
ENC28J60 PHY register addresses.
Functions
phy_error_msg ETH_SendQueued (void)
Enqueues the latest written packet and starts the transmission of a queued packet.
phy_error_msg ETH_Shift_Tx_Packets (void)
Copies the queued packets to the TX Buffer start address using the DMA setup.
void ETH_PacketListReset (void)
Resets the Ethernet packet list.
txPacket_t * ETH_NewPacket (void)
Allocates a new packet element and links it to the chained list.
void ETH_RemovePacket (txPacket_t *pPacket)
Deallocates a packet element and unlinks it from the chained list.
static uint16_t ETH_ComputeChecksum (uint16_t len, uint16_t seed)
Calculates the checksum.
static uint8_t ENC28_Rcr8 (enc28j60_registers_t a)
Reads one byte from Special Function Register (SFR).
static uint16_t ENC28_Rcr16 (enc28j60_registers_t a)
Reads two bytes from SFRs.
static void ENC28_Wcr8 (enc28j60_registers_t a, uint8_t v)
Writes one byte to SFRs.
static void ENC28_Wcr16 (enc28j60_registers_t a, uint16_t v)
Writes two bytes to SFRs.
static void ENC28_Bfs (enc28j60_registers_t a, char bits)
Sets the SFR bit field.
static void ENC28_Bfc (enc28j60_registers_t a, char bits)
Clears the SFR bit field.
static uint16_t ENC28_PhyRead (enc28j60_phy_registers_t a)
Reads the Physical Layer (PHY) register.
static void ENC28_PhyWrite (enc28j60_phy_registers_t a, uint16_t d)
Writes the PHY register.
static void ENC28_BankSel (enc28j60_registers_t r)
Selects the bank.
static void ETH_CloseSPI (void)
Releases the Serial Peripheral Interface (SPI) bus.
static void ETH_OpenSPI (void)
Connects the SPI bus.
Variables
uint8_t Control_Byte
ENC28J60 Control Byte.
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.
r |
register |
None. |
ENC28_Bfc()
static void ENC28_Bfc (enc28j60_registers_t a, char bits)[static]
Clears the SFR bit field.
a |
register |
bits |
None. |
ENC28_Bfs()
static void ENC28_Bfs (enc28j60_registers_t a, char bits)[static]
Sets the SFR bit field.
a |
register |
bits |
None. |
ENC28_PhyRead()
static uint16_t ENC28_PhyRead (enc28j60_phy_registers_t a)[static]
Reads the Physical Layer (PHY) register.
a |
register |
Register data. |
ENC28_PhyWrite()
static void ENC28_PhyWrite (enc28j60_phy_registers_t a, uint16_t d)[static]
Writes the PHY register.
a |
register |
d |
data |
None. |
ENC28_Rcr16()
static uint16_t ENC28_Rcr16 (enc28j60_registers_t a)[static]
Reads two bytes from SFRs.
a |
register |
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).
a |
register |
One byte of SFR value. |
ENC28_Wcr16()
static void ENC28_Wcr16 (enc28j60_registers_t a, uint16_t v)[static]
Writes two bytes to SFRs.
a |
register |
v |
16-bit value |
None. |
ENC28_Wcr8()
static void ENC28_Wcr8 (enc28j60_registers_t a, uint8_t v)[static]
Writes one byte to SFRs.
a |
register |
v |
8-bit value |
None. |
ETH_CloseSPI()
static void ETH_CloseSPI (void )[static]
Releases the Serial Peripheral Interface (SPI) bus.
None. |
None. |
ETH_ComputeChecksum()
static uint16_t ETH_ComputeChecksum (uint16_t len, uint16_t seed)[static]
Calculates the checksum.
len |
length |
seed |
Checksum. |
ETH_NewPacket()
txPacket_t * ETH_NewPacket (void )
Allocates a new packet element and links it to the chained list.
None. |
Packet address. |
ETH_OpenSPI()
static void ETH_OpenSPI (void )[static]
Connects the SPI bus.
None. |
None. |
ETH_PacketListReset()
void ETH_PacketListReset (void )
Resets the Ethernet packet list.
None. |
None. |
ETH_RemovePacket()
void ETH_RemovePacket (txPacket_t * pPacket)
Deallocates a packet element and unlinks it from the chained list.
pPacket |
packetHandle |
None. |
ETH_SendQueued()
phy_error_msg ETH_SendQueued (void )
Enqueues the latest written packet and starts the transmission of a queued packet.
None. |
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.
None. |
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.
Data structures
union receiveStatusVector_t
ENC28J60 receive status vector.
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
enum encX24J600_registers_t { XJ600_ETXSTL = (SFR_BANK0 | 0x00), XJ600_ETXLENL = (SFR_BANK0 | 0x02), XJ600_ERXSTL = (SFR_BANK0 | 0x04), XJ600_ERXTAILL = (SFR_BANK0 | 0x06), XJ600_ERXHEADL = (SFR_BANK0 | 0x08), XJ600_EDMASTL = (SFR_BANK0 | 0x0A), XJ600_EDMALENL = (SFR_BANK0 | 0x0C), XJ600_EDMADSTL = (SFR_BANK0 | 0x0E), XJ600_EDMACSL = (SFR_BANK0 | 0x10), XJ600_ETXSTATL = (SFR_BANK0 | 0x12), XJ600_ETXWIREL = (SFR_BANK0 | 0x14), XJ600_EHT1L = (SFR_BANK1 | 0x00), XJ600_EHT2L = (SFR_BANK1 | 0x02), XJ600_EHT3L = (SFR_BANK1 | 0x04), XJ600_EHT4L = (SFR_BANK1 | 0x06), XJ600_EPMM1L = (SFR_BANK1 | 0x08), XJ600_EPMM2L = (SFR_BANK1 | 0x0A), XJ600_EPMM3L = (SFR_BANK1 | 0x0C), XJ600_EPMM4L = (SFR_BANK1 | 0x0E), XJ600_EPMCSL = (SFR_BANK1 | 0x10), XJ600_EPMOL = (SFR_BANK1 | 0x12), XJ600_ERXFCONL = (SFR_BANK1 | 0x14), XJ600_MACON1L = (SFR_BANK2 | 0x00), XJ600_MACON2L = (SFR_BANK2 | 0x02), XJ600_MABBIPGL = (SFR_BANK2 | 0x04), XJ600_MAIPGL = (SFR_BANK2 | 0x06), XJ600_MACLCONL = (SFR_BANK2 | 0x08), XJ600_MAMXFLL = (SFR_BANK2 | 0x0A), XJ600_MICMDL = (SFR_BANK2 | 0x12), XJ600_MIREGADRL = (SFR_BANK2 | 0x14), XJ600_MAADR3L = (SFR_BANK3 | 0x00), XJ600_MAADR3H = (SFR_BANK3 | 0x01), XJ600_MAADR2L = (SFR_BANK3 | 0x02), XJ600_MAADR2H = (SFR_BANK3 | 0x03), XJ600_MAADR1L = (SFR_BANK3 | 0x04), XJ600_MAADR1H = (SFR_BANK3 | 0x05), XJ600_MIWRL = (SFR_BANK3 | 0x06), XJ600_MIRDL = (SFR_BANK3 | 0x08), XJ600_MISTATL = (SFR_BANK3 | 0x0A), XJ600_EPAUSL = (SFR_BANK3 | 0x0C), XJ600_ECON2L = (SFR_BANK3 | 0x0E), XJ600_ERXWML = (SFR_BANK3 | 0x10), XJ600_EIEL = (SFR_BANK3 | 0x12), XJ600_EIDLEDL = (SFR_BANK3 | 0x14), XJ600_EGPDATAL = (UNBANKED | 0x00), XJ600_ERXDATAL = (UNBANKED | 0x02), XJ600_EUDADATAL = (UNBANKED | 0x04), XJ600_EGPRDPTL = (UNBANKED | 0x06), XJ600_EGPWRPTL = (UNBANKED | 0x08), XJ600_ERXRDPTL = (UNBANKED | 0x0A), XJ600_ERXWRPTL = (UNBANKED | 0x0C), XJ600_EUDARDPTL = (UNBANKED | 0x0E), XJ600_EUDAWRPTL = (UNBANKED | 0x10), XJ600_EUDASTL = (SFR_COMMON | 0x16), XJ600_EUDANDL = (SFR_COMMON | 0x18), XJ600_ESTATL = (SFR_COMMON | 0x1A), XJ600_EIRL = (SFR_COMMON | 0x1C), XJ600_ECON1L = (SFR_COMMON | 0x1E) }
SFR addresses for the ENCx24J600 SPI mode.
enum encX24J600_1_byte_instructions_t { b0sel_inst = 0b11000000, b1sel_inst = 0b11000010, b2sel_inst = 0b11000100, b3sel_inst = 0b11000110, setethrst_inst = 0b11001010, fcdisable_inst = 0b11100000, fcsingle_inst = 0b11100010, fcmultiple_inst = 0b11100100, fcclear_inst = 0b11100110, setpktdec_inst = 0b11001100, dmastop_inst = 0b11010010, dmacksum_inst = 0b11011000, dmacksums_inst = 0b11011010, dmacopy_inst = 0b11011100, dmacopys_inst = 0b11011110, settxrts_inst = 0b11010100, enablerx_inst = 0b11101000, disablerx_inst = 0b11101010, seteie_inst = 0b11101100, clreie_inst = 0b11101110 }
SPI single byte instructions.
enum encX24J600_2_byte_instructions_t { rbsel_inst = 0b11001000 }
SPI two byte instructions.
enum encX24J600_3_byte_instructions_t { rgprdpt_inst = 0b01100010, rrxrdpt_inst = 0b01100110, rgpwrpt_inst = 0b01101110, rrxwrpt_inst = 0b01110010, rudawrpt_inst = 0b01110110, wgprdpt_inst = 0b01100000, wrxrdpt_inst = 0b01100100, wgpwrpt_inst = 0b01101100, wrxwrpt_inst = 0b01110000, wudawrpt_inst = 0b01110100 }
SPI three byte instructions.
enum encX24J600_N_byte_instructions_t { rcr_inst = 0b00000000, wcr_inst = 0b01000000, bfs_inst = 0b10000000, bfc_inst = 0b10100000, rcru_inst = 0b00100000, wcru_inst = 0b00100010, bfsu_inst = 0b00100100, bfcu_inst = 0b00100110, rgpdata_inst = 0b00101000, rrxdata_inst = 0b00101100, rudadata_inst = 0b00110000, wgpdata_inst = 0b00101010, wrxdata_inst = 0b00101110, wudadata_inst = 0b00110010 }
SPI N byte instructions.
enum encX24J600_phy_registers_t { PHCON1 = 0x00, PHSTAT1 = 0x01, PHANA = 0x04, PHANLPA = 0x05, PHANE = 0x06, PHCON2 = 0x11, PHSTAT2 = 0x1B, PHSTAT3 = 0x1F }
ENCX24J600 PHY registers.
Functions
phy_error_msg ETH_SendQueued (void)
Enqueues the latest written packet and starts the transmission of a queued packet.
phy_error_msg ETH_Shift_Tx_Packets (void)
Copies all the queued packets to the TX Buffer start address using the DMA setup.
void ETH_PacketListReset (void)
Resets the Ethernet packet list.
txPacket_t * ETH_NewPacket (void)
Allocates a new packet element and links it to the chained list.
void ETH_RemovePacket (txPacket_t *pPacket)
Deallocates a packet element and unlinks it from the chained list.
static uint16_t ETH_DMAComputeChecksum (uint16_t rxPtr, uint16_t len, uint16_t seed)
Calculates the checksum.
static void ETH_CloseSPI (void)
Releases the Serial Peripheral Interface (SPI) bus.
static void ETH_OpenSPI (void)
Connects the SPI bus.
static void waitForDMA (void)
Waits for the DMA.
static uint32_t ETH_readLinkStatus (void)
Checks for the link status.
static void ENCx24_BankselSPI (encX24J600_registers_t a)
Selects the SPI bank.
uint16_t ENCx24_Read (encX24J600_registers_t a)
Reads from Special Function Register (SFR).
uint8_t ETH_EdataRead (encX24J600_registers_t a)
Reads the 8-bit data from the ENCx24J600 register (work around for Errata).
void ENCx24_Write (encX24J600_registers_t a, uint16_t data)
Writes to SFRs.
void ENCx24_BFS (encX24J600_registers_t a, uint16_t bitMask)
Sets the SFR bit field.
void ENCx24_BFC (encX24J600_registers_t a, uint16_t bitMask)
Clears the SFR bit field.
uint16_t ENCx24_PhyRead (encX24J600_phy_registers_t a)
Reads the PHY register.
void ENCx24_PHYWrite (encX24J600_phy_registers_t a, uint16_t data)
Writes the PHY register.
uint8_t ETH_MACRead8 (encX24J600_registers_t a)
Reads the 8-bit MAC-related data from ENCx24J600 registers.
void ETH_MACWrite8 (encX24J600_registers_t a, uint8_t data)
Writes the 8-bit MAC-related data to ENCx24J600 registers.
void ETH_SetPktDec (void)
Decrements packet count.
void ETH_SetRXptr (uint16_t address)
RX packet read pointer.
void ETH_Set_TXRTS (void)
Packet transmission request.
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.
a |
register |
None. |
ENCx24_BFC()
void ENCx24_BFC (encX24J600_registers_t a, uint16_t bitMask)
Clears the SFR bit field.
a |
register |
bitMask |
None. |
ENCx24_BFS()
void ENCx24_BFS (encX24J600_registers_t a, uint16_t bitMask)
Sets the SFR bit field.
a |
register |
bitMask |
None. |
ENCx24_PhyRead()
uint16_t ENCx24_PhyRead (encX24J600_phy_registers_t a)
Reads the PHY register.
a |
register |
Two bytes of data. |
ENCx24_PHYWrite()
void ENCx24_PHYWrite (encX24J600_phy_registers_t a, uint16_t data)
Writes the PHY register.
a |
register |
data |
None. |
ENCx24_Read()
uint16_t ENCx24_Read (encX24J600_registers_t a)
Reads from Special Function Register (SFR).
a |
register |
Two bytes of SFR value. |
ENCx24_Write()
void ENCx24_Write (encX24J600_registers_t a, uint16_t data)
Writes to SFRs.
a |
register |
data |
None. |
ETH_CloseSPI()
static void ETH_CloseSPI (void )[static]
Releases the Serial Peripheral Interface (SPI) bus.
None. |
None. |
ETH_DMAComputeChecksum()
static uint16_t ETH_DMAComputeChecksum (uint16_t rxPtr, uint16_t len, uint16_t seed)[static]
Calculates the checksum.
rxPtr |
RX pointer |
len |
length |
seed |
Checksum. |
ETH_EdataRead()
uint8_t ETH_EdataRead (encX24J600_registers_t a)
Reads the 8-bit data from the ENCx24J600 register (work around for Errata).
a |
register |
One byte of data. |
ETH_MACRead8()
uint8_t ETH_MACRead8 (encX24J600_registers_t a)
Reads the 8-bit MAC-related data from ENCx24J600 registers.
a |
register |
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.
a |
register |
data |
None. |
ETH_NewPacket()
txPacket_t* ETH_NewPacket (void )
Allocates a new packet element and links it to the chained list.
None. |
Packet address. |
ETH_OpenSPI()
static void ETH_OpenSPI (void )[static]
Connects the SPI bus.
None. |
None. |
ETH_PacketListReset()
void ETH_PacketListReset (void )
Resets the Ethernet packet list.
None. |
None. |
ETH_readLinkStatus()
inline static uint32_t ETH_readLinkStatus (void )
Checks for the link status.
None. |
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.
*pPacket |
packetHandle |
None. |
ETH_SendQueued()
phy_error_msg ETH_SendQueued (void )
Enqueues the latest written packet and starts the transmission of a queued packet.
None. |
PHY_SUCCESS | |
PHY_BUFFER_BUSY |
ETH_Set_TXRTS()
void ETH_Set_TXRTS (void )
Packet transmission request.
None. |
None. |
ETH_SetPktDec()
void ETH_SetPktDec (void )
Decrements packet count.
None. |
None. |
ETH_SetRXptr()
void ETH_SetRXptr (uint16_t address)
RX packet read pointer.
address |
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.
None. |
PHY_SUCCESS | |
PHY_DMA_TIMEOUT |
waitForDMA()
inline static void waitForDMA (void )
Waits for the DMA.
None. |
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.
Data structures
union mac48Address_t
MAC Address (48-bits).
union mac64Address_t
MAC Address (64-bits).
Enumerations
enum phy_error_msg { PHY_ERROR = 0, PHY_SUCCESS, PHY_LINK_NOT_FOUND, PHY_BUFFER_BUSY, PHY_TX_LOGIC_NOT_IDLE, PHY_TX_QUEUED, PHY_DMA_TIMEOUT }
PHY status/errors.
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.
None. |
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.
len |
length |
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.
length |
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).
None. |
None. |
ETH_Flush()
void ETH_Flush (void )
Drops the rest of this packet and release the buffer. Clears all bytes from the RX buffer.
None. |
None. |
ETH_GetByteCount()
uint16_t ETH_GetByteCount (void )
Returns the the driver's byte count.
None. |
Byte count. |
ETH_GetFreeTxBufferSize()
uint16_t ETH_GetFreeTxBufferSize (void )
Returns the available space size in the Ethernet TX buffer.
None. |
Available space left in the TX buffer. |
ETH_GetMAC()
void ETH_GetMAC (uint8_t * macAddr)
Reads the MAC address.
*macAddr |
None. |
ETH_GetReadPtr()
uint16_t ETH_GetReadPtr (void )
Returns the value of the read pointer.
None. |
Pointer value. |
ETH_GetRxByteCount()
uint16_t ETH_GetRxByteCount (void )
Returns the receiver's byte count.
None. |
Byte count. |
ETH_GetStatusVectorByteCount()
uint16_t ETH_GetStatusVectorByteCount (void )
Returns the Status Vector's byte count.
None. |
Byte count. |
ETH_GetWritePtr()
uint16_t ETH_GetWritePtr (void )
Returns the value of the write pointer.
None. |
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.
None. |
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.
*data | |
len |
length |
offset |
None. |
ETH_MoveBackReadPtr()
void ETH_MoveBackReadPtr (uint16_t offset)
Moves back the read pointer.
offset |
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.
None. |
None. |
ETH_Read16()
uint16_t ETH_Read16 (void )
Reads two bytes of data from the RX buffer and returns them in host order.
None. |
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.
None. |
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.
None. |
Four bytes of data. |
ETH_Read8()
uint8_t ETH_Read8 (void )
Reads one byte of data from the RX buffer MAC.
None. |
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.
*buffer | |
length |
Read count. |
ETH_ReadSavedWRPT()
uint16_t ETH_ReadSavedWRPT (void )
Returns the saved write pointer.
None. |
Pointer value. |
ETH_ResetByteCount()
void ETH_ResetByteCount (void )
Resets the driver's byte count.
None. |
None. |
ETH_ResetReadPtr()
void ETH_ResetReadPtr (void )
Resets the receive pointer to the Init.
None. |
None. |
ETH_ResetReceiver()
void ETH_ResetReceiver (void )
Resets the receiver buffer.
None. |
None. |
ETH_RxComputeChecksum()
uint16_t ETH_RxComputeChecksum (uint16_t len, uint16_t seed)
Calculates the RX software checksum.
len |
length |
seed |
Checksum. |
ETH_SaveRDPT()
void ETH_SaveRDPT (void )
Saves the receive pointer for copy.
None. |
None. |
ETH_SaveWRPT()
void ETH_SaveWRPT (void )
Saves the write pointer for copy.
None. |
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.
None. |
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.
None. |
None. |
ETH_SetMAC()
void ETH_SetMAC (uint8_t * macAddr)
Sets the MAC address.
*macAddr |
None. |
ETH_SetReadPtr()
void ETH_SetReadPtr (uint16_t rdptr)
Sets the read pointer to a specific address.
rdptr |
Read pointer |
None. |
ETH_SetRxByteCount()
void ETH_SetRxByteCount (uint16_t count)
Sets the receiver's byte count.
count |
byte count |
None. |
ETH_SetStatusVectorByteCount()
void ETH_SetStatusVectorByteCount (uint16_t bc)
Sets the Status Vector's byte count.
bc |
Byte count |
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.
position | |
length | |
seed |
Checksum. |
ETH_TxReset()
void ETH_TxReset (void )
Resets the transmitter.
None. |
None. |
ETH_Write16()
void ETH_Write16 (uint16_t data)
Writes two bytes into the TX buffer MAC in Network order.
data |
None. |
ETH_Write24()
void ETH_Write24 (uint32_t data)
Writes three bytes into the TX buffer MAC in Network order.
data |
None. |
ETH_Write32()
void ETH_Write32 (uint32_t data)
Writes four bytes into the TX buffer MAC in Network order.
data |
None. |
ETH_Write8()
void ETH_Write8 (uint8_t data)
Writes one byte of data into the TX buffer MAC.
data |
None. |
ETH_WriteBlock()
uint16_t ETH_WriteBlock (const char * data, uint16_t length)
Writes a block of data into the TX buffer MAC.
*data | |
length |
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.
*dest_mac | |
type |
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.
*string |
None. |
MAC_getAddress()
const mac48Address_t* MAC_getAddress (void )
Returns the MAC address of type mac48Address_t.
None. |
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>
Public Attributes
2.4.3.1.2 Member Data Documentation
@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.1 Public Attributes
unsigned error: 1
unsigned pktReady: 1
unsigned up: 1
unsigned idle: 1
unsigned linkChange: 1
unsigned bufferBusy: 1
unsigned __pad0__: 3
uint16_t saveRDPT
uint16_t saveWRPT
2.4.3.2.2 Member Data Documentation
The documentation for this struct was generated from the following file:
source/
__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>
Public Attributes
2.4.3.3.2 Member Data Documentation
The documentation for this union was generated from the following file:
source/
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>
Public Attributes
2.4.3.4.2 Member Data Documentation
The documentation for this union was generated from the following file:
source/
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.1 Detailed Description
ENC28J60 PHSTAT2 register.
#include <enc28j60.h>
Public Attributes
2.4.3.5.2 Member Data Documentation
@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
uint8_t v [4]
struct {
uint16_t byteCount
unsigned long_drop_event: 1
unsigned __pad0__: 1
unsigned excessCarrierEvent: 1
unsigned __pad1__: 1
unsigned crcError: 1
unsigned lengthCheckError: 1
unsigned lengthLongError: 1
unsigned rxOK: 1
unsigned rxMulticast: 1
unsigned rxBroadcast: 1
unsigned dribbleNibble: 1
unsigned controlFrame: 1
unsigned pauseControlFrame: 1
unsigned unknownContrlFrame: 1
unsigned vlanTagPresent: 1
unsigned zero: 1
};
struct {
uint16_t byteCount
unsigned PreviouslyIgnored: 1
unsigned RXDCPreviouslySeen: 1
unsigned CarrierPreviouslySeen: 1
unsigned CodeViolation: 1
unsigned CRCError: 1
unsigned LengthCheckError: 1
unsigned LengthOutOfRange: 1
unsigned ReceiveOk: 1
unsigned Multicast: 1
unsigned Broadcast: 1
unsigned DribbleNibble: 1
unsigned ControlFrame: 1
unsigned PauseControlFrame: 1
unsigned UnsupportedOpcode: 1
unsigned VLANType: 1
unsigned RuntMatch: 1
unsigned filler: 1
unsigned HashMatch: 1
unsigned MagicPacketMatch: 1
unsigned PatternMatch: 1
unsigned UnicastMatch: 1
unsigned BroadcastMatch: 1
unsigned MulticastMatch: 1
unsigned ZeroH: 1
unsigned char Zero: 8
};
2.4.3.6.2 Member Data Documentation
The documentation for this union was generated from the following files:
source/
source/
@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.1 Public Attributes
uint16_t flags
uint16_t packetStart
uint16_t packetEnd
void * prevPacket
void * nextPacket
2.4.3.7.2 Member Data Documentation
The documentation for this struct was generated from the following file:
source/
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
const mac48Address_t * MAC_getAddress (void)
Returns the MAC address of type mac48Address_t.
phy_error_msg ETH_SendQueued (void)
Enqueues the latest written packet and starts the transmission of a queued packet.
phy_error_msg ETH_Shift_Tx_Packets (void)
Copies the queued packets to the TX Buffer start address using the DMA setup.
void ETH_PacketListReset (void)
Resets the Ethernet packet list.
txPacket_t * ETH_NewPacket (void)
Allocates a new packet element and links it to the chained list.
void ETH_RemovePacket (txPacket_t *pPacket)
Deallocates a packet element and unlinks it from the chained list.
static uint16_t ETH_ComputeChecksum (uint16_t len, uint16_t seed)
Calculates the checksum.
static uint8_t ENC28_Rcr8 (enc28j60_registers_t a)
Reads one byte from Special Function Register (SFR).
static uint16_t ENC28_Rcr16 (enc28j60_registers_t a)
Reads two bytes from SFRs.
static void ENC28_Wcr8 (enc28j60_registers_t a, uint8_t v)
Writes one byte to SFRs.
static void ENC28_Wcr16 (enc28j60_registers_t a, uint16_t v)
Writes two bytes to SFRs.
static void ENC28_Bfs (enc28j60_registers_t a, char bits)
Sets the SFR bit field.
static void ENC28_Bfc (enc28j60_registers_t a, char bits)
Clears the SFR bit field.
static uint16_t ENC28_PhyRead (enc28j60_phy_registers_t a)
Reads the Physical Layer (PHY) register.
static void ENC28_PhyWrite (enc28j60_phy_registers_t a, uint16_t d)
Writes the PHY register.
static void ENC28_BankSel (enc28j60_registers_t r)
Selects the bank.
static void ETH_CloseSPI (void)
Releases the Serial Peripheral Interface (SPI) bus.
static void ETH_OpenSPI (void)
Connects the SPI bus.
bool ETH_CheckLinkUp (void)
Checks for the link.
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.
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.
uint16_t ETH_ReadBlock (void *buffer, uint16_t length)
Reads a block of data from the RX 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.
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.
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.
phy_error_msg ETH_Send (void)
Sends the TX packet. Starts the transmission of packet or queues the packet that has been created.
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.
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.
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.
void ETH_SaveRDPT (void)
Saves the receive pointer for copy.
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.
void ETH_MoveBackReadPtr (uint16_t offset)
Moves back the read pointer.
void ETH_ResetReadPtr (void)
Resets the receive pointer to the Init.
uint16_t ETH_GetWritePtr (void)
Returns the value of the write pointer.
uint16_t ETH_GetRxByteCount (void)
Returns the receiver's byte count.
void ETH_SetRxByteCount (uint16_t count)
Sets the receiver'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.
void ETH_SaveWRPT (void)
Saves the write pointer for copy.
uint16_t ETH_ReadSavedWRPT (void)
Returns the saved write pointer.
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_TxReset (void)
Resets the transmitter.
2.4.4.1.2 Macros
#define MAC_ADDRESS {0x02, 0x00, 0x00, 0x00, 0x00, 0x01}
#define BROADCAST_MAC {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
#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.
#define RAMSIZE_ETH (0x1FFF)
#define MAX_TX_PACKET_SIZE (1518)
#define MIN_TX_PACKET_SIZE (64)
#define MAX_TX_PACKETS (20)
#define TX_STATUS_VECTOR_SIZE (7)
#define MIN_TX_PACKET (MIN_TX_PACKET_SIZE + TX_STATUS_VECTOR_SIZE)
#define TX_BUFFER_SIZE ((MAX_TX_PACKET_SIZE + TX_STATUS_VECTOR_SIZE) << 1)
#define TXSTART (RAMSIZE_ETH - TX_BUFFER_SIZE)
#define TXEND (RAMSIZE_ETH)
#define RXSTART (0)
#define TX_BUFFER_MID ((TXSTART) + ((TX_BUFFER_SIZE) >> 1))
#define SetBit(bitField, bitMask) do{ bitField = bitField | bitMask; } while(0)
#define ClearBit(bitField, bitMask) do{ bitField = bitField & (~bitMask); } while(0)
#define CheckBit(bitField, bitMask) (bool)(bitField & bitMask)
2.4.4.1.3 Variables
volatile ethernetDriver_t ethData
const mac48Address_t broadcastMAC = {BROADCAST_MAC}
const mac48Address_t * eth_MAC
static uint16_t nextPacketPointer
uint8_t ethListSize
static txPacket_t txData [MAX_TX_PACKETS]
static txPacket_t * pHead
static txPacket_t * pTail
uint16_t TXPacketSize
2.4.4.1.4 Detailed Description
This file provides the Ethernet driver API implementation for the ENC28J60 device.
ENC28J60 Ethernet Driver Source File
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.1 Data structures
union eir_t
ENC28J60 EIR register.
union phstat2_t
ENC28J60 PHSTAT2 register.
union receiveStatusVector_t
ENC28J60 receive status vector.
2.4.4.2.2 Macros
#define SFR_BANK0 0x00
#define SFR_BANK1 0x40
#define SFR_BANK2 0x80
#define SFR_BANK3 0xC0
#define SFR_COMMON 0xE0
#define BANK_MASK 0xE0
#define SFR_MASK 0x1F
#define byteSwap16(a) ((((uint16_t)a & (uint16_t)0xFF00) >> 8) | (((uint16_t)a & (uint16_t)0x00FF) << 8))
#define byteReverse32(a)
#define byteReverse24(a) (((((uint32_t)a & (uint32_t)0x00FF00) >> 8) | (((uint32_t)a & (uint32_t)0x0000FF) << 8)) << 8 | (uint32_t)a >> 0x10)
#define htons(a) byteSwap16(a)
#define ntohs(a) byteSwap16(a)
#define htonl(a) byteReverse32(a)
#define ntohl(a) byteReverse32(a)
#define convert_hton24(a) byteReverse24(a)
2.4.4.2.3 Enumerations
enum spi_inst_t { rcr_inst = 0x00, rbm_inst = 0x3A, wcr_inst = 0x40, wbm_inst = 0x7A, bfs_inst = 0x80, bfc_inst = 0xa0, src_inst = 0xFF }
SPI instructions.
enum sfr_bank_t { sfr_bank0 = SFR_BANK0, sfr_bank1 = SFR_BANK1, sfr_bank2 = SFR_BANK2, sfr_bank3 = SFR_BANK3, sfr_common = SFR_COMMON, sfr_bank0 = SFR_BANK0, sfr_bank1 = SFR_BANK1, sfr_bank2 = SFR_BANK2, sfr_bank3 = SFR_BANK3, sfr_common = SFR_COMMON }
SFR banks.
enum enc28j60_registers_t { J60_ERDPTL = (SFR_BANK0 | 0x00), J60_ERDPTH = (SFR_BANK0 | 0x01), J60_EWRPTL = (SFR_BANK0 | 0x02), J60_EWRPTH = (SFR_BANK0 | 0x03), J60_ETXSTL = (SFR_BANK0 | 0x04), J60_ETXSTH = (SFR_BANK0 | 0x05), J60_ETXNDL = (SFR_BANK0 | 0x06), J60_ETXNDH = (SFR_BANK0 | 0x07), J60_ERXSTL = (SFR_BANK0 | 0x08), J60_ERXSTH = (SFR_BANK0 | 0x09), J60_ERXNDL = (SFR_BANK0 | 0x0A), J60_ERXNDH = (SFR_BANK0 | 0x0B), J60_ERXRDPTL = (SFR_BANK0 | 0x0C), J60_ERXRDPTH = (SFR_BANK0 | 0x0D), J60_ERXWRPTL = (SFR_BANK0 | 0x0E), J60_ERXWRPTH = (SFR_BANK0 | 0x0F), J60_EDMASTL = (SFR_BANK0 | 0x10), J60_EDMASTH = (SFR_BANK0 | 0x11), J60_EDMANDL = (SFR_BANK0 | 0x12), J60_EDMANDH = (SFR_BANK0 | 0x13), J60_EDMADSTL = (SFR_BANK0 | 0x14), J60_EDMADSTH = (SFR_BANK0 | 0x15), J60_EDMACSL = (SFR_BANK0 | 0x16), J60_EDMACSH = (SFR_BANK0 | 0x17), RSRV_018 = (SFR_BANK0 | 0x18), RSRV_019 = (SFR_BANK0 | 0x19), RSRV_01A = (SFR_BANK0 | 0x1A), J60_EHT0 = (SFR_BANK1 | 0x00), J60_EHT1 = (SFR_BANK1 | 0x01), J60_EHT2 = (SFR_BANK1 | 0x02), J60_EHT3 = (SFR_BANK1 | 0x03), J60_EHT4 = (SFR_BANK1 | 0x04), J60_EHT5 = (SFR_BANK1 | 0x05), J60_EHT6 = (SFR_BANK1 | 0x06), J60_EHT7 = (SFR_BANK1 | 0x07), J60_EPMM0 = (SFR_BANK1 | 0x08), J60_EPMM1 = (SFR_BANK1 | 0x09), J60_EPMM2 = (SFR_BANK1 | 0x0A), J60_EPMM3 = (SFR_BANK1 | 0x0B), J60_EPMM4 = (SFR_BANK1 | 0x0C), J60_EPMM5 = (SFR_BANK1 | 0x0D), J60_EPMM6 = (SFR_BANK1 | 0x0E), J60_EPMM7 = (SFR_BANK1 | 0x0F), J60_EPMCSL = (SFR_BANK1 | 0x10), J60_EPMCSH = (SFR_BANK1 | 0x11), RSRV_112 = (SFR_BANK1 | 0x12), RSRV_113 = (SFR_BANK1 | 0x13), J60_EPMOL = (SFR_BANK1 | 0x14), J60_EPMOH = (SFR_BANK1 | 0x15), RSRV_116 = (SFR_BANK1 | 0x16), RSRV_117 = (SFR_BANK1 | 0x17), J60_ERXFCON = (SFR_BANK1 | 0x18), J60_EPKTCNT = (SFR_BANK1 | 0x19), RSRV_11A = (SFR_BANK1 | 0x1A), J60_MACON1 = (SFR_BANK2 | 0x00), RSRV_201 = (SFR_BANK2 | 0x01), J60_MACON3 = (SFR_BANK2 | 0x02), J60_MACON4 = (SFR_BANK2 | 0x03), J60_MABBIPG = (SFR_BANK2 | 0x04), RSRV_205 = (SFR_BANK2 | 0x05), J60_MAIPGL = (SFR_BANK2 | 0x06), J60_MAIPGH = (SFR_BANK2 | 0x07), J60_MACLCON1 = (SFR_BANK2 | 0x08), J60_MACLCON2 = (SFR_BANK2 | 0x09), J60_MAMXFLL = (SFR_BANK2 | 0x0A), J60_MAMXFLH = (SFR_BANK2 | 0x0B), RSRV_20C = (SFR_BANK2 | 0x0C), RSRV_20D = (SFR_BANK2 | 0x0D), RSRV_20E = (SFR_BANK2 | 0x0E), RSRV_20F = (SFR_BANK2 | 0x0F), RSRV_210 = (SFR_BANK2 | 0x10), RSRV_211 = (SFR_BANK2 | 0x11), J60_MICMD = (SFR_BANK2 | 0x12), RSRV_213 = (SFR_BANK2 | 0x13), J60_MIREGADR = (SFR_BANK2 | 0x14), RSRV_215 = (SFR_BANK2 | 0x15), J60_MIWRL = (SFR_BANK2 | 0x16), J60_MIWRH = (SFR_BANK2 | 0x17), J60_MIRDL = (SFR_BANK2 | 0x18), J60_MIRDH = (SFR_BANK2 | 0x19), RSRV_21A = (SFR_BANK2 | 0x1A), J60_MAADR5 = (SFR_BANK3 | 0x00), J60_MAADR6 = (SFR_BANK3 | 0x01), J60_MAADR3 = (SFR_BANK3 | 0x02), J60_MAADR4 = (SFR_BANK3 | 0x03), J60_MAADR1 = (SFR_BANK3 | 0x04), J60_MAADR2 = (SFR_BANK3 | 0x05), J60_EBSTSD = (SFR_BANK3 | 0x06), J60_EBSTCON = (SFR_BANK3 | 0x07), J60_EBSTCSL = (SFR_BANK3 | 0x08), J60_EBSTCSH = (SFR_BANK3 | 0x09), J60_MISTAT = (SFR_BANK3 | 0x0A), RSRV_30B = (SFR_BANK3 | 0x0B), RSRV_30C = (SFR_BANK3 | 0x0C), RSRV_30D = (SFR_BANK3 | 0x0D), RSRV_30E = (SFR_BANK3 | 0x0E), RSRV_30F = (SFR_BANK3 | 0x0F), RSRV_310 = (SFR_BANK3 | 0x10), RSRV_311 = (SFR_BANK3 | 0x11), J60_EREVID = (SFR_BANK3 | 0x12), RSRV_313 = (SFR_BANK3 | 0x13), RSRV_314 = (SFR_BANK3 | 0x14), J60_ECOCON = (SFR_BANK3 | 0x15), RSRV_316 = (SFR_BANK3 | 0x16), J60_EFLOCON = (SFR_BANK3 | 0x17), J60_EPAUSL = (SFR_BANK3 | 0x18), J60_EPAUSH = (SFR_BANK3 | 0x19), RSRV_31A = (SFR_BANK3 | 0x1A), J60_EIE = (SFR_COMMON | 0x1B), J60_EIR = (SFR_COMMON | 0x1C), J60_ESTAT = (SFR_COMMON | 0x1D), J60_ECON2 = (SFR_COMMON | 0x1E), J60_ECON1 = (SFR_COMMON | 0x1F) }
ENC28J60 registers.
enum enc28j60_phy_registers_t { J60_PHCON1 = 0x00, J60_PHSTAT1 = 0x01, J60_PHID1 = 0x02, J60_PHID2 = 0x03, J60_PHCON2 = 0x10, J60_PHSTAT2 = 0x11, J60_PHIE = 0x12, J60_PHIR = 0x13, J60_PHLCON = 0x14 }
ENC28J60 PHY register addresses.
2.4.4.2.4 Variables
uint8_t Control_Byte
ENC28J60 Control Byte.
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
phy_error_msg ETH_SendQueued (void)
Enqueues the latest written packet and starts the transmission of a queued packet.
phy_error_msg ETH_Shift_Tx_Packets (void)
Copies all the queued packets to the TX Buffer start address using the DMA setup.
void ETH_PacketListReset (void)
Resets the Ethernet packet list.
txPacket_t * ETH_NewPacket (void)
Allocates a new packet element and links it to the chained list.
void ETH_RemovePacket (txPacket_t *pPacket)
Deallocates a packet element and unlinks it from the chained list.
static uint16_t ETH_DMAComputeChecksum (uint16_t rxPtr, uint16_t len, uint16_t seed)
Calculates the checksum.
static void ETH_CloseSPI (void)
Releases the Serial Peripheral Interface (SPI) bus.
static void ETH_OpenSPI (void)
Connects the SPI bus.
static void waitForDMA (void)
Waits for the DMA.
static uint32_t ETH_readLinkStatus (void)
Checks for the link status.
const mac48Address_t * MAC_getAddress (void)
Returns the MAC address of type mac48Address_t.
void ETH_SendSystemReset (void)
Resets the system software.
void ETH_Init (void)
Sets up the Ethernet and starts the execution. Initializes the TX/RX buffer, the MAC and the PHY.
bool ETH_CheckLinkUp (void)
Checks for the link.
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_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.
phy_error_msg ETH_WriteStart (const mac48Address_t *dest_mac, uint16_t type)
Starts a packet if the Ethernet transmitter is idle.
phy_error_msg ETH_Send (void)
Sends the TX packet. Starts the transmission of packet or queues the packet that has been created.
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.
void ETH_GetMAC (uint8_t *macAddr)
Reads the MAC address.
void ETH_SetMAC (uint8_t *macAddr)
Sets the MAC address.
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_SaveRDPT (void)
Saves the receive pointer for copy.
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_GetReadPtr (void)
Returns the value of the read pointer.
void ETH_SetReadPtr (uint16_t rdptr)
Sets the read pointer to a specific address.
void ETH_MoveBackReadPtr (uint16_t offset)
Moves back the read pointer.
void ETH_ResetReadPtr (void)
Resets the receive pointer to the Init.
uint16_t ETH_GetWritePtr (void)
Returns the value of the write pointer.
uint16_t ETH_GetRxByteCount (void)
Returns the receiver's byte count.
void ETH_SetRxByteCount (uint16_t count)
Sets the receiver's byte count.
void ETH_SaveWRPT (void)
Saves the write pointer for copy.
uint16_t ETH_ReadSavedWRPT (void)
Returns the saved write pointer.
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_TxReset (void)
Resets the transmitter.
2.4.4.3.2 Macros
#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 MAX_TX_PACKET_SIZE (1518)
#define MIN_TX_PACKET_SIZE (64)
#define MAX_TX_PACKETS (20)
#define MIN_TX_PACKET (MIN_TX_PACKET_SIZE)
#define TX_BUFFER_SIZE (TXEND - TXSTART)
#define TX_BUFFER_MID ((TXSTART + TXEND) >> 1)
#define SetBit(bitField, bitMask) do{bitField = bitField | bitMask; } while(0)
#define ClearBit(bitField, bitMask) do{bitField = bitField & (~bitMask); } while(0)
#define CheckBit(bitField, bitMask) (bool)(bitField & bitMask)
#define MAC_ADDRESS {0x02, 0x00, 0x00, 0x00, 0x00, 0x01}
#define BROADCAST_MAC {0xff,0xff,0xff,0xff,0xff,0xff}
2.4.4.3.3 Variables
const mac48Address_t broadcastMAC = {BROADCAST_MAC}
volatile ethernetDriver_t ethData
uint8_t ethListSize
static txPacket_t txData [MAX_TX_PACKETS]
static txPacket_t * pHead
static txPacket_t * pTail
static uint16_t nextPacketPointer
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
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
static void ENCx24_BankselSPI (encX24J600_registers_t a)
Selects the SPI bank.
uint16_t ENCx24_Read (encX24J600_registers_t a)
Reads from Special Function Register (SFR).
void ENCx24_Write (encX24J600_registers_t a, uint16_t data)
Writes to SFRs.
void ENCx24_BFS (encX24J600_registers_t a, uint16_t bitMask)
Sets the SFR bit field.
void ENCx24_BFC (encX24J600_registers_t a, uint16_t bitMask)
Clears the SFR bit field.
uint16_t ENCx24_PhyRead (encX24J600_phy_registers_t a)
Reads the PHY register.
void ENCx24_PHYWrite (encX24J600_phy_registers_t a, uint16_t data)
Writes the PHY register.
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_Read32 (void)
Reads four bytes of data from the RX buffer and returns them in host order.
uint16_t ETH_ReadBlock (void *buffer, uint16_t length)
Reads a block of data from the RX 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.
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_Insert (char *data, uint16_t len, uint16_t offset)
Inserts N data bytes into a specific offset in the TX buffer/packet.
void ETH_Set_TXRTS (void)
Packet transmission request.
void ETH_SetPktDec (void)
Decrements packet count.
void ETH_SetRXptr (uint16_t address)
RX packet read pointer.
uint8_t ETH_EdataRead (encX24J600_registers_t a)
Reads the 8-bit data from the ENCx24J600 register (work around for Errata).
void ETH_MACWrite8 (encX24J600_registers_t a, uint8_t data)
Writes the 8-bit MAC-related data to ENCx24J600 registers.
uint8_t ETH_MACRead8 (encX24J600_registers_t a)
Reads the 8-bit MAC-related data from ENCx24J600 registers.
2.4.4.4.2 Variables
uint16_t TXPacketSize
receiveStatusVector_t rxPacketStatusVector = {{0, 0, 0, 0, 0, 0}}
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
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.1 Data structures
union receiveStatusVector_t
ENC28J60 receive status vector.
2.4.4.5.2 Functions
uint16_t ENCx24_Read (encX24J600_registers_t a)
Reads from Special Function Register (SFR).
uint8_t ETH_EdataRead (encX24J600_registers_t a)
Reads the 8-bit data from the ENCx24J600 register (work around for Errata).
void ENCx24_Write (encX24J600_registers_t a, uint16_t data)
Writes to SFRs.
void ENCx24_BFS (encX24J600_registers_t a, uint16_t bitMask)
Sets the SFR bit field.
void ENCx24_BFC (encX24J600_registers_t a, uint16_t bitMask)
Clears the SFR bit field.
uint16_t ENCx24_PhyRead (encX24J600_phy_registers_t a)
Reads the PHY register.
void ENCx24_PHYWrite (encX24J600_phy_registers_t a, uint16_t data)
Writes the PHY register.
uint8_t ETH_MACRead8 (encX24J600_registers_t a)
Reads the 8-bit MAC-related data from ENCx24J600 registers.
void ETH_MACWrite8 (encX24J600_registers_t a, uint8_t data)
Writes the 8-bit MAC-related data to ENCx24J600 registers.
void ETH_SetPktDec (void)
Decrements packet count.
void ETH_SetRXptr (uint16_t address)
RX packet read pointer.
void ETH_Set_TXRTS (void)
Packet transmission request.
2.4.4.5.3 Macros
#define byteSwap16(a) ((((uint16_t)a & (uint16_t)0xFF00) >> 8) | (((uint16_t)a & (uint16_t)0x00FF) << 8))
#define byteReverse32(a)
#define byteReverse24(a) (((((uint32_t)a & (uint32_t)0x00FF00) >> 8) | (((uint32_t)a & (uint32_t)0x0000FF) << 8)) << 8 | (uint32_t)a >> 0x10)
#define htons(a) byteSwap16(a)
#define ntohs(a) byteSwap16(a)
#define htonl(a) byteReverse32(a)
#define ntohl(a) byteReverse32(a)
#define convert_hton24(a) byteReverse24(a)
#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 SFR_BANK0 0x00
#define SFR_BANK1 0x20
#define SFR_BANK2 0x40
#define SFR_BANK3 0x60
#define UNBANKED 0X80
#define SFR_COMMON 0xE0
#define BANK_MASK 0xE0
#define SFR_MASK 0x1F
2.4.4.5.4 Enumerations
enum sfr_bank_t { sfr_bank0 = SFR_BANK0, sfr_bank1 = SFR_BANK1, sfr_bank2 = SFR_BANK2, sfr_bank3 = SFR_BANK3, sfr_common = SFR_COMMON, sfr_bank0 = SFR_BANK0, sfr_bank1 = SFR_BANK1, sfr_bank2 = SFR_BANK2, sfr_bank3 = SFR_BANK3, sfr_common = SFR_COMMON }
enum encX24J600_registers_t { XJ600_ETXSTL = (SFR_BANK0 | 0x00), XJ600_ETXLENL = (SFR_BANK0 | 0x02), XJ600_ERXSTL = (SFR_BANK0 | 0x04), XJ600_ERXTAILL = (SFR_BANK0 | 0x06), XJ600_ERXHEADL = (SFR_BANK0 | 0x08), XJ600_EDMASTL = (SFR_BANK0 | 0x0A), XJ600_EDMALENL = (SFR_BANK0 | 0x0C), XJ600_EDMADSTL = (SFR_BANK0 | 0x0E), XJ600_EDMACSL = (SFR_BANK0 | 0x10), XJ600_ETXSTATL = (SFR_BANK0 | 0x12), XJ600_ETXWIREL = (SFR_BANK0 | 0x14), XJ600_EHT1L = (SFR_BANK1 | 0x00), XJ600_EHT2L = (SFR_BANK1 | 0x02), XJ600_EHT3L = (SFR_BANK1 | 0x04), XJ600_EHT4L = (SFR_BANK1 | 0x06), XJ600_EPMM1L = (SFR_BANK1 | 0x08), XJ600_EPMM2L = (SFR_BANK1 | 0x0A), XJ600_EPMM3L = (SFR_BANK1 | 0x0C), XJ600_EPMM4L = (SFR_BANK1 | 0x0E), XJ600_EPMCSL = (SFR_BANK1 | 0x10), XJ600_EPMOL = (SFR_BANK1 | 0x12), XJ600_ERXFCONL = (SFR_BANK1 | 0x14), XJ600_MACON1L = (SFR_BANK2 | 0x00), XJ600_MACON2L = (SFR_BANK2 | 0x02), XJ600_MABBIPGL = (SFR_BANK2 | 0x04), XJ600_MAIPGL = (SFR_BANK2 | 0x06), XJ600_MACLCONL = (SFR_BANK2 | 0x08), XJ600_MAMXFLL = (SFR_BANK2 | 0x0A), XJ600_MICMDL = (SFR_BANK2 | 0x12), XJ600_MIREGADRL = (SFR_BANK2 | 0x14), XJ600_MAADR3L = (SFR_BANK3 | 0x00), XJ600_MAADR3H = (SFR_BANK3 | 0x01), XJ600_MAADR2L = (SFR_BANK3 | 0x02), XJ600_MAADR2H = (SFR_BANK3 | 0x03), XJ600_MAADR1L = (SFR_BANK3 | 0x04), XJ600_MAADR1H = (SFR_BANK3 | 0x05), XJ600_MIWRL = (SFR_BANK3 | 0x06), XJ600_MIRDL = (SFR_BANK3 | 0x08), XJ600_MISTATL = (SFR_BANK3 | 0x0A), XJ600_EPAUSL = (SFR_BANK3 | 0x0C), XJ600_ECON2L = (SFR_BANK3 | 0x0E), XJ600_ERXWML = (SFR_BANK3 | 0x10), XJ600_EIEL = (SFR_BANK3 | 0x12), XJ600_EIDLEDL = (SFR_BANK3 | 0x14), XJ600_EGPDATAL = (UNBANKED | 0x00), XJ600_ERXDATAL = (UNBANKED | 0x02), XJ600_EUDADATAL = (UNBANKED | 0x04), XJ600_EGPRDPTL = (UNBANKED | 0x06), XJ600_EGPWRPTL = (UNBANKED | 0x08), XJ600_ERXRDPTL = (UNBANKED | 0x0A), XJ600_ERXWRPTL = (UNBANKED | 0x0C), XJ600_EUDARDPTL = (UNBANKED | 0x0E), XJ600_EUDAWRPTL = (UNBANKED | 0x10), XJ600_EUDASTL = (SFR_COMMON | 0x16), XJ600_EUDANDL = (SFR_COMMON | 0x18), XJ600_ESTATL = (SFR_COMMON | 0x1A), XJ600_EIRL = (SFR_COMMON | 0x1C), XJ600_ECON1L = (SFR_COMMON | 0x1E) }
SFR addresses for the ENCx24J600 SPI mode.
enum encX24J600_1_byte_instructions_t { b0sel_inst = 0b11000000, b1sel_inst = 0b11000010, b2sel_inst = 0b11000100, b3sel_inst = 0b11000110, setethrst_inst = 0b11001010, fcdisable_inst = 0b11100000, fcsingle_inst = 0b11100010, fcmultiple_inst = 0b11100100, fcclear_inst = 0b11100110, setpktdec_inst = 0b11001100, dmastop_inst = 0b11010010, dmacksum_inst = 0b11011000, dmacksums_inst = 0b11011010, dmacopy_inst = 0b11011100, dmacopys_inst = 0b11011110, settxrts_inst = 0b11010100, enablerx_inst = 0b11101000, disablerx_inst = 0b11101010, seteie_inst = 0b11101100, clreie_inst = 0b11101110 }
SPI single byte instructions.
enum encX24J600_2_byte_instructions_t { rbsel_inst = 0b11001000 }
SPI two byte instructions.
enum encX24J600_3_byte_instructions_t { rgprdpt_inst = 0b01100010, rrxrdpt_inst = 0b01100110, rgpwrpt_inst = 0b01101110, rrxwrpt_inst = 0b01110010, rudawrpt_inst = 0b01110110, wgprdpt_inst = 0b01100000, wrxrdpt_inst = 0b01100100, wgpwrpt_inst = 0b01101100, wrxwrpt_inst = 0b01110000, wudawrpt_inst = 0b01110100 }
SPI three byte instructions.
enum encX24J600_N_byte_instructions_t { rcr_inst = 0b00000000, wcr_inst = 0b01000000, bfs_inst = 0b10000000, bfc_inst = 0b10100000, rcru_inst = 0b00100000, wcru_inst = 0b00100010, bfsu_inst = 0b00100100, bfcu_inst = 0b00100110, rgpdata_inst = 0b00101000, rrxdata_inst = 0b00101100, rudadata_inst = 0b00110000, wgpdata_inst = 0b00101010, wrxdata_inst = 0b00101110, wudadata_inst = 0b00110010 }
SPI N byte instructions.
2.4.4.5.5 Variables
2.4.4.5.6 Detailed Description
This header file provides the serial interface API for the ENCx24J600 devices.
ENCx24J600 spi Header File
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
#define RAMSIZE_ETH 0x6000ul
#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 ETH_HEADER_SIZE 14
#define IP_PROTOCOL_POS 23
#define ESTAT_PHYLINK 0x0100
#define ESTAT_RSTDONE 0x0800
#define ESTAT_PHYDPX 0x0400
#define ESTAT_PHYRDY 0x0200
#define ESTAT_PKTCNT 0x00FF
#define ESTAT_RXBUSY 0x2000
#define ESTAT_CLKRDY 0x1000
#define MACON2_FULDPX_ON 0x0001
#define MACON2_FULDPX_OFF 0xFFFE
#define EIR_CRYPTEN 0x8000
#define EIR_LINKIF 0x0800
#define EIR_TXIF 0x0008
#define EIR_PKTIF 0x0040
#define EIR_RXABTIF 0x0002
#define EIR_PCFULIF 0x0001
#define ECON1_RXEN 0x0001
#define ECON1_TXRTS 0x0002
#define ECON1_DMANOCS 0x0004
#define ECON1_DMACSSD 0x0008
#define ECON1_DMACPY 0x0010
#define ECON1_DMAST 0x0020
#define ECON1_PKTDEC 0x0100
#define ECON1_AESST 0x0800
#define ECON1_HASHLST 0x1000
#define ECON1_HASHOP 0x2000
#define ECON1_HASHEN 0x4000
#define ECON1_MODEXST 0x8000
#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.
#define ECON2_ETHEN 0x8000
#define ECON2_AUTOFC 0x0080
#define ECON2_STRCH 0x4000
#define ECON2_ETHRST 0x0010
#define ECON2_RXRST 0x0020
2.4.4.6.2 Enumerations
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.1 Data structures
struct ethernetDriver_t
struct txPacket_t
union mac48Address_t
MAC Address (48-bits).
union mac64Address_t
MAC Address (64-bits).
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.3 Macros
#define ETH_packetReady() ethData.pktReady
#define ETH_linkCheck() ethData.up
#define ETH_linkChanged() ethData.linkChange
2.4.4.7.4 Enumerations
enum phy_error_msg { PHY_ERROR = 0, PHY_SUCCESS, PHY_LINK_NOT_FOUND, PHY_BUFFER_BUSY, PHY_TX_LOGIC_NOT_IDLE, PHY_TX_QUEUED, PHY_DMA_TIMEOUT }
PHY status/errors.
2.4.4.7.5 Variables
volatile ethernetDriver_t ethData
const mac48Address_t broadcastMAC
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