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 MCP23S17 PinDetect USBDevice
watchdog_ec.h
00001 #include "mbed.h" 00002 00003 class Watchdog { 00004 public: 00005 // Load timeout value in watchdog timer and enable 00006 void kick(float s) { 00007 LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK 00008 uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4 00009 LPC_WDT->WDTC = s * (float)clk; 00010 LPC_WDT->WDMOD = 0x3; // Enabled and Reset 00011 kick(); 00012 } 00013 // "kick" or "feed" the dog - reset the watchdog timer 00014 // by writing this required bit pattern 00015 void kick() { 00016 LPC_WDT->WDFEED = 0xAA; 00017 LPC_WDT->WDFEED = 0x55; 00018 } 00019 }; 00020 00021 // Setup the watchdog timer 00022 Watchdog wdt; 00023 00024 DigitalIn pb(p22); 00025 DigitalOut myled(p26); 00026 00027 int prev; 00028 00029 int run_watchdogEC() { 00030 wdt.kick(10.0); 00031 00032 prev = pb; 00033 00034 int count = 0; 00035 00036 while(1) { 00037 if (prev != pb) { 00038 count++; 00039 } 00040 prev = pb; 00041 myled = !pb; 00042 00043 if (count == 2) { 00044 while (1) { 00045 ; 00046 } 00047 } 00048 00049 wdt.kick(); 00050 } 00051 }
Generated on Sun Jul 17 2022 17:11:11 by
1.7.2