avr32_eth_driver.h File Reference

AVR32 Ethernet MAC driver. More...

Go to the source code of this file.

Data Structures

struct  Avr32TxBufferDesc
 Transmit buffer descriptor. More...
 
struct  Avr32RxBufferDesc
 Receive buffer descriptor. More...
 

Macros

#define AVR32_ETH_TX_BUFFER_COUNT   2
 
#define AVR32_ETH_TX_BUFFER_SIZE   1536
 
#define AVR32_ETH_RX_BUFFER_COUNT   48
 
#define AVR32_ETH_RX_BUFFER_SIZE   128
 
#define AVR32_ETH_IRQ_PRIORITY   2
 
#define MACB_RMII_EREFCK_MASK   (1 << (AVR32_MACB_TX_CLK_0_PIN - 32))
 
#define MACB_RMII_ETXEN_MASK   (1 << (AVR32_MACB_TX_EN_0_PIN - 32))
 
#define MACB_RMII_ETX0_MASK   (1 << (AVR32_MACB_TXD_0_PIN - 32))
 
#define MACB_RMII_ETX1_MASK   (1 << (AVR32_MACB_TXD_1_PIN - 32))
 
#define MACB_RMII_ERX0_MASK   (1 << (AVR32_MACB_RXD_0_PIN - 32))
 
#define MACB_RMII_ERX1_MASK   (1 << (AVR32_MACB_RXD_1_PIN - 32))
 
#define MACB_RMII_ERXER_MASK   (1 << (AVR32_MACB_RX_ER_0_PIN - 32))
 
#define MACB_RMII_ECRSDV_MASK   (1 << (AVR32_MACB_RX_DV_0_PIN - 32))
 
#define MACB_RMII_MDC_MASK   (1 << (AVR32_MACB_MDC_0_PIN - 32))
 
#define MACB_RMII_MDIO_MASK   (1 << (AVR32_MACB_MDIO_0_PIN - 32))
 
#define MACB_RMII_MASK
 
#define MACB_MAN_SOF_01   (1 << AVR32_MACB_MAN_SOF_OFFSET)
 
#define MACB_MAN_RW_01   (1 << AVR32_MACB_MAN_RW_OFFSET)
 
#define MACB_MAN_RW_10   (2 << AVR32_MACB_MAN_RW_OFFSET)
 
#define MACB_MAN_CODE_10   (2 << AVR32_MACB_MAN_CODE_OFFSET)
 
#define MACB_TX_USED   0x80000000
 
#define MACB_TX_WRAP   0x40000000
 
#define MACB_TX_ERROR   0x20000000
 
#define MACB_TX_UNDERRUN   0x10000000
 
#define MACB_TX_EXHAUSTED   0x08000000
 
#define MACB_TX_NO_CRC   0x00010000
 
#define MACB_TX_LAST   0x00008000
 
#define MACB_TX_LENGTH   0x000007FF
 
#define MACB_RX_ADDRESS   0xFFFFFFFC
 
#define MACB_RX_WRAP   0x00000002
 
#define MACB_RX_OWNERSHIP   0x00000001
 
#define MACB_RX_BROADCAST   0x80000000
 
#define MACB_RX_MULTICAST_HASH   0x40000000
 
#define MACB_RX_UNICAST_HASH   0x20000000
 
#define MACB_RX_EXT_ADDR   0x10000000
 
#define MACB_RX_SAR1   0x04000000
 
#define MACB_RX_SAR2   0x02000000
 
#define MACB_RX_SAR3   0x01000000
 
#define MACB_RX_SAR4   0x00800000
 
#define MACB_RX_TYPE_ID   0x00400000
 
#define MACB_RX_VLAN_TAG   0x00200000
 
#define MACB_RX_PRIORITY_TAG   0x00100000
 
#define MACB_RX_VLAN_PRIORITY   0x000E0000
 
#define MACB_RX_CFI   0x00010000
 
#define MACB_RX_EOF   0x00008000
 
#define MACB_RX_SOF   0x00004000
 
#define MACB_RX_OFFSET   0x00003000
 
#define MACB_RX_LENGTH   0x00000FFF
 

Functions

error_t avr32EthInit (NetInterface *interface)
 AVR32 Ethernet MAC initialization. More...
 
void avr32EthInitGpio (NetInterface *interface)
 GPIO configuration. More...
 
void avr32EthInitBufferDesc (NetInterface *interface)
 Initialize buffer descriptors. More...
 
void avr32EthTick (NetInterface *interface)
 AVR32 Ethernet MAC timer handler. More...
 
