ChipCenter Questlink
SEARCH CHIPCENTER
Search Type:
Search for:




Knowledge Centers
Product Reviews
Data Sheets
Guides & Experts
News
International
Ask Us
Circuit Cellar Online
App Notes
NetSeminars
Careers
Resources
FAQ
EE Times Network
Electronics Group Sites

Untitled Document
Listing 6ýThis is the last stop on the road to hardware initialization of the RTL8019AS. This 
                segment of code puts the all-important receive buffer ring into 
                place and initializes all of the necessary buffer ring register 
                pointers.

void rt_init(int iobase, char *EthAddress)
{
#asm
;
; 	rt_init(int iobase, char* EthAddress);
;
;		Initializes RealTek chip
;
	push	ix
	ld	ix,(sp+@SP+iobase+2)

ioe	ld (ix),0x60			; stop nic, change to register page 1

	ld	hl,ix			; set ethernet address
	inc	hl
	ex	de,hl
	ld	hl, (sp+@SP+EthAddress+2)
	
	ld	bc,6
	ioe	ldir			; copy eth address to NIC registers

	inc	de
	xor	a
	ld	b,8
pdri_loop3:
	ioe	ld (de),a
	inc	de
	djnz	pdri_loop3

	;
	; initialize the interface
	;

	ld	a,0x21			; stop nic, abort remote dma
	ioe	ld (ix),a

	ld	hl,16			; wait 1.6ms for tx/rx to complete
	call	tickwait

	ld	a,0x58			; normal operation, initialize remote
	ioe	ld (ix+PD_DATACFG),a	;    dma, fifo threshhold 8 bytes

	xor	a			; remote dma byte count = 0000h
	ioe	ld (ix+PD_RMTBCNT0),a
	ioe	ld (ix+PD_RMTBCNT1),a
	ioe	ld (ix+PD_RMTSADR0),a	; remote dma start address = 4000h
	ld	a,0x40
	ioe	ld (ix+PD_RMTSADR1),a

	ld	a,0x20			; monitor mode
	ioe	ld (ix+PD_RXCFG),a

	ld	a,0x02			; place NIC in loopback
	ioe	ld (ix+PD_TXCFG),a

	ld	a,0x46			; tx buffer < 4600h <= rx buffer
	ioe	ld (ix+PD_PAGESTART),a
	ioe	ld (ix+PD_BOUNDARY),a

	ld	a,PD_PAGE_STOP		; rx buffer < 8000h
	ioe	ld (ix+PD_PAGESTOP),a

	ld	a,0xff			; clear all interrupt flags
	ioe	ld (ix+PD_INTSTATUS),a

	ld	a,0x40			; 4000h < tx buffer
	ioe	ld (ix+PD_TXPAGE),a

	ld	a,0x61			; stop nic, change to register page 1
	ioe	ld (ix),a

	ld	a,0x46			; next place to rx a packet
	ioe	ld (ix+PD_CURRENT),a

	ld	a,0x22			; start nic, abort remote dma
	ioe	ld (ix),a

	xor	a			; change from loopback mode to normal op
	ioe	ld (ix+PD_TXCFG),a

	ld	a,0x04			; accept broadcast packets
	ioe	ld (ix+PD_RXCFG),a

	ld	a,0xff			; clear any pending interrupts
	ioe	ld (ix+PD_INTSTATUS),a

	pop	ix
#endasm
}
Click here to get your listing up.

Copyright © 2003 ChipCenter-QuestLink
About ChipCenter-Questlink  Contact Us  Privacy Statement   Advertising Information  FAQ