Monitor for central heating system (e.g. 2zones+hw) Supports up to 15 temp probes (DS18B20/DS18S20) 3 valve monitors Gas pulse meter recording Use stand-alone or with nodeEnergyServer See http://robdobson.com/2015/09/central-heating-monitor
Dependencies: EthernetInterfacePlusHostname NTPClient Onewire RdWebServer SDFileSystem-RTOS mbed-rtos mbed-src
Diff: Watchdog.h
- Revision:
- 12:a52996515063
- Child:
- 19:0367cb46d003
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Watchdog.h Sun Feb 22 22:08:37 2015 +0000 @@ -0,0 +1,35 @@ +#ifndef __WATCHDOG__H +#define __WATCHDOG__H +#include "mbed.h" + +// Simon's Watchdog code from +// http://mbed.org/forum/mbed/topic/508/ +class Watchdog +{ + public: + // Load timeout value in watchdog timer and enable + void SetTimeoutSecs(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->WDMOD = 0x3; // Enabled and Reset + Feed(); + } + // "kick" or "feed" the dog - reset the watchdog timer + // by writing this required bit pattern + void Feed() + { + LPC_WDT->WDFEED = 0xAA; + LPC_WDT->WDFEED = 0x55; + } + + bool WatchdogCausedRestart() + { + if ((LPC_WDT->WDMOD >> 2) & 1) + return true; + return false; + } +}; + +#endif