ksz8851_driver.c File Reference

KSZ8851 Ethernet controller. More...

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

Go to the source code of this file.

Macros

#define TRACE_LEVEL   NIC_TRACE_LEVEL
 

Functions

error_t ksz8851Init (NetInterface *interface)
 KSZ8851 controller initialization. More...
 
__weak_func void ksz8851InitHook (NetInterface *interface)
 KSZ8851 custom configuration. More...
 
void ksz8851Tick (NetInterface *interface)
 KSZ8851 timer handler. More...
 
void ksz8851EnableIrq (NetInterface *interface)
 Enable interrupts. More...
 
void ksz8851DisableIrq (NetInterface *interface)
 Disable interrupts. More...
 
bool_t ksz8851IrqHandler (NetInterface *interface)
 KSZ8851 interrupt service routine. More...
 
void ksz8851EventHandler (NetInterface *interface)
 KSZ8851 event handler. More...
 
error_t ksz8851SendPacket (NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
 Send a packet. More...
 
error_t ksz8851ReceivePacket (NetInterface *interface)
 Receive a packet. More...
 
error_t ksz8851UpdateMacAddrFilter (NetInterface *interface)
 Configure MAC address filtering. More...
 
void ksz8851WriteReg (NetInterface *interface, uint8_t address, uint16_t data)
 Write KSZ8851 register. More...
 
uint16_t ksz8851ReadReg (NetInterface *interface, uint8_t address)
 Read KSZ8851 register. More...
 
void ksz8851WriteFifo (NetInterface *interface, const uint8_t *data, size_t length)
 Write TX FIFO. More...
 
void ksz8851ReadFifo (NetInterface *interface, uint8_t *data, size_t length)
 Read RX FIFO. More...
 
void ksz8851SetBit (NetInterface *interface, uint8_t address, uint16_t mask)
 Set bit field. More...
 
void ksz8851ClearBit (NetInterface *interface, uint8_t address, uint16_t mask)
 Clear bit field. More...
 
uint32_t ksz8851CalcCrc (const void *data, size_t length)
 CRC calculation. More...
 
void ksz8851DumpReg (NetInterface *interface)
 Dump registers for debugging purpose. More...
 

Variables

const NicDriver ksz8851Driver
 KSZ8851 driver. More...
 

Detailed Description

KSZ8851 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 ksz8851_driver.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   NIC_TRACE_LEVEL

Definition at line 32 of file ksz8851_driver.c.

Function Documentation

◆ ksz8851CalcCrc()

uint32_t ksz8851CalcCrc ( const void *  data,
size_t  length 
)

CRC calculation.

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 874 of file ksz8851_driver.c.

◆ ksz8851ClearBit()

void ksz8851ClearBit ( NetInterface interface,
uint8_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 856 of file ksz8851_driver.c.

◆ ksz8851DisableIrq()

void ksz8851DisableIrq ( NetInterface interface)

Disable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 218 of file ksz8851_driver.c.

◆ ksz8851DumpReg()

void ksz8851DumpReg ( NetInterface interface)

Dump registers for debugging purpose.

Parameters
[in]interfaceUnderlying network interface

Definition at line 914 of file ksz8851_driver.c.

◆ ksz8851EnableIrq()

void ksz8851EnableIrq ( NetInterface interface)

Enable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 203 of file ksz8851_driver.c.

◆ ksz8851EventHandler()

void ksz8851EventHandler ( NetInterface interface)

KSZ8851 event handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 306 of file ksz8851_driver.c.

◆ ksz8851Init()

error_t ksz8851Init ( NetInterface interface)

KSZ8851 controller initialization.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 71 of file ksz8851_driver.c.

◆ ksz8851InitHook()

__weak_func void ksz8851InitHook ( NetInterface interface)

KSZ8851 custom configuration.

Parameters
[in]interfaceUnderlying network interface

Definition at line 183 of file ksz8851_driver.c.

◆ ksz8851IrqHandler()

bool_t ksz8851IrqHandler ( NetInterface interface)

KSZ8851 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 234 of file ksz8851_driver.c.

◆ ksz8851ReadFifo()

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

Read RX FIFO.

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

Definition at line 766 of file ksz8851_driver.c.

◆ ksz8851ReadReg()

uint16_t ksz8851ReadReg ( NetInterface interface,
uint8_t  address 
)

Read KSZ8851 register.

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

Definition at line 658 of file ksz8851_driver.c.

◆ ksz8851ReceivePacket()

error_t ksz8851ReceivePacket ( NetInterface interface)

Receive a packet.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 468 of file ksz8851_driver.c.

◆ ksz8851SendPacket()

error_t ksz8851SendPacket ( 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 392 of file ksz8851_driver.c.

◆ ksz8851SetBit()

void ksz8851SetBit ( NetInterface interface,
uint8_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 838 of file ksz8851_driver.c.

◆ ksz8851Tick()

void ksz8851Tick ( NetInterface interface)

KSZ8851 timer handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 193 of file ksz8851_driver.c.

◆ ksz8851UpdateMacAddrFilter()

error_t ksz8851UpdateMacAddrFilter ( NetInterface interface)

Configure MAC address filtering.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 549 of file ksz8851_driver.c.

◆ ksz8851WriteFifo()

void ksz8851WriteFifo ( NetInterface interface,
const uint8_t *  data,
size_t  length 
)

Write TX FIFO.

Parameters
[in]interfaceUnderlying network interface
[in]dataPointer to the data being written
[in]lengthNumber of data to write

Definition at line 715 of file ksz8851_driver.c.

◆ ksz8851WriteReg()

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

Write KSZ8851 register.

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

Definition at line 606 of file ksz8851_driver.c.

Variable Documentation

◆ ksz8851Driver

const NicDriver ksz8851Driver
Initial value:
=
{
NULL,
NULL,
NULL,
}
#define ETH_MTU
Definition: ethernet.h:116
error_t ksz8851UpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
error_t ksz8851Init(NetInterface *interface)
KSZ8851 controller initialization.
void ksz8851Tick(NetInterface *interface)
KSZ8851 timer handler.
void ksz8851EnableIrq(NetInterface *interface)
Enable interrupts.
error_t ksz8851SendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
void ksz8851EventHandler(NetInterface *interface)
KSZ8851 event handler.
void ksz8851DisableIrq(NetInterface *interface)
Disable interrupts.
@ NIC_TYPE_ETHERNET
Ethernet interface.
Definition: nic.h:83
#define TRUE
Definition: os_port.h:50
#define FALSE
Definition: os_port.h:46

KSZ8851 driver.

Definition at line 44 of file ksz8851_driver.c.