Let say there is a 32 bits register defined as TIMER and its 32 bits address TIMER_ADDR in the memory (DDRAM).
uint32_t TIMER_ADDR; // 32 bits address declared as uint32_t
The layout of TIMER is defined as:
struct timer {
uint32_t start:1;
uint32_t mode: 3;
uint32_t init: 4;
uint32_t value:24
}
Later I defined a local var loc_timer as:
struct timer loc_timer;
How can I to read this register to a local register in the program so I can modify the content
loc_timer.mode = 4;
loc_timer.init = 10;
and write it back to register TIMER ?
something like
(*(uint32_t *))&loc_timer = (*((uint32_t *)(TIMER_ADDR))); // read
(*((uint32_t *)(TIMER_ADDR))) = (*(uint32_t *))&loc_timer; // write
but it does not work :-(