mk6x_eth_driver.h File Reference

NXP Kinetis K60/K64/K65/K66 Ethernet MAC controller. More...

Go to the source code of this file.


#define MK6X_ETH_TX_BUFFER_SIZE   1536
#define MK6X_ETH_RX_BUFFER_SIZE   1536
#define MPU   SYSMPU
#define ENET_TBD0_R   0x8000
#define ENET_TBD0_TO1   0x4000
#define ENET_TBD0_W   0x2000
#define ENET_TBD0_TO2   0x1000
#define ENET_TBD0_L   0x0800
#define ENET_TBD0_TC   0x0400
#define ENET_TBD4_INT   0x4000
#define ENET_TBD4_TS   0x2000
#define ENET_TBD4_PINS   0x1000
#define ENET_TBD4_IINS   0x0800
#define ENET_TBD5_TXE   0x8000
#define ENET_TBD5_UE   0x2000
#define ENET_TBD5_EE   0x1000
#define ENET_TBD5_FE   0x0800
#define ENET_TBD5_LCE   0x0400
#define ENET_TBD5_OE   0x0200
#define ENET_TBD5_TSE   0x0100
#define ENET_TBD8_BDU   0x8000
#define ENET_RBD0_E   0x8000
#define ENET_RBD0_RO1   0x4000
#define ENET_RBD0_W   0x2000
#define ENET_RBD0_RO2   0x1000
#define ENET_RBD0_L   0x0800
#define ENET_RBD0_M   0x0100
#define ENET_RBD0_BC   0x0080
#define ENET_RBD0_MC   0x0040
#define ENET_RBD0_LG   0x0020
#define ENET_RBD0_NO   0x0010
#define ENET_RBD0_CR   0x0004
#define ENET_RBD0_OV   0x0002
#define ENET_RBD0_TR   0x0001
#define ENET_RBD4_ME   0x8000
#define ENET_RBD4_PE   0x0400
#define ENET_RBD4_CE   0x0200
#define ENET_RBD4_UC   0x0100
#define ENET_RBD4_INT   0x0080
#define ENET_RBD5_VPCP   0xE000
#define ENET_RBD5_ICE   0x0020
#define ENET_RBD5_PCR   0x0010
#define ENET_RBD5_VLAN   0x0004
#define ENET_RBD5_IPV6   0x0002
#define ENET_RBD5_FRAG   0x0001
#define ENET_RBD6_HEADER_LENGTH   0xF800
#define ENET_RBD8_BDU   0x8000


error_t mk6xEthInit (NetInterface *interface)
 Kinetis K6x Ethernet MAC initialization. More...
void mk6xEthInitGpio (NetInterface *interface)
void mk6xEthInitBufferDesc (NetInterface *interface)
 Initialize buffer descriptors. More...
void mk6xEthTick (NetInterface *interface)
 Kinetis K6x Ethernet MAC timer handler. More...
void mk6xEthEnableIrq (NetInterface *interface)
 Enable interrupts. More...
void mk6xEthDisableIrq (NetInterface *interface)
 Disable interrupts. More...
void mk6xEthEventHandler (NetInterface *interface)
 Kinetis K6x Ethernet MAC event handler. More...
error_t mk6xEthSendPacket (NetInterface *interface, const NetBuffer *buffer, size_t offset)
 Send a packet. More...
error_t mk6xEthReceivePacket (NetInterface *interface)
 Receive a packet. More...
error_t mk6xEthUpdateMacAddrFilter (NetInterface *interface)
 Configure MAC address filtering. More...
error_t mk6xEthUpdateMacConfig (NetInterface *interface)
 Adjust MAC configuration parameters for proper operation. More...
