mk6x_eth_driver.h File Reference

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

Go to the source code of this file.

Macros

#define MK6X_ETH_TX_BUFFER_COUNT   3
 
#define MK6X_ETH_TX_BUFFER_SIZE   1536
 
#define MK6X_ETH_RX_BUFFER_COUNT   6
 
#define MK6X_ETH_RX_BUFFER_SIZE   1536
 
#define MK6X_ETH_IRQ_PRIORITY_GROUPING   3
 
#define MK6X_ETH_IRQ_GROUP_PRIORITY   12
 
#define MK6X_ETH_IRQ_SUB_PRIORITY   0
 
#define MPU   SYSMPU
 
#define MPU_CESR_VLD_MASK   SYSMPU_CESR_VLD_MASK
 
#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_TBD1_DATA_LENGTH   0xFFFF
 
#define ENET_TBD2_DATA_POINTER_H   0xFFFF
 
#define ENET_TBD3_DATA_POINTER_L   0xFFFF
 
#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_TBD10_TIMESTAMP_H   0xFFFF
 
#define ENET_TBD11_TIMESTAMP_L   0xFFFF
 
#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_RBD1_DATA_LENGTH   0xFFFF
 
#define ENET_RBD2_DATA_POINTER_H   0xFFFF
 
#define ENET_RBD3_DATA_POINTER_L   0xFFFF
 
#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_RBD6_PROTOCOL_TYPE   0x00FF
 
#define ENET_RBD7_PAYLOAD_CHECKSUM   0xFFFF
 
#define ENET_RBD8_BDU   0x8000
 
#define ENET_RBD10_TIMESTAMP_H   0xFFFF
 
#define ENET_RBD11_TIMESTAMP_L   0xFFFF
 

Functions

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 phyAddr, uint8_t regAddr, uint16_t data)
 Write PHY register. More...
 
uint16_t mk6xEthReadPhyReg (uint8_t phyAddr, uint8_t regAddr)
 Read PHY register. More...
 
uint32_t mk6xEthCalcCrc (const void *data, size_t length)
 CRC calculation. More...
 

Variables

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

Detailed Description

Freescale Kinetis K60/K64/K65/K66 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 mk6x_eth_driver.h.

Macro Definition Documentation

◆ ENET_RBD0_BC

#define ENET_RBD0_BC   0x0080

Definition at line 122 of file mk6x_eth_driver.h.

◆ ENET_RBD0_CR

#define ENET_RBD0_CR   0x0004

Definition at line 126 of file mk6x_eth_driver.h.

◆ ENET_RBD0_E

#define ENET_RBD0_E   0x8000

Definition at line 116 of file mk6x_eth_driver.h.

◆ ENET_RBD0_L

#define ENET_RBD0_L   0x0800

Definition at line 120 of file mk6x_eth_driver.h.

◆ ENET_RBD0_LG

#define ENET_RBD0_LG   0x0020

Definition at line 124 of file mk6x_eth_driver.h.

◆ ENET_RBD0_M

#define ENET_RBD0_M   0x0100

Definition at line 121 of file mk6x_eth_driver.h.

◆ ENET_RBD0_MC

#define ENET_RBD0_MC   0x0040

Definition at line 123 of file mk6x_eth_driver.h.

◆ ENET_RBD0_NO

#define ENET_RBD0_NO   0x0010

Definition at line 125 of file mk6x_eth_driver.h.

◆ ENET_RBD0_OV

#define ENET_RBD0_OV   0x0002

Definition at line 127 of file mk6x_eth_driver.h.

◆ ENET_RBD0_RO1

#define ENET_RBD0_RO1   0x4000

Definition at line 117 of file mk6x_eth_driver.h.

◆ ENET_RBD0_RO2

#define ENET_RBD0_RO2   0x1000

Definition at line 119 of file mk6x_eth_driver.h.

◆ ENET_RBD0_TR

#define ENET_RBD0_TR   0x0001

Definition at line 128 of file mk6x_eth_driver.h.

◆ ENET_RBD0_W

#define ENET_RBD0_W   0x2000

Definition at line 118 of file mk6x_eth_driver.h.

◆ ENET_RBD10_TIMESTAMP_H

#define ENET_RBD10_TIMESTAMP_H   0xFFFF

Definition at line 147 of file mk6x_eth_driver.h.

◆ ENET_RBD11_TIMESTAMP_L

#define ENET_RBD11_TIMESTAMP_L   0xFFFF

Definition at line 148 of file mk6x_eth_driver.h.

◆ ENET_RBD1_DATA_LENGTH

#define ENET_RBD1_DATA_LENGTH   0xFFFF

Definition at line 129 of file mk6x_eth_driver.h.

◆ ENET_RBD2_DATA_POINTER_H

#define ENET_RBD2_DATA_POINTER_H   0xFFFF

Definition at line 130 of file mk6x_eth_driver.h.

◆ ENET_RBD3_DATA_POINTER_L

#define ENET_RBD3_DATA_POINTER_L   0xFFFF

Definition at line 131 of file mk6x_eth_driver.h.

◆ ENET_RBD4_CE

#define ENET_RBD4_CE   0x0200

