Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

# rtl8019.h

Go to the documentation of this file.

    00001 /*! \file rtl8019.h \brief Realtek RTL8019AS Ethernet Interface Driver. */
    00002 //*****************************************************************************
    00003 //
    00004 // File Name    : 'rtl8019.h'
    00005 // Title        : Realtek RTL8019AS Ethernet Interface Driver
    00006 // Author       : Pascal Stang
    00007 // Created      : 7/6/2004
    00008 // Revised      : 8/22/2005
    00009 // Version      : 0.1
    00010 // Target MCU   : Atmel AVR series
    00011 // Editor Tabs  : 4
    00012 //
    00013 /// \ingroup network
    00014 /// \defgroup rtl8019 Realtek RTL8019AS Ethernet Interface Driver (rtl8019.c)
    00015 /// \code #include "net/rtl8019.h" \endcode
    00016 /// \par Overview
    00017 ///     This driver provides initialization and transmit/receive
    00018 /// functions for the Realtek RTL8019AS 10Mb Ethernet Controller and PHY.
    00019 ///
    00020 /// Based in part on code by Louis Beaudoin (www.embedded-creations.com).
    00021 /// Thanks to Adam Dunkels and Louis Beaudoin for providing the initial
    00022 /// structure in which to write this driver.
    00023 //
    00024 //*****************************************************************************
    00025 //@{
    00026
    00027 #ifndef RTL8019_H
    00028 #define RTL8019_H
    00029
    00030 #define nop()   asm volatile ("nop")
    00031
    00032 // RTL8019 Control Register Offsets
    00033 // Page 0 - Read/Write
    00034 #define CR          0x00    // Command Register
    00035 #define PSTART      0x01    // Page Start Register
    00036 #define PSTOP       0x02    // Page Stop Register
    00037 #define BNRY        0x03    // Boundary Pointer
    00038 #define RDMAPORT    0x10    // DMA Data Port
    00039 #define MEMR        0x14    // MII/EEPROM Access Register
    00040 #define TR          0x15    // Test Register
    00041 #define SPP_DPR     0x18    // Standard Printer Port Data
    00042 #define SSP_SPR     0x19    // Standard Printer Port Status
    00043 #define SSP_CPR     0x1A    // Standard Printer Port Control
    00044 // Page 0 - Read
    00045 #define TSR         0x04    // Transmit Status Register
    00046 #define NCR         0x05    // Number of Collisions Register
    00047 #define ISR         0x07    // Interrupt Status Register
    00048 #define CRDA0       0x08    // Current Remote DMA Address 0
    00049 #define CRDA1       0x09    // Current Remote DMA Address 1
    00050 #define RSR         0x0C    // Receive Status Register
    00051 #define CNTR0       0x0D
    00052 #define CNTR1       0x0E
    00053 #define CNTR2       0x0F
    00054 #define GPI         0x17    // General-Purpose Input
    00055 #define RSTPORT     0x1F    // Reset
    00056 // Page 0 - Write
    00057 #define TPSR        0x04    // Transmit Page Start Address
    00058 #define TBCR0       0x05    // Transmit Byte Count Register 0
    00059 #define TBCR1       0x06    // Transmit Byte Count Register 1
    00060 #define RSAR0       0x08    // Remote Start Address Register 0
    00061 #define RSAR1       0x09    // Remote Start Address Register 1
    00062 #define RBCR0       0x0A    // Remote Byte Count 0
    00063 #define RBCR1       0x0B    // Remote Byte Count 1
    00064 #define RCR         0x0C    // Receive Config Register
    00065 #define TCR         0x0D    // Transmit Config Register
    00066 #define DCR         0x0E    // Data Config Register
    00067 #define IMR         0x0F    // Interrupt Mask Register
    00068 #define GPOC        0x17    // General-Purpose Output Control
    00069 // Page 1 - Read/Write
    00070 #define PAR0        0x01    // Physical Address Register 0
    00071 #define PAR1        0x02    // Physical Address Register 1
    00072 #define PAR2        0x03    // Physical Address Register 2
    00073 #define PAR3        0x04    // Physical Address Register 3
    00074 #define PAR4        0x05    // Physical Address Register 4
    00075 #define PAR5        0x06    // Physical Address Register 5
    00076 #define CURR        0x07    // Page 1
    00077 #define CPR         0x07    // Current Page Register
    00078
    00079 #define RTL_EECR    0x01    // page 3
    00080 #define CR9346      0x01    // Page 3
    00081 #define CONFIG2     0x05    // page 3
    00082 #define CONFIG3     0x06    // page 3
    00083
    00084 // RTL8019/NE2000 CR Register Bit Definitions
    00085 #define  PS1        0x80
    00086 #define  PS0        0x40
    00087 #define  RD2        0x20
    00088 #define  RD1        0x10
    00089 #define  RD0        0x08
    00090 #define  TXP        0x04
    00091 #define  START      0x02
    00092 #define  STOP       0x01
    00093 // RTL8019/NE2000 ISR Register Bit Definitions
    00094 #define  RST        0x80
    00095 #define  RDC        0x40
    00096 #define  OVW        0x10
    00097 #define  RXE        0x08
    00098 #define  TXE        0x04
    00099 #define  PTX        0x02
    00100 #define  PRX        0x01
    00101 // RTL8019/NE2000 RCR Register Bit Definitions
    00102 #define  MON        0x20
    00103 #define  PRO        0x10
    00104 #define  AM         0x08
    00105 #define  AB         0x04
    00106 #define  AR         0x02
    00107 #define  SEP        0x01
    00108 // RTL8019/NE2000 TCR Register Bit Definitions
    00109 #define  FDU        0x80    // full duplex
    00110 #define  PD         0x40    // pad disable
    00111 #define  RLO        0x20    // retry of late collisions
    00112 #define  LB1        0x04    // loopback 1
    00113 #define  LB0        0x02    // loopback 0
    00114 #define  CRC        0x01    // generate CRC
    00115 // RTL8019 EECR Register Bit Definitions
    00116 #define  EEM1       0x80
    00117 #define  EEM0       0x40
    00118 #define  EECS       0x08
    00119 #define  EESK       0x04
    00120 #define  EEDI       0x02
    00121 #define  EEDO       0x01
    00122
    00123
    00124 // RTL8019 Initial Register Values
    00125 // RCR : INT trigger active high and Accept Broadcast ENET packets
    00126 #define RCR_INIT        (AB)
    00127 #define DCR_INIT        0x58    // FIFO thrsh. 8bits, 8bit DMA transfer
    00128 // TCR : default transmit operation - CRC is generated
    00129 #define TCR_INIT        0x00
    00130 // IMR : interrupt enabled for receive and overrun events
    00131 #define IMR_INIT        0x11    // PRX and OVW interrupt enabled
    00132 // buffer boundaries
    00133 //  transmit has 6 256-byte pages
    00134 //  receive has 26 256-byte pages
    00135 //  entire available packet buffer space is allocated
    00136 #define TXSTART_INIT    0x40
    00137 #define RXSTART_INIT    0x46
    00138 #define RXSTOP_INIT     0x60
    00139
    00140 // Ethernet constants
    00141 #define ETHERNET_MIN_PACKET_LENGTH  0x3C
    00142 //#define ETHERNET_HEADER_LENGTH        0x0E
    00143
    00144 // offsets into ax88796 ethernet packet header
    00145 #define  PKTHEADER_STATUS       0x00    // packet status
    00146 #define  PKTHEADER_NEXTPAGE     0x01    // next buffer page
    00147 #define  PKTHEADER_PKTLENL      0x02    // packet length low
    00148 #define  PKTHEADER_PKTLENH      0x03    // packet length high
    00149
    00150
    00151 // functions
    00152 #include "nic.h"
    00153
    00154 // setup ports for I/O
    00155 void rtl8019SetupPorts(void);
    00156
    00157 // read ax88796 register
    00158 unsigned char rtl8019Read(unsigned char address);
    00159
    00160 // write ax88796 register
    00161 void rtl8019Write(unsigned char address, unsigned char data);
    00162
    00163 // initialize the ethernet interface for transmit/receive
    00164 void rtl8019Init(void);
    00165
    00166 // packet transmit functions
    00167 void rtl8019BeginPacketSend(unsigned int packetLength);
    00168 void rtl8019SendPacketData(unsigned char * localBuffer, unsigned int length);
    00169 void rtl8019EndPacketSend(void);
    00170
    00171 // packet receive functions
    00172 unsigned int rtl8019BeginPacketRetreive(void);
    00173 void rtl8019RetreivePacketData(unsigned char * localBuffer, unsigned int length);
    00174 void rtl8019EndPacketRetreive(void);
    00175
    00176 // Processes RTL8019 interrupts.
    00177 // Currently, this function looks only for a receive overflow condition.
    00178 // The function need not be called in response to an interrupt,
    00179 // but can be executed just before checking the receive buffer for incoming packets.
    00180 void rtl8019ProcessInterrupt(void);
    00181
    00182 // execute procedure for recovering from a receive overflow
    00183 // this should be done when the receive memory fills up with packets
    00184 void rtl8019ReceiveOverflowRecover(void);
    00185
    00186 // formatted print of all important RTL8019 registers
    00187 void rtl8019RegDump(void);
    00188
    00189 #endif
    00190 //@}