I would like to share interrupt routine between class. I followed this tutorial.
But I need to call a member function in callback function, I have the issue :

This is my code :
Timer.h
static void (*__handleISR)(void);
class Timer
{
public:
Timer();
~Timer();
static void init();
static void handleISR(void (*function)(void));
};
Timer.cpp
Timer::Timer()
{
}
Timer::~Timer()
{}
void Timer::init()
{
TCCR2A = 0; //default
TIMSK2 = 0b00000001; // TOIE2
}
ISR (TIMER2_OVF_vect)
{
// 256-6=250 --> (250 x 16uS = 4mS)
// Recharge le timer pour que la prochaine interruption se declenche dans 4mS
TCNT2 = 6;
__handleISR();
}
Device.h
class Device
{
public:
Device();
private:
void isr();
};
Device.cpp
Device::Device()
{
Timer::init();
Timer::handleISR(isr);
}
void Device::isr()
{
// Do my stuff
}
If I set function isr() static, it works. But I need to call member from Device in isr().
How I can call non static member function ? Or another solution ?