Fork of Smoothie to port to mbed non-LPC targets.

Dependencies:   mbed

Fork of Smoothie by Stéphane Cachat

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Watchdog.cpp Source File

Watchdog.cpp

00001 #include "Watchdog.h"
00002 
00003 #include <lpc17xx_wdt.h>
00004 
00005 #include <mri.h>
00006 
00007 // TODO : comment this
00008 // Basically, when stuff stop answering, reset, or enter MRI mode, or something
00009 
00010 Watchdog::Watchdog(uint32_t timeout, WDT_ACTION action)
00011 {
00012     WDT_Init(WDT_CLKSRC_IRC, (action == WDT_MRI)?WDT_MODE_INT_ONLY:WDT_MODE_RESET);
00013     WDT_Start(timeout);
00014     WDT_Feed();
00015 }
00016 
00017 void Watchdog::feed()
00018 {
00019     WDT_Feed();
00020 }
00021 
00022 void Watchdog::on_module_loaded()
00023 {
00024     register_for_event(ON_IDLE);
00025     feed();
00026 }
00027 
00028 void Watchdog::on_idle(void*)
00029 {
00030     feed();
00031 }
00032 
00033 
00034 extern "C" void WDT_IRQHandler(void)
00035 {
00036     WDT_ClrTimeOutFlag();
00037     WDT_Feed();
00038     __debugbreak();
00039 }