Using timerAttachInterrupt inside a library

dalvikvm
Posts: 3
Joined: Wed Mar 14, 2018 7:05 am

Using timerAttachInterrupt inside a library

Postby dalvikvm » 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():

Code: Select all

void IRAM_ATTR TriggerTimer::cdInterrupt(){
 //some codes
}
This is how I used the attachTimerInterrupt() function:

Code: Select all

void TriggerTimer::startTimer(){
  timer = timerBegin(0, 80, true);
  timerAttachInterrupt(timer, &cdInterrupt, true);
  timerAlarmWrite(timer, 1000000, true);
  timerAlarmEnable(timer);
}
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?

dalvikvm
Posts: 3
Joined: Wed Mar 14, 2018 7:05 am

Re: Using timerAttachInterrupt inside a library

Postby dalvikvm » Fri Mar 16, 2018 3:13 am

I was able to fix it by making the function static in the header file.

Who is online

Users browsing this forum: No registered users and 94 guests