Definition at line 134 of file mk6x_eth_driver.h.

◆ ENET_RBD4_INT

#define ENET_RBD4_INT   0x0080

Definition at line 136 of file mk6x_eth_driver.h.

◆ ENET_RBD4_ME

#define ENET_RBD4_ME   0x8000

Definition at line 132 of file mk6x_eth_driver.h.

◆ ENET_RBD4_PE

#define ENET_RBD4_PE   0x0400

Definition at line 133 of file mk6x_eth_driver.h.

◆ ENET_RBD4_UC

#define ENET_RBD4_UC   0x0100

Definition at line 135 of file mk6x_eth_driver.h.

◆ ENET_RBD5_FRAG

#define ENET_RBD5_FRAG   0x0001

Definition at line 142 of file mk6x_eth_driver.h.

◆ ENET_RBD5_ICE

#define ENET_RBD5_ICE   0x0020

Definition at line 138 of file mk6x_eth_driver.h.

◆ ENET_RBD5_IPV6

#define ENET_RBD5_IPV6   0x0002

Definition at line 141 of file mk6x_eth_driver.h.

◆ ENET_RBD5_PCR

#define ENET_RBD5_PCR   0x0010

Definition at line 139 of file mk6x_eth_driver.h.

◆ ENET_RBD5_VLAN

#define ENET_RBD5_VLAN   0x0004

Definition at line 140 of file mk6x_eth_driver.h.

◆ ENET_RBD5_VPCP

#define ENET_RBD5_VPCP   0xE000

Definition at line 137 of file mk6x_eth_driver.h.

◆ ENET_RBD6_HEADER_LENGTH

#define ENET_RBD6_HEADER_LENGTH   0xF800

Definition at line 143 of file mk6x_eth_driver.h.

◆ ENET_RBD6_PROTOCOL_TYPE

#define ENET_RBD6_PROTOCOL_TYPE   0x00FF

Definition at line 144 of file mk6x_eth_driver.h.

◆ ENET_RBD7_PAYLOAD_CHECKSUM

#define ENET_RBD7_PAYLOAD_CHECKSUM   0xFFFF

Definition at line 145 of file mk6x_eth_driver.h.

◆ ENET_RBD8_BDU

#define ENET_RBD8_BDU   0x8000

Definition at line 146 of file mk6x_eth_driver.h.

◆ ENET_TBD0_L

#define ENET_TBD0_L   0x0800

Definition at line 95 of file mk6x_eth_driver.h.

◆ ENET_TBD0_R

#define ENET_TBD0_R   0x8000

Definition at line 91 of file mk6x_eth_driver.h.

◆ ENET_TBD0_TC

#define ENET_TBD0_TC   0x0400

Definition at line 96 of file mk6x_eth_driver.h.

◆ ENET_TBD0_TO1

#define ENET_TBD0_TO1   0x4000

Definition at line 92 of file mk6x_eth_driver.h.

◆ ENET_TBD0_TO2

#define ENET_TBD0_TO2   0x1000

Definition at line 94 of file mk6x_eth_driver.h.

◆ ENET_TBD0_W

#define ENET_TBD0_W   0x2000

Definition at line 93 of file mk6x_eth_driver.h.

◆ ENET_TBD10_TIMESTAMP_H

#define ENET_TBD10_TIMESTAMP_H   0xFFFF

Definition at line 112 of file mk6x_eth_driver.h.

◆ ENET_TBD11_TIMESTAMP_L

#define ENET_TBD11_TIMESTAMP_L   0xFFFF

Definition at line 113 of file mk6x_eth_driver.h.

◆ ENET_TBD1_DATA_LENGTH

#define ENET_TBD1_DATA_LENGTH   0xFFFF

Definition at line 97 of file mk6x_eth_driver.h.

◆ ENET_TBD2_DATA_POINTER_H

#define ENET_TBD2_DATA_POINTER_H   0xFFFF

Definition at line 98 of file mk6x_eth_driver.h.

◆ ENET_TBD3_DATA_POINTER_L

#define ENET_TBD3_DATA_POINTER_L   0xFFFF

Definition at line 99 of file mk6x_eth_driver.h.

◆ ENET_TBD4_IINS

#define ENET_TBD4_IINS   0x0800

Definition at line 103 of file mk6x_eth_driver.h.

◆ ENET_TBD4_INT

#define ENET_TBD4_INT   0x4000

Definition at line 100 of file mk6x_eth_driver.h.

◆ ENET_TBD4_PINS

#define ENET_TBD4_PINS   0x1000

Definition at line 102 of file mk6x_eth_driver.h.

◆ ENET_TBD4_TS

#define ENET_TBD4_TS   0x2000

Definition at line 101 of file mk6x_eth_driver.h.

◆ ENET_TBD5_EE

#define ENET_TBD5_EE   0x1000

Definition at line 106 of file mk6x_eth_driver.h.

◆ ENET_TBD5_FE

#define ENET_TBD5_FE   0x0800

Definition at line 107 of file mk6x_eth_driver.h.

◆ ENET_TBD5_LCE

#define ENET_TBD5_LCE   0x0400

