Embed:
(wiki syntax)
Show/hide line numbers
sam9263_eth.h
Go to the documentation of this file.
00001 /** 00002 * @file sam9263_eth.h 00003 * @brief AT91SAM9263 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 _SAM9263_ETH_H 00030 #define _SAM9263_ETH_H 00031 00032 //Number of TX buffers 00033 #ifndef SAM9263_ETH_TX_BUFFER_COUNT 00034 #define SAM9263_ETH_TX_BUFFER_COUNT 3 00035 #elif (SAM9263_ETH_TX_BUFFER_COUNT < 1) 00036 #error SAM9263_ETH_TX_BUFFER_COUNT parameter is not valid 00037 #endif 00038 00039 //TX buffer size 00040 #ifndef SAM9263_ETH_TX_BUFFER_SIZE 00041 #define SAM9263_ETH_TX_BUFFER_SIZE 1536 00042 #elif (SAM9263_ETH_TX_BUFFER_SIZE != 1536) 00043 #error SAM9263_ETH_TX_BUFFER_SIZE parameter is not valid 00044 #endif 00045 00046 //Number of RX buffers 00047 #ifndef SAM9263_ETH_RX_BUFFER_COUNT 00048 #define SAM9263_ETH_RX_BUFFER_COUNT 72 00049 #elif (SAM9263_ETH_RX_BUFFER_COUNT < 12) 00050 #error SAM9263_ETH_RX_BUFFER_COUNT parameter is not valid 00051 #endif 00052 00053 //RX buffer size 00054 #ifndef SAM9263_ETH_RX_BUFFER_SIZE 00055 #define SAM9263_ETH_RX_BUFFER_SIZE 128 00056 #elif (SAM9263_ETH_RX_BUFFER_SIZE != 128) 00057 #error SAM9263_ETH_RX_BUFFER_SIZE parameter is not valid 00058 #endif 00059 00060 //EMAC controller base address 00061 #define AT91C_BASE_EMAC AT91C_BASE_MACB 00062 00063 //RMII signals 00064 #define AT91C_EMAC_RMII_MASK_C AT91C_PC25_ERXDV 00065 00066 #define AT91C_EMAC_RMII_MASK_E (AT91C_PE30_EMDIO | \ 00067 AT91C_PE29_EMDC | AT91C_PE28_ETXEN | AT91C_PE27_ERXER | AT91C_PE26_ERX1 | \ 00068 AT91C_PE25_ERX0 | AT91C_PE24_ETX1 | AT91C_PE23_ETX0 | AT91C_PE21_ETXCK) 00069 00070 //PHY maintenance register (EMAC_MAN) 00071 #define AT91C_EMAC_SOF_01 (1 << 30) 00072 #define AT91C_EMAC_RW_01 (1 << 28) 00073 #define AT91C_EMAC_RW_10 (2 << 28) 00074 #define AT91C_EMAC_CODE_10 (2 << 16) 00075 00076 //TX buffer descriptor flags 00077 #define AT91C_EMAC_TX_USED 0x80000000 00078 #define AT91C_EMAC_TX_WRAP 0x40000000 00079 #define AT91C_EMAC_TX_ERROR 0x20000000 00080 #define AT91C_EMAC_TX_UNDERRUN 0x10000000 00081 #define AT91C_EMAC_TX_EXHAUSTED 0x08000000 00082 #define AT91C_EMAC_TX_NO_CRC 0x00010000 00083 #define AT91C_EMAC_TX_LAST 0x00008000 00084 #define AT91C_EMAC_TX_LENGTH 0x000007FF 00085 00086 //RX buffer descriptor flags 00087 #define AT91C_EMAC_RX_ADDRESS 0xFFFFFFFC 00088 #define AT91C_EMAC_RX_WRAP 0x00000002 00089 #define AT91C_EMAC_RX_OWNERSHIP 0x00000001 00090 #define AT91C_EMAC_RX_BROADCAST 0x80000000 00091 #define AT91C_EMAC_RX_MULTICAST_HASH 0x40000000 00092 #define AT91C_EMAC_RX_UNICAST_HASH 0x20000000 00093 #define AT91C_EMAC_RX_EXT_ADDR 0x10000000 00094 #define AT91C_EMAC_RX_SAR1 0x04000000 00095 #define AT91C_EMAC_RX_SAR2 0x02000000 00096 #define AT91C_EMAC_RX_SAR3 0x01000000 00097 #define AT91C_EMAC_RX_SAR4 0x00800000 00098 #define AT91C_EMAC_RX_TYPE_ID 0x00400000 00099 #define AT91C_EMAC_RX_VLAN_TAG 0x00200000 00100 #define AT91C_EMAC_RX_PRIORITY_TAG 0x00100000 00101 #define AT91C_EMAC_RX_VLAN_PRIORITY 0x000E0000 00102 #define AT91C_EMAC_RX_CFI 0x00010000 00103 #define AT91C_EMAC_RX_EOF 0x00008000 00104 #define AT91C_EMAC_RX_SOF 0x00004000 00105 #define AT91C_EMAC_RX_OFFSET 0x00003000 00106 #define AT91C_EMAC_RX_LENGTH 0x00000FFF 00107 00108 00109 /** 00110 * @brief Transmit buffer descriptor 00111 **/ 00112 00113 typedef struct 00114 { 00115 uint32_t address; 00116 uint32_t status; 00117 } Sam9263TxBufferDesc; 00118 00119 00120 /** 00121 * @brief Receive buffer descriptor 00122 **/ 00123 00124 typedef struct 00125 { 00126 uint32_t address; 00127 uint32_t status; 00128 } Sam9263RxBufferDesc; 00129 00130 00131 //SAM9263 Ethernet MAC driver 00132 extern const NicDriver sam9263EthDriver; 00133 00134 //SAM9263 Ethernet MAC related functions 00135 error_t sam9263EthInit(NetInterface *interface); 00136 void sam9263EthInitGpio(NetInterface *interface); 00137 void sam9263EthInitBufferDesc(NetInterface *interface); 00138 00139 void sam9263EthTick(NetInterface *interface); 00140 00141 void sam9263EthEnableIrq(NetInterface *interface); 00142 void sam9263EthDisableIrq(NetInterface *interface); 00143 void sam9263EthIrqHandler(void); 00144 void sam9263EthEventHandler(NetInterface *interface); 00145 00146 error_t sam9263EthSendPacket(NetInterface *interface, 00147 const NetBuffer *buffer, size_t offset); 00148 00149 error_t sam9263EthReceivePacket(NetInterface *interface); 00150 00151 error_t sam9263EthSetMulticastFilter(NetInterface *interface); 00152 error_t sam9263EthUpdateMacConfig(NetInterface *interface); 00153 00154 void sam9263EthWritePhyReg(uint8_t phyAddr, uint8_t regAddr, uint16_t data); 00155 uint16_t sam9263EthReadPhyReg(uint8_t phyAddr, uint8_t regAddr); 00156 00157 //Wrapper for the interrupt service routine 00158 void emacIrqWrapper(void); 00159 00160 #endif 00161
Generated on Tue Jul 12 2022 17:10:16 by
