1 //***************************************************************************** 2 // 3 // ethernet.h - Defines and Macros for the ethernet module. 4 // 5 // Copyright (c) 2006-2012 Texas Instruments Incorporated. All rights reserved. 6 // Software License Agreement 7 // 8 // Redistribution and use in source and binary forms, with or without 9 // modification, are permitted provided that the following conditions 10 // are met: 11 // 12 // Redistributions of source code must retain the above copyright 13 // notice, this list of conditions and the following disclaimer. 14 // 15 // Redistributions in binary form must reproduce the above copyright 16 // notice, this list of conditions and the following disclaimer in the 17 // documentation and/or other materials provided with the 18 // distribution. 19 // 20 // Neither the name of Texas Instruments Incorporated nor the names of 21 // its contributors may be used to endorse or promote products derived 22 // from this software without specific prior written permission. 23 // 24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 // 36 // This is part of revision 9453 of the Stellaris Peripheral Driver Library. 37 // 38 //***************************************************************************** 39 40 #ifndef __ETHERNET_H__ 41 #define __ETHERNET_H__ 42 43 //***************************************************************************** 44 // 45 // If building with a C++ compiler, make all of the definitions in this header 46 // have a C binding. 47 // 48 //***************************************************************************** 49 #ifdef __cplusplus 50 extern "C" 51 { 52 #endif 53 54 //***************************************************************************** 55 // 56 // Values that can be passed to EthernetConfigSet as the ulConfig value, and 57 // returned from EthernetConfigGet. 58 // 59 //***************************************************************************** 60 #define ETH_CFG_TS_TSEN 0x010000 // Enable Timestamp (CCP) 61 #define ETH_CFG_RX_BADCRCDIS 0x000800 // Disable RX BAD CRC Packets 62 #define ETH_CFG_RX_PRMSEN 0x000400 // Enable RX Promiscuous 63 #define ETH_CFG_RX_AMULEN 0x000200 // Enable RX Multicast 64 #define ETH_CFG_TX_DPLXEN 0x000010 // Enable TX Duplex Mode 65 #define ETH_CFG_TX_CRCEN 0x000004 // Enable TX CRC Generation 66 #define ETH_CFG_TX_PADEN 0x000002 // Enable TX Padding 67 68 //***************************************************************************** 69 // 70 // Values that can be passed to EthernetIntEnable, EthernetIntDisable, and 71 // EthernetIntClear as the ulIntFlags parameter, and returned from 72 // EthernetIntStatus. 73 // 74 //***************************************************************************** 75 #define ETH_INT_PHY 0x040 // PHY Event/Interrupt 76 #define ETH_INT_MDIO 0x020 // Management Transaction 77 #define ETH_INT_RXER 0x010 // RX Error 78 #define ETH_INT_RXOF 0x008 // RX FIFO Overrun 79 #define ETH_INT_TX 0x004 // TX Complete 80 #define ETH_INT_TXER 0x002 // TX Error 81 #define ETH_INT_RX 0x001 // RX Complete 82 83 //***************************************************************************** 84 // 85 // Helper Macros for Ethernet Processing 86 // 87 //***************************************************************************** 88 // 89 // htonl/ntohl - big endian/little endian byte swapping macros for 90 // 32-bit (long) values 91 // 92 //***************************************************************************** 93 #ifndef htonl 94 #define htonl(a) \ 95 ((((a) >> 24) & 0x000000ff) | \ 96 (((a) >> 8) & 0x0000ff00) | \ 97 (((a) << 8) & 0x00ff0000) | \ 98 (((a) << 24) & 0xff000000)) 99 #endif 100 101 #ifndef ntohl 102 #define ntohl(a) htonl((a)) 103 #endif 104 105 //***************************************************************************** 106 // 107 // htons/ntohs - big endian/little endian byte swapping macros for 108 // 16-bit (short) values 109 // 110 //***************************************************************************** 111 #ifndef htons 112 #define htons(a) \ 113 ((((a) >> 8) & 0x00ff) | \ 114 (((a) << 8) & 0xff00)) 115 #endif 116 117 #ifndef ntohs 118 #define ntohs(a) htons((a)) 119 #endif 120 121 //***************************************************************************** 122 // 123 // API Function prototypes 124 // 125 //***************************************************************************** 126 extern void EthernetInitExpClk(unsigned long ulBase, unsigned long ulEthClk); 127 extern void EthernetConfigSet(unsigned long ulBase, unsigned long ulConfig); 128 extern unsigned long EthernetConfigGet(unsigned long ulBase); 129 extern void EthernetMACAddrSet(unsigned long ulBase, 130 unsigned char *pucMACAddr); 131 extern void EthernetMACAddrGet(unsigned long ulBase, 132 unsigned char *pucMACAddr); 133 extern void EthernetEnable(unsigned long ulBase); 134 extern void EthernetDisable(unsigned long ulBase); 135 extern tBoolean EthernetPacketAvail(unsigned long ulBase); 136 extern tBoolean EthernetSpaceAvail(unsigned long ulBase); 137 extern long EthernetPacketGetNonBlocking(unsigned long ulBase, 138 unsigned char *pucBuf, 139 long lBufLen); 140 extern long EthernetPacketGet(unsigned long ulBase, unsigned char *pucBuf, 141 long lBufLen); 142 extern long EthernetPacketPutNonBlocking(unsigned long ulBase, 143 unsigned char *pucBuf, 144 long lBufLen); 145 extern long EthernetPacketPut(unsigned long ulBase, unsigned char *pucBuf, 146 long lBufLen); 147 extern void EthernetIntRegister(unsigned long ulBase, 148 void (*pfnHandler)(void)); 149 extern void EthernetIntUnregister(unsigned long ulBase); 150 extern void EthernetIntEnable(unsigned long ulBase, unsigned long ulIntFlags); 151 extern void EthernetIntDisable(unsigned long ulBase, unsigned long ulIntFlags); 152 extern unsigned long EthernetIntStatus(unsigned long ulBase, tBoolean bMasked); 153 extern void EthernetIntClear(unsigned long ulBase, unsigned long ulIntFlags); 154 extern void EthernetPHYAddrSet(unsigned long ulBase, unsigned char ucAddr); 155 extern void EthernetPHYWrite(unsigned long ulBase, unsigned char ucRegAddr, 156 unsigned long ulData); 157 extern unsigned long EthernetPHYRead(unsigned long ulBase, 158 unsigned char ucRegAddr); 159 extern void EthernetPHYPowerOff(unsigned long ulBase); 160 extern void EthernetPHYPowerOn(unsigned long ulBase); 161 162 //***************************************************************************** 163 // 164 // Several Ethernet APIs have been renamed, with the original function name 165 // being deprecated. These defines provide backward compatibility. 166 // 167 //***************************************************************************** 168 #ifndef DEPRECATED 169 #include "driverlib/sysctl.h" 170 #define EthernetInit(a) \ 171 EthernetInitExpClk(a, SysCtlClockGet()) 172 #define EthernetPacketNonBlockingGet(a, b, c) \ 173 EthernetPacketGetNonBlocking(a, b, c) 174 #define EthernetPacketNonBlockingPut(a, b, c) \ 175 EthernetPacketPutNonBlocking(a, b, c) 176 #endif 177 178 //***************************************************************************** 179 // 180 // Mark the end of the C bindings section for C++ compilers. 181 // 182 //***************************************************************************** 183 #ifdef __cplusplus 184 } 185 #endif 186 187 #endif // __ETHERNET_H__ 188