Added definition for LCP11u24 and LCP11u24
Fork of Watchdog by
I added support for LPC11U24, ARCH GPRS and ARCH GPRS V2
Revision 7:00706eb585ce, committed 2015-03-17
- Comitter:
- kinan
- Date:
- Tue Mar 17 18:12:08 2015 +0000
- Parent:
- 6:e0f547e22dd5
- Commit message:
- Added a watchdog
Changed in this revision
Watchdog.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Watchdog.cpp Mon Mar 16 01:04:32 2015 +0000 +++ b/Watchdog.cpp Tue Mar 17 18:12:08 2015 +0000 @@ -41,6 +41,36 @@ bool Watchdog::WatchdogCausedReset() { return wdreset; } +#elif defined(TARGET_ARCH_GPRS) || defined(TARGET_LPC11U24) +/// Watchdog gets instantiated at the module level +Watchdog::Watchdog() { + wdreset = (LPC_WWDT->MOD >> 2) & 1; // capture the cause of the previous reset +} + +void Watchdog::Configure(float s) { + LPC_SYSCON->SYSAHBCLKCTRL |= 0x8000; + LPC_SYSCON->PDRUNCFG &= 0xFFBF; + LPC_SYSCON->WDTOSCCTRL = 0x40; + + uint32_t clk = 100000; + LPC_WWDT->TC = s * (float)clk; + + LPC_WWDT->CLKSEL = 0x1; // Set CLK src to PCLK + LPC_WWDT->MOD = 0x3; // Enabled and Reset + Service(); +} + +/// "Service", "kick" or "feed" the dog - reset the watchdog timer +/// by writing this required bit pattern +void Watchdog::Service() { + LPC_WWDT->FEED = 0xAA; + LPC_WWDT->FEED = 0x55; +} + +/// get the flag to indicate if the watchdog causes the reset +bool Watchdog::WatchdogCausedReset() { + return wdreset; +} #elif defined( TARGET_LPC4088 ) // from Gesotec Gesotec /// Watchdog gets instantiated at the module level