Best way to mate interrupts with c++ periephal drivers?
Hey!
Lets say I write general Can periephal driver in c++ for stm32f4 series(which I'm actually doing), then interrupt handlers for can1 and can2.
Now the proplem is how do I tell lets say can 1 rx interrupt, that >>this instance of object<< is the one which you should use to access correct circular buffer to fill.
What comes to my mind is that I could put X amount of static pointers inside the namespace but outside the periephal class object(to limit scope), and then in the constructor set correct address to the pointer, but is there better ways?
I'm not really fan of the Arduino way of copypasting the driver in different static objects, one for each periephal because that leads to hard to maintain very error prone code.(I assume they still do that)