The WatchDogTimer Library written to be fully compatible with C++11 and as header-only to use easily.
#include <wdt.hpp>
// Or
#include "wdt.hpp"
class MyWatchdogTimer : public WatchdogTimer
{
public:
virtual void on_timeout()
{
// To do when your dog is bark.
...
}
};
MyWatchdogTimer wdt;
// wdt is scheduled to call on_timeout() after 100ms once.
wdt.kick(100);
As well as, you can also kick your dog to watch forever by calling kick()
with loop
flag true
.
// wdt is scheduled to call on_timeout() after 100ms forever.
wdt.kick(100, true);
while (true)
{
// To do somethings
...
if (there_is_no_problem)
wdt.clear();
}
wdt.stop();