Skip to content

Commit

Permalink
add esp8266 comments and specfic code
Browse files Browse the repository at this point in the history
  • Loading branch information
brentru committed Dec 3, 2021
1 parent d03cd2a commit ea6155d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
Empty file.
18 changes: 13 additions & 5 deletions examples/BasicUsage/BasicUsage.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

void setup() {
Serial.begin(115200);
while(!Serial) delay(10);
while (!Serial)
delay(10);
// wait for Arduino Serial Monitor (native USB boards)

Serial.println("Adafruit Watchdog Library Demo!");
Expand All @@ -29,8 +30,9 @@ void setup() {

// Now loop a few times and periodically reset the watchdog.
Serial.println("Looping ten times while resetting the watchdog...");
for(int i = 1; i <= 10; ++i) {
Serial.print("Loop #"); Serial.println(i, DEC);
for (int i = 1; i <= 10; ++i) {
Serial.print("Loop #");
Serial.println(i, DEC);
delay(1000);
// Reset watchdog with every loop to make sure the sketch keeps running.
// If you comment out this call watch what happens in about 4 iterations!
Expand All @@ -41,7 +43,7 @@ void setup() {
#ifndef NRF52_SERIES // cannot disable nRF's WDT
// Disable the watchdog entirely by calling Watchdog.disable();
Watchdog.disable();
#endif
#endif

// Finally demonstrate the watchdog resetting by enabling it for a shorter
// period of time and waiting a long time without a reset. Notice you can
Expand All @@ -54,7 +56,13 @@ void setup() {
Serial.print(countdownMS, DEC);
Serial.println(" milliseconds!");
Serial.println();
delay(countdownMS+1000);
#ifndef ARDUINO_ARCH_ESP8266
delay(countdownMS + 1000);
#else
// Calls to delay() and yield() feed the ESP8266's
// hardware and software watchdog timers, delayMicroseconds does not.
delayMicroseconds(countdownMS * 1000);
#endif

// Execution will never get here because the watchdog resets the Arduino!
}
Expand Down
Empty file removed examples/Sleep/.esp32.test.skip
Empty file.
Empty file removed examples/Sleep/.esp8266.test.skip
Empty file.
Empty file removed examples/Sleep/.nrf52840.test.skip
Empty file.
11 changes: 6 additions & 5 deletions utility/WatchdogESP8266.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
/**********************************************************************************************/
int WatchdogESP8266::enable(int maxPeriodMS) {
ESP.wdtDisable();
if (maxPeriodMS < 0)
return 0;

Expand All @@ -30,17 +29,19 @@ int WatchdogESP8266::enable(int maxPeriodMS) {

/**************************************************************************/
/*!
@brief Feeds the Watchdog Timer.
@brief Feeds the Watchdog timer.
NOTE: Calling yield() or delay() also feeds the hardware and software
watchdog timers.
*/
/**************************************************************************/
void WatchdogESP8266::reset() { ESP.wdtFeed(); }

/**************************************************************************/
/*!
@brief Disables the Watchdog Timer.
NOTE: Please don't stop software watchdog too long
(less than 6 seconds), otherwise it will trigger the hardware
watchdog reset.
NOTE: Please don't stop the software WDT too long
(less than 6 seconds), otherwise it will trigger a hardware
watchdog reset!
*/
/**************************************************************************/
void WatchdogESP8266::disable() { ESP.wdtDisable(); }
Expand Down

0 comments on commit ea6155d

Please sign in to comment.