I suspect this can't be done but I may as well ask
If I have a class e.g. MyClass and it has a method called callback() which I'd like to be able to get called by as an ISR
but when I try to write the code to in by MyClass::setup()
e.g.
MyClass::setup()
{
attachInterrupt(2,&this->callback,FALLING)
}
I get compile errors
error: ISO C++ forbids taking the address of a bound member function to form a pointer to member function.
As far as I can tell there is no solution to ISR's calling methods in a class
It seems to be possible to call a static function in the class, but this is an issue if I have more than one instance of the class, each being triggered off a different interrupt.
I've read this stackoverflow question and answers but they all seem to suggest its not possible.
I'd be happy to declare a function pointer in my class as a property / variable and initialise it in the constructor, but it just doesn't seem to be possible to access the function pointer to a method in C++ at all.
PS.
What I'm really trying to do is to use SPI DMA with multiple SPI devices and hence the possibilities of multiple DMA callbacks into different instances of the SPI class e.g. on the Due.