Closed
Description
Is your feature request/improvement related to a problem? Please describe.
I'm using the HardwareTimer class and would like to pass a custom parameters to the interrupt callback. Currently the only way of doing this is to use global variable(s).
Describe the solution you'd like
I guess the easiest fix without breaking any compatibility would be to add a pointer for every timer channel that can be accessed from within the interrupt:
Usage:
static inline void isr(HardwareTimer* timer) {
if(timer == nullptr){
return;
}
custom_class* param = (custom_class*)timer->getArg();
if(param == nullptr){
return;
}
param ->work();
}
custom_class param;
HardwareTimer m_timer(TIM1);
m_timer.attachInterrupt(GptChannel::isr, (void*)¶m);