Attache the Arduino ISR function to the class member
Posted: Fri Mar 25, 2022 10:53 pm
I was intend to use timer interrupt for limited instances of a class in my ESP32 Arduino project, my first code conception was as follows
however, I came to this problem, how can I change the variable inside the interrupt regards to each class instance
any help really appreciated
- typedef void (*irqCallback) (void);
- irqCallback timerCBArray[] ={ timerCB0 };
- void ARDUINO_ISR_ATTR timerCB0(){
- portENTER_CRITICAL_ISR(&lock0);
- //manipulate class private and public variables
- portEXIT_CRITICAL_ISR(&lock0);
- }
- hw_timer_t * timer[3] = NULL;
- class myClass
- {
- private:
- irqCallback timmerCB;
- volatile uint8_t pri_var1,pri_var2;
- static uint8_t class_instance_number=0;
- public:
- volatile uint8_t pub_var1,pub_var2;
- myClass(/* args */);
- ~myClass();
- };
any help really appreciated