1 //***************************************************************************** 2 // 3 // ethernet.h - Defines and Macros for the ethernet module. 4 // 5 // Copyright (c) 2006-2011 Texas Instruments Incorporated. All rights reserved. 6 // Software License Agreement 7 // 8 // Texas Instruments (TI) is supplying this software for use solely and 9 // exclusively on TI's microcontroller products. The software is owned by 10 // TI and/or its suppliers, and is protected under applicable copyright 11 // laws. You may not combine this software with "viral" open-source 12 // software in order to form a larger program. 13 // 14 // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. 15 // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT 16 // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY 18 // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL 19 // DAMAGES, FOR ANY REASON WHATSOEVER. 20 // 21 // This is part of revision 8264 of the Stellaris Peripheral Driver Library. 22 // 23 //***************************************************************************** 24 25 #ifndef __ETHERNET_H__ 26 #define __ETHERNET_H__ 27 28 //***************************************************************************** 29 // 30 // If building with a C++ compiler, make all of the definitions in this header 31 // have a C binding. 32 // 33 //***************************************************************************** 34 #ifdef __cplusplus 35 extern "C" 36 { 37 #endif 38 39 //***************************************************************************** 40 // 41 // Values that can be passed to EthernetConfigSet as the ulConfig value, and 42 // returned from EthernetConfigGet. 43 // 44 //***************************************************************************** 45 #define ETH_CFG_TS_TSEN 0x010000 // Enable Timestamp (CCP) 46 #define ETH_CFG_RX_BADCRCDIS 0x000800 // Disable RX BAD CRC Packets 47 #define ETH_CFG_RX_PRMSEN 0x000400 // Enable RX Promiscuous 48 #define ETH_CFG_RX_AMULEN 0x000200 // Enable RX Multicast 49 #define ETH_CFG_TX_DPLXEN 0x000010 // Enable TX Duplex Mode 50 #define ETH_CFG_TX_CRCEN 0x000004 // Enable TX CRC Generation 51 #define ETH_CFG_TX_PADEN 0x000002 // Enable TX Padding 52 53 //***************************************************************************** 54 // 55 // Values that can be passed to EthernetIntEnable, EthernetIntDisable, and 56 // EthernetIntClear as the ulIntFlags parameter, and returned from 57 // EthernetIntStatus. 58 // 59 //***************************************************************************** 60 #define ETH_INT_PHY 0x040 // PHY Event/Interrupt 61 #define ETH_INT_MDIO 0x020 // Management Transaction 62 #define ETH_INT_RXER 0x010 // RX Error 63 #define ETH_INT_RXOF 0x008 // RX FIFO Overrun 64 #define ETH_INT_TX 0x004 // TX Complete 65 #define ETH_INT_TXER 0x002 // TX Error 66 #define ETH_INT_RX 0x001 // RX Complete 67 68 //***************************************************************************** 69 // 70 // Helper Macros for Ethernet Processing 71 // 72 //***************************************************************************** 73 // 74 // htonl/ntohl - big endian/little endian byte swapping macros for 75 // 32-bit (long) values 76 // 77 //***************************************************************************** 78 #ifndef htonl 79 #define htonl(a) \ 80 ((((a) >> 24) & 0x000000ff) | \ 81 (((a) >> 8) & 0x0000ff00) | \ 82 (((a) << 8) & 0x00ff0000) | \ 83 (((a) << 24) & 0xff000000)) 84 #endif 85 86 #ifndef ntohl 87 #define ntohl(a) htonl((a)) 88 #endif 89 90 //***************************************************************************** 91 // 92 // htons/ntohs - big endian/little endian byte swapping macros for 93 // 16-bit (short) values 94 // 95 //***************************************************************************** 96 #ifndef htons 97 #define htons(a) \ 98 ((((a) >> 8) & 0x00ff) | \ 99 (((a) << 8) & 0xff00)) 100 #endif 101 102 #ifndef ntohs 103 #define ntohs(a) htons((a)) 104 #endif 105 106 //***************************************************************************** 107 // 108 // API Function prototypes 109 // 110 //***************************************************************************** 111 extern void EthernetInitExpClk(unsigned long ulBase, unsigned long ulEthClk); 112 extern void EthernetConfigSet(unsigned long ulBase, unsigned long ulConfig); 113 extern unsigned long EthernetConfigGet(unsigned long ulBase); 114 extern void EthernetMACAddrSet(unsigned long ulBase, 115 unsigned char *pucMACAddr); 116 extern void EthernetMACAddrGet(unsigned long ulBase, 117 unsigned char *pucMACAddr); 118 extern void EthernetEnable(unsigned long ulBase); 119 extern void EthernetDisable(unsigned long ulBase); 120 extern tBoolean EthernetPacketAvail(unsigned long ulBase); 121 extern tBoolean EthernetSpaceAvail(unsigned long ulBase); 122 extern long EthernetPacketGetNonBlocking(unsigned long ulBase, 123 unsigned char *pucBuf, 124 long lBufLen); 125 extern long EthernetPacketGet(unsigned long ulBase, unsigned char *pucBuf, 126 long lBufLen); 127 extern long EthernetPacketPutNonBlocking(unsigned long ulBase, 128 unsigned char *pucBuf, 129 long lBufLen); 130 extern long EthernetPacketPut(unsigned long ulBase, unsigned char *pucBuf, 131 long lBufLen); 132 extern void EthernetIntRegister(unsigned long ulBase, 133 void (*pfnHandler)(void)); 134 extern void EthernetIntUnregister(unsigned long ulBase); 135 extern void EthernetIntEnable(unsigned long ulBase, unsigned long ulIntFlags); 136 extern void EthernetIntDisable(unsigned long ulBase, unsigned long ulIntFlags); 137 extern unsigned long EthernetIntStatus(unsigned long ulBase, tBoolean bMasked); 138 extern void EthernetIntClear(unsigned long ulBase, unsigned long ulIntFlags); 139 extern void EthernetPHYAddrSet(unsigned long ulBase, unsigned char ucAddr); 140 extern void EthernetPHYWrite(unsigned long ulBase, unsigned char ucRegAddr, 141 unsigned long ulData); 142 extern unsigned long EthernetPHYRead(unsigned long ulBase, 143 unsigned char ucRegAddr); 144 extern void EthernetPHYPowerOff(unsigned long ulBase); 145 extern void EthernetPHYPowerOn(unsigned long ulBase); 146 147 //***************************************************************************** 148 // 149 // Several Ethernet APIs have been renamed, with the original function name 150 // being deprecated. These defines provide backward compatibility. 151 // 152 //***************************************************************************** 153 #ifndef DEPRECATED 154 #include "driverlib/sysctl.h" 155 #define EthernetInit(a) \ 156 EthernetInitExpClk(a, SysCtlClockGet()) 157 #define EthernetPacketNonBlockingGet(a, b, c) \ 158 EthernetPacketGetNonBlocking(a, b, c) 159 #define EthernetPacketNonBlockingPut(a, b, c) \ 160 EthernetPacketPutNonBlocking(a, b, c) 161 #endif 162 163 //***************************************************************************** 164 // 165 // Mark the end of the C bindings section for C++ compilers. 166 // 167 //***************************************************************************** 168 #ifdef __cplusplus 169 } 170 #endif 171 172 #endif // __ETHERNET_H__ 173