aps3_eth_driver.h File Reference

Cortus APS3 Ethernet MAC controller. More...

#include "core/nic.h"

Go to the source code of this file.

Data Structures

struct  Aps3TxDmaDesc
 TX DMA descriptor. More...
 
struct  Aps3RxDmaDesc
 RX DMA descriptor. More...
 

Macros

#define APS3_ETH_TX_BUFFER_COUNT   4
 
#define APS3_ETH_TX_BUFFER_SIZE   1536
 
#define APS3_ETH_RX_BUFFER_COUNT   4
 
#define APS3_ETH_RX_BUFFER_SIZE   1536
 
#define APS3_ETH_IRQ_PRIORITY   0
 
#define TX_IRQ_MASK_TRANSMIT_ERROR   0x0001
 
#define TX_IRQ_MASK_EXCESSIVE_DEFERRAL   0x0002
 
#define TX_IRQ_MASK_EXCESSIVE_COLLISION   0x0004
 
#define TX_IRQ_MASK_LATE_COLLISION   0x0008
 
#define TX_IRQ_MASK_FRAME_TOO_LONG   0x0010
 
#define TX_IRQ_MASK_MEMORY_ERROR   0x0020
 
#define TX_IRQ_MASK_FRAME_SENT   0x0040
 
#define TX_IRQ_MASK_MEMORY_AVAILABLE   0x0080
 
#define TX_IRQ_MASK_THRESHOLD_REACHED   0x0100
 
#define TX_IRQ_MASK_MEMORY_EMPTY   0x0200
 
#define RX_IRQ_MASK_RECEIVE_ERROR   0x0001
 
#define RX_IRQ_MASK_LENGTH_FIELD_ERROR   0x0002
 
#define RX_IRQ_MASK_FRAME_TOO_LONG   0x0004
 
#define RX_IRQ_MASK_SHORT_FRAME   0x0008
 
#define RX_IRQ_MASK_ODD_NIBBLE_COUNT   0x0010
 
#define RX_IRQ_MASK_INVALID_ADDRESS   0x0020
 
#define RX_IRQ_MASK_PHY_ERROR   0x0040
 
#define RX_IRQ_MASK_CRC_ERROR   0x0080
 
#define RX_IRQ_MASK_MEMORY_ERROR   0x0100
 
#define RX_IRQ_MASK_WAKEUP_ON_LAN   0x0200
 
#define RX_IRQ_MASK_FRAME_READY   0x0400
 
#define RX_IRQ_MASK_THRESHOLD_REACHED   0x0800
 
#define RX_IRQ_MASK_FRAME_OVERFLOW   0x1000
 
#define TX_DESC_TRANSMIT_ERROR   0x0001
 
#define TX_DESC_EXCESSIVE_DEFERRAL   0x0002
 
#define TX_DESC_EXCESSIVE_COLLISION   0x0003
 
#define TX_DESC_LATE_COLLISION   0x0004
 
#define TX_DESC_FRAME_TOO_LONG   0x0010
 
#define TX_DESC_MEMORY_ERROR   0x0020
 
#define RX_DESC_RECEIVE_ERROR   0x0001
 
#define RX_DESC_LENGTH_FIELD_ERROR   0x0002
 
#define RX_DESC_FRAME_TOO_LONG   0x0003
 
#define RX_DESC_SHORT_FRAME   0x0004
 
#define RX_DESC_ODD_NIBBLE_COUNT   0x0010
 
#define RX_DESC_INVALID_ADDRESS   0x0020
 
#define RX_DESC_PHY_ERROR   0x0040
 
#define RX_DESC_CRC_ERROR   0x0080
 
#define RX_DESC_MEMORY_ERROR   0x0100
 

Functions

error_t aps3EthInit (NetInterface *interface)
 Cortus APS3 Ethernet MAC initialization. More...
 
void aps3EthInitDmaDesc (NetInterface *interface)
 Initialize DMA descriptor lists. More...
 
void aps3EthTick (NetInterface *interface)
 Cortus APS3 Ethernet MAC timer handler. More...
 
void aps3EthEnableIrq (NetInterface *interface)
 Enable interrupts. More...
 
void aps3EthDisableIrq (NetInterface *interface)
 Disable interrupts. More...
 
void aps3EthTxIrqHandler (void) __attribute__((noinline))
 Ethernet MAC transmit interrupt service routine. More...
 
