diff options
author | Christopher Browne <cbbrowne@ca.afilias.info> | 2016-07-07 11:13:22 -0400 |
---|---|---|
committer | Christopher Browne <cbbrowne@ca.afilias.info> | 2016-07-07 11:13:22 -0400 |
commit | 97dfbd1afce005392aa8f067e89bdf95334bdea5 (patch) | |
tree | 1b198dd239bcb49564c31f124978abde0b467a81 /tmk_core/common/avr/bootloader.c | |
parent | 2e1cfaf73fccdfaba2d7542f00bd7c3d49998d5d (diff) | |
parent | ad43d450ca1b988d196da80e2a745f45f24068f6 (diff) |
Merge branch 'master' of https://github.com/jackhumbert/qmk_firmware
Diffstat (limited to 'tmk_core/common/avr/bootloader.c')
-rw-r--r-- | tmk_core/common/avr/bootloader.c | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/tmk_core/common/avr/bootloader.c b/tmk_core/common/avr/bootloader.c index 7c744e8c79..fb9bf2d1c3 100644 --- a/tmk_core/common/avr/bootloader.c +++ b/tmk_core/common/avr/bootloader.c @@ -73,26 +73,46 @@ uint32_t reset_key __attribute__ ((section (".noinit"))); /* initialize MCU status by watchdog reset */ void bootloader_jump(void) { -#ifdef PROTOCOL_LUFA - USB_Disable(); - cli(); - _delay_ms(2000); -#endif + #ifndef CATERINA_BOOTLOADER -#ifdef PROTOCOL_PJRC - cli(); - UDCON = 1; - USBCON = (1<<FRZCLK); - UCSR1B = 0; - _delay_ms(5); -#endif + #ifdef PROTOCOL_LUFA + USB_Disable(); + cli(); + _delay_ms(2000); + #endif - // watchdog reset - reset_key = BOOTLOADER_RESET_KEY; - wdt_enable(WDTO_250MS); - for (;;); -} + #ifdef PROTOCOL_PJRC + cli(); + UDCON = 1; + USBCON = (1<<FRZCLK); + UCSR1B = 0; + _delay_ms(5); + #endif + + // watchdog reset + reset_key = BOOTLOADER_RESET_KEY; + wdt_enable(WDTO_250MS); + for (;;); + + #else + // this block may be optional + // TODO: figure it out + + uint16_t *const bootKeyPtr = (uint16_t *)0x0800; + // Value used by Caterina bootloader use to determine whether to run the + // sketch or the bootloader programmer. + uint16_t bootKey = 0x7777; + + *bootKeyPtr = bootKey; + + // setup watchdog timeout + wdt_enable(WDTO_60MS); + + while(1) {} // wait for watchdog timer to trigger + + #endif +} /* this runs before main() */ void bootloader_jump_after_watchdog_reset(void) __attribute__ ((used, naked, section (".init3"))); |