[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] C structs for Hardware definitions
From: |
Larry Barello |
Subject: |
[avr-gcc-list] C structs for Hardware definitions |
Date: |
Mon, 26 May 2003 10:48:48 -0700 |
Before I go type in a bunch of stuff, is there any good reason why C structs &
bitfields
can't be used to access hardware, like the USART control registers? Is it a
matter of
efficiency: with a dereferenced pointer GCC has to treat it like memory and not
use the
bit test/set instructions? Or is it dealing with the screwy I/O map of the
AVR? Then I
can write one set of handlers for the USARTs and pass the pointer to make
things happen.
e.g.
typedef struct
{
unsigned char UDR;
struct
{
unsigned char bitthis:1;
unsigned char bitthat:1;
unsigned char etc:3;
} USCRA;
struct
{
...
} USCRB;
...
unsigned UBRR;
} *pUSART;
pUSART USART0 = 0xXX, USART1 = 0xYYY;
...
if (USART0->bitthis == 0) ...
----
Larry Barello
www.barello.net
- [avr-gcc-list] C structs for Hardware definitions,
Larry Barello <=