Reset the watchdog timer on the ESP8266

See: https://github.com/felis/USB_Host_Shield_2.0/pull/263#issuecomment-279222338
This commit is contained in:
Kristian Sloth Lauszus 2017-02-14 00:27:35 +01:00
parent 4cb265e9a8
commit 3952d900ff

View file

@ -60,6 +60,9 @@ void setup() {
uint8_t sample_rd = 0;
uint8_t gpinpol_copy = Usb.regRd(rGPINPOL);
for(uint8_t i = 0; i < 16; i++) {
#ifdef ESP8266
yield(); // needed in order to reset the watchdog timer on the ESP8266
#endif
for(uint16_t j = 0; j < 65535; j++) {
Usb.regWr(rGPINPOL, sample_wr);
sample_rd = Usb.regRd(rGPINPOL);
@ -206,7 +209,11 @@ void loop() {
print_hex(buf.bNumConfigurations, 8);
/**/
E_Notify(PSTR("\r\n\nAll tests passed. Press RESET to restart test"), 0x80);
while(1);
while(1) {
#ifdef ESP8266
yield(); // needed in order to reset the watchdog timer on the ESP8266
#endif
}
}
break;
case( USB_STATE_ERROR):
@ -228,6 +235,9 @@ void halt55() {
while(1) {
Usb.regWr(0x55, 0x55);
#ifdef ESP8266
yield(); // needed in order to reset the watchdog timer on the ESP8266
#endif
}
}
@ -253,7 +263,11 @@ void print_hex(int v, int num_places) {
/* prints "Press any key" and returns when key is pressed */
void press_any_key() {
E_Notify(PSTR("\r\nPress any key to continue..."), 0x80);
while(Serial.available() <= 0); //wait for input
while(Serial.available() <= 0) { // wait for input
#ifdef ESP8266
yield(); // needed in order to reset the watchdog timer on the ESP8266
#endif
}
Serial.read(); //empty input buffer
return;
}