void mk6xEthWritePhyReg (uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
 Write PHY register. More...
uint16_t mk6xEthReadPhyReg (uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
 Read PHY register. More...
uint32_t mk6xEthCalcCrc (const void *data, size_t length)
 CRC calculation. More...


const NicDriver mk6xEthDriver
 Kinetis K6x Ethernet MAC driver. More...

Detailed Description

NXP Kinetis K60/K64/K65/K66 Ethernet MAC controller.


SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2019 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.

Oryx Embedded SARL (

Definition in file mk6x_eth_driver.h.

Macro Definition Documentation


#define ENET_RBD0_BC   0x0080

Definition at line 124 of file mk6x_eth_driver.h.


#define ENET_RBD0_CR   0x0004

Definition at line 128 of file mk6x_eth_driver.h.


#define ENET_RBD0_E   0x8000

Definition at line 118 of file mk6x_eth_driver.h.


#define ENET_RBD0_L   0x0800

Definition at line 122 of file mk6x_eth_driver.h.


#define ENET_RBD0_LG   0x0020

Definition at line 126 of file mk6x_eth_driver.h.


#define ENET_RBD0_M   0x0100

Definition at line 123 of file mk6x_eth_driver.h.


#define ENET_RBD0_MC   0x0040

Definition at line 125 of file mk6x_eth_driver.h.


#define ENET_RBD0_NO   0x0010

Definition at line 127 of file mk6x_eth_driver.h.


#define ENET_RBD0_OV   0x0002

Definition at line 129 of file mk6x_eth_driver.h.


#define ENET_RBD0_RO1   0x4000

Definition at line 119 of file mk6x_eth_driver.h.


#define ENET_RBD0_RO2   0x1000

Definition at line 121 of file mk6x_eth_driver.h.


#define ENET_RBD0_TR   0x0001

Definition at line 130 of file mk6x_eth_driver.h.


#define ENET_RBD0_W   0x2000

Definition at line 120 of file mk6x_eth_driver.h.



Definition at line 149 of file mk6x_eth_driver.h.



Definition at line 150 of file mk6x_eth_driver.h.



Definition at line 131 of file mk6x_eth_driver.h.



Definition at line 132 of file mk6x_eth_driver.h.



Definition at line 133 of file mk6x_eth_driver.h.


#define ENET_RBD4_CE   0x0200

Definition at line 136 of file mk6x_eth_driver.h.


#define ENET_RBD4_INT   0x0080

Definition at line 138 of file mk6x_eth_driver.h.


#define ENET_RBD4_ME   0x8000

Definition at line 134 of file mk6x_eth_driver.h.


#define ENET_RBD4_PE   0x0400

Definition at line 135 of file mk6x_eth_driver.h.


#define ENET_RBD4_UC   0x0100

Definition at line 137 of file mk6x_eth_driver.h.


#define ENET_RBD5_FRAG   0x0001

Definition at line 144 of file mk6x_eth_driver.h.


#define ENET_RBD5_ICE   0x0020

Definition at line 140 of file mk6x_eth_driver.h.


#define ENET_RBD5_IPV6   0x0002

Definition at line 143 of file mk6x_eth_driver.h.


#define ENET_RBD5_PCR   0x0010

Definition at line 141 of file mk6x_eth_driver.h.


#define ENET_RBD5_VLAN   0x0004

Definition at line 142 of file mk6x_eth_driver.h.


#define ENET_RBD5_VPCP   0xE000

Definition at line 139 of file mk6x_eth_driver.h.


#define ENET_RBD6_HEADER_LENGTH   0xF800

Definition at line 145 of file mk6x_eth_driver.h.



Definition at line 146 of file mk6x_eth_driver.h.



Definition at line 147 of file mk6x_eth_driver.h.


#define ENET_RBD8_BDU   0x8000

Definition at line 148 of file mk6x_eth_driver.h.


#define ENET_TBD0_L   0x0800

Definition at line 97 of file mk6x_eth_driver.h.


#define ENET_TBD0_R   0x8000

Definition at line 93 of file mk6x_eth_driver.h.


#define ENET_TBD0_TC   0x0400

Definition at line 98 of file mk6x_eth_driver.h.


#define ENET_TBD0_TO1   0x4000

Definition at line 94 of file mk6x_eth_driver.h.


#define ENET_TBD0_TO2   0x1000

Definition at line 96 of file mk6x_eth_driver.h.


#define ENET_TBD0_W   0x2000

Definition at line 95 of file mk6x_eth_driver.h.



Definition at line 114 of file mk6x_eth_driver.h.



Definition at line 115 of file mk6x_eth_driver.h.



Definition at line 99 of file mk6x_eth_driver.h.



Definition at line 100 of file mk6x_eth_driver.h.



Definition at line 101 of file mk6x_eth_driver.h.


#define ENET_TBD4_IINS   0x0800

Definition at line 105 of file mk6x_eth_driver.h.


#define ENET_TBD4_INT   0x4000

Definition at line 102 of file mk6x_eth_driver.h.


#define ENET_TBD4_PINS   0x1000

Definition at line 104 of file mk6x_eth_driver.h.


#define ENET_TBD4_TS   0x2000

Definition at line 103 of file mk6x_eth_driver.h.


#define ENET_TBD5_EE   0x1000

Definition at line 108 of file mk6x_eth_driver.h.


#define ENET_TBD5_FE   0x0800

Definition at line 109 of file mk6x_eth_driver.h.


#define ENET_TBD5_LCE   0x0400

Definition at line 110 of file mk6x_eth_driver.h.


#define ENET_TBD5_OE   0x0200

Definition at line 111 of file mk6x_eth_driver.h.


#define ENET_TBD5_TSE   0x0100

Definition at line 112 of file mk6x_eth_driver.h.


#define ENET_TBD5_TXE   0x8000

Definition at line 106 of file mk6x_eth_driver.h.


#define ENET_TBD5_UE   0x2000

Definition at line 107 of file mk6x_eth_driver.h.


#define ENET_TBD8_BDU   0x8000

Definition at line 113 of file mk6x_eth_driver.h.



Definition at line 71 of file mk6x_eth_driver.h.



Definition at line 64 of file mk6x_eth_driver.h.



Definition at line 78 of file mk6x_eth_driver.h.



Definition at line 50 of file mk6x_eth_driver.h.


#define MK6X_ETH_RX_BUFFER_SIZE   1536

Definition at line 57 of file mk6x_eth_driver.h.



Definition at line 36 of file mk6x_eth_driver.h.


#define MK6X_ETH_TX_BUFFER_SIZE   1536

Definition at line 43 of file mk6x_eth_driver.h.


#define MPU   SYSMPU

Definition at line 85 of file mk6x_eth_driver.h.



Definition at line 89 of file mk6x_eth_driver.h.

Function Documentation

◆ mk6xEthCalcCrc()

uint32_t mk6xEthCalcCrc ( const void *  data,
size_t  length 

CRC calculation.

[in]dataPointer to the data over which to calculate the CRC
[in]lengthNumber of bytes to process
Resulting CRC value

Definition at line 1046 of file mk6x_eth_driver.c.

◆ mk6xEthDisableIrq()

void mk6xEthDisableIrq ( NetInterface interface)

Disable interrupts.

[in]interfaceUnderlying network interface

Definition at line 499 of file mk6x_eth_driver.c.

◆ mk6xEthEnableIrq()

void mk6xEthEnableIrq ( NetInterface interface)

Enable interrupts.

[in]interfaceUnderlying network interface

Definition at line 482 of file mk6x_eth_driver.c.

◆ mk6xEthEventHandler()

void mk6xEthEventHandler ( NetInterface interface)

Kinetis K6x Ethernet MAC event handler.

[in]interfaceUnderlying network interface

Definition at line 614 of file mk6x_eth_driver.c.

◆ mk6xEthInit()

error_t mk6xEthInit ( NetInterface interface)

Kinetis K6x Ethernet MAC initialization.

[in]interfaceUnderlying network interface
Error code

Definition at line 133 of file mk6x_eth_driver.c.

◆ mk6xEthInitBufferDesc()

void mk6xEthInitBufferDesc ( NetInterface interface)

Initialize buffer descriptors.

[in]interfaceUnderlying network interface

Definition at line 407 of file mk6x_eth_driver.c.

◆ mk6xEthInitGpio()

void mk6xEthInitGpio ( NetInterface interface)

◆ mk6xEthReadPhyReg()

uint16_t mk6xEthReadPhyReg ( uint8_t  opcode,
uint8_t  phyAddr,
uint8_t  regAddr 

Read PHY register.

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

Definition at line 999 of file mk6x_eth_driver.c.

◆ mk6xEthReceivePacket()

error_t mk6xEthReceivePacket ( NetInterface interface)

Receive a packet.

[in]interfaceUnderlying network interface
Error code

Definition at line 737 of file mk6x_eth_driver.c.

◆ mk6xEthSendPacket()

error_t mk6xEthSendPacket ( NetInterface interface,
const NetBuffer buffer,
size_t  offset 

Send a packet.

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

Definition at line 667 of file mk6x_eth_driver.c.

◆ mk6xEthTick()

void mk6xEthTick ( NetInterface interface)

Kinetis K6x Ethernet MAC timer handler.

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

[in]interfaceUnderlying network interface

Definition at line 470 of file mk6x_eth_driver.c.

◆ mk6xEthUpdateMacAddrFilter()

error_t mk6xEthUpdateMacAddrFilter ( NetInterface interface)

Configure MAC address filtering.

[in]interfaceUnderlying network interface
Error code

Definition at line 814 of file mk6x_eth_driver.c.

◆ mk6xEthUpdateMacConfig()

error_t mk6xEthUpdateMacConfig ( NetInterface interface)

Adjust MAC configuration parameters for proper operation.

[in]interfaceUnderlying network interface
Error code

Definition at line 903 of file mk6x_eth_driver.c.

◆ mk6xEthWritePhyReg()

void mk6xEthWritePhyReg ( uint8_t  opcode,
uint8_t  phyAddr,
uint8_t  regAddr,
uint16_t  data 

Write PHY register.

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

Definition at line 957 of file mk6x_eth_driver.c.

Variable Documentation

◆ mk6xEthDriver

const NicDriver mk6xEthDriver

Kinetis K6x Ethernet MAC driver.

Definition at line 106 of file mk6x_eth_driver.c.