#include "esp_system.h"
const int wdtTimeout = 1000;
hw_timer_t *timer0 = NULL;
hw_timer_t *timer1 = NULL;
hw_timer_t *timer2 = NULL;
hw_timer_t *timer3 = NULL;
void ARDUINO_ISR_ATTR resetModule0() {
Serial.println("1");
timerDetachInterrupt(timer0);
timer0 = NULL;
}
void ARDUINO_ISR_ATTR resetModule1() {
Serial.println("2");
timerDetachInterrupt(timer1);
timer1 = NULL;
}
void ARDUINO_ISR_ATTR resetModule2() {
Serial.println("3");
timerDetachInterrupt(timer2);
timer2 = NULL;
}
void ARDUINO_ISR_ATTR resetModule3() {
Serial.println("4");
timerDetachInterrupt(timer3);
timer3 = NULL;
}
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println("running setup");
timer0 = timerBegin(0, 80, true); //timer 0, div 80
timerAttachInterrupt(timer0, &resetModule0, true); //attach callback
timerAlarmWrite(timer0, wdtTimeout * 1000, false); //set time in us
timer1 = timerBegin(1, 80, true); //timer 0, div 80
timerAttachInterrupt(timer1, &resetModule1, true); //attach callback
timerAlarmWrite(timer1, wdtTimeout * 2000, false); //set time in us
timer2 = timerBegin(2, 80, true); //timer 0, div 80
timerAttachInterrupt(timer2, &resetModule2, true); //attach callback
timerAlarmWrite(timer2, wdtTimeout * 3000, false); //set time in us
timer3 = timerBegin(3, 80, true); //timer 0, div 80
timerAttachInterrupt(timer3, &resetModule3, true); //attach callback
timerAlarmWrite(timer3, wdtTimeout * 4000, false); //set time in us
timerAlarmEnable(timer0);
timerAlarmEnable(timer1);
timerAlarmEnable(timer2);
timerAlarmEnable(timer3);
}
void loop() {
Serial.print("#");
delay(100);
}