This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Accessing fixed addresses


Using a list of defines like this:

 #define HARDWARE_REG         (*(volatile BYTE *)(0xF000))

is a pretty typical way, another method I use that lends itself well
for grouping related, contiguous registers in a structured way, is to
define a structure containing the regs, define a pointer to that struct,
and initialise the pointer to the apropriate hardware address.

e.g.
processor with a 16 bit timer register at F000, F001 and an 8 bit timer
control and
status register at F002, F003: 

struct cpu_regs
{
volatile	WORD	timer_count;
		BYTE	timer_ctl;
volatile	BYTE	timer_status;
}

struct cpu_regs	*io_register = 0xF000;

Now you can use the io registers like members of a struct:

io_register->timer_count = TIMER_START_COUNT;
io_register->timer_ctl = TIMER_CTL_START;

while(!io_register->timer_status);


    
-- 
|\/|
|/\|  randall@elgar.com
|\/|  rsl@zanshinsys.com http://www.zanshinsys.com
_______________________________________________
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
_______________________________________________
To remove yourself from the crossgcc list, send
mail to crossgcc-request@cygnus.com with the
text 'unsubscribe' (without the quotes) in the
body of the message.