allow both DFU and watchdog
authorJim Morris <morris@wolfman.com>
Mon, 9 Nov 2015 23:10:52 +0000 (15:10 -0800)
committerJim Morris <morris@wolfman.com>
Mon, 9 Nov 2015 23:10:52 +0000 (15:10 -0800)
src/main.cpp

index 39ee957..4664f5c 100644 (file)
@@ -205,19 +205,19 @@ void init() {
 
     if( kernel->config->value( dfu_enable_checksum )->by_default(false)->as_bool() ){
         kernel->add_module( new(AHB0) DFU(&u));
-        kernel->streams->printf("WARNING Watchdog is disabled when DFU is enabled\n");
+    }
 
+    // 10 second watchdog timeout (or config as seconds)
+    float t= kernel->config->value( watchdog_timeout_checksum )->by_default(10.0F)->as_number();
+    if(t > 0.1F) {
+        // NOTE setting WDT_RESET with the current bootloader would leave it in DFU mode which would be suboptimal
+        kernel->add_module( new Watchdog(t*1000000, WDT_MRI)); // WDT_RESET));
+        kernel->streams->printf("Watchdog enabled for %f seconds\n", t);
     }else{
-        // 10 second watchdog timeout (or config as seconds)
-        float t= kernel->config->value( watchdog_timeout_checksum )->by_default(10.0F)->as_number();
-        if(t > 0) {
-            kernel->add_module( new Watchdog(t*1000000, WDT_MRI)); // WDT_RESET));
-            kernel->streams->printf("Watchdog enabled for %f seconds\n", t);
-        }else{
-            kernel->streams->printf("WARNING Watchdog is disabled\n");
-        }
+        kernel->streams->printf("WARNING Watchdog is disabled\n");
     }
 
+
     kernel->add_module( &u );
 
     // clear up the config cache to save some memory