avr-libc-dev
[Top][All Lists]
Advanced

[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:12:27 -0700

On Dec 19, 2007 12:35 PM, Weddington, Eric <address@hidden> wrote:
> > The General Purpose I/O Registers (GPIOR0 through GIPOR3) are directly
> > bit-accessible. It would be a very handy feature to be able to place a
> > static bool (or any variable, I suppose) in the GPIO registers.
>
> Hi Shaun,
>
> Could you be more specific? Anyone can use bitwise operators now to
> achieve this. Do you have something different in mind?
>
> Eric

Bit flags in GPIO registers can be accomplished right now using
accessor macros, such as
#define my_flag (GPIOR0 & 0x80)
#define set_my_flag(f) ((f) ? (GPIOR0 |= 0x80) : (GPIOR0 &= ~0x80))

This method works fine, so the functionality does already exist. The
need to use a set_my_flag macro is not ideal though. I'd like to be
able to change only the declaration of static bool my_flag; without
having to change all the code that accesses it. In particular,
changing all the instances of my_flag = true; to set_my_flag(true).

So, my wishlist item is to be able to use an attribute on a static
bool to locate it in the GPIO section, similar to PROGMEM, such as
#define IOMEM __attribute__((__iomem__))
static bool IOMEM my_flag;

I suspect this feature would probably require a fair bit of GCC
hacking for a relatively minor syntactic improvement, but I'd
appreciate it!

Cheers,
Shaun




reply via email to

[Prev in Thread] Current Thread [Next in Thread]