[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-libc-dev] Wishlist: place static bool in GPIO registers
From: |
Stu Bell |
Subject: |
RE: [avr-libc-dev] Wishlist: place static bool in GPIO registers |
Date: |
Wed, 19 Dec 2007 14:39:22 -0700 |
> The bit-field approach solves my primary complaint by not needing any
> accessor functions. Both if (my_flag) and my_flag = true; work as
> expected. As for the declaration, perhaps #define my_flag
> (GPIOR0_BIT.bit0) would be sufficient, where GPIOR0_BIT is defined
> by avr-libc as
>
> #define GPIOR0_BIT (*(volatile BitRegisterType
*)_SFR_MEM_ADDR(GPIOR0))
I think you need the pointer dereference (GPIOR0_BIT->bit0) instead of
the member dereference (GPIOR0_BIT.bit0). Otherwise, what you suggest
is a pretty good idea.
Best regards,
Stu Bell
DataPlay (DPHI, Inc.)
-----Original Message-----
From: Shaun Jackman [mailto:address@hidden
Sent: Wednesday, December 19, 2007 2:26 PM
To: Stu Bell
Cc: Weddington, Eric; address@hidden
Subject: Re: [avr-libc-dev] Wishlist: place static bool in GPIO
registers
On Dec 19, 2007 1:24 PM, Stu Bell <address@hidden> wrote:
...
> The real problem with a full workup would be a macro to help define
> "bit" variables. For example it would be cool to do something like
> the
> following:
>
> #define DECLARE_BIT_VARIABLE(var,port,bnum) \
> #define (name) ((volatile BitRegisterType*)_SFR_MEM_ADDR( (port )
> )->bit ## bnum
>
>
> The above code is completely wrong, as the preprocessor won't allow a
> declare within a declare. Does someone have a clue how to "nicely"
> declare a bit variable other than putting the above into a long
> explanation in the comment header/documentation (which will surely be
> ignored by the noobs)?
...
Cheers,
Shaun