Question.5
A developer registers a C++ object method as an RTOS callback:
class Button {
public:
void onClick() { toggle_led(); }
static void isr_wrapper(void* ctx) {
static_cast<Button*>(ctx)->onClick();
}
void register_isr() {
attach_interrupt(PIN_5, isr_wrapper, this);
}
};Why is this passed as the void* context?