Skip to content

Conversation

@usbalbin
Copy link
Owner

@usbalbin usbalbin commented Oct 12, 2025

I have exposed this as two macros(to be renamed).

  • make_foo requires the addresses to be known at proc_macro time, as in literals. This could be made to be zero cost since the value of the static itself is not needed, by moving it into some wonky linker section.
  • make_bar requires the name of a symbol to use as addressing base and a offset. Also this could be made zero cost as above.

As yet another alternative it might also be possible to to put the address in the value of the static. This way we could either at const eval time or at runtime, put in the address as the value of the static. However this would cause a memory cost of 4 bytes per metric.

// Hardcoded address
make_foo!(DWT_CYCCNT: i8 @ 0xE0001004, "DWT_CYCCNT");

// Hardcoded offset relative to symbol name
make_bar!(RELATIVE_TO_SYMBOL: u32 @ MY_ATOMIC + 0x0000, "RELATIVE_TO_SYMBOL");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants