Closed pablosun closed 7 years ago
Example ino with LinkIt SDK API:
// WDT: Watch Dog example
//
// Hardware: LinkIt 7697
//
// This example calls LinkIt SDK v4.x API directly
#include <hal_wdt.h> // The header for WDT API
void setup() {
// Before we enable WDT, we read reset status
// to know if we are rebooting from a WDT reset.
hal_wdt_config_t wdt_config;
wdt_config.mode = HAL_WDT_MODE_RESET;
wdt_config.seconds = 4; // If the WDT starved for 4 second, reset.
// Initialize hardware
Serial.begin(9600);
pinMode(6, INPUT);
if (HAL_WDT_STATUS_OK != hal_wdt_init(&wdt_config)) {
//error handle
Serial.println("cannot initialize watch dog, hang here.");
while (1)
{
delay(10);
}
}
hal_wdt_enable(HAL_WDT_ENABLE_MAGIC); //enable WDT to start the timer.
hal_wdt_feed(HAL_WDT_FEED_MAGIC); //feed the WDT regularly.
}
void loop() {
delay(100);
Serial.print("time=");
Serial.println(millis());
// if USR button is pressed, feed the watchdog to prevent reset.
if (digitalRead(6))
{
hal_wdt_feed(HAL_WDT_FEED_MAGIC);
Serial.println("Feed WDT");
}
}
There are HW watch dog functionality in MT7697, but it is not exposed to Arduino.