lan9250_driver.c File Reference

LAN9250 Ethernet controller. More...

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

Go to the source code of this file.

Macros

#define TRACE_LEVEL   NIC_TRACE_LEVEL
 

Functions

error_t lan9250Init (NetInterface *interface)
 LAN9250 controller initialization. More...
 
__weak_func void lan9250InitHook (NetInterface *interface)
 LAN9250 custom configuration. More...
 
void lan9250Tick (NetInterface *interface)
 LAN9250 timer handler. More...
 
void lan9250EnableIrq (NetInterface *interface)
 Enable interrupts. More...
 
void lan9250DisableIrq (NetInterface *interface)
 Disable interrupts. More...
 
bool_t lan9250IrqHandler (NetInterface *interface)
 LAN9250 interrupt service routine. More...
 
void lan9250EventHandler (NetInterface *interface)
 LAN9250 event handler. More...
 
error_t lan9250SendPacket (NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
 Send a packet. More...
 
error_t lan9250ReceivePacket (NetInterface *interface)
 Receive a packet. More...
 
void lan9250DropPacket (NetInterface *interface, size_t length)
 Drop the received packet. More...
 
error_t lan9250UpdateMacAddrFilter (NetInterface *interface)
 Configure MAC address filtering. More...
 
void lan9250WriteSysReg (NetInterface *interface, uint16_t address, uint32_t data)
 Write system CSR register. More...
 
uint32_t lan9250ReadSysReg (NetInterface *interface, uint16_t address)
 Read system CSR register. More...
 
void lan9250DumpSysReg (NetInterface *interface)
 Dump system CSR registers for debugging purpose. More...
 
void lan9250WriteMacReg (NetInterface *interface, uint8_t address, uint32_t data)
 Write host MAC CSR register. More...
 
uint32_t lan9250ReadMacReg (NetInterface *interface, uint8_t address)
 Read host MAC CSR register. More...
 
void lan9250DumpMacReg (NetInterface *interface)
 Dump host MAC CSR registers for debugging purpose. More...
 
void lan9250WritePhyReg (NetInterface *interface, uint8_t address, uint16_t data)
 Write PHY register. More...
 
uint16_t lan9250ReadPhyReg (NetInterface *interface, uint8_t address)
 Read PHY register. More...
 
void lan9250DumpPhyReg (NetInterface *interface)
 Dump PHY registers for debugging purpose. More...
 
void lan9250WriteMmdReg (NetInterface *interface, uint8_t devAddr, uint16_t regAddr, uint16_t data)
 Write MMD register. More...
 
uint16_t lan9250ReadMmdReg (NetInterface *interface, uint8_t devAddr, uint16_t regAddr)
 Read MMD register. More...
 
void lan9250WriteFifo (NetInterface *interface, const uint8_t *data, size_t length)
 Write TX FIFO. More...
 
void lan9250ReadFifo (NetInterface *interface, uint8_t *data, size_t length)
 Read RX FIFO. More...
 
uint32_t lan9250CalcCrc (const void *data, size_t length)
 CRC calculation. More...
 

Variables

const NicDriver lan9250Driver
 LAN9250 driver. More...
 

Detailed Description

LAN9250 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.4

Definition in file lan9250_driver.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   NIC_TRACE_LEVEL

Definition at line 32 of file lan9250_driver.c.

Function Documentation

◆ lan9250CalcCrc()

uint32_t lan9250CalcCrc ( 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 1080 of file lan9250_driver.c.

◆ lan9250DisableIrq()

void lan9250DisableIrq ( NetInterface interface)

Disable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 230 of file lan9250_driver.c.

◆ lan9250DropPacket()

void lan9250DropPacket ( NetInterface interface,
size_t  length 
)

Drop the received packet.

Parameters
[in]interfaceUnderlying network interface
[in]lengthLength of the packet, in bytes

Definition at line 573 of file lan9250_driver.c.

◆ lan9250DumpMacReg()

void lan9250DumpMacReg ( NetInterface interface)

Dump host MAC CSR registers for debugging purpose.

Parameters
[in]interfaceUnderlying network interface

Definition at line 825 of file lan9250_driver.c.

◆ lan9250DumpPhyReg()

void lan9250DumpPhyReg ( NetInterface interface)

Dump PHY registers for debugging purpose.

Parameters
[in]interfaceUnderlying network interface

Definition at line 921 of file lan9250_driver.c.

◆ lan9250DumpSysReg()

void lan9250DumpSysReg ( NetInterface interface)

Dump system CSR registers for debugging purpose.

Parameters
[in]interfaceUnderlying network interface

Definition at line 731 of file lan9250_driver.c.

◆ lan9250EnableIrq()

void lan9250EnableIrq ( NetInterface interface)

Enable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 215 of file lan9250_driver.c.

◆ lan9250EventHandler()

void lan9250EventHandler ( NetInterface interface)

LAN9250 event handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 319 of file lan9250_driver.c.

◆ lan9250Init()

error_t lan9250Init ( NetInterface interface)

LAN9250 controller initialization.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 71 of file lan9250_driver.c.

◆ lan9250InitHook()

__weak_func void lan9250InitHook ( NetInterface interface)

LAN9250 custom configuration.

Parameters
[in]interfaceUnderlying network interface

Definition at line 195 of file lan9250_driver.c.

◆ lan9250IrqHandler()

bool_t lan9250IrqHandler ( NetInterface interface)

LAN9250 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 246 of file lan9250_driver.c.

◆ lan9250ReadFifo()

void lan9250ReadFifo ( 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 1042 of file lan9250_driver.c.

◆ lan9250ReadMacReg()

uint32_t lan9250ReadMacReg ( NetInterface interface,
uint8_t  address 
)

Read host MAC CSR register.

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

Definition at line 792 of file lan9250_driver.c.

◆ lan9250ReadMmdReg()

uint16_t lan9250ReadMmdReg ( NetInterface interface,
uint8_t  devAddr,
uint16_t  regAddr 
)

Read MMD register.

Parameters
[in]interfaceUnderlying network interface
[in]devAddrDevice address
[in]regAddrRegister address
Returns
MMD register value

Definition at line 975 of file lan9250_driver.c.

◆ lan9250ReadPhyReg()

uint16_t lan9250ReadPhyReg ( NetInterface interface,
uint8_t  address 
)

Read PHY register.

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

Definition at line 887 of file lan9250_driver.c.

◆ lan9250ReadSysReg()

uint32_t lan9250ReadSysReg ( NetInterface interface,
uint16_t  address 
)

Read system CSR register.

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

Definition at line 698 of file lan9250_driver.c.

◆ lan9250ReceivePacket()

error_t lan9250ReceivePacket ( NetInterface interface)

Receive a packet.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 498 of file lan9250_driver.c.

◆ lan9250SendPacket()

error_t lan9250SendPacket ( 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 429 of file lan9250_driver.c.

◆ lan9250Tick()

void lan9250Tick ( NetInterface interface)

LAN9250 timer handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 205 of file lan9250_driver.c.

◆ lan9250UpdateMacAddrFilter()

error_t lan9250UpdateMacAddrFilter ( NetInterface interface)

Configure MAC address filtering.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 612 of file lan9250_driver.c.

◆ lan9250WriteFifo()

void lan9250WriteFifo ( 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 1003 of file lan9250_driver.c.

◆ lan9250WriteMacReg()

void lan9250WriteMacReg ( NetInterface interface,
uint8_t  address,
uint32_t  data 
)

Write host MAC CSR register.

Parameters
[in]interfaceUnderlying network interface
[in]addressHost MAC register address
[in]dataRegister value

Definition at line 755 of file lan9250_driver.c.

◆ lan9250WriteMmdReg()

void lan9250WriteMmdReg ( NetInterface interface,
uint8_t  devAddr,
uint16_t  regAddr,
uint16_t  data 
)

Write MMD register.

Parameters
[in]interfaceUnderlying network interface
[in]devAddrDevice address
[in]regAddrRegister address
[in]dataMMD register value

Definition at line 946 of file lan9250_driver.c.

◆ lan9250WritePhyReg()

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

Write PHY register.

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

Definition at line 849 of file lan9250_driver.c.

◆ lan9250WriteSysReg()

void lan9250WriteSysReg ( NetInterface interface,
uint16_t  address,
uint32_t  data 
)

Write system CSR register.

Parameters
[in]interfaceUnderlying network interface
[in]addressRegister address
[in]dataSystem register value

Definition at line 667 of file lan9250_driver.c.

Variable Documentation

◆ lan9250Driver

const NicDriver lan9250Driver
error_t lan9250Init(NetInterface *interface)
LAN9250 controller initialization.
error_t lan9250UpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
#define TRUE
Definition: os_port.h:50
void lan9250EnableIrq(NetInterface *interface)
Enable interrupts.
void lan9250DisableIrq(NetInterface *interface)
Disable interrupts.
#define FALSE
Definition: os_port.h:46
error_t lan9250SendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
void lan9250EventHandler(NetInterface *interface)
LAN9250 event handler.
#define ETH_MTU
Definition: ethernet.h:116
void lan9250Tick(NetInterface *interface)
LAN9250 timer handler.
@ NIC_TYPE_ETHERNET
Ethernet interface.
Definition: nic.h:83