avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-chat] question about _SFR_IO8() and friends


From: Britton Kerin
Subject: [avr-chat] question about _SFR_IO8() and friends
Date: Tue, 16 Sep 2014 16:17:56 -0800

I'm on arduino (-mmcu=atmega328p), so I end up wtih __AVR_ARCH__ of 5 and
__SFR_OFFSET of 0x20.  I'm not using _SFR_ASM_COMPAT.  So _SFR_IO8 ends up
coming from:

  #define _SFR_IO8(io_addr) _MMIO_BYTE((io_addr) + __SFR_OFFSET)

I'd like to allow a register to be initialized using one of the
symbolic macros, e.g. DDRD:

   uint8_t dir_reg = DDRD;

and later be able to use it:

  macro_expecting_DDRD (dir_reg);

But I guess this won't work, since the dereference in __MMIO_BYTE will
already have happened.  Nor do I want __SFR_OFFSET added in a second time.
So I'm guessing what I should do is:

  macro_expecting_DDRD (_SFR_MEM8 (dir_reg));

I'm just a tiny bit sad at the fact that the DDRD macro isn't hiding the
underlying interface entirely, and wondering if this is the correct and
decent way or if there is some other nearby way?

Thanks,
Britton



reply via email to

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