I want to put this code, that i used for generate a precise interrupt into a library:
Code: Select all
hw_timer_t * timer0 = NULL;
portMUX_TYPE timerMux0 = portMUX_INITIALIZER_UNLOCKED;
void IRAM_ATTR onTimer0(){
portENTER_CRITICAL_ISR(&timerMux0);
//Code
portEXIT_CRITICAL_ISR(&timerMux0);
}
void setup() {
timer0 = timerBegin(0, 80, true);
timerAttachInterrupt(timer0, &onTimer0, true);
timerAlarmWrite(timer0, 2000000, true);
timerAlarmEnable(timer0); // enable
}
Does anybody know how to implement it ?
I hope to have explain it well, Many thanks