Improved Leonardo bootloader

The power-on reset detection didn't work properly, but has now been
fixed
This commit is contained in:
Kristian Lauszus 2012-10-01 04:33:26 +02:00 committed by Cristian Maglie
parent 554c211ec4
commit ef6f1eb11d
2 changed files with 257 additions and 1026 deletions

File diff suppressed because it is too large Load Diff

View File

@ -123,11 +123,11 @@ int main(void)
if (mcusr_state & (1<<EXTRF)) {
// External reset - we should continue to self-programming mode.
} else if (mcusr_state == (1<<PORF) && pgm_read_word(0) != 0xFFFF) {
} else if ((mcusr_state & (1<<PORF)) && (pgm_read_word(0) != 0xFFFF)) {
// After a power-on reset skip the bootloader and jump straight to sketch
// if one exists.
StartSketch();
} else if ((mcusr_state == (1<<WDRF)) && (bootKeyPtrVal != bootKey) && (pgm_read_word(0) != 0xFFFF)) {
} else if ((mcusr_state & (1<<WDRF)) && (bootKeyPtrVal != bootKey) && (pgm_read_word(0) != 0xFFFF)) {
// If it looks like an "accidental" watchdog reset then start the sketch.
StartSketch();
}