void aps3EthRxIrqHandler (void) __attribute__((noinline))
 Ethernet MAC receive interrupt service routine. More...
 
void aps3EthEventHandler (NetInterface *interface)
 Cortus APS3 Ethernet MAC event handler. More...
 
error_t aps3EthSendPacket (NetInterface *interface, const NetBuffer *buffer, size_t offset)
 Send a packet. More...
 
error_t aps3EthReceivePacket (NetInterface *interface)
 Receive a packet. More...
 
error_t aps3EthUpdateMacAddrFilter (NetInterface *interface)
 Configure MAC address filtering. More...
 
error_t aps3EthUpdateMacConfig (NetInterface *interface)
 Adjust MAC configuration parameters for proper operation. More...
 
void aps3EthWritePhyReg (uint8_t phyAddr, uint8_t regAddr, uint16_t data)
 Write PHY register. More...
 
uint16_t aps3EthReadPhyReg (uint8_t phyAddr, uint8_t regAddr)
 Read PHY register. More...
 
uint32_t aps3EthCalcCrc (const void *data, size_t length)
 CRC calculation. More...
 

Variables

const NicDriver aps3EthDriver
 Cortus APS3 Ethernet MAC driver. More...
 

Detailed Description

Cortus APS3 Ethernet MAC 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 aps3_eth_driver.h.

Macro Definition Documentation

◆ APS3_ETH_IRQ_PRIORITY

#define APS3_ETH_IRQ_PRIORITY   0

Definition at line 65 of file aps3_eth_driver.h.

◆ APS3_ETH_RX_BUFFER_COUNT

#define APS3_ETH_RX_BUFFER_COUNT   4

Definition at line 51 of file aps3_eth_driver.h.

◆ APS3_ETH_RX_BUFFER_SIZE

#define APS3_ETH_RX_BUFFER_SIZE   1536

Definition at line 58 of file aps3_eth_driver.h.

◆ APS3_ETH_TX_BUFFER_COUNT

#define APS3_ETH_TX_BUFFER_COUNT   4

Definition at line 37 of file aps3_eth_driver.h.

◆ APS3_ETH_TX_BUFFER_SIZE

#define APS3_ETH_TX_BUFFER_SIZE   1536

Definition at line 44 of file aps3_eth_driver.h.

◆ RX_DESC_CRC_ERROR

#define RX_DESC_CRC_ERROR   0x0080

Definition at line 113 of file aps3_eth_driver.h.

◆ RX_DESC_FRAME_TOO_LONG

#define RX_DESC_FRAME_TOO_LONG   0x0003

Definition at line 108 of file aps3_eth_driver.h.

◆ RX_DESC_INVALID_ADDRESS

#define RX_DESC_INVALID_ADDRESS   0x0020

Definition at line 111 of file aps3_eth_driver.h.

◆ RX_DESC_LENGTH_FIELD_ERROR

#define RX_DESC_LENGTH_FIELD_ERROR   0x0002

Definition at line 107 of file aps3_eth_driver.h.

◆ RX_DESC_MEMORY_ERROR

#define RX_DESC_MEMORY_ERROR   0x0100

Definition at line 114 of file aps3_eth_driver.h.

◆ RX_DESC_ODD_NIBBLE_COUNT

#define RX_DESC_ODD_NIBBLE_COUNT   0x0010

Definition at line 110 of file aps3_eth_driver.h.

◆ RX_DESC_PHY_ERROR

#define RX_DESC_PHY_ERROR   0x0040

Definition at line 112 of file aps3_eth_driver.h.

◆ RX_DESC_RECEIVE_ERROR

#define RX_DESC_RECEIVE_ERROR   0x0001

Definition at line 106 of file aps3_eth_driver.h.

◆ RX_DESC_SHORT_FRAME

#define RX_DESC_SHORT_FRAME   0x0004

Definition at line 109 of file aps3_eth_driver.h.

◆ RX_IRQ_MASK_CRC_ERROR

#define RX_IRQ_MASK_CRC_ERROR   0x0080

Definition at line 90 of file aps3_eth_driver.h.

◆ RX_IRQ_MASK_FRAME_OVERFLOW

#define RX_IRQ_MASK_FRAME_OVERFLOW   0x1000

Definition at line 95 of file aps3_eth_driver.h.

