Page 1 of 1

Attache the Arduino ISR function to the class member

Posted: Fri Mar 25, 2022 10:53 pm
by mkeyno
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
  1. typedef void (*irqCallback)  (void);
  2.                 irqCallback timerCBArray[] ={  timerCB0 };
  3.  
  4. void ARDUINO_ISR_ATTR timerCB0(){
  5.   portENTER_CRITICAL_ISR(&lock0);  
  6.     //manipulate class private and public variables
  7.   portEXIT_CRITICAL_ISR(&lock0);              
  8.   }
  9.  
  10. hw_timer_t * timer[3] = NULL;
  11.  
  12. class myClass
  13. {
  14. private:
  15.   irqCallback timmerCB;
  16.   volatile uint8_t pri_var1,pri_var2;
  17.   static uint8_t class_instance_number=0;
  18. public:
  19.   volatile uint8_t pub_var1,pub_var2;
  20.   myClass(/* args */);
  21.   ~myClass();
  22. };
however, I came to this problem, how can I change the variable inside the interrupt regards to each class instance
any help really appreciated