void avr32EthEnableIrq (NetInterface *interface)
 Enable interrupts. More...
 
void avr32EthDisableIrq (NetInterface *interface)
 Disable interrupts. More...
 
void avr32EthIrqWrapper (void)
 
bool_t avr32EthIrqHandler (void)
 AVR32 Ethernet MAC interrupt service routine. More...
 
void avr32EthEventHandler (NetInterface *interface)
 AVR32 Ethernet MAC event handler. More...
 
error_t avr32EthSendPacket (NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
 Send a packet. More...
 
error_t avr32EthReceivePacket (NetInterface *interface)
 Receive a packet. More...
 
error_t avr32EthUpdateMacAddrFilter (NetInterface *interface)
 Configure MAC address filtering. More...
 
error_t avr32EthUpdateMacConfig (NetInterface *interface)
 Adjust MAC configuration parameters for proper operation. More...
 
void avr32EthWritePhyReg (uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
 Write PHY register. More...
 
uint16_t avr32EthReadPhyReg (uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
 Read PHY register. More...
 

Variables

const NicDriver avr32EthDriver
 AVR32 Ethernet MAC driver. More...
 

Detailed Description

AVR32 Ethernet MAC driver.

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 avr32_eth_driver.h.

Macro Definition Documentation

◆ AVR32_ETH_IRQ_PRIORITY

#define AVR32_ETH_IRQ_PRIORITY   2

Definition at line 64 of file avr32_eth_driver.h.

◆ AVR32_ETH_RX_BUFFER_COUNT

#define AVR32_ETH_RX_BUFFER_COUNT   48

Definition at line 50 of file avr32_eth_driver.h.

◆ AVR32_ETH_RX_BUFFER_SIZE

#define AVR32_ETH_RX_BUFFER_SIZE   128

Definition at line 57 of file avr32_eth_driver.h.

◆ AVR32_ETH_TX_BUFFER_COUNT

#define AVR32_ETH_TX_BUFFER_COUNT   2

Definition at line 36 of file avr32_eth_driver.h.

◆ AVR32_ETH_TX_BUFFER_SIZE

#define AVR32_ETH_TX_BUFFER_SIZE   1536

Definition at line 43 of file avr32_eth_driver.h.

◆ MACB_MAN_CODE_10

#define MACB_MAN_CODE_10   (2 << AVR32_MACB_MAN_CODE_OFFSET)

Definition at line 90 of file avr32_eth_driver.h.

◆ MACB_MAN_RW_01

#define MACB_MAN_RW_01   (1 << AVR32_MACB_MAN_RW_OFFSET)

Definition at line 88 of file avr32_eth_driver.h.

◆ MACB_MAN_RW_10

#define MACB_MAN_RW_10   (2 << AVR32_MACB_MAN_RW_OFFSET)

Definition at line 89 of file avr32_eth_driver.h.

◆ MACB_MAN_SOF_01

#define MACB_MAN_SOF_01   (1 << AVR32_MACB_MAN_SOF_OFFSET)

Definition at line 87 of file avr32_eth_driver.h.

◆ MACB_RMII_ECRSDV_MASK

#define MACB_RMII_ECRSDV_MASK   (1 << (AVR32_MACB_RX_DV_0_PIN - 32))

Definition at line 77 of file avr32_eth_driver.h.

◆ MACB_RMII_EREFCK_MASK

#define MACB_RMII_EREFCK_MASK   (1 << (AVR32_MACB_TX_CLK_0_PIN - 32))

Definition at line 70 of file avr32_eth_driver.h.

◆ MACB_RMII_ERX0_MASK

#define MACB_RMII_ERX0_MASK   (1 << (AVR32_MACB_RXD_0_PIN - 32))

Definition at line 74 of file avr32_eth_driver.h.

◆ MACB_RMII_ERX1_MASK

#define MACB_RMII_ERX1_MASK   (1 << (AVR32_MACB_RXD_1_PIN - 32))

Definition at line 75 of file avr32_eth_driver.h.

◆ MACB_RMII_ERXER_MASK

#define MACB_RMII_ERXER_MASK   (1 << (AVR32_MACB_RX_ER_0_PIN - 32))

Definition at line 76 of file avr32_eth_driver.h.

◆ MACB_RMII_ETX0_MASK

#define MACB_RMII_ETX0_MASK   (1 << (AVR32_MACB_TXD_0_PIN - 32))

Definition at line 72 of file avr32_eth_driver.h.

◆ MACB_RMII_ETX1_MASK

#define MACB_RMII_ETX1_MASK   (1 << (AVR32_MACB_TXD_1_PIN - 32))

Definition at line 73 of file avr32_eth_driver.h.

◆ MACB_RMII_ETXEN_MASK

#define MACB_RMII_ETXEN_MASK   (1 << (AVR32_MACB_TX_EN_0_PIN - 32))

Definition at line 71 of file avr32_eth_driver.h.

◆ MACB_RMII_MASK

#define MACB_RMII_MASK

◆ MACB_RMII_MDC_MASK

#define MACB_RMII_MDC_MASK   (1 << (AVR32_MACB_MDC_0_PIN - 32))

Definition at line 78 of file avr32_eth_driver.h.

◆ MACB_RMII_MDIO_MASK

#define MACB_RMII_MDIO_MASK   (1 << (AVR32_MACB_MDIO_0_PIN - 32))

Definition at line 79 of file avr32_eth_driver.h.

◆ MACB_RX_ADDRESS

#define MACB_RX_ADDRESS   0xFFFFFFFC

Definition at line 103 of file avr32_eth_driver.h.

◆ MACB_RX_BROADCAST

#define MACB_RX_BROADCAST   0x80000000

Definition at line 106 of file avr32_eth_driver.h.

◆ MACB_RX_CFI

#define MACB_RX_CFI   0x00010000

Definition at line 118 of file avr32_eth_driver.h.

◆ MACB_RX_EOF

#define MACB_RX_EOF   0x00008000

Definition at line 119 of file avr32_eth_driver.h.

◆ MACB_RX_EXT_ADDR

#define MACB_RX_EXT_ADDR   0x10000000

Definition at line 109 of file avr32_eth_driver.h.

◆ MACB_RX_LENGTH

#define MACB_RX_LENGTH   0x00000FFF

Definition at line 122 of file avr32_eth_driver.h.

◆ MACB_RX_MULTICAST_HASH

#define MACB_RX_MULTICAST_HASH   0x40000000

Definition at line 107 of file avr32_eth_driver.h.

◆ MACB_RX_OFFSET

#define MACB_RX_OFFSET   0x00003000

Definition at line 121 of file avr32_eth_driver.h.

◆ MACB_RX_OWNERSHIP

#define MACB_RX_OWNERSHIP   0x00000001

Definition at line 105 of file avr32_eth_driver.h.

◆ MACB_RX_PRIORITY_TAG

#define MACB_RX_PRIORITY_TAG   0x00100000

Definition at line 116 of file avr32_eth_driver.h.

◆ MACB_RX_SAR1

#define MACB_RX_SAR1   0x04000000

Definition at line 110 of file avr32_eth_driver.h.

◆ MACB_RX_SAR2

#define MACB_RX_SAR2   0x02000000

Definition at line 111 of file avr32_eth_driver.h.

◆ MACB_RX_SAR3

#define MACB_RX_SAR3   0x01000000

Definition at line 112 of file avr32_eth_driver.h.

◆ MACB_RX_SAR4

#define MACB_RX_SAR4   0x00800000

Definition at line 113 of file avr32_eth_driver.h.

◆ MACB_RX_SOF

#define MACB_RX_SOF   0x00004000

Definition at line 120 of file avr32_eth_driver.h.

◆ MACB_RX_TYPE_ID

#define MACB_RX_TYPE_ID   0x00400000

Definition at line 114 of file avr32_eth_driver.h.

◆ MACB_RX_UNICAST_HASH

#define MACB_RX_UNICAST_HASH   0x20000000

Definition at line 108 of file avr32_eth_driver.h.

◆ MACB_RX_VLAN_PRIORITY

#define MACB_RX_VLAN_PRIORITY   0x000E0000

Definition at line 117 of file avr32_eth_driver.h.

◆ MACB_RX_VLAN_TAG

#define MACB_RX_VLAN_TAG   0x00200000

Definition at line 115 of file avr32_eth_driver.h.

◆ MACB_RX_WRAP

#define MACB_RX_WRAP   0x00000002

Definition at line 104 of file avr32_eth_driver.h.

◆ MACB_TX_ERROR

#define MACB_TX_ERROR   0x20000000

Definition at line 95 of file avr32_eth_driver.h.

◆ MACB_TX_EXHAUSTED

#define MACB_TX_EXHAUSTED   0x08000000

Definition at line 97 of file avr32_eth_driver.h.

◆ MACB_TX_LAST

#define MACB_TX_LAST   0x00008000

Definition at line 99 of file avr32_eth_driver.h.

◆ MACB_TX_LENGTH

#define MACB_TX_LENGTH   0x000007FF

Definition at line 100 of file avr32_eth_driver.h.

◆ MACB_TX_NO_CRC

#define MACB_TX_NO_CRC   0x00010000

Definition at line 98 of file avr32_eth_driver.h.

◆ MACB_TX_UNDERRUN

#define MACB_TX_UNDERRUN   0x10000000

Definition at line 96 of file avr32_eth_driver.h.

◆ MACB_TX_USED

#define MACB_TX_USED   0x80000000

Definition at line 93 of file avr32_eth_driver.h.

◆ MACB_TX_WRAP

#define MACB_TX_WRAP   0x40000000

Definition at line 94 of file avr32_eth_driver.h.

Function Documentation

◆ avr32EthDisableIrq()

void avr32EthDisableIrq ( NetInterface interface)

Disable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 353 of file avr32_eth_driver.c.

◆ avr32EthEnableIrq()

void avr32EthEnableIrq ( NetInterface interface)

Enable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 325 of file avr32_eth_driver.c.

◆ avr32EthEventHandler()

void avr32EthEventHandler ( NetInterface interface)

AVR32 Ethernet MAC event handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 451 of file avr32_eth_driver.c.

◆ avr32EthInit()

error_t avr32EthInit ( NetInterface interface)

AVR32 Ethernet MAC initialization.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 117 of file avr32_eth_driver.c.

◆ avr32EthInitBufferDesc()

void avr32EthInitBufferDesc ( NetInterface interface)

Initialize buffer descriptors.

Parameters
[in]interfaceUnderlying network interface

Definition at line 247 of file avr32_eth_driver.c.

◆ avr32EthInitGpio()

void avr32EthInitGpio ( NetInterface interface)

GPIO configuration.

Parameters
[in]interfaceUnderlying network interface

Definition at line 225 of file avr32_eth_driver.c.

◆ avr32EthIrqHandler()

bool_t avr32EthIrqHandler ( void  )

AVR32 Ethernet MAC interrupt service routine.

Returns
TRUE if a higher priority task must be woken. Else FALSE is returned

Definition at line 398 of file avr32_eth_driver.c.

◆ avr32EthIrqWrapper()

void avr32EthIrqWrapper ( void  )

◆ avr32EthReadPhyReg()

uint16_t avr32EthReadPhyReg ( uint8_t  opcode,
uint8_t  phyAddr,
uint8_t  regAddr 
)

Read PHY register.

Parameters
[in]opcodeAccess type (2 bits)
[in]phyAddrPHY address (5 bits)
[in]regAddrRegister address (5 bits)
Returns
Register value

Definition at line 840 of file avr32_eth_driver.c.

◆ avr32EthReceivePacket()

error_t avr32EthReceivePacket ( NetInterface interface)

Receive a packet.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 554 of file avr32_eth_driver.c.

◆ avr32EthSendPacket()

error_t avr32EthSendPacket ( 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 487 of file avr32_eth_driver.c.

◆ avr32EthTick()

void avr32EthTick ( NetInterface interface)

AVR32 Ethernet MAC timer handler.

This routine is periodically called by the TCP/IP stack to handle periodic operations such as polling the link state

Parameters
[in]interfaceUnderlying network interface

Definition at line 300 of file avr32_eth_driver.c.

◆ avr32EthUpdateMacAddrFilter()

error_t avr32EthUpdateMacAddrFilter ( NetInterface interface)

Configure MAC address filtering.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 686 of file avr32_eth_driver.c.

◆ avr32EthUpdateMacConfig()

error_t avr32EthUpdateMacConfig ( NetInterface interface)

Adjust MAC configuration parameters for proper operation.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 758 of file avr32_eth_driver.c.

◆ avr32EthWritePhyReg()

void avr32EthWritePhyReg ( uint8_t  opcode,
uint8_t  phyAddr,
uint8_t  regAddr,
uint16_t  data 
)

Write PHY register.

Parameters
[in]opcodeAccess type (2 bits)
[in]phyAddrPHY address (5 bits)
[in]regAddrRegister address (5 bits)
[in]dataRegister value

Definition at line 801 of file avr32_eth_driver.c.

Variable Documentation

◆ avr32EthDriver

const NicDriver avr32EthDriver
extern

AVR32 Ethernet MAC driver.

Definition at line 90 of file avr32_eth_driver.c.

#define MACB_RMII_MDC_MASK
#define MACB_RMII_ERX0_MASK
#define MACB_RMII_EREFCK_MASK
#define MACB_RMII_ERX1_MASK
#define MACB_RMII_MDIO_MASK
#define MACB_RMII_ETXEN_MASK
#define MACB_RMII_ETX1_MASK
#define MACB_RMII_ECRSDV_MASK