#include <mri.h>
+extern "C" {
+ static uint32_t _set_high_on_debug[5] = {
+ (1 << 4) | (1 << 10) | (1 << 19) | (1 << 21),
+ 0,
+ 0,
+ 0,
+ 0
+ };
+ static uint32_t _set_low_on_debug[5] = {
+ 0,
+ 0,
+ (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7),
+ 0,
+ 0
+ };
+
+ static LPC_GPIO_TypeDef* io;
+ static int i;
+
+ void __mriPlatform_EnteringDebuggerHook()
+ {
+ for (i = 0; i < 5; i++)
+ {
+ io = (LPC_GPIO_TypeDef*) (LPC_GPIO_BASE + (0x20 * i));
+ io->FIOMASK &= ~(_set_high_on_debug[i] | _set_low_on_debug[i]);
+ io->FIOSET = _set_high_on_debug[i];
+ io->FIOCLR = _set_low_on_debug[i];
+ }
+ }
+
+ void __mriPlatform_LeavingDebuggerHook()
+ {
+ }
+}
+
Watchdog::Watchdog(uint32_t timeout, WDT_ACTION action)
{
WDT_Init(WDT_CLKSRC_IRC, (action == WDT_MRI)?WDT_MODE_INT_ONLY:WDT_MODE_RESET);
WDT_Feed();
}
+void Watchdog::on_module_loaded()
+{
+ register_for_event(ON_IDLE);
+ feed();
+}
+
+void Watchdog::on_idle(void*)
+{
+ feed();
+}
+
+
extern "C" void WDT_IRQHandler(void)
{
WDT_ClrTimeOutFlag();
WDT_Feed();
__debugbreak();
-}
\ No newline at end of file
+}
#include <stdint.h>
+#include "Module.h"
+
typedef enum
{
WDT_MRI,
WDT_RESET,
} WDT_ACTION;
-class Watchdog
+extern "C" {
+ void __mriPlatform_EnteringDebuggerHook();
+ void __mriPlatform_LeavingDebuggerHook();
+}
+
+class Watchdog : public Module
{
public:
Watchdog(uint32_t timeout, WDT_ACTION action);
void feed();
+
+ void on_module_loaded();
+ void on_idle(void*);
};
#endif /* _WATCHDOG_H */
// }
// kernel->add_module( new Laser(p21) );
+// kernel->add_module( &wd );
kernel->add_module( new Extruder() );
kernel->add_module( new SimpleShell() );
kernel->add_module( new Configurator() );