Low Level function - ISA Bus
[Ethernet to uC(microcontrollers)]


Detailed Description

Definition of function's and parameter's to access RTL8019 chip, using ISA protocol
Author:
by Pinto de Castro(sirpdc@gmail.com)
 #include <isa_bus.h>


Address Bus Configuration

#define ADDR_PORT   PORTA
 data port used for address bus
#define ADDR_DDR   DDRA
 data direction for address bus
#define ADDR_PINS   0b00011111
 port pins used by address bus( 1 indicate that the pin is used)

Data Bus Configuration

#define DATA_PORT_L   PORTC
 port used for data bus
#define DATA_DDR_L   DDRC
 data direction for data bus
#define DATA_READ_L   PINC
 port used to read data
#define DATA_PINS_L   0b11111111
 port pins used by data bus
(1 indicate that the pin is used)

Control Bus Configuration

#define CNTRL_PORT   PORTA
 port used for control bus
#define CNTRL_DDR   DDRA
 data direction for control bus
#define CNTRL_PINS   0b11100000
 port pins used by control bus (1 indicate that the pin is used)
#define RESET_PIN   0b10000000
 port pin used by reset line (1 indicate that the pin is used)
#define READ_PIN   0b00100000
 port pin used by read line (1 indicate that the pin is used)
#define WRITE_PIN   0b01000000
 port pin used by write line (1 indicate that the pin is used)

Defines

#define SetBits(_port_sss, _mask_sss)   _port_sss |= (_mask_sss)
 Set bit's positions that have 1 on mask.
#define RstBits(_port_sss, _mask_sss)   _port_sss &= (~ (_mask_sss) )
 Reset bit's positions that have 0 on mask.
#define WritePort(_port_sss, _mask_sss, _value_sss)
 Write a new value to port using mask:
1) put 0 on all the mask bits that are 0
2) put 1 on all the mask bits that are 1.
#define nop()   asm volatile("nop\n\t"::)
 Insert a nop.
#define WaitState()
 Insert a delay ~= 125ns.

Functions

void rtl8019write (unsigned char data, unsigned char address)
 Writes byte to RTL8019 register.
unsigned char rtl8019read (unsigned char address)
 Reads byte from RTL8019 register.
void rtl8019SetupPorts (void)
 Sets up the ports used for communication with the RTL8019 NIC (data bus, address bus, read, write, and reset).


Define Documentation

#define ADDR_DDR   DDRA
 

data direction for address bus

Warning:
Must be compatible with ADDR_PORT

Definition at line 34 of file isa_bus.h.

Referenced by rtl8019read(), rtl8019SetupPorts(), and rtl8019write().

#define ADDR_PINS   0b00011111
 

port pins used by address bus( 1 indicate that the pin is used)

Definition at line 36 of file isa_bus.h.

Referenced by rtl8019read(), rtl8019SetupPorts(), and rtl8019write().

#define ADDR_PORT   PORTA
 

data port used for address bus

Definition at line 32 of file isa_bus.h.

Referenced by rtl8019read(), and rtl8019write().

#define CNTRL_DDR   DDRA
 

data direction for control bus

Warning:
Must be compatible with CNTRL_PORT

Definition at line 60 of file isa_bus.h.

Referenced by rtl8019SetupPorts().

#define CNTRL_PINS   0b11100000
 

port pins used by control bus (1 indicate that the pin is used)

Definition at line 62 of file isa_bus.h.

Referenced by rtl8019SetupPorts().

#define CNTRL_PORT   PORTA
 

port used for control bus

Definition at line 58 of file isa_bus.h.

Referenced by main(), rtl8019read(), rtl8019SetupPorts(), and rtl8019write().

#define DATA_DDR_L   DDRC
 

data direction for data bus

Warning:
Must be compatible with DATA_PORT

Definition at line 45 of file isa_bus.h.

Referenced by rtl8019SetupPorts(), and rtl8019write().

#define DATA_PINS_L   0b11111111
 

port pins used by data bus
(1 indicate that the pin is used)

Definition at line 51 of file isa_bus.h.

Referenced by rtl8019SetupPorts(), and rtl8019write().

#define DATA_PORT_L   PORTC
 

port used for data bus

