Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed PID Sensorv2 xbeeCom
Diff: quadCommand/KL25Z_Watchdog.h
- Revision:
- 0:853ffcef6c67
- Child:
- 1:e4439be6e1b9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/quadCommand/KL25Z_Watchdog.h Wed Oct 15 04:59:58 2014 +0000 @@ -0,0 +1,65 @@ +//The section commented out is the ideal way to set the actual Watchdog timer. + +#ifdef DEBUG_WATCHDOG + #include "mbed.h" + Serial wd(USBTX, USBRX); + #define NL "\n\r" + #define PRINT wd.printf //Serial.print(x) + #define PRINTF wd.printf //Serial.print(x, y) + #define PRINTLN(x) PRINT(x);PRINT(NL) +#else + #define PRINT(x) + #define PRINTF(...) + #define PRINTLN(x) +#endif + +class Watchdog { +public: + Ticker dog; + int hang; + int check; + Watchdog(float time) + { + check = 1; + hang = 0; + } + Watchdog() + { + check = 1; + hang = 0; + } + + void enable(float time) + { + dog.attach(this,&Watchdog::checker, time); + kick(); + } + + void kick() + { + hang = rand(); + //reset timer +// SIM->SRVCOP = 0x55; +// SIM->SRVCOP = 0xAA; + } + + void kick(float s) { +// SIM->COPC = 0xCu; + kick(); + } + + void disable() + { +// SIM->COPC = 0; + } + + void checker() + { + if (hang == check) + { + + NVIC_SystemReset(); + } + check = hang; + } +}; \ No newline at end of file