Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
Diff: Watchdog.h
- Revision:
- 0:664899e0b988
- Child:
- 12:d472f9811262
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Watchdog.h Sat Jun 30 02:03:51 2012 +0000 @@ -0,0 +1,28 @@ +#ifndef MB_Watchdog +#define MB_Watchdog + +// Simon's Watchdog code from +// http://mbed.org/forum/mbed/topic/508/ +namespace Watchdog { + + // "kick" or "feed" the dog - reset the watchdog timer + // by writing this required bit pattern + void kick() { + LPC_WDT->WDFEED = 0xAA; + LPC_WDT->WDFEED = 0x55; + } + + // Load timeout value in watchdog timer and enable + void kick(const float s) { + LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK + // WD has a fixed /4 prescaler, PCLK default is /4 + static const float clk = static_cast<float>(SystemCoreClock / 16); + LPC_WDT->WDTC = s * clk; + LPC_WDT->WDMOD = 0x3; // Enabled and Reset + kick(); + } + +}; + + +#endif // MB_Watchdog