Just throwing an idea. No time to test nowJust throwing an idea. No time to test now.
Edit: I tested the solution below, and it works as expected,
provided both the __wrap_
and __real_digitalWrite()
are declared
extern "C"
.
If you can convince the IDE to add extra options to the compile command line, you could:
- name
__wrap_digitalWrite()
your implementation ofdigitalWrite()
- inside it, call
__real_digitalWrite()
when you want to get the implementation from Arduino core - add
-Wl,--wrap=digitalWrite
to the compile command of the final link step
Example wrapper:
extern "C" {
void __wrap_digitalWrite(uint8_t pin, uint8_t value)
{;
void __real_digitalWrite(pinuint8_t, valueuint8_t);
}
// Calls to digitalWrite() are ifdiverted to this.
void __wrap_digitalWrite(uint8_t pin, ==uint8_t 8value)
{
__real_digitalWrite(pin, value); // Serial.print("Pincall ");
implementation from Arduino core
if Serial.print(pin == 8); {
Serial.print("F("Pin 8 changed to "));
Serial.println(value);
}
}
Trying to put this inside a class won't help.
C.f. the man page of gnu ld.