I am using the ESP32 Arduino Framework and I have some GPIO expanders attached via I²C. They work fine and I now want to map some unused pin numbers to them so I can used my custom pin numbers in pinMode, digitalRead and digitalWrite.
Luckily, the Arduino core links these functions weakly.
extern void pinMode(uint8_t pin, uint8_t mode) __attribute__ ((weak, alias("__pinMode")));
I defined my own functions like so:
void pinMode(uint8_t pin, uint8_t mode) {
if(pin<0x80)
// call conventional handler
else
// communicate with GPIO expander via I²C
}
Unfortunately, calling any of the functions will not result in the linker picking my implementation but the linker picks the default implementation.
Any ideas how to override the weakly linked pinMode, digitalWrite and digitalRead?