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

Fork of Watchdog by David Smart

Revision:
3:a6655a236a10
Parent:
2:2873f068f325
--- a/Watchdog.cpp	Thu Jun 16 20:55:38 2011 +0000
+++ b/Watchdog.cpp	Tue Jun 03 12:07:38 2014 +0000
@@ -16,7 +16,7 @@
 #include "Watchdog.h"
 
 
-
+#if defined( TARGET_LPC1768 )
 /// Watchdog gets instantiated at the module level
 Watchdog::Watchdog() {
     wdreset = (LPC_WDT->WDMOD >> 2) & 1;    // capture the cause of the previous reset
@@ -42,5 +42,31 @@
 bool Watchdog::WatchdogCausedReset() {
     return wdreset;
 }
+#elif defined( TARGET_LPC4088 )
+/// Watchdog gets instantiated at the module level
+Watchdog::Watchdog() {
+    wdreset = (LPC_WDT->MOD >> 2) & 1;    // capture the cause of the previous reset
+}
 
+/// Load timeout value in watchdog timer and enable
+void Watchdog::Configure(float s) {
+    //LPC_WDT->CLKSEL = 0x1;                // Set CLK src to PCLK
+    uint32_t clk = 500000 / 4;    // WD has a fixed /4 prescaler, and a 500khz oscillator
+    LPC_WDT->TC = (uint32_t)(s * (float)clk);
+    LPC_WDT->MOD = 0x3;                   // Enabled and Reset
+    Service();
+}
 
+/// "Service", "kick" or "feed" the dog - reset the watchdog timer
+/// by writing this required bit pattern
+void Watchdog::Service() {
+    LPC_WDT->FEED = 0xAA;
+    LPC_WDT->FEED = 0x55;
+}
+
+/// get the flag to indicate if the watchdog causes the reset
+bool Watchdog::WatchdogCausedReset() {
+    return wdreset;
+}
+#endif
+