update firmware.bin
[clinton/Smoothieware.git] / src / libs / Watchdog.cpp
CommitLineData
073b1698
MM
1#include "Watchdog.h"
2
3#include <lpc17xx_wdt.h>
4
5#include <mri.h>
6
d337942a
MM
7// TODO : comment this
8// Basically, when stuff stop answering, reset, or enter MRI mode, or something
93694d6b 9
073b1698
MM
10Watchdog::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
17void Watchdog::feed()
18{
19 WDT_Feed();
20}
21
6eeb045a
MM
22void Watchdog::on_module_loaded()
23{
24 register_for_event(ON_IDLE);
25 feed();
26}
27
28void Watchdog::on_idle(void*)
29{
30 feed();
31}
32
33
073b1698
MM
34extern "C" void WDT_IRQHandler(void)
35{
36 WDT_ClrTimeOutFlag();
37 WDT_Feed();
38 __debugbreak();
6eeb045a 39}