enc28j60_driver.c File Reference

ENC28J60 Ethernet controller. More...

#include <limits.h>
#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...
 
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)
 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

Copyright (C) 2010-2018 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
1.9.0

Definition in file enc28j60_driver.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   NIC_TRACE_LEVEL

Definition at line 30 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 920 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 898 of file enc28j60_driver.c.

◆ enc28j60DisableIrq()

void enc28j60DisableIrq ( NetInterface interface)

Disable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 256 of file enc28j60_driver.c.

◆ enc28j60DumpPhyReg()

void enc28j60DumpPhyReg ( NetInterface interface)

Dump PHY registers for debugging purpose.

Parameters
[in]interfaceUnderlying network interface

Definition at line 1003 of file enc28j60_driver.c.

◆ enc28j60DumpReg()

void enc28j60DumpReg ( NetInterface interface)

Dump registers for debugging purpose.

Parameters
[in]interfaceUnderlying network interface

Definition at line 954 of file enc28j60_driver.c.

◆ enc28j60EnableIrq()

void enc28j60EnableIrq ( NetInterface interface)

Enable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 244 of file enc28j60_driver.c.

◆ enc28j60EventHandler()

void enc28j60EventHandler ( NetInterface interface)

ENC28J60 event handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 331 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 70 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 269 of file enc28j60_driver.c.

◆ enc28j60ReadBuffer()

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

Read SRAM buffer.

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

Definition at line 849 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 765 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 708 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 468 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 630 of file enc28j60_driver.c.

◆ enc28j60SendPacket()

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

Send a packet.

Parameters
[in]interfaceUnderlying network interface
[in]bufferMulti-part buffer containing the data to send
[in]offsetOffset to the first data byte
Returns
Error code

Definition at line 405 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 876 of file enc28j60_driver.c.

◆ enc28j60SoftReset()

void enc28j60SoftReset ( NetInterface interface)

ENC28J60 controller reset.

Parameters
[in]interfaceUnderlying network interface

Definition at line 611 of file enc28j60_driver.c.

◆ enc28j60Tick()

void enc28j60Tick ( NetInterface interface)

ENC28J60 timer handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 234 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 548 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 796 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 743 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 683 of file enc28j60_driver.c.

Variable Documentation

◆ enc28j60Driver

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

ENC28J60 driver.

Definition at line 43 of file enc28j60_driver.c.