Simple library to manage the WatchDog timer, tested on LPC1768

Revision:
0:3744cb611b63
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WatchDogTimer.cpp	Sat Jan 03 13:26:51 2015 +0000
@@ -0,0 +1,24 @@
+/**
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ */
+
+#include "WatchDogTimer.h"
+
+int WatchDogTimer::systemResetReason() {
+    return ((LPC_WDT->WDMOD >> 2) & 1) ? SYSTEM_RESET_WATCH_DOG : SYSTEM_RESET_NORMAL;
+}
+
+WatchDogTimer::WatchDogTimer(float seconds) {
+    LPC_WDT->WDCLKSEL = 0x1;                // Set CLK src to PCLK
+    uint32_t clk = SystemCoreClock / 16;    // WD has a fixed /4 prescaler, PCLK default is /4 
+    LPC_WDT->WDTC = seconds * (float)clk;   // Load WD Timer Constant with value determined by float s
+    LPC_WDT->WDMOD = 0x3;                   // Enabled and Reset        
+    feed();
+}
+
+void WatchDogTimer::feed() {
+    LPC_WDT->WDFEED = 0xAA;
+    LPC_WDT->WDFEED = 0x55;
+}
\ No newline at end of file