Currently pseudocode (the exact structure of pin_type is irrelevant):
Code: Select all
//variant.cpp
const pin_type variant_pins[] = {...}
//gpio.h
extern const pin_type variant_pins[];
inline void digitalWrite(pin, value) {...variant_pins[pin]...}
//x.ino
...gpio.h included...
digitalWrite(PA0, LOW);
//other.cpp
...gpio.h included...
digitalWrite(PA1, LOW);
I could put the whole list into the header (as static local), which works, but then it is duplicated in every compilation unit when used.
I checked https://stackoverflow.com/q/5010216/834966 , https://stackoverflow.com/q/11403800/834966 , -fmerge-all-constants , -flto and god knows what already.
I always get either no compile time evaluation, or duplicated array.
Anybody knows some solution to this?