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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -