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 CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
Watchdog/Watchdog.cpp@8:ecf68db484af, 2014-10-10 (annotated)
- Committer:
- martydd3
- Date:
- Fri Oct 10 21:46:52 2014 +0000
- Revision:
- 8:ecf68db484af
- Parent:
- 6:6a04210a3f4f
Added IMD monitoring code based on Kiran's calculations
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| martydd3 | 6:6a04210a3f4f | 1 | // Simon's Watchdog code from |
| martydd3 | 6:6a04210a3f4f | 2 | // http://mbed.org/forum/mbed/topic/508/ |
| martydd3 | 6:6a04210a3f4f | 3 | |
| martydd3 | 6:6a04210a3f4f | 4 | #include "mbed.h" |
| martydd3 | 6:6a04210a3f4f | 5 | |
| martydd3 | 6:6a04210a3f4f | 6 | class Watchdog { |
| martydd3 | 6:6a04210a3f4f | 7 | public: |
| martydd3 | 6:6a04210a3f4f | 8 | // Load timeout value in watchdog timer and enable |
| martydd3 | 6:6a04210a3f4f | 9 | void kick(float s) { |
| martydd3 | 6:6a04210a3f4f | 10 | LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK |
| martydd3 | 6:6a04210a3f4f | 11 | uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4 |
| martydd3 | 6:6a04210a3f4f | 12 | LPC_WDT->WDTC = s * (float)clk; |
| martydd3 | 6:6a04210a3f4f | 13 | LPC_WDT->WDMOD = 0x3; // Enabled and Reset |
| martydd3 | 6:6a04210a3f4f | 14 | kick(); |
| martydd3 | 6:6a04210a3f4f | 15 | } |
| martydd3 | 6:6a04210a3f4f | 16 | // "kick" or "feed" the dog - reset the watchdog timer |
| martydd3 | 6:6a04210a3f4f | 17 | // by writing this required bit pattern |
| martydd3 | 6:6a04210a3f4f | 18 | void kick() { |
| martydd3 | 6:6a04210a3f4f | 19 | LPC_WDT->WDFEED = 0xAA; |
| martydd3 | 6:6a04210a3f4f | 20 | LPC_WDT->WDFEED = 0x55; |
| martydd3 | 6:6a04210a3f4f | 21 | } |
| martydd3 | 6:6a04210a3f4f | 22 | }; |
