This provides a basic Watchdog service, and includes a startup detection to determine if the reset was caused by the WD.

Dependents:   A_CANAdapter LeonardoMbos AVC_2012 RT_CAN ... more

Using this Watchdog Class

#include "Watchdog.h"

Watchdog wd;

...
void 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
   }
}
Revision:
2:2873f068f325
Parent:
1:5a1ff72b5915
Child:
4:22c5c4aa4661
--- a/Watchdog.h	Sun Mar 20 23:24:36 2011 +0000
+++ b/Watchdog.h	Thu Jun 16 20:55:38 2011 +0000
@@ -3,7 +3,8 @@
 /// This provides basic Watchdog service for the mbed. You can configure
 /// various timeout intervals that meet your system needs. Additionally,
 /// it is possible to identify if the Watchdog was the cause of any 
-/// system restart.
+/// system restart, permitting the application code to take appropriate
+/// behavior.
 /// 
 /// Adapted from Simon's Watchdog code from http://mbed.org/forum/mbed/topic/508/
 ///
@@ -12,11 +13,23 @@
 ///     this copyright statement remains in the source file.
 /// @author David Smart
 ///
+/// History
+/// \li v1.00 - 20110616: initial release with some documentation improvements
+///
 #ifndef WATCHDOG_H
 #define WATCHDOG_H
 #include "mbed.h"
 
-/// Watchdog provides the interface to the Watchdog feature
+/// 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:
 /// @code
@@ -25,11 +38,14 @@
 /// ...
 /// main() {
 ///    if (wd.WatchdogCausedReset())
-///        pc.printf("Watchdog caused reset. WD being armed for 30s cycle.\r\n");
+///        pc.printf("Watchdog caused reset.\r\n");
 ///      
-///    wd.Configure(30.0);      // sets the timeout interval
+///    wd.Configure(3.0);       // sets the timeout interval
 ///    for (;;) {
 ///         wd.Service();       // kick the dog before the timeout
+///         // do other work
+///    }
+/// }
 /// @endcode
 ///
 class Watchdog {