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