update firmware.bin
[clinton/Smoothieware.git] / src / libs / Watchdog.cpp
1 #include "Watchdog.h"
2
3 #include <lpc17xx_wdt.h>
4
5 #include <mri.h>
6
7 // TODO : comment this
8 // Basically, when stuff stop answering, reset, or enter MRI mode, or something
9
10 Watchdog::Watchdog(uint32_t timeout, WDT_ACTION action)
11 {
12 WDT_Init(WDT_CLKSRC_IRC, (action == WDT_MRI)?WDT_MODE_INT_ONLY:WDT_MODE_RESET);
13 WDT_Start(timeout);
14 WDT_Feed();
15 }
16
17 void Watchdog::feed()
18 {
19 WDT_Feed();
20 }
21
22 void Watchdog::on_module_loaded()
23 {
24 register_for_event(ON_IDLE);
25 feed();
26 }
27
28 void Watchdog::on_idle(void*)
29 {
30 feed();
31 }
32
33
34 extern "C" void WDT_IRQHandler(void)
35 {
36 WDT_ClrTimeOutFlag();
37 WDT_Feed();
38 __debugbreak();
39 }