> 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:[EMAIL PROTECTED] Sent: Wednesday, December 19, 2007 2:26 PM To: Stu Bell Cc: Weddington, Eric; [email protected] Subject: Re: [avr-libc-dev] Wishlist: place static bool in GPIO registers On Dec 19, 2007 1:24 PM, Stu Bell <[EMAIL PROTECTED]> 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 _______________________________________________ AVR-libc-dev mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/avr-libc-dev
