mirror of
				https://github.com/0xFEEDC0DE64/arduino-esp32.git
				synced 2025-11-04 08:01:38 +01:00 
			
		
		
		
	* TX Flow Control and Code cleanup * Use semaphore instead of delay TX functionality is done. * Use single buffer and empty queue on exit * Fix compile issues because of LwIP code relocation * Add temporary header to fix Azure not compiling * Fix AsyncUDP early init * AsyncUDP Multicast fixes * Add source mac address and rework multicast * Allow redefinition of default pins for Serials 1 and 2 * Update IDF to 3276a13 * Update esptool.py to 2.5.0 * Fix sketches * Fix log level in BluetoothSetial
		
			
				
	
	
		
			40 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
#include "esp_system.h"
 | 
						|
 | 
						|
const int button = 0;         //gpio to use to trigger delay
 | 
						|
const int wdtTimeout = 3000;  //time in ms to trigger the watchdog
 | 
						|
hw_timer_t *timer = NULL;
 | 
						|
 | 
						|
void IRAM_ATTR resetModule() {
 | 
						|
  ets_printf("reboot\n");
 | 
						|
  esp_restart();
 | 
						|
}
 | 
						|
 | 
						|
void setup() {
 | 
						|
  Serial.begin(115200);
 | 
						|
  Serial.println();
 | 
						|
  Serial.println("running setup");
 | 
						|
 | 
						|
  pinMode(button, INPUT_PULLUP);                    //init control pin
 | 
						|
  timer = timerBegin(0, 80, true);                  //timer 0, div 80
 | 
						|
  timerAttachInterrupt(timer, &resetModule, true);  //attach callback
 | 
						|
  timerAlarmWrite(timer, wdtTimeout * 1000, false); //set time in us
 | 
						|
  timerAlarmEnable(timer);                          //enable interrupt
 | 
						|
}
 | 
						|
 | 
						|
void loop() {
 | 
						|
  Serial.println("running main loop");
 | 
						|
 | 
						|
  timerWrite(timer, 0); //reset timer (feed watchdog)
 | 
						|
  long loopTime = millis();
 | 
						|
  //while button is pressed, delay up to 3 seconds to trigger the timer
 | 
						|
  while (!digitalRead(button)) {
 | 
						|
    Serial.println("button pressed");
 | 
						|
    delay(500);
 | 
						|
  }
 | 
						|
  delay(1000); //simulate work
 | 
						|
  loopTime = millis() - loopTime;
 | 
						|
  
 | 
						|
  Serial.print("loop time is = ");
 | 
						|
  Serial.println(loopTime); //should be under 3000
 | 
						|
}
 |