new
Watchdog Class Reference
The Watchdog class provides the interface to the Watchdog feature. More...
#include <watchdog.h>
Public Member Functions | |
Watchdog () | |
Create a Watchdog object. | |
void | Configure (float timeout) |
Configure the timeout for the Watchdog. | |
void | Service () |
Service the Watchdog so it does not cause a system reset. | |
bool | WatchdogCausedReset () |
WatchdogCausedReset identifies if the cause of the system reset was the Watchdog. |
Detailed Description
The Watchdog class provides the interface to the Watchdog feature.
Embedded programs, by their nature, are usually unattended. If things go wrong, it is usually important that the system attempts to recover. Aside from robust software, a hardware watchdog can monitor the system and initiate a system reset when appropriate.
This Watchdog is patterned after one found elsewhere on the mbed site, however this one also provides a method for the application software to determine the cause of the reset - watchdog or otherwise.
example:
Watchdog wd; ... main() { if (wd.WatchdogCausedReset()) pc.printf("Watchdog caused reset.\r\n"); wd.Configure(3.0); // sets the timeout interval for (;;) { wd.Service(); // kick the dog before the timeout // do other work } }
Definition at line 51 of file watchdog.h.
Constructor & Destructor Documentation
Watchdog | ( | ) |
Create a Watchdog object.
Watchdog gets instantiated at the module level.
example:
Watchdog wd; // placed before main
Definition at line 33 of file watchdog.cpp.
Member Function Documentation
void Configure | ( | float | timeout ) |
Configure the timeout for the Watchdog.
Load timeout value in watchdog timer and enable.
This configures the Watchdog service and starts it. It must be serviced before the timeout, or the system will be restarted.
example:
... wd.Configure(1.4); // configure for a 1.4 second timeout ...
- Parameters:
-
[in] timeout in seconds, as a floating point number
- Returns:
- none
Definition at line 54 of file watchdog.cpp.
void Service | ( | ) |
Service the Watchdog so it does not cause a system reset.
"Service", "kick" or "feed" the dog - reset the watchdog timer by writing this required bit pattern
example:
wd.Service();
- Returns:
- none
Definition at line 117 of file watchdog.cpp.
bool WatchdogCausedReset | ( | ) |
WatchdogCausedReset identifies if the cause of the system reset was the Watchdog.
get the flag to indicate if the watchdog causes the reset
example:
if (wd.WatchdogCausedReset())) {
- Returns:
- true if the Watchdog was the cause of the reset
Definition at line 128 of file watchdog.cpp.
Generated on Sun Aug 7 2022 17:59:38 by 1.7.2