class member function as an interrupt service routine

Yah, the ISR cannot be a member. You can do things like this...

class Stuff
{
private:
  static Stuff* isr_handler;
protected:
  void handle_isr() { .. isr code goes here .. }
public:
  Stuff(): isr_hander(this) {}
  static isr() { if ( isr_handler ) isr_handler->handle_isr(); }
};

Stuff::isr_handler = 0;

Then call Stuff::isr() in the real ISR. This will ensure that the most recently-constructed object gets the interrupt handler, in the "handle_isr()" method.

1 Like