From 787a68948fa0d5e251e22a623071082c8c0561b1 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 13 May 2022 20:35:49 -0700 Subject: [Core] Add Reboot keycode to core (#15990) --- platforms/avr/bootloaders/bootloadhid.c | 7 +++++++ platforms/avr/bootloaders/caterina.c | 9 +++++++++ platforms/avr/bootloaders/custom.c | 9 +++++++++ platforms/avr/bootloaders/dfu.c | 9 ++++++++- platforms/avr/bootloaders/halfkay.c | 10 ++++++++++ platforms/avr/bootloaders/usbasploader.c | 9 +++++++++ 6 files changed, 52 insertions(+), 1 deletion(-) (limited to 'platforms/avr') 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 __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 +#include #include __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) { + } +} -- cgit v1.2.1