Webserver+3d print

Dependents:   Nucleo

Committer:
Sergunb
Date:
Sat Feb 04 18:15:49 2017 +0000
Revision:
0:8918a71cdbe9
nothing else

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sergunb 0:8918a71cdbe9 1 /**
Sergunb 0:8918a71cdbe9 2 * @file mk6x_eth.h
Sergunb 0:8918a71cdbe9 3 * @brief Freescale Kinetis K60/K64/K65/K66 Ethernet MAC controller
Sergunb 0:8918a71cdbe9 4 *
Sergunb 0:8918a71cdbe9 5 * @section License
Sergunb 0:8918a71cdbe9 6 *
Sergunb 0:8918a71cdbe9 7 * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
Sergunb 0:8918a71cdbe9 8 *
Sergunb 0:8918a71cdbe9 9 * This file is part of CycloneTCP Open.
Sergunb 0:8918a71cdbe9 10 *
Sergunb 0:8918a71cdbe9 11 * This program is free software; you can redistribute it and/or
Sergunb 0:8918a71cdbe9 12 * modify it under the terms of the GNU General Public License
Sergunb 0:8918a71cdbe9 13 * as published by the Free Software Foundation; either version 2
Sergunb 0:8918a71cdbe9 14 * of the License, or (at your option) any later version.
Sergunb 0:8918a71cdbe9 15 *
Sergunb 0:8918a71cdbe9 16 * This program is distributed in the hope that it will be useful,
Sergunb 0:8918a71cdbe9 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Sergunb 0:8918a71cdbe9 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Sergunb 0:8918a71cdbe9 19 * GNU General Public License for more details.
Sergunb 0:8918a71cdbe9 20 *
Sergunb 0:8918a71cdbe9 21 * You should have received a copy of the GNU General Public License
Sergunb 0:8918a71cdbe9 22 * along with this program; if not, write to the Free Software Foundation,
Sergunb 0:8918a71cdbe9 23 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Sergunb 0:8918a71cdbe9 24 *
Sergunb 0:8918a71cdbe9 25 * @author Oryx Embedded SARL (www.oryx-embedded.com)
Sergunb 0:8918a71cdbe9 26 * @version 1.7.6
Sergunb 0:8918a71cdbe9 27 **/
Sergunb 0:8918a71cdbe9 28
Sergunb 0:8918a71cdbe9 29 #ifndef _MK6X_ETH_H
Sergunb 0:8918a71cdbe9 30 #define _MK6X_ETH_H
Sergunb 0:8918a71cdbe9 31
Sergunb 0:8918a71cdbe9 32 //Number of TX buffers
Sergunb 0:8918a71cdbe9 33 #ifndef MK6X_ETH_TX_BUFFER_COUNT
Sergunb 0:8918a71cdbe9 34 #define MK6X_ETH_TX_BUFFER_COUNT 3
Sergunb 0:8918a71cdbe9 35 #elif (MK6X_ETH_TX_BUFFER_COUNT < 1)
Sergunb 0:8918a71cdbe9 36 #error MK6X_ETH_TX_BUFFER_COUNT parameter is not valid
Sergunb 0:8918a71cdbe9 37 #endif
Sergunb 0:8918a71cdbe9 38
Sergunb 0:8918a71cdbe9 39 //TX buffer size
Sergunb 0:8918a71cdbe9 40 #ifndef MK6X_ETH_TX_BUFFER_SIZE
Sergunb 0:8918a71cdbe9 41 #define MK6X_ETH_TX_BUFFER_SIZE 1536
Sergunb 0:8918a71cdbe9 42 #elif (MK6X_ETH_TX_BUFFER_SIZE != 1536)
Sergunb 0:8918a71cdbe9 43 #error MK6X_ETH_TX_BUFFER_SIZE parameter is not valid
Sergunb 0:8918a71cdbe9 44 #endif
Sergunb 0:8918a71cdbe9 45
Sergunb 0:8918a71cdbe9 46 //Number of RX buffers
Sergunb 0:8918a71cdbe9 47 #ifndef MK6X_ETH_RX_BUFFER_COUNT
Sergunb 0:8918a71cdbe9 48 #define MK6X_ETH_RX_BUFFER_COUNT 6
Sergunb 0:8918a71cdbe9 49 #elif (MK6X_ETH_RX_BUFFER_COUNT < 1)
Sergunb 0:8918a71cdbe9 50 #error MK6X_ETH_RX_BUFFER_COUNT parameter is not valid
Sergunb 0:8918a71cdbe9 51 #endif
Sergunb 0:8918a71cdbe9 52
Sergunb 0:8918a71cdbe9 53 //RX buffer size
Sergunb 0:8918a71cdbe9 54 #ifndef MK6X_ETH_RX_BUFFER_SIZE
Sergunb 0:8918a71cdbe9 55 #define MK6X_ETH_RX_BUFFER_SIZE 1536
Sergunb 0:8918a71cdbe9 56 #elif (MK6X_ETH_RX_BUFFER_SIZE != 1536)
Sergunb 0:8918a71cdbe9 57 #error MK6X_ETH_RX_BUFFER_SIZE parameter is not valid
Sergunb 0:8918a71cdbe9 58 #endif
Sergunb 0:8918a71cdbe9 59
Sergunb 0:8918a71cdbe9 60 //Interrupt priority grouping
Sergunb 0:8918a71cdbe9 61 #ifndef MK6X_ETH_IRQ_PRIORITY_GROUPING
Sergunb 0:8918a71cdbe9 62 #define MK6X_ETH_IRQ_PRIORITY_GROUPING 3
Sergunb 0:8918a71cdbe9 63 #elif (MK6X_ETH_IRQ_PRIORITY_GROUPING < 0)
Sergunb 0:8918a71cdbe9 64 #error MK6X_ETH_IRQ_PRIORITY_GROUPING parameter is not valid
Sergunb 0:8918a71cdbe9 65 #endif
Sergunb 0:8918a71cdbe9 66
Sergunb 0:8918a71cdbe9 67 //Ethernet interrupt group priority
Sergunb 0:8918a71cdbe9 68 #ifndef MK6X_ETH_IRQ_GROUP_PRIORITY
Sergunb 0:8918a71cdbe9 69 #define MK6X_ETH_IRQ_GROUP_PRIORITY 12
Sergunb 0:8918a71cdbe9 70 #elif (MK6X_ETH_IRQ_GROUP_PRIORITY < 0)
Sergunb 0:8918a71cdbe9 71 #error MK6X_ETH_IRQ_GROUP_PRIORITY parameter is not valid
Sergunb 0:8918a71cdbe9 72 #endif
Sergunb 0:8918a71cdbe9 73
Sergunb 0:8918a71cdbe9 74 //Ethernet interrupt subpriority
Sergunb 0:8918a71cdbe9 75 #ifndef MK6X_ETH_IRQ_SUB_PRIORITY
Sergunb 0:8918a71cdbe9 76 #define MK6X_ETH_IRQ_SUB_PRIORITY 0
Sergunb 0:8918a71cdbe9 77 #elif (MK6X_ETH_IRQ_SUB_PRIORITY < 0)
Sergunb 0:8918a71cdbe9 78 #error MK6X_ETH_IRQ_SUB_PRIORITY parameter is not valid
Sergunb 0:8918a71cdbe9 79 #endif
Sergunb 0:8918a71cdbe9 80
Sergunb 0:8918a71cdbe9 81 //Enhanced transmit buffer descriptor
Sergunb 0:8918a71cdbe9 82 #define ENET_TBD0_R 0x8000
Sergunb 0:8918a71cdbe9 83 #define ENET_TBD0_TO1 0x4000
Sergunb 0:8918a71cdbe9 84 #define ENET_TBD0_W 0x2000
Sergunb 0:8918a71cdbe9 85 #define ENET_TBD0_TO2 0x1000
Sergunb 0:8918a71cdbe9 86 #define ENET_TBD0_L 0x0800
Sergunb 0:8918a71cdbe9 87 #define ENET_TBD0_TC 0x0400
Sergunb 0:8918a71cdbe9 88 #define ENET_TBD1_DATA_LENGTH 0xFFFF
Sergunb 0:8918a71cdbe9 89 #define ENET_TBD2_DATA_POINTER_H 0xFFFF
Sergunb 0:8918a71cdbe9 90 #define ENET_TBD3_DATA_POINTER_L 0xFFFF
Sergunb 0:8918a71cdbe9 91 #define ENET_TBD4_INT 0x4000
Sergunb 0:8918a71cdbe9 92 #define ENET_TBD4_TS 0x2000
Sergunb 0:8918a71cdbe9 93 #define ENET_TBD4_PINS 0x1000
Sergunb 0:8918a71cdbe9 94 #define ENET_TBD4_IINS 0x0800
Sergunb 0:8918a71cdbe9 95 #define ENET_TBD5_TXE 0x8000
Sergunb 0:8918a71cdbe9 96 #define ENET_TBD5_UE 0x2000
Sergunb 0:8918a71cdbe9 97 #define ENET_TBD5_EE 0x1000
Sergunb 0:8918a71cdbe9 98 #define ENET_TBD5_FE 0x0800
Sergunb 0:8918a71cdbe9 99 #define ENET_TBD5_LCE 0x0400
Sergunb 0:8918a71cdbe9 100 #define ENET_TBD5_OE 0x0200
Sergunb 0:8918a71cdbe9 101 #define ENET_TBD5_TSE 0x0100
Sergunb 0:8918a71cdbe9 102 #define ENET_TBD8_BDU 0x8000
Sergunb 0:8918a71cdbe9 103 #define ENET_TBD10_TIMESTAMP_H 0xFFFF
Sergunb 0:8918a71cdbe9 104 #define ENET_TBD11_TIMESTAMP_L 0xFFFF
Sergunb 0:8918a71cdbe9 105
Sergunb 0:8918a71cdbe9 106 //Enhanced receive buffer descriptor
Sergunb 0:8918a71cdbe9 107 #define ENET_RBD0_E 0x8000
Sergunb 0:8918a71cdbe9 108 #define ENET_RBD0_RO1 0x4000
Sergunb 0:8918a71cdbe9 109 #define ENET_RBD0_W 0x2000
Sergunb 0:8918a71cdbe9 110 #define ENET_RBD0_RO2 0x1000
Sergunb 0:8918a71cdbe9 111 #define ENET_RBD0_L 0x0800
Sergunb 0:8918a71cdbe9 112 #define ENET_RBD0_M 0x0100
Sergunb 0:8918a71cdbe9 113 #define ENET_RBD0_BC 0x0080
Sergunb 0:8918a71cdbe9 114 #define ENET_RBD0_MC 0x0040
Sergunb 0:8918a71cdbe9 115 #define ENET_RBD0_LG 0x0020
Sergunb 0:8918a71cdbe9 116 #define ENET_RBD0_NO 0x0010
Sergunb 0:8918a71cdbe9 117 #define ENET_RBD0_CR 0x0004
Sergunb 0:8918a71cdbe9 118 #define ENET_RBD0_OV 0x0002
Sergunb 0:8918a71cdbe9 119 #define ENET_RBD0_TR 0x0001
Sergunb 0:8918a71cdbe9 120 #define ENET_RBD1_DATA_LENGTH 0xFFFF
Sergunb 0:8918a71cdbe9 121 #define ENET_RBD2_DATA_POINTER_H 0xFFFF
Sergunb 0:8918a71cdbe9 122 #define ENET_RBD3_DATA_POINTER_L 0xFFFF
Sergunb 0:8918a71cdbe9 123 #define ENET_RBD4_ME 0x8000
Sergunb 0:8918a71cdbe9 124 #define ENET_RBD4_PE 0x0400
Sergunb 0:8918a71cdbe9 125 #define ENET_RBD4_CE 0x0200
Sergunb 0:8918a71cdbe9 126 #define ENET_RBD4_UC 0x0100
Sergunb 0:8918a71cdbe9 127 #define ENET_RBD4_INT 0x0080
Sergunb 0:8918a71cdbe9 128 #define ENET_RBD5_VPCP 0xE000
Sergunb 0:8918a71cdbe9 129 #define ENET_RBD5_ICE 0x0020
Sergunb 0:8918a71cdbe9 130 #define ENET_RBD5_PCR 0x0010
Sergunb 0:8918a71cdbe9 131 #define ENET_RBD5_VLAN 0x0004
Sergunb 0:8918a71cdbe9 132 #define ENET_RBD5_IPV6 0x0002
Sergunb 0:8918a71cdbe9 133 #define ENET_RBD5_FRAG 0x0001
Sergunb 0:8918a71cdbe9 134 #define ENET_RBD6_HEADER_LENGTH 0xF800
Sergunb 0:8918a71cdbe9 135 #define ENET_RBD6_PROTOCOL_TYPE 0x00FF
Sergunb 0:8918a71cdbe9 136 #define ENET_RBD7_PAYLOAD_CHECKSUM 0xFFFF
Sergunb 0:8918a71cdbe9 137 #define ENET_RBD8_BDU 0x8000
Sergunb 0:8918a71cdbe9 138 #define ENET_RBD10_TIMESTAMP_H 0xFFFF
Sergunb 0:8918a71cdbe9 139 #define ENET_RBD11_TIMESTAMP_L 0xFFFF
Sergunb 0:8918a71cdbe9 140
Sergunb 0:8918a71cdbe9 141 //Kinetis K6x Ethernet MAC driver
Sergunb 0:8918a71cdbe9 142 extern const NicDriver mk6xEthDriver;
Sergunb 0:8918a71cdbe9 143
Sergunb 0:8918a71cdbe9 144 //Kinetis K6x Ethernet MAC related functions
Sergunb 0:8918a71cdbe9 145 error_t mk6xEthInit(NetInterface *interface);
Sergunb 0:8918a71cdbe9 146 void mk6xEthInitGpio(NetInterface *interface);
Sergunb 0:8918a71cdbe9 147 void mk6xEthInitBufferDesc(NetInterface *interface);
Sergunb 0:8918a71cdbe9 148
Sergunb 0:8918a71cdbe9 149 void mk6xEthTick(NetInterface *interface);
Sergunb 0:8918a71cdbe9 150
Sergunb 0:8918a71cdbe9 151 void mk6xEthEnableIrq(NetInterface *interface);
Sergunb 0:8918a71cdbe9 152 void mk6xEthDisableIrq(NetInterface *interface);
Sergunb 0:8918a71cdbe9 153 void mk6xEthEventHandler(NetInterface *interface);
Sergunb 0:8918a71cdbe9 154
Sergunb 0:8918a71cdbe9 155 error_t mk6xEthSendPacket(NetInterface *interface,
Sergunb 0:8918a71cdbe9 156 const NetBuffer *buffer, size_t offset);
Sergunb 0:8918a71cdbe9 157
Sergunb 0:8918a71cdbe9 158 error_t mk6xEthReceivePacket(NetInterface *interface);
Sergunb 0:8918a71cdbe9 159
Sergunb 0:8918a71cdbe9 160 error_t mk6xEthSetMulticastFilter(NetInterface *interface);
Sergunb 0:8918a71cdbe9 161 error_t mk6xEthUpdateMacConfig(NetInterface *interface);
Sergunb 0:8918a71cdbe9 162
Sergunb 0:8918a71cdbe9 163 void mk6xEthWritePhyReg(uint8_t phyAddr, uint8_t regAddr, uint16_t data);
Sergunb 0:8918a71cdbe9 164 uint16_t mk6xEthReadPhyReg(uint8_t phyAddr, uint8_t regAddr);
Sergunb 0:8918a71cdbe9 165
Sergunb 0:8918a71cdbe9 166 uint32_t mk6xEthCalcCrc(const void *data, size_t length);
Sergunb 0:8918a71cdbe9 167
Sergunb 0:8918a71cdbe9 168 #endif
Sergunb 0:8918a71cdbe9 169