Webserver+3d print
Embed:
(wiki syntax)
Show/hide line numbers
samv71_eth.h
Go to the documentation of this file.
00001 /** 00002 * @file samv71_eth.h 00003 * @brief SAMV71 Ethernet MAC controller 00004 * 00005 * @section License 00006 * 00007 * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. 00008 * 00009 * This file is part of CycloneTCP Open. 00010 * 00011 * This program is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU General Public License 00013 * as published by the Free Software Foundation; either version 2 00014 * of the License, or (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program; if not, write to the Free Software Foundation, 00023 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00024 * 00025 * @author Oryx Embedded SARL (www.oryx-embedded.com) 00026 * @version 1.7.6 00027 **/ 00028 00029 #ifndef _SAMV71_ETH_H 00030 #define _SAMV71_ETH_H 00031 00032 //Number of TX buffers 00033 #ifndef SAMV71_ETH_TX_BUFFER_COUNT 00034 #define SAMV71_ETH_TX_BUFFER_COUNT 4 00035 #elif (SAMV71_ETH_TX_BUFFER_COUNT < 1) 00036 #error SAMV71_ETH_TX_BUFFER_COUNT parameter is not valid 00037 #endif 00038 00039 //TX buffer size 00040 #ifndef SAMV71_ETH_TX_BUFFER_SIZE 00041 #define SAMV71_ETH_TX_BUFFER_SIZE 1536 00042 #elif (SAMV71_ETH_TX_BUFFER_SIZE != 1536) 00043 #error SAMV71_ETH_TX_BUFFER_SIZE parameter is not valid 00044 #endif 00045 00046 //Number of RX buffers 00047 #ifndef SAMV71_ETH_RX_BUFFER_COUNT 00048 #define SAMV71_ETH_RX_BUFFER_COUNT 96 00049 #elif (SAMV71_ETH_RX_BUFFER_COUNT < 12) 00050 #error SAMV71_ETH_RX_BUFFER_COUNT parameter is not valid 00051 #endif 00052 00053 //RX buffer size 00054 #ifndef SAMV71_ETH_RX_BUFFER_SIZE 00055 #define SAMV71_ETH_RX_BUFFER_SIZE 128 00056 #elif (SAMV71_ETH_RX_BUFFER_SIZE != 128) 00057 #error SAMV71_ETH_RX_BUFFER_SIZE parameter is not valid 00058 #endif 00059 00060 //Number of dummy buffers 00061 #ifndef SAMV71_ETH_DUMMY_BUFFER_COUNT 00062 #define SAMV71_ETH_DUMMY_BUFFER_COUNT 2 00063 #elif (SAMV71_ETH_DUMMY_BUFFER_COUNT < 1) 00064 #error SAMV71_ETH_DUMMY_BUFFER_COUNT parameter is not valid 00065 #endif 00066 00067 //Dummy buffer size 00068 #ifndef SAMV71_ETH_DUMMY_BUFFER_SIZE 00069 #define SAMV71_ETH_DUMMY_BUFFER_SIZE 128 00070 #elif (SAMV71_ETH_DUMMY_BUFFER_SIZE != 128) 00071 #error SAMV71_ETH_DUMMY_BUFFER_SIZE parameter is not valid 00072 #endif 00073 00074 //Interrupt priority grouping 00075 #ifndef SAMV71_ETH_IRQ_PRIORITY_GROUPING 00076 #define SAMV71_ETH_IRQ_PRIORITY_GROUPING 4 00077 #elif (SAMV71_ETH_IRQ_PRIORITY_GROUPING < 0) 00078 #error SAMV71_ETH_IRQ_PRIORITY_GROUPING parameter is not valid 00079 #endif 00080 00081 //Ethernet interrupt group priority 00082 #ifndef SAMV71_ETH_IRQ_GROUP_PRIORITY 00083 #define SAMV71_ETH_IRQ_GROUP_PRIORITY 6 00084 #elif (SAMV71_ETH_IRQ_GROUP_PRIORITY < 0) 00085 #error SAMV71_ETH_IRQ_GROUP_PRIORITY parameter is not valid 00086 #endif 00087 00088 //Ethernet interrupt subpriority 00089 #ifndef SAMV71_ETH_IRQ_SUB_PRIORITY 00090 #define SAMV71_ETH_IRQ_SUB_PRIORITY 0 00091 #elif (SAMV71_ETH_IRQ_SUB_PRIORITY < 0) 00092 #error SAMV71_ETH_IRQ_SUB_PRIORITY parameter is not valid 00093 #endif 00094 00095 //RMII signals 00096 #define GMAC_RMII_MASK (PIO_PD9A_GMDIO | PIO_PD8A_GMDC | \ 00097 PIO_PD7A_GRXER | PIO_PD6A_GRX1 | PIO_PD5A_GRX0 | PIO_PD4A_GRXDV | \ 00098 PIO_PD3A_GTX1 | PIO_PD2A_GTX0 | PIO_PD1A_GTXEN | PIO_PD0A_GTXCK) 00099 00100 //TX buffer descriptor flags 00101 #define GMAC_TX_USED 0x80000000 00102 #define GMAC_TX_WRAP 0x40000000 00103 #define GMAC_TX_RLE_ERROR 0x20000000 00104 #define GMAC_TX_UNDERRUN_ERROR 0x10000000 00105 #define GMAC_TX_AHB_ERROR 0x08000000 00106 #define GMAC_TX_LATE_COL_ERROR 0x04000000 00107 #define GMAC_TX_CHECKSUM_ERROR 0x00700000 00108 #define GMAC_TX_NO_CRC 0x00010000 00109 #define GMAC_TX_LAST 0x00008000 00110 #define GMAC_TX_LENGTH 0x00003FFF 00111 00112 //RX buffer descriptor flags 00113 #define GMAC_RX_ADDRESS 0xFFFFFFFC 00114 #define GMAC_RX_WRAP 0x00000002 00115 #define GMAC_RX_OWNERSHIP 0x00000001 00116 #define GMAC_RX_BROADCAST 0x80000000 00117 #define GMAC_RX_MULTICAST_HASH 0x40000000 00118 #define GMAC_RX_UNICAST_HASH 0x20000000 00119 #define GMAC_RX_SAR 0x08000000 00120 #define GMAC_RX_SAR_MASK 0x06000000 00121 #define GMAC_RX_TYPE_ID 0x01000000 00122 #define GMAC_RX_SNAP 0x01000000 00123 #define GMAC_RX_TYPE_ID_MASK 0x00C00000 00124 #define GMAC_RX_CHECKSUM_VALID 0x00C00000 00125 #define GMAC_RX_VLAN_TAG 0x00200000 00126 #define GMAC_RX_PRIORITY_TAG 0x00100000 00127 #define GMAC_RX_VLAN_PRIORITY 0x000E0000 00128 #define GMAC_RX_CFI 0x00010000 00129 #define GMAC_RX_EOF 0x00008000 00130 #define GMAC_RX_SOF 0x00004000 00131 #define GMAC_RX_LENGTH_MSB 0x00002000 00132 #define GMAC_RX_BAD_FCS 0x00002000 00133 #define GMAC_RX_LENGTH 0x00001FFF 00134 00135 00136 /** 00137 * @brief Transmit buffer descriptor 00138 **/ 00139 00140 typedef struct 00141 { 00142 uint32_t address; 00143 uint32_t status; 00144 } Samv71TxBufferDesc; 00145 00146 00147 /** 00148 * @brief Receive buffer descriptor 00149 **/ 00150 00151 typedef struct 00152 { 00153 uint32_t address; 00154 uint32_t status; 00155 } Samv71RxBufferDesc; 00156 00157 00158 //SAMV71 Ethernet MAC driver 00159 extern const NicDriver samv71EthDriver; 00160 00161 //SAMV71 Ethernet MAC related functions 00162 error_t samv71EthInit(NetInterface *interface); 00163 void samv71EthInitGpio(NetInterface *interface); 00164 void samv71EthInitBufferDesc(NetInterface *interface); 00165 00166 void samv71EthTick(NetInterface *interface); 00167 00168 void samv71EthEnableIrq(NetInterface *interface); 00169 void samv71EthDisableIrq(NetInterface *interface); 00170 void samv71EthEventHandler(NetInterface *interface); 00171 00172 error_t samv71EthSendPacket(NetInterface *interface, 00173 const NetBuffer *buffer, size_t offset); 00174 00175 error_t samv71EthReceivePacket(NetInterface *interface); 00176 00177 error_t samv71EthSetMulticastFilter(NetInterface *interface); 00178 error_t samv71EthUpdateMacConfig(NetInterface *interface); 00179 00180 void samv71EthWritePhyReg(uint8_t phyAddr, uint8_t regAddr, uint16_t data); 00181 uint16_t samv71EthReadPhyReg(uint8_t phyAddr, uint8_t regAddr); 00182 00183 #endif 00184
Generated on Tue Jul 12 2022 17:10:16 by
