Test program for watchdog timer library. LED will flash for 5 seconds then simulate a hard fault. Watchdog timer will timeout after 3 seconds and reset the system.

Dependencies:   WatchdogTimer mbed

Revision:
0:882d720a2cc6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jun 30 16:45:14 2015 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+#include "WatchdogTimer.h"
+
+DigitalOut led(LED1);
+WatchdogTimer watchdogTimer(3); //Watchdog timer with 3 second timeout
+
+int main()
+{
+    Timer timer;
+    timer.start();
+    
+    //NOTE: Ensure your main loop operations don't take longer than the watchdog timeout you set
+    while(1)
+    {
+        //Flash LED for five seconds
+        if (timer.read_ms() < 5000)
+        {
+            led = 1;
+            wait(0.2);
+            led = 0;
+            wait(0.2);
+        }
+        else
+        {
+            //Simulate hard fault
+            while(1) {}
+        }
+        
+        //Kick the watchdog to reset its timer
+        watchdogTimer.kick();
+    }
+}