diff options
Diffstat (limited to 'tmk_core/common/avr/bootloader.c')
| -rw-r--r-- | tmk_core/common/avr/bootloader.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tmk_core/common/avr/bootloader.c b/tmk_core/common/avr/bootloader.c index ad547b985..34db8d0b0 100644 --- a/tmk_core/common/avr/bootloader.c +++ b/tmk_core/common/avr/bootloader.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #include <stdint.h> | 1 | #include <stdint.h> |
| 2 | #include <stdbool.h> | 2 | #include <stdbool.h> |
| 3 | #include <avr/io.h> | 3 | #include <avr/io.h> |
| 4 | #include <avr/eeprom.h> | ||
| 4 | #include <avr/interrupt.h> | 5 | #include <avr/interrupt.h> |
| 5 | #include <avr/wdt.h> | 6 | #include <avr/wdt.h> |
| 6 | #include <util/delay.h> | 7 | #include <util/delay.h> |
| @@ -89,6 +90,12 @@ void bootloader_jump(void) { | |||
| 89 | _delay_ms(5); | 90 | _delay_ms(5); |
| 90 | #endif | 91 | #endif |
| 91 | 92 | ||
| 93 | #ifdef BOOTLOADHID_BOOTLOADER | ||
| 94 | // force bootloadHID to stay in bootloader mode, so that it waits | ||
| 95 | // for a new firmware to be flashed | ||
| 96 | eeprom_write_byte((uint8_t *)1, 0x00); | ||
| 97 | #endif | ||
| 98 | |||
| 92 | // watchdog reset | 99 | // watchdog reset |
| 93 | reset_key = BOOTLOADER_RESET_KEY; | 100 | reset_key = BOOTLOADER_RESET_KEY; |
| 94 | wdt_enable(WDTO_250MS); | 101 | wdt_enable(WDTO_250MS); |
| @@ -114,6 +121,11 @@ void bootloader_jump(void) { | |||
| 114 | #endif | 121 | #endif |
| 115 | } | 122 | } |
| 116 | 123 | ||
| 124 | #ifdef __AVR_ATmega32A__ | ||
| 125 | // MCUSR is actually called MCUCSR in ATmega32A | ||
| 126 | #define MCUSR MCUCSR | ||
| 127 | #endif | ||
| 128 | |||
| 117 | /* this runs before main() */ | 129 | /* this runs before main() */ |
| 118 | void bootloader_jump_after_watchdog_reset(void) __attribute__ ((used, naked, section (".init3"))); | 130 | void bootloader_jump_after_watchdog_reset(void) __attribute__ ((used, naked, section (".init3"))); |
| 119 | void bootloader_jump_after_watchdog_reset(void) | 131 | void bootloader_jump_after_watchdog_reset(void) |
