1 //*****************************************************************************
\r
3 // ethernet.h - Defines and Macros for the ethernet module.
\r
5 // Copyright (c) 2006-2007 Luminary Micro, Inc. All rights reserved.
\r
7 // Software License Agreement
\r
9 // Luminary Micro, Inc. (LMI) is supplying this software for use solely and
\r
10 // exclusively on LMI's microcontroller products.
\r
12 // The software is owned by LMI and/or its suppliers, and is protected under
\r
13 // applicable copyright laws. All rights are reserved. Any use in violation
\r
14 // of the foregoing restrictions may subject the user to criminal sanctions
\r
15 // under applicable laws, as well as to civil liability for the breach of the
\r
16 // terms and conditions of this license.
\r
18 // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
\r
19 // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
\r
20 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
\r
21 // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
\r
22 // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
\r
24 // This is part of revision 1408 of the Stellaris Peripheral Driver Library.
\r
26 //*****************************************************************************
\r
28 #ifndef __ETHERNET_H__
\r
29 #define __ETHERNET_H__
\r
36 //*****************************************************************************
\r
38 // Values that can be passed to EthernetConfigSet as the ulConfig value, and
\r
39 // returned from EthernetConfigGet.
\r
41 //*****************************************************************************
\r
42 #define ETH_CFG_RX_BADCRCDIS 0x000800 // Disable RX BAD CRC Packets
\r
43 #define ETH_CFG_RX_PRMSEN 0x000400 // Enable RX Promiscuous
\r
44 #define ETH_CFG_RX_AMULEN 0x000200 // Enable RX Multicast
\r
45 #define ETH_CFG_TX_DPLXEN 0x000010 // Enable TX Duplex Mode
\r
46 #define ETH_CFG_TX_CRCEN 0x000004 // Enable TX CRC Generation
\r
47 #define ETH_CFG_TX_PADEN 0x000002 // Enable TX Padding
\r
49 //*****************************************************************************
\r
51 // Values that can be passed to EthernetIntEnable, EthernetIntDisable, and
\r
52 // EthernetIntClear as the ulIntFlags parameter, and returned from
\r
53 // EthernetIntStatus.
\r
55 //*****************************************************************************
\r
56 #define ETH_INT_PHY 0x040 // PHY Event/Interrupt
\r
57 #define ETH_INT_MDIO 0x020 // Management Transaction
\r
58 #define ETH_INT_RXER 0x010 // RX Error
\r
59 #define ETH_INT_RXOF 0x008 // RX FIFO Overrun
\r
60 #define ETH_INT_TX 0x004 // TX Complete
\r
61 #define ETH_INT_TXER 0x002 // TX Error
\r
62 #define ETH_INT_RX 0x001 // RX Complete
\r
64 //*****************************************************************************
\r
66 // The following define values that can be passed as register addresses to
\r
67 // EthernetPHYRead and EthernetPHYWrite.
\r
69 //*****************************************************************************
\r
70 #define PHY_MR0 0 // Control
\r
71 #define PHY_MR1 1 // Status
\r
72 #define PHY_MR2 2 // PHY Identifier 1
\r
73 #define PHY_MR3 3 // PHY Identifier 2
\r
74 #define PHY_MR4 4 // Auto-Neg. Advertisement
\r
75 #define PHY_MR5 5 // Auto-Neg. Link Partner Ability
\r
76 #define PHY_MR6 6 // Auto-Neg. Expansion
\r
77 // 7-15 Reserved/Not Implemented
\r
78 #define PHY_MR16 16 // Vendor Specific
\r
79 #define PHY_MR17 17 // Interrupt Control/Status
\r
80 #define PHY_MR18 18 // Diagnostic Register
\r
81 #define PHY_MR19 19 // Transceiver Control
\r
83 #define PHY_MR23 23 // LED Configuration Register
\r
84 #define PHY_MR24 24 // MDI/MDIX Control Register
\r
85 // 25-31 Reserved/Not Implemented
\r
87 //*****************************************************************************
\r
89 // The following define bit fields in the ETH_MR0 register
\r
91 //*****************************************************************************
\r
92 #define PHY_MR0_RESET 0x8000 // Reset the PHY
\r
93 #define PHY_MR0_LOOPBK 0x4000 // TXD to RXD Loopback
\r
94 #define PHY_MR0_SPEEDSL 0x2000 // Speed Selection
\r
95 #define PHY_MR0_SPEEDSL_10 0x0000 // Speed Selection 10BASE-T
\r
96 #define PHY_MR0_SPEEDSL_100 0x2000 // Speed Selection 100BASE-T
\r
97 #define PHY_MR0_ANEGEN 0x1000 // Auto-Negotiation Enable
\r
98 #define PHY_MR0_PWRDN 0x0800 // Power Down
\r
99 #define PHY_MR0_RANEG 0x0200 // Restart Auto-Negotiation
\r
100 #define PHY_MR0_DUPLEX 0x0100 // Enable full duplex
\r
101 #define PHY_MR0_DUPLEX_HALF 0x0000 // Enable half duplex mode
\r
102 #define PHY_MR0_DUPLEX_FULL 0x0100 // Enable full duplex mode
\r
104 //*****************************************************************************
\r
106 // The following define bit fields in the ETH_MR1 register
\r
108 //*****************************************************************************
\r
109 #define PHY_MR1_ANEGC 0x0020 // Auto-Negotiate Complete
\r
110 #define PHY_MR1_RFAULT 0x0010 // Remove Fault Detected
\r
111 #define PHY_MR1_LINK 0x0004 // Link Established
\r
112 #define PHY_MR1_JAB 0x0002 // Jabber Condition Detected
\r
114 //*****************************************************************************
\r
116 // The following define bit fields in the ETH_MR17 register
\r
118 //*****************************************************************************
\r
119 #define PHY_MR17_RXER_IE 0x4000 // Enable Receive Error Interrupt
\r
120 #define PHY_MR17_LSCHG_IE 0x0400 // Enable Link Status Change Int.
\r
121 #define PHY_MR17_ANEGCOMP_IE 0x0100 // Enable Auto-Negotiate Cmpl. Int.
\r
122 #define PHY_MR17_RXER_INT 0x0040 // Receive Error Interrupt
\r
123 #define PHY_MR17_LSCHG_INT 0x0004 // Link Status Change Interrupt
\r
124 #define PHY_MR17_ANEGCOMP_INT 0x0001 // Auto-Negotiate Complete Int.
\r
126 //*****************************************************************************
\r
128 // The following define bit fields in the ETH_MR18 register
\r
130 //*****************************************************************************
\r
131 #define PHY_MR18_ANEGF 0x1000 // Auto-Negotiate Failed
\r
132 #define PHY_MR18_DPLX 0x0800 // Duplex Mode Negotiated
\r
133 #define PHY_MR18_DPLX_HALF 0x0000 // Half Duplex Mode Negotiated
\r
134 #define PHY_MR18_DPLX_FULL 0x0800 // Full Duplex Mode Negotiated
\r
135 #define PHY_MR18_RATE 0x0400 // Rate Negotiated
\r
136 #define PHY_MR18_RATE_10 0x0000 // Rate Negotiated is 10BASE-T
\r
137 #define PHY_MR18_RATE_100 0x0400 // Rate Negotiated is 100BASE-TX
\r
139 //*****************************************************************************
\r
141 // The following define bit fields in the ETH_MR23 register
\r
143 //*****************************************************************************
\r
144 #define PHY_MR23_LED1 0x00f0 // LED1 Configuration
\r
145 #define PHY_MR23_LED1_LINK 0x0000 // LED1 is Link Status
\r
146 #define PHY_MR23_LED1_RXTX 0x0010 // LED1 is RX or TX Activity
\r
147 #define PHY_MR23_LED1_TX 0x0020 // LED1 is TX Activity
\r
148 #define PHY_MR23_LED1_RX 0x0030 // LED1 is RX Activity
\r
149 #define PHY_MR23_LED1_COL 0x0040 // LED1 is RX Activity
\r
150 #define PHY_MR23_LED1_100 0x0050 // LED1 is RX Activity
\r
151 #define PHY_MR23_LED1_10 0x0060 // LED1 is RX Activity
\r
152 #define PHY_MR23_LED1_DUPLEX 0x0070 // LED1 is RX Activity
\r
153 #define PHY_MR23_LED1_LINKACT 0x0080 // LED1 is Link Status + Activity
\r
154 #define PHY_MR23_LED0 0x000f // LED0 Configuration
\r
155 #define PHY_MR23_LED0_LINK 0x0000 // LED0 is Link Status
\r
156 #define PHY_MR23_LED0_RXTX 0x0001 // LED0 is RX or TX Activity
\r
157 #define PHY_MR23_LED0_TX 0x0002 // LED0 is TX Activity
\r
158 #define PHY_MR23_LED0_RX 0x0003 // LED0 is RX Activity
\r
159 #define PHY_MR23_LED0_COL 0x0004 // LED0 is RX Activity
\r
160 #define PHY_MR23_LED0_100 0x0005 // LED0 is RX Activity
\r
161 #define PHY_MR23_LED0_10 0x0006 // LED0 is RX Activity
\r
162 #define PHY_MR23_LED0_DUPLEX 0x0007 // LED0 is RX Activity
\r
163 #define PHY_MR23_LED0_LINKACT 0x0008 // LED0 is Link Status + Activity
\r
165 //*****************************************************************************
\r
167 // The following define bit fields in the ETH_MR24 register
\r
169 //*****************************************************************************
\r
170 #define PHY_MR24_MDIX 0x0020 // Auto-Switching Configuration
\r
171 #define PHY_MR24_MDIX_NORMAL 0x0000 // Auto-Switching in passthrough
\r
172 #define PHY_MR23_MDIX_CROSSOVER 0x0020 // Auto-Switching in crossover
\r
174 //*****************************************************************************
\r
176 // Helper Macros for Ethernet Processing
\r
178 //*****************************************************************************
\r
180 // htonl/ntohl - big endian/little endian byte swapping macros for
\r
181 // 32-bit (long) values
\r
183 //*****************************************************************************
\r
186 ((((a) >> 24) & 0x000000ff) | \
\r
187 (((a) >> 8) & 0x0000ff00) | \
\r
188 (((a) << 8) & 0x00ff0000) | \
\r
189 (((a) << 24) & 0xff000000))
\r
193 #define ntohl(a) htonl((a))
\r
196 //*****************************************************************************
\r
198 // htons/ntohs - big endian/little endian byte swapping macros for
\r
199 // 16-bit (short) values
\r
201 //*****************************************************************************
\r
204 ((((a) >> 8) & 0x00ff) | \
\r
205 (((a) << 8) & 0xff00))
\r
209 #define ntohs(a) htons((a))
\r
212 //*****************************************************************************
\r
214 // API Function prototypes
\r
216 //*****************************************************************************
\r
217 extern void EthernetInit(unsigned long ulBase);
\r
218 extern void EthernetConfigSet(unsigned long ulBase, unsigned long ulConfig);
\r
219 extern unsigned long EthernetConfigGet(unsigned long ulBase);
\r
220 extern void EthernetMACAddrSet(unsigned long ulBase,
\r
221 unsigned char *pucMACAddr);
\r
222 extern void EthernetMACAddrGet(unsigned long ulBase,
\r
223 unsigned char *pucMACAddr);
\r
224 extern void EthernetEnable(unsigned long ulBase);
\r
225 extern void EthernetDisable(unsigned long ulBase);
\r
226 extern tBoolean EthernetPacketAvail(unsigned long ulBase);
\r
227 extern tBoolean EthernetSpaceAvail(unsigned long ulBase);
\r
228 extern long EthernetPacketNonBlockingGet(unsigned long ulBase,
\r
229 unsigned char *pucBuf,
\r
231 extern long EthernetPacketGet(unsigned long ulBase, unsigned char *pucBuf,
\r
233 extern long EthernetPacketNonBlockingPut(unsigned long ulBase,
\r
234 unsigned char *pucBuf,
\r
236 extern long EthernetPacketPut(unsigned long ulBase, unsigned char *pucBuf,
\r
238 extern void EthernetIntRegister(unsigned long ulBase,
\r
239 void (*pfnHandler)(void));
\r
240 extern void EthernetIntUnregister(unsigned long ulBase);
\r
241 extern void EthernetIntEnable(unsigned long ulBase, unsigned long ulIntFlags);
\r
242 extern void EthernetIntDisable(unsigned long ulBase, unsigned long ulIntFlags);
\r
243 extern unsigned long EthernetIntStatus(unsigned long ulBase, tBoolean bMasked);
\r
244 extern void EthernetIntClear(unsigned long ulBase, unsigned long ulIntFlags);
\r
245 extern void EthernetPHYWrite(unsigned long ulBase, unsigned char ucRegAddr,
\r
246 unsigned long ulData);
\r
247 extern unsigned long EthernetPHYRead(unsigned long ulBase,
\r
248 unsigned char ucRegAddr);
\r
254 #endif // __ETHERNET_H__
\r