Webserver+3d print
Embed:
(wiki syntax)
Show/hide line numbers
sam7x_eth.h
Go to the documentation of this file.
00001 /** 00002 * @file sam7x_eth.h 00003 * @brief AT91SAM7X 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 _SAM7X_ETH_H 00030 #define _SAM7X_ETH_H 00031 00032 //Number of TX buffers 00033 #ifndef SAM7X_ETH_TX_BUFFER_COUNT 00034 #define SAM7X_ETH_TX_BUFFER_COUNT 2 00035 #elif (SAM7X_ETH_TX_BUFFER_COUNT < 1) 00036 #error SAM7X_ETH_TX_BUFFER_COUNT parameter is not valid 00037 #endif 00038 00039 //TX buffer size 00040 #ifndef SAM7X_ETH_TX_BUFFER_SIZE 00041 #define SAM7X_ETH_TX_BUFFER_SIZE 1536 00042 #elif (SAM7X_ETH_TX_BUFFER_SIZE != 1536) 00043 #error SAM7X_ETH_TX_BUFFER_SIZE parameter is not valid 00044 #endif 00045 00046 //Number of RX buffers 00047 #ifndef SAM7X_ETH_RX_BUFFER_COUNT 00048 #define SAM7X_ETH_RX_BUFFER_COUNT 48 00049 #elif (SAM7X_ETH_RX_BUFFER_COUNT < 12) 00050 #error SAM7X_ETH_RX_BUFFER_COUNT parameter is not valid 00051 #endif 00052 00053 //RX buffer size 00054 #ifndef SAM7X_ETH_RX_BUFFER_SIZE 00055 #define SAM7X_ETH_RX_BUFFER_SIZE 128 00056 #elif (SAM7X_ETH_RX_BUFFER_SIZE != 128) 00057 #error SAM7X_ETH_RX_BUFFER_SIZE parameter is not valid 00058 #endif 00059 00060 //MII signals 00061 #define AT91C_EMAC_MII_MASK (AT91C_PB17_ERXCK | AT91C_PB16_ECOL | \ 00062 AT91C_PB15_ERXDV_ECRSDV | AT91C_PB14_ERX3 | AT91C_PB13_ERX2 | AT91C_PB12_ETXER | \ 00063 AT91C_PB11_ETX3 | AT91C_PB10_ETX2 | AT91C_PB9_EMDIO | AT91C_PB8_EMDC | \ 00064 AT91C_PB7_ERXER | AT91C_PB6_ERX1 | AT91C_PB5_ERX0 | AT91C_PB4_ECRS | \ 00065 AT91C_PB3_ETX1 | AT91C_PB2_ETX0 | AT91C_PB1_ETXEN | AT91C_PB0_ETXCK_EREFCK) 00066 00067 //PHY maintenance register (EMAC_MAN) 00068 #define AT91C_EMAC_SOF_01 (1 << 30) 00069 #define AT91C_EMAC_RW_01 (1 << 28) 00070 #define AT91C_EMAC_RW_10 (2 << 28) 00071 #define AT91C_EMAC_CODE_10 (2 << 16) 00072 00073 //TX buffer descriptor flags 00074 #define AT91C_EMAC_TX_USED 0x80000000 00075 #define AT91C_EMAC_TX_WRAP 0x40000000 00076 #define AT91C_EMAC_TX_ERROR 0x20000000 00077 #define AT91C_EMAC_TX_UNDERRUN 0x10000000 00078 #define AT91C_EMAC_TX_EXHAUSTED 0x08000000 00079 #define AT91C_EMAC_TX_NO_CRC 0x00010000 00080 #define AT91C_EMAC_TX_LAST 0x00008000 00081 #define AT91C_EMAC_TX_LENGTH 0x000007FF 00082 00083 //RX buffer descriptor flags 00084 #define AT91C_EMAC_RX_ADDRESS 0xFFFFFFFC 00085 #define AT91C_EMAC_RX_WRAP 0x00000002 00086 #define AT91C_EMAC_RX_OWNERSHIP 0x00000001 00087 #define AT91C_EMAC_RX_BROADCAST 0x80000000 00088 #define AT91C_EMAC_RX_MULTICAST_HASH 0x40000000 00089 #define AT91C_EMAC_RX_UNICAST_HASH 0x20000000 00090 #define AT91C_EMAC_RX_EXT_ADDR 0x10000000 00091 #define AT91C_EMAC_RX_SAR1 0x04000000 00092 #define AT91C_EMAC_RX_SAR2 0x02000000 00093 #define AT91C_EMAC_RX_SAR3 0x01000000 00094 #define AT91C_EMAC_RX_SAR4 0x00800000 00095 #define AT91C_EMAC_RX_TYPE_ID 0x00400000 00096 #define AT91C_EMAC_RX_VLAN_TAG 0x00200000 00097 #define AT91C_EMAC_RX_PRIORITY_TAG 0x00100000 00098 #define AT91C_EMAC_RX_VLAN_PRIORITY 0x000E0000 00099 #define AT91C_EMAC_RX_CFI 0x00010000 00100 #define AT91C_EMAC_RX_EOF 0x00008000 00101 #define AT91C_EMAC_RX_SOF 0x00004000 00102 #define AT91C_EMAC_RX_OFFSET 0x00003000 00103 #define AT91C_EMAC_RX_LENGTH 0x00000FFF 00104 00105 00106 /** 00107 * @brief Transmit buffer descriptor 00108 **/ 00109 00110 typedef struct 00111 { 00112 uint32_t address; 00113 uint32_t status; 00114 } Sam7xTxBufferDesc; 00115 00116 00117 /** 00118 * @brief Receive buffer descriptor 00119 **/ 00120 00121 typedef struct 00122 { 00123 uint32_t address; 00124 uint32_t status; 00125 } Sam7xRxBufferDesc; 00126 00127 00128 //SAM7X Ethernet MAC driver 00129 extern const NicDriver sam7xEthDriver; 00130 00131 //SAM7X Ethernet MAC related functions 00132 error_t sam7xEthInit(NetInterface *interface); 00133 void sam7xEthInitGpio(NetInterface *interface); 00134 void sam7xEthInitBufferDesc(NetInterface *interface); 00135 00136 void sam7xEthTick(NetInterface *interface); 00137 00138 void sam7xEthEnableIrq(NetInterface *interface); 00139 void sam7xEthDisableIrq(NetInterface *interface); 00140 void sam7xEthIrqHandler(void); 00141 void sam7xEthEventHandler(NetInterface *interface); 00142 00143 error_t sam7xEthSendPacket(NetInterface *interface, 00144 const NetBuffer *buffer, size_t offset); 00145 00146 error_t sam7xEthReceivePacket(NetInterface *interface); 00147 00148 error_t sam7xEthSetMulticastFilter(NetInterface *interface); 00149 error_t sam7xEthUpdateMacConfig(NetInterface *interface); 00150 00151 void sam7xEthWritePhyReg(uint8_t phyAddr, uint8_t regAddr, uint16_t data); 00152 uint16_t sam7xEthReadPhyReg(uint8_t phyAddr, uint8_t regAddr); 00153 00154 //Wrapper for the interrupt service routine 00155 void emacIrqWrapper(void); 00156 00157 #endif 00158
Generated on Tue Jul 12 2022 17:10:16 by
