From f060df9747bf2bf78c3c8d156e15cf9fe85ebf0c Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 13 Dec 2012 14:23:14 -0800 Subject: [PATCH] AP_HAL_AVR: now that we can detect the APM revision, use wdt reboot on apm2 --- libraries/AP_HAL_AVR/Scheduler.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libraries/AP_HAL_AVR/Scheduler.cpp b/libraries/AP_HAL_AVR/Scheduler.cpp index c415539d07..a9e18e528a 100644 --- a/libraries/AP_HAL_AVR/Scheduler.cpp +++ b/libraries/AP_HAL_AVR/Scheduler.cpp @@ -4,6 +4,7 @@ #if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) #include +#include #include #include "HAL_AVR.h" @@ -212,17 +213,24 @@ void AVRScheduler::end_atomic() { void AVRScheduler::reboot() { hal.uartA->println_P(PSTR("GOING DOWN FOR A REBOOT\r\n")); hal.scheduler->delay(100); - +#if CONFIG_HAL_BOARD == HAL_BOARD_APM2 + /* The APM2 bootloader will reset the watchdog shortly after + * starting, so we can use the watchdog to force a reboot + */ + cli(); + wdt_enable(WDTO_15MS); + for(;;); +#else cli(); /* Making a null pointer call will cause all AVRs to reboot * but they may not come back alive properly - we need to setup * the IO the way the bootloader would. - * pch will go back and fix this. */ void (*fn)(void) = NULL; fn(); - for(;;); +#endif + } #endif