📄 rtl8019.lis
字号:
.module rtl8019.c
.area text(rom, con, rel)
0000 .dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\rtl8019.c
0000 .dbfunc e rtl8019SetupPorts _rtl8019SetupPorts fV
.even
0000 _rtl8019SetupPorts::
0000 .dbline -1
0000 .dbline 163
0000 ; #include "rtl8019.h"
0000 ;
0000 ; /*****************************************************************************
0000 ; * Module Name: Realtek 8019AS Driver
0000 ; *
0000 ; * Created By: Louis Beaudoin (www.embedded-creations.com)
0000 ; *
0000 ; * Original Release: September 21, 2002
0000 ; *
0000 ; * Module Description:
0000 ; * Provides functions to initialize the Realtek 8019AS, and send and retreive
0000 ; * packets
0000 ; *
0000 ; * November 16, 2003 - Louis Beaudoin
0000 ; * The rtl8019Write and Read functions/macros were changed to support
0000 ; * three methods of communcating with the NIC
0000 ; * Interfacing with the AVR ports changed from sbi/cbi/etc functions
0000 ; * to direct port names
0000 ; * Renamed functions to be more consistant with the two NIC drivers
0000 ; * Overrun function now retransmits if resend is set (thanks Krzysztof)
0000 ; *
0000 ; * November 15, 2002 - Louis Beaudoin
0000 ; * processRTL8019Interrupt() - bit mask mistake fixed
0000 ; *
0000 ; * November 8, 2003 - Louis Beaudoin
0000 ; * Changed delay library function calls
0000 ; *
0000 ; * September 30, 2002 - Louis Beaudoin
0000 ; * Receive functions modified to handle errors encountered when receiving a
0000 ; * fast data stream. Functions now manually retreive data instead of
0000 ; * using the send packet command. Interface improved by checking for
0000 ; * overruns and data in the buffer internally.
0000 ; * Corrected the overrun function - overrun flag was not reset after overrun
0000 ; * Added support for the Imagecraft Compiler
0000 ; * Added support to communicate with the NIC using general I/O ports
0000 ; *
0000 ; *****************************************************************************/
0000 ;
0000 ;
0000 ; /*****************************************************************************
0000 ; * rtl8019Write( RTL_ADDRESS, RTL_DATA )
0000 ; * Args: 1. unsigned char RTL_ADDRESS - register offset of RTL register
0000 ; * 2. unsigned char RTL_DATA - data to write to register
0000 ; * Created By: Louis Beaudoin
0000 ; * Date: September 21, 2002
0000 ; * Description: Writes byte to RTL8019 register.
0000 ; *
0000 ; * Notes - If using the External SRAM Interface, performs a write to
0000 ; * address MEMORY_MAPPED_RTL8019_OFFSET + (RTL_ADDRESS<<8)
0000 ; * The address is sent in the non-multiplxed upper address port so
0000 ; * no latch is required.
0000 ; *
0000 ; * If using general I/O ports, the data port is left in the input
0000 ; * state with pullups enabled
0000 ; *
0000 ; *****************************************************************************/
0000 ; #if NIC_CONNECTION == MEMORY_MAPPED_HIGHADDR
0000 ; #define rtl8019Write(RTL_ADDRESS,RTL_DATA) do{ *(volatile unsigned char *) \
0000 ; (MEMORY_MAPPED_RTL8019_OFFSET \
0000 ; + (((unsigned char)(RTL_ADDRESS)) << 8)) = \
0000 ; (unsigned char)(RTL_DATA); } while(0)
0000 ;
0000 ; #endif
0000 ;
0000 ; #if NIC_CONNECTION == MEMORY_MAPPED
0000 ; #define rtl8019Write(RTL_ADDRESS,RTL_DATA) do{ *(volatile unsigned char *) \
0000 ; (MEMORY_MAPPED_RTL8019_OFFSET \
0000 ; + (unsigned char)(RTL_ADDRESS)) = \
0000 ; (unsigned char)(RTL_DATA); } while(0)
0000 ;
0000 ; #endif
0000 ;
0000 ; #if NIC_CONNECTION == GENERAL_IO
0000 ;
0000 ; void rtl8019Write(unsigned char address, unsigned char data)
0000 ; {
0000 ; // assert the address, leaving the non-address pins intact
0000 ; address |= (RTL8019_ADDRESS_PORT & ~RTL8019_ADDRESS_MASK);
0000 ; RTL8019_ADDRESS_PORT = address;
0000 ;
0000 ; // set data bus as output and place data on bus
0000 ; RTL8019_DATA_DDR = 0xFF;
0000 ; RTL8019_DATA_PORT = data;
0000 ;
0000 ; // toggle write pin
0000 ; RTL8019_CONTROL_PORT &= ~_BV(RTL8019_CONTROL_WRITEPIN);
0000 ; nop();
0000 ; RTL8019_CONTROL_PORT |= _BV(RTL8019_CONTROL_WRITEPIN);
0000 ;
0000 ;
0000 ; // set data port back to input with pullups enabled
0000 ; RTL8019_DATA_DDR = 0x00;
0000 ; RTL8019_DATA_PORT = 0xFF;
0000 ; }
0000 ;
0000 ; #endif
0000 ;
0000 ; /*****************************************************************************
0000 ; * rtl8019Read(RTL_ADDRESS)
0000 ; * Args: unsigned char RTL_ADDRESS - register offset of RTL register
0000 ; * Created By: Louis Beaudoin
0000 ; * Date: September 21, 2002
0000 ; * Description: Reads byte from RTL8019 register
0000 ; *
0000 ; * Notes - If using the External SRAM Interface, performs a read from
0000 ; * address MEMORY_MAPPED_RTL8019_OFFSET + (RTL_ADDRESS<<8)
0000 ; * The address is sent in the non-multiplxed upper address port so
0000 ; * no latch is required.
0000 ; *
0000 ; * If using general I/O ports, the data port is assumed to already be
0000 ; * an input, and is left as an input port when done
0000 ; *
0000 ; *****************************************************************************/
0000 ; #if NIC_CONNECTION == MEMORY_MAPPED_HIGHADDR
0000 ; #define rtl8019Read(RTL_ADDRESS) (*(volatile unsigned char *) \
0000 ; (MEMORY_MAPPED_RTL8019_OFFSET \
0000 ; + (((unsigned char)(RTL_ADDRESS)) << 8)) )
0000 ; #endif
0000 ;
0000 ; #if NIC_CONNECTION == MEMORY_MAPPED
0000 ;
0000 ; #define rtl8019Read(RTL_ADDRESS) (*(volatile unsigned char *) \
0000 ; (MEMORY_MAPPED_RTL8019_OFFSET \
0000 ; + (unsigned char)(RTL_ADDRESS)) )
0000 ; #endif
0000 ;
0000 ; #if NIC_CONNECTION == GENERAL_IO
0000 ;
0000 ; unsigned char rtl8019Read(unsigned char address)
0000 ; {
0000 ; unsigned char byte;
0000 ;
0000 ; // assert the address, leaving the non-address pins intact
0000 ; address |= (RTL8019_ADDRESS_PORT & ~RTL8019_ADDRESS_MASK);
0000 ; RTL8019_ADDRESS_PORT = address;
0000 ;
0000 ; // assert read
0000 ; RTL8019_CONTROL_PORT &= ~_BV(RTL8019_CONTROL_READPIN);
0000 ; nop();
0000 ;
0000 ; // read in the data
0000 ; byte = RTL8019_DATA_PIN;
0000 ;
0000 ; // negate read
0000 ; RTL8019_CONTROL_PORT |= _BV(RTL8019_CONTROL_READPIN);
0000 ;
0000 ; return byte;
0000 ; }
0000 ;
0000 ; #endif
0000 ;
0000 ;
0000 ;
0000 ; /*****************************************************************************
0000 ; * rtl8019SetupPorts(void);
0000 ; *
0000 ; * Created By: Louis Beaudoin
0000 ; * Date: September 21, 2002
0000 ; * Description: Sets up the ports used for communication with the RTL8019 NIC
0000 ; * (data bus, address bus, read, write, and reset)
0000 ; *****************************************************************************/
0000 ; void rtl8019SetupPorts(void)
0000 ; {
0000 .dbline 183
0000 ;
0000 ; #if NIC_CONNECTION == GENERAL_IO
0000 ;
0000 ; // make the address port output
0000 ; RTL8019_ADDRESS_DDR = RTL8019_ADDRESS_MASK;
0000 ;
0000 ; // make the data port input with pull-ups
0000 ; RTL8019_DATA_PORT = 0xFF;
0000 ;
0000 ; // make the control port read and write pins outputs and asserted
0000 ; RTL8019_CONTROL_DDR |= _BV(RTL8019_CONTROL_READPIN);
0000 ; RTL8019_CONTROL_DDR |= _BV(RTL8019_CONTROL_WRITEPIN);
0000 ;
0000 ; RTL8019_CONTROL_PORT |= _BV(RTL8019_CONTROL_READPIN);
0000 ; RTL8019_CONTROL_PORT |= _BV(RTL8019_CONTROL_WRITEPIN);
0000 ;
0000 ; #else
0000 ;
0000 ; // enable external SRAM interface - no wait states
0000 ; MCUCR |= _BV(SRE);
0000 85B7 in R24,0x35
0002 8068 ori R24,128
0004 85BF out 0x35,R24
0006 .dbline 188
0006 ;
0006 ; #endif
0006 ;
0006 ; // enable output pin for Resetting the RTL8019
0006 ; RTL8019_RESET_DDR |= _BV(RTL8019_RESET_PIN);
0006 80916400 lds R24,100
000A 8860 ori R24,8
000C 80936400 sts 100,R24
0010 .dbline -2
0010 L1:
0010 .dbline 0 ; func end
0010 0895 ret
0012 .dbend
0012 .dbfunc e rtl8019BeginPacketSend _rtl8019BeginPacketSend fV
0012 ; sendPacketLength -> R10,R11
0012 ; packetLength -> R16,R17
.even
0012 _rtl8019BeginPacketSend::
0012 0E940000 xcall push_gset4x
0016 .dbline -1
0016 .dbline 304
0016 ; }
0016 ;
0016 ;
0016 ;
0016 ; /*****************************************************************************
0016 ; * HARD_RESET_RTL8019()
0016 ; *
0016 ; * Created By: Louis Beaudoin
0016 ; * Date: September 21, 2002
0016 ; * Description: Simply toggles the pin that resets the NIC
0016 ; *****************************************************************************/
0016 ; #define HARD_RESET_RTL8019() do{ RTL8019_RESET_PORT |= _BV(RTL8019_RESET_PIN);\
0016 ; delay_ms(10); \
0016 ; RTL8019_RESET_PORT &= ~_BV(RTL8019_RESET_PIN);}\
0016 ; while(0)
0016 ;
0016 ;
0016 ;
0016 ; /*****************************************************************************
0016 ; * rtl8019Overrun(void);
0016 ; *
0016 ; * Created By: Louis Beaudoin
0016 ; * Date: September 21, 2002
0016 ; * Description: "Canned" receive buffer overrun function originally from
0016 ; * a National Semiconductor appnote
0016 ; * Notes: This function must be called before retreiving packets from
0016 ; * the NIC if there is a buffer overrun
0016 ; *****************************************************************************/
0016 ; void rtl8019Overrun(void);
0016 ;
0016 ;
0016 ;
0016 ;
0016 ; //******************************************************************
0016 ; //* REALTEK CONTROL REGISTER OFFSETS
0016 ; //* All offsets in Page 0 unless otherwise specified
0016 ; //* All functions accessing CR must leave CR in page 0 upon exit
0016 ; //******************************************************************
0016 ; #define CR 0x00
0016 ; #define PSTART 0x01
0016 ; #define PAR0 0x01 // Page 1
0016 ; #define CR9346 0x01 // Page 3
0016 ; #define PSTOP 0x02
0016 ; #define BNRY 0x03
0016 ; #define TSR 0x04
0016 ; #define TPSR 0x04
0016 ; #define TBCR0 0x05
0016 ; #define NCR 0x05
0016 ; #define TBCR1 0x06
0016 ; #define ISR 0x07
0016 ; #define CURR 0x07 // Page 1
0016 ; #define RSAR0 0x08
0016 ; #define CRDA0 0x08
0016 ; #define RSAR1 0x09
0016 ; #define CRDA1 0x09
0016 ; #define RBCR0 0x0A
0016 ; #define RBCR1 0x0B
0016 ; #define RSR 0x0C
0016 ; #define RCR 0x0C
0016 ; #define TCR 0x0D
0016 ; #define CNTR0 0x0D
0016 ; #define DCR 0x0E
0016 ; #define CNTR1 0x0E
0016 ; #define IMR 0x0F
0016 ; #define CNTR2 0x0F
0016 ; #define RDMAPORT 0x10
0016 ; #define RSTPORT 0x18
0016 ; #define CONFIG2 0x05 // page 3
0016 ; #define CONFIG3 0x06 // page 3
0016 ; #define RTL_EECR 0x01 // page 3
0016 ;
0016 ;
0016 ;
0016 ; /*****************************************************************************
0016 ; *
0016 ; * RTL ISR Register Bits
0016 ; *
0016 ; *****************************************************************************/
0016 ; #define ISR_RST 7
0016 ; #define ISR_OVW 4
0016 ; #define ISR_PRX 0
0016 ; #define ISR_RDC 6
0016 ; #define ISR_PTX 1
0016 ;
0016 ;
0016 ; /*****************************************************************************
0016 ; *
0016 ; * RTL Register Initialization Values
0016 ; *
0016 ; *****************************************************************************/
0016 ; // RCR : accept broadcast packets and packets destined to this MAC
0016 ; // drop short frames and receive errors
0016 ; #define RCR_INIT 0x04
0016 ;
0016 ; // TCR : default transmit operation - CRC is generated
0016 ; #define TCR_INIT 0x00
0016 ;
0016 ; // DCR : allows send packet to be used for packet retreival
0016 ; // FIFO threshold: 8-bits (works)
0016 ; // 8-bit transfer mode
0016 ; #define DCR_INIT 0x58
0016 ;
0016 ; // IMR : interrupt enabled for receive and overrun events
0016 ; #define IMR_INIT 0x11
0016 ;
0016 ; // buffer boundaries - transmit has 6 256-byte pages
0016 ; // receive has 26 256-byte pages
0016 ; // entire available packet buffer space is allocated
0016 ; #define TXSTART_INIT 0x40
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -