?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 6

Line No. Rev Author Line
1 6 kaklik /*! \file rtl8019.h \brief Realtek RTL8019AS Ethernet Interface Driver. */
2 //*****************************************************************************
3 //
4 // File Name : 'rtl8019.h'
5 // Title : Realtek RTL8019AS Ethernet Interface Driver
6 // Author : Pascal Stang
7 // Created : 7/6/2004
8 // Revised : 8/22/2005
9 // Version : 0.1
10 // Target MCU : Atmel AVR series
11 // Editor Tabs : 4
12 //
13 /// \ingroup network
14 /// \defgroup rtl8019 Realtek RTL8019AS Ethernet Interface Driver (rtl8019.c)
15 /// \code #include "net/rtl8019.h" \endcode
16 /// \par Overview
17 /// This driver provides initialization and transmit/receive
18 /// functions for the Realtek RTL8019AS 10Mb Ethernet Controller and PHY.
19 ///
20 /// Based in part on code by Louis Beaudoin (www.embedded-creations.com).
21 /// Thanks to Adam Dunkels and Louis Beaudoin for providing the initial
22 /// structure in which to write this driver.
23 //
24 //*****************************************************************************
25 //@{
26  
27 #ifndef RTL8019_H
28 #define RTL8019_H
29  
30 #define nop() asm volatile ("nop")
31  
32 // RTL8019 Control Register Offsets
33 // Page 0 - Read/Write
34 #define CR 0x00 // Command Register
35 #define PSTART 0x01 // Page Start Register
36 #define PSTOP 0x02 // Page Stop Register
37 #define BNRY 0x03 // Boundary Pointer
38 #define RDMAPORT 0x10 // DMA Data Port
39 #define MEMR 0x14 // MII/EEPROM Access Register
40 #define TR 0x15 // Test Register
41 #define SPP_DPR 0x18 // Standard Printer Port Data
42 #define SSP_SPR 0x19 // Standard Printer Port Status
43 #define SSP_CPR 0x1A // Standard Printer Port Control
44 // Page 0 - Read
45 #define TSR 0x04 // Transmit Status Register
46 #define NCR 0x05 // Number of Collisions Register
47 #define ISR 0x07 // Interrupt Status Register
48 #define CRDA0 0x08 // Current Remote DMA Address 0
49 #define CRDA1 0x09 // Current Remote DMA Address 1
50 #define RSR 0x0C // Receive Status Register
51 #define CNTR0 0x0D
52 #define CNTR1 0x0E
53 #define CNTR2 0x0F
54 #define GPI 0x17 // General-Purpose Input
55 #define RSTPORT 0x1F // Reset
56 // Page 0 - Write
57 #define TPSR 0x04 // Transmit Page Start Address
58 #define TBCR0 0x05 // Transmit Byte Count Register 0
59 #define TBCR1 0x06 // Transmit Byte Count Register 1
60 #define RSAR0 0x08 // Remote Start Address Register 0
61 #define RSAR1 0x09 // Remote Start Address Register 1
62 #define RBCR0 0x0A // Remote Byte Count 0
63 #define RBCR1 0x0B // Remote Byte Count 1
64 #define RCR 0x0C // Receive Config Register
65 #define TCR 0x0D // Transmit Config Register
66 #define DCR 0x0E // Data Config Register
67 #define IMR 0x0F // Interrupt Mask Register
68 #define GPOC 0x17 // General-Purpose Output Control
69 // Page 1 - Read/Write
70 #define PAR0 0x01 // Physical Address Register 0
71 #define PAR1 0x02 // Physical Address Register 1
72 #define PAR2 0x03 // Physical Address Register 2
73 #define PAR3 0x04 // Physical Address Register 3
74 #define PAR4 0x05 // Physical Address Register 4
75 #define PAR5 0x06 // Physical Address Register 5
76 #define CURR 0x07 // Page 1
77 #define CPR 0x07 // Current Page Register
78  
79 #define RTL_EECR 0x01 // page 3
80 #define CR9346 0x01 // Page 3
81 #define CONFIG2 0x05 // page 3
82 #define CONFIG3 0x06 // page 3
83  
84 // RTL8019/NE2000 CR Register Bit Definitions
85 #define PS1 0x80
86 #define PS0 0x40
87 #define RD2 0x20
88 #define RD1 0x10
89 #define RD0 0x08
90 #define TXP 0x04
91 #define START 0x02
92 #define STOP 0x01
93 // RTL8019/NE2000 ISR Register Bit Definitions
94 #define RST 0x80
95 #define RDC 0x40
96 #define OVW 0x10
97 #define RXE 0x08
98 #define TXE 0x04
99 #define PTX 0x02
100 #define PRX 0x01
101 // RTL8019/NE2000 RCR Register Bit Definitions
102 #define MON 0x20
103 #define PRO 0x10
104 #define AM 0x08
105 #define AB 0x04
106 #define AR 0x02
107 #define SEP 0x01
108 // RTL8019/NE2000 TCR Register Bit Definitions
109 #define FDU 0x80 // full duplex
110 #define PD 0x40 // pad disable
111 #define RLO 0x20 // retry of late collisions
112 #define LB1 0x04 // loopback 1
113 #define LB0 0x02 // loopback 0
114 #define CRC 0x01 // generate CRC
115 // RTL8019 EECR Register Bit Definitions
116 #define EEM1 0x80
117 #define EEM0 0x40
118 #define EECS 0x08
119 #define EESK 0x04
120 #define EEDI 0x02
121 #define EEDO 0x01
122  
123  
124 // RTL8019 Initial Register Values
125 // RCR : INT trigger active high and Accept Broadcast ENET packets
126 #define RCR_INIT (AB)
127 #define DCR_INIT 0x58 // FIFO thrsh. 8bits, 8bit DMA transfer
128 // TCR : default transmit operation - CRC is generated
129 #define TCR_INIT 0x00
130 // IMR : interrupt enabled for receive and overrun events
131 #define IMR_INIT 0x11 // PRX and OVW interrupt enabled
132 // buffer boundaries
133 // transmit has 6 256-byte pages
134 // receive has 26 256-byte pages
135 // entire available packet buffer space is allocated
136 #define TXSTART_INIT 0x40
137 #define RXSTART_INIT 0x46
138 #define RXSTOP_INIT 0x60
139  
140 // Ethernet constants
141 #define ETHERNET_MIN_PACKET_LENGTH 0x3C
142 //#define ETHERNET_HEADER_LENGTH 0x0E
143  
144 // offsets into ax88796 ethernet packet header
145 #define PKTHEADER_STATUS 0x00 // packet status
146 #define PKTHEADER_NEXTPAGE 0x01 // next buffer page
147 #define PKTHEADER_PKTLENL 0x02 // packet length low
148 #define PKTHEADER_PKTLENH 0x03 // packet length high
149  
150  
151 // functions
152 #include "nic.h"
153  
154 // setup ports for I/O
155 void rtl8019SetupPorts(void);
156  
157 // read ax88796 register
158 unsigned char rtl8019Read(unsigned char address);
159  
160 // write ax88796 register
161 void rtl8019Write(unsigned char address, unsigned char data);
162  
163 // initialize the ethernet interface for transmit/receive
164 void rtl8019Init(void);
165  
166 // packet transmit functions
167 void rtl8019BeginPacketSend(unsigned int packetLength);
168 void rtl8019SendPacketData(unsigned char * localBuffer, unsigned int length);
169 void rtl8019EndPacketSend(void);
170  
171 // packet receive functions
172 unsigned int rtl8019BeginPacketRetreive(void);
173 void rtl8019RetreivePacketData(unsigned char * localBuffer, unsigned int length);
174 void rtl8019EndPacketRetreive(void);
175  
176 // Processes RTL8019 interrupts.
177 // Currently, this function looks only for a receive overflow condition.
178 // The function need not be called in response to an interrupt,
179 // but can be executed just before checking the receive buffer for incoming packets.
180 void rtl8019ProcessInterrupt(void);
181  
182 // execute procedure for recovering from a receive overflow
183 // this should be done when the receive memory fills up with packets
184 void rtl8019ReceiveOverflowRecover(void);
185  
186 // formatted print of all important RTL8019 registers
187 void rtl8019RegDump(void);
188  
189 #endif
190 //@}
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3