◆ RX_IRQ_MASK_FRAME_READY

#define RX_IRQ_MASK_FRAME_READY   0x0400

Definition at line 93 of file aps3_eth_driver.h.

◆ RX_IRQ_MASK_FRAME_TOO_LONG

#define RX_IRQ_MASK_FRAME_TOO_LONG   0x0004

Definition at line 85 of file aps3_eth_driver.h.

◆ RX_IRQ_MASK_INVALID_ADDRESS

#define RX_IRQ_MASK_INVALID_ADDRESS   0x0020

Definition at line 88 of file aps3_eth_driver.h.

◆ RX_IRQ_MASK_LENGTH_FIELD_ERROR

#define RX_IRQ_MASK_LENGTH_FIELD_ERROR   0x0002

Definition at line 84 of file aps3_eth_driver.h.

◆ RX_IRQ_MASK_MEMORY_ERROR

#define RX_IRQ_MASK_MEMORY_ERROR   0x0100

Definition at line 91 of file aps3_eth_driver.h.

◆ RX_IRQ_MASK_ODD_NIBBLE_COUNT

#define RX_IRQ_MASK_ODD_NIBBLE_COUNT   0x0010

Definition at line 87 of file aps3_eth_driver.h.

◆ RX_IRQ_MASK_PHY_ERROR

#define RX_IRQ_MASK_PHY_ERROR   0x0040

Definition at line 89 of file aps3_eth_driver.h.

◆ RX_IRQ_MASK_RECEIVE_ERROR

#define RX_IRQ_MASK_RECEIVE_ERROR   0x0001

Definition at line 83 of file aps3_eth_driver.h.

◆ RX_IRQ_MASK_SHORT_FRAME

#define RX_IRQ_MASK_SHORT_FRAME   0x0008

Definition at line 86 of file aps3_eth_driver.h.

◆ RX_IRQ_MASK_THRESHOLD_REACHED

#define RX_IRQ_MASK_THRESHOLD_REACHED   0x0800

Definition at line 94 of file aps3_eth_driver.h.

◆ RX_IRQ_MASK_WAKEUP_ON_LAN

#define RX_IRQ_MASK_WAKEUP_ON_LAN   0x0200

Definition at line 92 of file aps3_eth_driver.h.

◆ TX_DESC_EXCESSIVE_COLLISION

#define TX_DESC_EXCESSIVE_COLLISION   0x0003

Definition at line 100 of file aps3_eth_driver.h.

◆ TX_DESC_EXCESSIVE_DEFERRAL

#define TX_DESC_EXCESSIVE_DEFERRAL   0x0002

Definition at line 99 of file aps3_eth_driver.h.

◆ TX_DESC_FRAME_TOO_LONG

#define TX_DESC_FRAME_TOO_LONG   0x0010

Definition at line 102 of file aps3_eth_driver.h.

◆ TX_DESC_LATE_COLLISION

#define TX_DESC_LATE_COLLISION   0x0004

Definition at line 101 of file aps3_eth_driver.h.

◆ TX_DESC_MEMORY_ERROR

#define TX_DESC_MEMORY_ERROR   0x0020

Definition at line 103 of file aps3_eth_driver.h.

◆ TX_DESC_TRANSMIT_ERROR

#define TX_DESC_TRANSMIT_ERROR   0x0001

Definition at line 98 of file aps3_eth_driver.h.

◆ TX_IRQ_MASK_EXCESSIVE_COLLISION

#define TX_IRQ_MASK_EXCESSIVE_COLLISION   0x0004

Definition at line 73 of file aps3_eth_driver.h.

◆ TX_IRQ_MASK_EXCESSIVE_DEFERRAL

#define TX_IRQ_MASK_EXCESSIVE_DEFERRAL   0x0002

Definition at line 72 of file aps3_eth_driver.h.

◆ TX_IRQ_MASK_FRAME_SENT

#define TX_IRQ_MASK_FRAME_SENT   0x0040

Definition at line 77 of file aps3_eth_driver.h.

◆ TX_IRQ_MASK_FRAME_TOO_LONG

#define TX_IRQ_MASK_FRAME_TOO_LONG   0x0010

Definition at line 75 of file aps3_eth_driver.h.

◆ TX_IRQ_MASK_LATE_COLLISION

#define TX_IRQ_MASK_LATE_COLLISION   0x0008

