a

Fork of Watchdog by Bernard Remond

Revision:
2:2873f068f325
Parent:
0:7a316f14da9c
Child:
3:5959d3d35221
--- a/Watchdog.cpp	Sun Mar 20 23:24:36 2011 +0000
+++ b/Watchdog.cpp	Thu Jun 16 20:55:38 2011 +0000
@@ -1,4 +1,17 @@
-
+/// @file Watchdog.cpp provides the interface to the Watchdog module
+///
+/// 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.
+/// 
+/// Adapted from Simon's Watchdog code from http://mbed.org/forum/mbed/topic/508/
+///
+/// @note Copyright © 2011 by Smartware Computing, all rights reserved.
+///     This software may be used to derive new software, as long as
+///     this copyright statement remains in the source file.
+/// @author David Smart
+///
 #include "mbed.h"
 #include "Watchdog.h"
 
@@ -6,14 +19,14 @@
 
 /// Watchdog gets instantiated at the module level
 Watchdog::Watchdog() {
-    wdreset = (LPC_WDT->WDMOD >> 2) & 1;
+    wdreset = (LPC_WDT->WDMOD >> 2) & 1;    // capture the cause of the previous reset
 }
 
 /// Load timeout value in watchdog timer and enable
 void Watchdog::Configure(float s) {
     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 = s * (float)clk;
+    LPC_WDT->WDTC = (uint32_t)(s * (float)clk);
     LPC_WDT->WDMOD = 0x3;                   // Enabled and Reset
     Service();
 }