Using timerAttachInterrupt inside a library
Posted: Wed Mar 14, 2018 7:19 am
I moved most of my code to a library but one particular function call gives me an error when compiling.
This is the function needed for the timerAttachInterrupt():
This is how I used the attachTimerInterrupt() function:
The compiler forbids me taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function. It suggests me to use &TriggerTimer::cdInterrupt as a parameters which also gives me an error because the timerAttachInterrupt expects void(*)() and not void(TriggerTimer*)(). How do I solve this problem?
This is the function needed for the timerAttachInterrupt():
Code: Select all
void IRAM_ATTR TriggerTimer::cdInterrupt(){
//some codes
}
Code: Select all
void TriggerTimer::startTimer(){
timer = timerBegin(0, 80, true);
timerAttachInterrupt(timer, &cdInterrupt, true);
timerAlarmWrite(timer, 1000000, true);
timerAlarmEnable(timer);
}