Definition at line 108 of file mk6x_eth_driver.h.

◆ ENET_TBD5_OE

#define ENET_TBD5_OE   0x0200

Definition at line 109 of file mk6x_eth_driver.h.

◆ ENET_TBD5_TSE

#define ENET_TBD5_TSE   0x0100

Definition at line 110 of file mk6x_eth_driver.h.

◆ ENET_TBD5_TXE

#define ENET_TBD5_TXE   0x8000

Definition at line 104 of file mk6x_eth_driver.h.

◆ ENET_TBD5_UE

#define ENET_TBD5_UE   0x2000

Definition at line 105 of file mk6x_eth_driver.h.

◆ ENET_TBD8_BDU

#define ENET_TBD8_BDU   0x8000

Definition at line 111 of file mk6x_eth_driver.h.

◆ MK6X_ETH_IRQ_GROUP_PRIORITY

#define MK6X_ETH_IRQ_GROUP_PRIORITY   12

Definition at line 69 of file mk6x_eth_driver.h.

◆ MK6X_ETH_IRQ_PRIORITY_GROUPING

#define MK6X_ETH_IRQ_PRIORITY_GROUPING   3

Definition at line 62 of file mk6x_eth_driver.h.

◆ MK6X_ETH_IRQ_SUB_PRIORITY

#define MK6X_ETH_IRQ_SUB_PRIORITY   0

Definition at line 76 of file mk6x_eth_driver.h.

◆ MK6X_ETH_RX_BUFFER_COUNT

#define MK6X_ETH_RX_BUFFER_COUNT   6

Definition at line 48 of file mk6x_eth_driver.h.

◆ MK6X_ETH_RX_BUFFER_SIZE

#define MK6X_ETH_RX_BUFFER_SIZE   1536

Definition at line 55 of file mk6x_eth_driver.h.

◆ MK6X_ETH_TX_BUFFER_COUNT

#define MK6X_ETH_TX_BUFFER_COUNT   3

Definition at line 34 of file mk6x_eth_driver.h.

◆ MK6X_ETH_TX_BUFFER_SIZE

#define MK6X_ETH_TX_BUFFER_SIZE   1536

Definition at line 41 of file mk6x_eth_driver.h.

◆ MPU

#define MPU   SYSMPU

Definition at line 83 of file mk6x_eth_driver.h.

◆ MPU_CESR_VLD_MASK

#define MPU_CESR_VLD_MASK   SYSMPU_CESR_VLD_MASK

Definition at line 87 of file mk6x_eth_driver.h.

Function Documentation

◆ mk6xEthCalcCrc()

uint32_t mk6xEthCalcCrc ( 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 996 of file mk6x_eth_driver.c.

◆ mk6xEthDisableIrq()

void mk6xEthDisableIrq ( NetInterface interface)

Disable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 493 of file mk6x_eth_driver.c.

◆ mk6xEthEnableIrq()

void mk6xEthEnableIrq ( NetInterface interface)

Enable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 476 of file mk6x_eth_driver.c.

◆ mk6xEthEventHandler()

void mk6xEthEventHandler ( NetInterface interface)

Kinetis K6x Ethernet MAC event handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 608 of file mk6x_eth_driver.c.

◆ mk6xEthInit()

error_t mk6xEthInit ( NetInterface interface)

Kinetis K6x Ethernet MAC initialization.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 131 of file mk6x_eth_driver.c.

◆ mk6xEthInitBufferDesc()

void mk6xEthInitBufferDesc ( NetInterface interface)

Initialize buffer descriptors.

Parameters
[in]interfaceUnderlying network interface

Definition at line 401 of file mk6x_eth_driver.c.

◆ mk6xEthInitGpio()

void mk6xEthInitGpio ( NetInterface interface)

◆ mk6xEthReadPhyReg()

uint16_t mk6xEthReadPhyReg ( uint8_t  phyAddr,
uint8_t  regAddr 
)

Read PHY register.

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

Definition at line 966 of file mk6x_eth_driver.c.

◆ mk6xEthReceivePacket()

error_t mk6xEthReceivePacket ( NetInterface interface)

Receive a packet.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 731 of file mk6x_eth_driver.c.

◆ mk6xEthSendPacket()

error_t mk6xEthSendPacket ( 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 661 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

Parameters
[in]interfaceUnderlying network interface

Definition at line 464 of file mk6x_eth_driver.c.

◆ mk6xEthUpdateMacAddrFilter()

error_t mk6xEthUpdateMacAddrFilter ( NetInterface interface)

Configure MAC address filtering.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 808 of file mk6x_eth_driver.c.

◆ mk6xEthUpdateMacConfig()

error_t mk6xEthUpdateMacConfig ( NetInterface interface)

Adjust MAC configuration parameters for proper operation.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 884 of file mk6x_eth_driver.c.

◆ mk6xEthWritePhyReg()

void mk6xEthWritePhyReg ( 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 937 of file mk6x_eth_driver.c.

Variable Documentation

◆ mk6xEthDriver

const NicDriver mk6xEthDriver

Kinetis K6x Ethernet MAC driver.

Definition at line 104 of file mk6x_eth_driver.c.