Extract the bootloader-rebooter into its own 'utils' file

pull/18/head
Jesse Vincent 9 years ago
parent 8af35dd87f
commit 414fe9de84

@ -21,6 +21,7 @@ void setup();
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include <avr/wdt.h> #include <avr/wdt.h>
#include "key_defs.h" #include "key_defs.h"
#include "KeyboardConfig.h" #include "KeyboardConfig.h"
#include "led_control.h" #include "led_control.h"
@ -48,9 +49,6 @@ byte load_primary_keymap();
//internals
void reboot_bootloader();
// hardware keymap interaction // hardware keymap interaction
void setup_pins(); void setup_pins();

@ -143,26 +143,6 @@ void scan_matrix() {
// Command mode // 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() { void setup() {
wdt_disable(); wdt_disable();

@ -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
}

@ -0,0 +1,5 @@
#pragma once
#include <avr/wdt.h>
void reboot_bootloader();
Loading…
Cancel
Save