Definition at line 42 of file isa_bus.h.

Referenced by rtl8019SetupPorts(), and rtl8019write().

#define DATA_READ_L   PINC
 

port used to read data

Warning:
Must be compatible with DATA_PORT

Definition at line 48 of file isa_bus.h.

Referenced by rtl8019read().

 
#define nop  )     asm volatile("nop\n\t"::)
 

Insert a nop.

Definition at line 105 of file isa_bus.h.

#define READ_PIN   0b00100000
 

port pin used by read line (1 indicate that the pin is used)

Definition at line 66 of file isa_bus.h.

Referenced by rtl8019read(), and rtl8019SetupPorts().

#define RESET_PIN   0b10000000
 

port pin used by reset line (1 indicate that the pin is used)

Definition at line 64 of file isa_bus.h.

Referenced by main(), and rtl8019SetupPorts().

#define RstBits _port_sss,
_mask_sss   )     _port_sss &= (~ (_mask_sss) )
 

Reset bit's positions that have 0 on mask.

Definition at line 92 of file isa_bus.h.

Referenced by main(), rtl8019read(), rtl8019SetupPorts(), and rtl8019write().

#define SetBits _port_sss,
_mask_sss   )     _port_sss |= (_mask_sss)
 

Set bit's positions that have 1 on mask.

Definition at line 90 of file isa_bus.h.

Referenced by main(), rtl8019read(), rtl8019SetupPorts(), and rtl8019write().

 
#define WaitState  ) 
 

Value:

{ \
        nop(); \
        nop(); \
}
Insert a delay ~= 125ns.

Warning:
Crystal values about 16MHz => PERIOD=62.5us
=> WaitState = 2*62.5us=125ns
If you change the crystal pay attention to this

Definition at line 113 of file isa_bus.h.

Referenced by rtl8019read(), and rtl8019write().

#define WRITE_PIN   0b01000000
 

port pin used by write line (1 indicate that the pin is used)

Definition at line 68 of file isa_bus.h.

Referenced by rtl8019SetupPorts(), and rtl8019write().

#define WritePort _port_sss,
_mask_sss,
_value_sss   ) 
 

Value:

RstBits( _port_sss, (_mask_sss) ); \
                        SetBits( _port_sss, ( (_mask_sss) & (_value_sss) ) )
Write a new value to port using mask:
1) put 0 on all the mask bits that are 0
2) put 1 on all the mask bits that are 1.

Attention:
i use the mask on seting bits just to be sure that i will not modify the rest of port content.

Definition at line 100 of file isa_bus.h.

Referenced by rtl8019read(), and rtl8019write().


Function Documentation

unsigned char rtl8019read unsigned char  address  ) 
 

Reads byte from RTL8019 register.

Parameters:
address address of register to read
Warning:
The data port is assumed to be already configured as input, and is left as an input port when done

Definition at line 54 of file isa_bus.c.

References ADDR_DDR, ADDR_PINS, ADDR_PORT, ASSERT, CNTRL_PORT, DATA_READ_L, READ_PIN, RstBits, SetBits, WaitState, and WritePort.

void rtl8019SetupPorts void   ) 
 

Sets up the ports used for communication with the RTL8019 NIC (data bus, address bus, read, write, and reset).

Definition at line 84 of file isa_bus.c.

References ADDR_DDR, ADDR_PINS, CNTRL_DDR, CNTRL_PINS, CNTRL_PORT, DATA_DDR_L, DATA_PINS_L, DATA_PORT_L, READ_PIN, RESET_PIN, RstBits, SetBits, and WRITE_PIN.

Referenced by main().

void rtl8019write unsigned char  data,
unsigned char  address
 

Writes byte to RTL8019 register.

Parameters:
data - byte to write to register
address - register address
Warning:
The data port is left in the input state with pullups enabled.

Definition at line 20 of file isa_bus.c.

References ADDR_DDR, ADDR_PINS, ADDR_PORT, ASSERT, CNTRL_PORT, DATA_DDR_L, DATA_PINS_L, DATA_PORT_L, RstBits, SetBits, WaitState, WRITE_PIN, and WritePort.


Generated on Fri Jan 6 22:23:18 2006 for EtherProgs by  doxygen 1.4.5