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: EthernetInterfacePlusHostname NTPClient Onewire RdWebServer SDFileSystem-RTOS mbed-rtos mbed-src
Watchdog.h
00001 #ifndef __WATCHDOG__H 00002 #define __WATCHDOG__H 00003 #include "mbed.h" 00004 00005 // Simon's Watchdog code from 00006 // http://mbed.org/forum/mbed/topic/508/ 00007 class Watchdog 00008 { 00009 public: 00010 // Load timeout value in watchdog timer and enable 00011 void SetTimeoutSecs(float s) 00012 { 00013 LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK 00014 uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4 00015 LPC_WDT->WDTC = s * (float)clk; 00016 LPC_WDT->WDMOD = 0x3; // Enabled and Reset 00017 Feed(); 00018 } 00019 // "kick" or "feed" the dog - reset the watchdog timer 00020 // by writing this required bit pattern 00021 void Feed() 00022 { 00023 __disable_irq(); 00024 LPC_WDT->WDFEED = 0xAA; 00025 LPC_WDT->WDFEED = 0x55; 00026 __enable_irq(); 00027 } 00028 00029 bool WatchdogCausedRestart() 00030 { 00031 if ((LPC_WDT->WDMOD >> 2) & 1) 00032 return true; 00033 return false; 00034 } 00035 }; 00036 00037 #endif
Generated on Tue Jul 12 2022 18:43:11 by
1.7.2