Jonathan Jones
/
Radios
Radio Structures in OOP
Diff: utils/Watchdog/Watchdog.h
- Revision:
- 2:7d523bdd2f50
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utils/Watchdog/Watchdog.h Sun Dec 28 06:05:17 2014 +0000 @@ -0,0 +1,19 @@ +#include "mbed.h" + +class Watchdog { +public: +// Load timeout value in watchdog timer and enable + void set(float s) { + LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK + uint32_t clk = SystemCoreClock>>4; // WD has a fixed /4 prescaler, PCLK default is /4 + LPC_WDT->WDTC = s * (float)clk; + LPC_WDT->WDMOD = 0x3; // Enabled and Reset + renew(); + } +// "kick" or "feed" the dog - reset the watchdog timer +// by writing this required bit pattern + void renew() { + LPC_WDT->WDFEED = 0xAA; + LPC_WDT->WDFEED = 0x55; + } +};