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)? ...
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)) Cheers, Shaun _______________________________________________ AVR-libc-dev mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/avr-libc-dev
