Watchdog Timer for the K64F. User can set timeout value from 1 to 356 seconds with a one second resolution.
Dependents: Telliskivi2_2014 mbed-IBooth-ETH TwitterReader
Watchdog.cpp
- Committer:
- loopsva
- Date:
- 2014-10-20
- Revision:
- 0:2a46d40a176e
- Child:
- 1:70e99b5845fd
File content as of revision 0:2a46d40a176e:
#include "mbed.h" #include "Watchdog.h" void Watchdog::kick(int toVal) { const uint32_t K64FWDONESEC = 0x00B80000; //approx 1 second delay if((toVal < 1) || (toVal > 356)) toVal = 356; WDOG_UNLOCK = 0xC520; WDOG_UNLOCK = 0xD928; uint32_t wdogCntl = K64FWDONESEC * toVal; WDOG_TOVALH = wdogCntl >> 16; WDOG_TOVALL = wdogCntl & 0xFFFF; EnableWDOG(); } void Watchdog::kick() { WDOG_REFRESH = 0xA602; WDOG_REFRESH = 0xB480; } void Watchdog::DisableWDOG() { WDOG_UNLOCK = 0xC520; WDOG_UNLOCK = 0xD928; WDOG_STCTRLH &= 0xFFFE; } void Watchdog::EnableWDOG() { WDOG_UNLOCK = 0xC520; WDOG_UNLOCK = 0xD928; WDOG_STCTRLH |= 0x0001; kick(); }