Definition at line 74 of file aps3_eth_driver.h.

◆ TX_IRQ_MASK_MEMORY_AVAILABLE

#define TX_IRQ_MASK_MEMORY_AVAILABLE   0x0080

Definition at line 78 of file aps3_eth_driver.h.

◆ TX_IRQ_MASK_MEMORY_EMPTY

#define TX_IRQ_MASK_MEMORY_EMPTY   0x0200

Definition at line 80 of file aps3_eth_driver.h.

◆ TX_IRQ_MASK_MEMORY_ERROR

#define TX_IRQ_MASK_MEMORY_ERROR   0x0020

Definition at line 76 of file aps3_eth_driver.h.

◆ TX_IRQ_MASK_THRESHOLD_REACHED

#define TX_IRQ_MASK_THRESHOLD_REACHED   0x0100

Definition at line 79 of file aps3_eth_driver.h.

◆ TX_IRQ_MASK_TRANSMIT_ERROR

#define TX_IRQ_MASK_TRANSMIT_ERROR   0x0001

Definition at line 71 of file aps3_eth_driver.h.

Function Documentation

◆ aps3EthCalcCrc()

uint32_t aps3EthCalcCrc ( 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 624 of file aps3_eth_driver.c.

◆ aps3EthDisableIrq()

void aps3EthDisableIrq ( NetInterface interface)

Disable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 262 of file aps3_eth_driver.c.

◆ aps3EthEnableIrq()

void aps3EthEnableIrq ( NetInterface interface)

Enable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 246 of file aps3_eth_driver.c.

◆ aps3EthEventHandler()

void aps3EthEventHandler ( NetInterface interface)

Cortus APS3 Ethernet MAC event handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 338 of file aps3_eth_driver.c.

◆ aps3EthInit()

error_t aps3EthInit ( NetInterface interface)

Cortus APS3 Ethernet MAC initialization.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 90 of file aps3_eth_driver.c.

◆ aps3EthInitDmaDesc()

void aps3EthInitDmaDesc ( NetInterface interface)

Initialize DMA descriptor lists.

Parameters
[in]interfaceUnderlying network interface

Definition at line 187 of file aps3_eth_driver.c.

◆ aps3EthReadPhyReg()

uint16_t aps3EthReadPhyReg ( uint8_t  phyAddr,
uint8_t  regAddr 
)

Read PHY register.

Parameters
[in]phyAddrPHY address
[in]regAddrRegister address
Returns
Register value

Definition at line 597 of file aps3_eth_driver.c.

◆ aps3EthReceivePacket()

error_t aps3EthReceivePacket ( NetInterface interface)

Receive a packet.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 429 of file aps3_eth_driver.c.

◆ aps3EthRxIrqHandler()

void aps3EthRxIrqHandler ( void  )

Ethernet MAC receive interrupt service routine.

Definition at line 310 of file aps3_eth_driver.c.

◆ aps3EthSendPacket()

error_t aps3EthSendPacket ( 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 368 of file aps3_eth_driver.c.

◆ aps3EthTick()

void aps3EthTick ( NetInterface interface)

Cortus APS3 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 234 of file aps3_eth_driver.c.

◆ aps3EthTxIrqHandler()

void aps3EthTxIrqHandler ( void  )

Ethernet MAC transmit interrupt service routine.

Definition at line 277 of file aps3_eth_driver.c.

◆ aps3EthUpdateMacAddrFilter()

error_t aps3EthUpdateMacAddrFilter ( NetInterface interface)

Configure MAC address filtering.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 482 of file aps3_eth_driver.c.

◆ aps3EthUpdateMacConfig()

error_t aps3EthUpdateMacConfig ( NetInterface interface)

Adjust MAC configuration parameters for proper operation.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 543 of file aps3_eth_driver.c.

◆ aps3EthWritePhyReg()

void aps3EthWritePhyReg ( uint8_t  phyAddr,
uint8_t  regAddr,
uint16_t  data 
)

Write PHY register.

Parameters
[in]phyAddrPHY address
[in]regAddrRegister address
[in]dataRegister value

Definition at line 571 of file aps3_eth_driver.c.

Variable Documentation

◆ aps3EthDriver

const NicDriver aps3EthDriver

Cortus APS3 Ethernet MAC driver.

Definition at line 63 of file aps3_eth_driver.c.