c++ - Preprocessor directive for certain address space -
lets wanted define directive take int8_t , store specified memory location 0x0071. how this?
i know say
#define ddra 0xaa
and make ddra = 0xaa, how make typing
ddra = 0xbb;
will write 0xbb in address location 0x0071?
the avr-gcc headers define i/o ports using internal _sfr_io8
macro, e.g. in <avr/iom328p.h>
:
#define portb _sfr_io8(0x05)
this macro defined in <avr/srf_defs.h>
as:
#define _sfr_io8(io_addr) _mmio_byte((io_addr) + __sfr_offset)
which, in turn, resolved _mmio_byte
macro in same file:
#define _mmio_byte(mem_addr) (*(volatile uint8_t *)(mem_addr))
the definition of __sfr_offset
is… little obscure. has 32-byte offset between avr i/o space , start of memory.
tl;dr: #define ddra _sfr_io8(0x71)
, standard headers part should doing if it's standard i/o port.
Comments
Post a Comment