[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-libc-dev] Wishlist: place static bool in GPIO registers
From: |
Shaun Jackman |
Subject: |
Re: [avr-libc-dev] Wishlist: place static bool in GPIO registers |
Date: |
Wed, 19 Dec 2007 14:59:21 -0700 |
On Dec 19, 2007 2:39 PM, Stu Bell <address@hidden> wrote:
> > 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.
I did the pointer dereference in the GPIOR0_BIT macro to match the
usual avr-libc style. GPIOR0, for example, is not a pointer but an
lvalue.
Cheers,
Shaun