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: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
watchdog.h@76:b07effe83fb8, 2015-02-25 (annotated)
- Committer:
- xinlei
- Date:
- Wed Feb 25 10:06:11 2015 +0000
- Revision:
- 76:b07effe83fb8
watchdog: added watchdog;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| xinlei | 76:b07effe83fb8 | 1 | #ifndef WATCHDOG_H |
| xinlei | 76:b07effe83fb8 | 2 | #define WATCHDOG_H |
| xinlei | 76:b07effe83fb8 | 3 | #include "mbed.h" |
| xinlei | 76:b07effe83fb8 | 4 | |
| xinlei | 76:b07effe83fb8 | 5 | class Watchdog { |
| xinlei | 76:b07effe83fb8 | 6 | public: |
| xinlei | 76:b07effe83fb8 | 7 | // Load timeout value in watchdog timer and enable |
| xinlei | 76:b07effe83fb8 | 8 | void kick(float s) { |
| xinlei | 76:b07effe83fb8 | 9 | LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK |
| xinlei | 76:b07effe83fb8 | 10 | uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4 |
| xinlei | 76:b07effe83fb8 | 11 | LPC_WDT->WDTC = s * (float)clk; |
| xinlei | 76:b07effe83fb8 | 12 | LPC_WDT->WDMOD = 0x3; // Enabled and Reset |
| xinlei | 76:b07effe83fb8 | 13 | kick(); |
| xinlei | 76:b07effe83fb8 | 14 | } |
| xinlei | 76:b07effe83fb8 | 15 | // "kick" or "feed" the dog - reset the watchdog timer |
| xinlei | 76:b07effe83fb8 | 16 | // by writing this required bit pattern |
| xinlei | 76:b07effe83fb8 | 17 | void kick() { |
| xinlei | 76:b07effe83fb8 | 18 | LPC_WDT->WDFEED = 0xAA; |
| xinlei | 76:b07effe83fb8 | 19 | LPC_WDT->WDFEED = 0x55; |
| xinlei | 76:b07effe83fb8 | 20 | } |
| xinlei | 76:b07effe83fb8 | 21 | }; |
| xinlei | 76:b07effe83fb8 | 22 | #endif /* WATCHDOG_H */ |

Cumulocity