diff options
Diffstat (limited to 'platforms/avr')
-rw-r--r-- | platforms/avr/bootloaders/bootloadhid.c | 7 | ||||
-rw-r--r-- | platforms/avr/bootloaders/caterina.c | 9 | ||||
-rw-r--r-- | platforms/avr/bootloaders/custom.c | 9 | ||||
-rw-r--r-- | platforms/avr/bootloaders/dfu.c | 9 | ||||
-rw-r--r-- | platforms/avr/bootloaders/halfkay.c | 10 | ||||
-rw-r--r-- | platforms/avr/bootloaders/usbasploader.c | 9 |
6 files changed, 52 insertions, 1 deletions
diff --git a/platforms/avr/bootloaders/bootloadhid.c b/platforms/avr/bootloaders/bootloadhid.c index ae58760d7d..b91dca6d27 100644 --- a/platforms/avr/bootloaders/bootloadhid.c +++ b/platforms/avr/bootloaders/bootloadhid.c @@ -31,3 +31,10 @@ __attribute__((weak)) void bootloader_jump(void) { for (;;) ; } + +__attribute__((weak)) void mcu_reset(void) { + // watchdog reset + wdt_enable(WDTO_250MS); + for (;;) + ; +} diff --git a/platforms/avr/bootloaders/caterina.c b/platforms/avr/bootloaders/caterina.c index 82a16a3765..2b5f613d6d 100644 --- a/platforms/avr/bootloaders/caterina.c +++ b/platforms/avr/bootloaders/caterina.c @@ -37,3 +37,12 @@ __attribute__((weak)) void bootloader_jump(void) { while (1) { } } + +__attribute__((weak)) void mcu_reset(void) { + // setup watchdog timeout + wdt_enable(WDTO_60MS); + + // wait for watchdog timer to trigger + while (1) { + } +} diff --git a/platforms/avr/bootloaders/custom.c b/platforms/avr/bootloaders/custom.c index 624fbe242a..72b19f6671 100644 --- a/platforms/avr/bootloaders/custom.c +++ b/platforms/avr/bootloaders/custom.c @@ -15,5 +15,14 @@ */ #include "bootloader.h" +#include <avr/wdt.h> __attribute__((weak)) void bootloader_jump(void) {} +__attribute__((weak)) void mcu_reset(void) { + // setup watchdog timeout + wdt_enable(WDTO_60MS); + + // wait for watchdog timer to trigger + while (1) { + } +} diff --git a/platforms/avr/bootloaders/dfu.c b/platforms/avr/bootloaders/dfu.c index 06b2c8963a..dbbb5f4ab6 100644 --- a/platforms/avr/bootloaders/dfu.c +++ b/platforms/avr/bootloaders/dfu.c @@ -34,8 +34,15 @@ __attribute__((weak)) void bootloader_jump(void) { UCSR1B = 0; _delay_ms(5); // 5 seems to work fine - // watchdog reset reset_key = BOOTLOADER_RESET_KEY; + // watchdog reset + wdt_enable(WDTO_250MS); + for (;;) + ; +} + +__attribute__((weak)) void mcu_reset(void) { + // watchdog reset wdt_enable(WDTO_250MS); for (;;) ; diff --git a/platforms/avr/bootloaders/halfkay.c b/platforms/avr/bootloaders/halfkay.c index 651696f988..402f5f2778 100644 --- a/platforms/avr/bootloaders/halfkay.c +++ b/platforms/avr/bootloaders/halfkay.c @@ -17,6 +17,7 @@ #include "bootloader.h" #include <avr/interrupt.h> +#include <avr/wdt.h> #include <util/delay.h> __attribute__((weak)) void bootloader_jump(void) { @@ -126,3 +127,12 @@ __attribute__((weak)) void bootloader_jump(void) { asm volatile("jmp 0x1FC00"); #endif } + +__attribute__((weak)) void mcu_reset(void) { + // setup watchdog timeout + wdt_enable(WDTO_60MS); + + // wait for watchdog timer to trigger + while (1) { + } +} diff --git a/platforms/avr/bootloaders/usbasploader.c b/platforms/avr/bootloaders/usbasploader.c index 008bd16069..333010eefa 100644 --- a/platforms/avr/bootloaders/usbasploader.c +++ b/platforms/avr/bootloaders/usbasploader.c @@ -54,3 +54,12 @@ __attribute__((weak)) void bootloader_jump(void) { #endif [bootaddrme] "M"((((FLASH_SIZE - BOOTLOADER_SIZE) >> 1) >> 8) & 0xff), [bootaddrlo] "M"((((FLASH_SIZE - BOOTLOADER_SIZE) >> 1) >> 0) & 0xff)); } + +__attribute__((weak)) void mcu_reset(void) { + // setup watchdog timeout + wdt_enable(WDTO_15MS); + + // wait for watchdog timer to trigger + while (1) { + } +} |