Britton Kerin <[email protected]> wrote: > I'd like to allow a register to be initialized using one of the > symbolic macros, e.g. DDRD: > > uint8_t dir_reg = DDRD;
As you already noticed, this already dereferences the port, so you're about to initialize dir_reg with the *contents* of DDRD. What you need is basically explained in the FAQ: http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_port_pass const volatile uint8_t *dir_reg = &DDRD; If you can manage to declare it "const", there are chances the compiler can really generate optimal code (using IN/OUT, rather than memory access instructions) when your macro uses it. Obviously, your macro must then be written to accept a pointer (rather than the register name), and dereference it. -- cheers, Joerg .-.-. --... ...-- -.. . DL8DTL http://www.sax.de/~joerg/ Never trust an operating system you don't have sources for. ;-) _______________________________________________ AVR-chat mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/avr-chat
