using esp32 attachInterrupt in myclass library

teldrive
Posts: 1
Joined: Thu Oct 13, 2022 10:38 pm

using esp32 attachInterrupt in myclass library

Postby teldrive » Thu Oct 13, 2022 10:54 pm

Hi everyone i am migrating a library (working fine) for arduino uno to work with esp32 but i am currenly blocked, i have seen in forums some incompatibility issues with arduino compiling cpp , but not sure if related to my issue

--------------------------------------------------------------on file myclass.h
public:
void begin();
void IRAM_ATTR timerISR();
void IRAM_ATTR pinchangeISR1();

--------------------------------------------------------------on file myclass.cpp
include "myclass.h"
hw_timer_t * Timer1 = NULL;

void begin(){
attachInterrupt(digitalPinToInterrupt(rxPin1), pinchangeISR1, CHANGE);

Timer1 = timerBegin(0, 80, true);
timerAttachInterrupt(Timer1,timerISR,true);
timerAlarmWrite(Timer1, DALI_TE, true);
timerAlarmEnable(Timer1);
}

void IRAM_ATTR myclass::timerISR() {
.........my funtion
};
void IRAM_ATTR myclass::pinchangeISR1(){
.........my funtion
};

----------------------------------------------------------------------------------------------
and I receive compile errors:
error: invalid use of non-static member function attachInterrupt(digitalPinToInterrupt(rxPin1), pinchangeISR1, CHANGE);
error: cannot declare member function 'void myclass::timerISR()' to have static linkage [-fpermissive]
static void IRAM_ATTR myclass::timerISR() {

.............if I define instead timerAttachInterrupt(Timer1,&timerISR,true);, obtain other error
error: cannot convert 'void (myclass::*)()' to 'void (*)()' for argument '2' to 'void timerAttachInterrupt(hw_timer_t*, void (*)(), bool)'
timerAttachInterrupt(Timer1,&timerISR,true);


please help

Who is online

Users browsing this forum: Corand and 107 guests