enc28j60_driver.c File Reference

ENC28J60 Ethernet controller. More...

#include "core/net.h"
#include "drivers/eth/enc28j60_driver.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   NIC_TRACE_LEVEL
 

Functions

error_t enc28j60Init (NetInterface *interface)
 ENC28J60 controller initialization. More...
 
__weak_func void enc28j60InitHook (NetInterface *interface)
 ENC28J60 custom configuration. More...
 
void enc28j60Tick (NetInterface *interface)
 ENC28J60 timer handler. More...
 
void enc28j60EnableIrq (NetInterface *interface)
 Enable interrupts. More...
 
void enc28j60DisableIrq (NetInterface *interface)
 Disable interrupts. More...
 
bool_t enc28j60IrqHandler (NetInterface *interface)
 ENC28J60 interrupt service routine. More...
 
void enc28j60EventHandler (NetInterface *interface)
 ENC28J60 event handler. More...
 
error_t enc28j60SendPacket (NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
 Send a packet. More...
 
error_t enc28j60ReceivePacket (NetInterface *interface)
 Receive a packet. More...
 
error_t enc28j60UpdateMacAddrFilter (NetInterface *interface)
 Configure MAC address filtering. More...
 
void enc28j60SoftReset (NetInterface *interface)
 ENC28J60 controller reset. More...
 
void enc28j60SelectBank (NetInterface *interface, uint16_t address)
 Bank selection. More...
 
void enc28j60WriteReg (NetInterface *interface, uint16_t address, uint8_t data)
 Write ENC28J60 register. More...
 
uint8_t enc28j60ReadReg (NetInterface *interface, uint16_t address)
 Read ENC28J60 register. More...
 
void enc28j60WritePhyReg (NetInterface *interface, uint16_t address, uint16_t data)
 Write PHY register. More...
 
uint16_t enc28j60ReadPhyReg (NetInterface *interface, uint16_t address)
 Read PHY register. More...
 
void enc28j60WriteBuffer (NetInterface *interface, const NetBuffer *buffer, size_t offset)
 Write SRAM buffer. More...
 
void enc28j60ReadBuffer (NetInterface *interface, uint8_t *data, size_t length)
 Read SRAM buffer. More...
 
void enc28j60SetBit (NetInterface *interface, uint16_t address, uint16_t mask)
 Set bit field. More...
 
void enc28j60ClearBit (NetInterface *interface, uint16_t address, uint16_t mask)
 Clear bit field. More...
 
uint32_t enc28j60CalcCrc (const void *data, size_t length)
 CRC calculation using the polynomial 0x4C11DB7. More...
 
void enc28j60DumpReg (NetInterface *interface)
 Dump registers for debugging purpose. More...
 
void enc28j60DumpPhyReg (NetInterface *interface)
 Dump PHY registers for debugging purpose. More...
 

Variables

const NicDriver enc28j60Driver
 ENC28J60 driver. More...
 

Detailed Description

ENC28J60 Ethernet controller.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file enc28j60_driver.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   NIC_TRACE_LEVEL

Definition at line 32 of file enc28j60_driver.c.

Function Documentation

◆ enc28j60CalcCrc()

uint32_t enc28j60CalcCrc ( const void *  data,
size_t  length 
)

CRC calculation using the polynomial 0x4C11DB7.

Parameters
[in]dataPointer to the data over which to calculate the CRC
[in]lengthNumber of bytes to process
Returns
Resulting CRC value

Definition at line 970 of file enc28j60_driver.c.

◆ enc28j60ClearBit()

void enc28j60ClearBit ( NetInterface interface,
uint16_t  address,
uint16_t  mask 
)

Clear bit field.

Parameters
[in]interfaceUnderlying network interface
[in]addressRegister address
[in]maskBits to clear in the target register

Definition at line 948 of file enc28j60_driver.c.

◆ enc28j60DisableIrq()

void enc28j60DisableIrq ( NetInterface interface)

Disable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 275 of file enc28j60_driver.c.

◆ enc28j60DumpPhyReg()

void enc28j60DumpPhyReg ( NetInterface interface)

Dump PHY registers for debugging purpose.

Parameters
[in]interfaceUnderlying network interface

Definition at line 1065 of file enc28j60_driver.c.

◆ enc28j60DumpReg()

void enc28j60DumpReg ( NetInterface interface)

Dump registers for debugging purpose.

Parameters
[in]interfaceUnderlying network interface

Definition at line 1010 of file enc28j60_driver.c.

◆ enc28j60EnableIrq()

void enc28j60EnableIrq ( NetInterface interface)

Enable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 260 of file enc28j60_driver.c.

◆ enc28j60EventHandler()

void enc28j60EventHandler ( NetInterface interface)

ENC28J60 event handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 354 of file enc28j60_driver.c.

◆ enc28j60Init()

error_t enc28j60Init ( NetInterface interface)

ENC28J60 controller initialization.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 71 of file enc28j60_driver.c.

◆ enc28j60InitHook()

__weak_func void enc28j60InitHook ( NetInterface interface)

ENC28J60 custom configuration.

Parameters
[in]interfaceUnderlying network interface

Definition at line 240 of file enc28j60_driver.c.

◆ enc28j60IrqHandler()

bool_t enc28j60IrqHandler ( NetInterface interface)

ENC28J60 interrupt service routine.

Parameters
[in]interfaceUnderlying network interface
Returns
TRUE if a higher priority task must be woken. Else FALSE is returned

Definition at line 291 of file enc28j60_driver.c.

◆ enc28j60ReadBuffer()

void enc28j60ReadBuffer ( NetInterface interface,
uint8_t *  data,
size_t  length 
)

Read SRAM buffer.

Parameters
[in]interfaceUnderlying network interface
[out]dataBuffer where to store the incoming data
[in]lengthNumber of data to read

Definition at line 897 of file enc28j60_driver.c.

◆ enc28j60ReadPhyReg()

uint16_t enc28j60ReadPhyReg ( NetInterface interface,
uint16_t  address 
)

Read PHY register.

Parameters
[in]interfaceUnderlying network interface
[in]addressPHY register address
Returns
Register value

Definition at line 808 of file enc28j60_driver.c.

◆ enc28j60ReadReg()

uint8_t enc28j60ReadReg ( NetInterface interface,
uint16_t  address 
)

Read ENC28J60 register.

Parameters
[in]interfaceUnderlying network interface
[in]addressRegister address
Returns
Register value

Definition at line 746 of file enc28j60_driver.c.

◆ enc28j60ReceivePacket()

error_t enc28j60ReceivePacket ( NetInterface interface)

Receive a packet.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 495 of file enc28j60_driver.c.

◆ enc28j60SelectBank()

void enc28j60SelectBank ( NetInterface interface,
uint16_t  address 
)

Bank selection.

Parameters
[in]interfaceUnderlying network interface
[in]addressRegister address

Definition at line 668 of file enc28j60_driver.c.

◆ enc28j60SendPacket()

error_t enc28j60SendPacket ( NetInterface interface,
const NetBuffer buffer,
size_t  offset,
NetTxAncillary ancillary 
)

Send a packet.

Parameters
[in]interfaceUnderlying network interface
[in]bufferMulti-part buffer containing the data to send
[in]offsetOffset to the first data byte
[in]ancillaryAdditional options passed to the stack along with the packet
Returns
Error code

Definition at line 431 of file enc28j60_driver.c.

◆ enc28j60SetBit()

void enc28j60SetBit ( NetInterface interface,
uint16_t  address,
uint16_t  mask 
)

Set bit field.

Parameters
[in]interfaceUnderlying network interface
[in]addressRegister address
[in]maskBits to set in the target register

Definition at line 926 of file enc28j60_driver.c.

◆ enc28j60SoftReset()

void enc28j60SoftReset ( NetInterface interface)

ENC28J60 controller reset.

Parameters
[in]interfaceUnderlying network interface

Definition at line 649 of file enc28j60_driver.c.

◆ enc28j60Tick()

void enc28j60Tick ( NetInterface interface)

ENC28J60 timer handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 250 of file enc28j60_driver.c.

◆ enc28j60UpdateMacAddrFilter()

error_t enc28j60UpdateMacAddrFilter ( NetInterface interface)

Configure MAC address filtering.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 586 of file enc28j60_driver.c.

◆ enc28j60WriteBuffer()

void enc28j60WriteBuffer ( NetInterface interface,
const NetBuffer buffer,
size_t  offset 
)

Write SRAM buffer.

Parameters
[in]interfaceUnderlying network interface
[in]bufferMulti-part buffer containing the data to be written
[in]offsetOffset to the first data byte

Definition at line 842 of file enc28j60_driver.c.

◆ enc28j60WritePhyReg()

void enc28j60WritePhyReg ( NetInterface interface,
uint16_t  address,
uint16_t  data 
)

Write PHY register.

Parameters
[in]interfaceUnderlying network interface
[in]addressPHY register address
[in]dataRegister value

Definition at line 783 of file enc28j60_driver.c.

◆ enc28j60WriteReg()

void enc28j60WriteReg ( NetInterface interface,
uint16_t  address,
uint8_t  data 
)

Write ENC28J60 register.

Parameters
[in]interfaceUnderlying network interface
[in]addressRegister address
[in]dataRegister value

Definition at line 721 of file enc28j60_driver.c.

Variable Documentation

◆ enc28j60Driver

const NicDriver enc28j60Driver
Initial value:
=
{
NULL,
NULL,
NULL,
}
void enc28j60DisableIrq(NetInterface *interface)
Disable interrupts.
error_t enc28j60SendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
void enc28j60EnableIrq(NetInterface *interface)
Enable interrupts.
void enc28j60Tick(NetInterface *interface)
ENC28J60 timer handler.
void enc28j60EventHandler(NetInterface *interface)
ENC28J60 event handler.
error_t enc28j60UpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
error_t enc28j60Init(NetInterface *interface)
ENC28J60 controller initialization.
#define ETH_MTU
Definition: ethernet.h:116
@ NIC_TYPE_ETHERNET
Ethernet interface.
Definition: nic.h:83
#define TRUE
Definition: os_port.h:50
#define FALSE
Definition: os_port.h:46

ENC28J60 driver.

Definition at line 44 of file enc28j60_driver.c.