diff --git a/KeyboardioFirmware.h b/KeyboardioFirmware.h index b2b7d8a6..8567b40f 100644 --- a/KeyboardioFirmware.h +++ b/KeyboardioFirmware.h @@ -21,6 +21,7 @@ void setup(); #include #include #include + #include "key_defs.h" #include "KeyboardConfig.h" #include "led_control.h" @@ -48,9 +49,6 @@ byte load_primary_keymap(); -//internals -void reboot_bootloader(); - // hardware keymap interaction void setup_pins(); diff --git a/KeyboardioFirmware.ino b/KeyboardioFirmware.ino index 02fd73d4..9c3cf210 100644 --- a/KeyboardioFirmware.ino +++ b/KeyboardioFirmware.ino @@ -143,26 +143,6 @@ void scan_matrix() { // Command mode // -void reboot_bootloader() { - // Set the magic bits to get a Caterina-based device - // to reboot into the bootloader and stay there, rather - // than run move onward - // - // These values are the same as those defined in - // Caterina.c - - uint16_t bootKey = 0x7777; - uint16_t *const bootKeyPtr = (uint16_t *)0x0800; - - // Stash the magic key - *bootKeyPtr = bootKey; - - // Set a watchdog timer - wdt_enable(WDTO_120MS); - - while (1) {} // This infinite loop ensures nothing else - // happens before the watchdog reboots us -} void setup() { wdt_disable(); diff --git a/utils.cpp b/utils.cpp new file mode 100644 index 00000000..4d11467d --- /dev/null +++ b/utils.cpp @@ -0,0 +1,23 @@ +#include "utils.h" + +void reboot_bootloader() { + // Set the magic bits to get a Caterina-based device + // to reboot into the bootloader and stay there, rather + // than run move onward + // + // These values are the same as those defined in + // Caterina.c + + uint16_t bootKey = 0x7777; + uint16_t *const bootKeyPtr = (uint16_t *)0x0800; + + // Stash the magic key + *bootKeyPtr = bootKey; + + // Set a watchdog timer + wdt_enable(WDTO_120MS); + + while (1) {} // This infinite loop ensures nothing else + // happens before the watchdog reboots us +} + diff --git a/utils.h b/utils.h new file mode 100644 index 00000000..9c61a98a --- /dev/null +++ b/utils.h @@ -0,0 +1,5 @@ +#pragma once + +#include + +void reboot_bootloader(); \ No newline at end of file