diff options
author | Zach Eveland <zeveland@blacklabel-development.com> | 2012-02-14 09:59:48 -0500 |
---|---|---|
committer | Zach Eveland <zeveland@blacklabel-development.com> | 2012-02-14 09:59:48 -0500 |
commit | b28e6c2f9cc344cb2ba4ca080b97ad39aa6e2d0d (patch) | |
tree | 9bbaa19aa201eaccee51da077350dbe5120f3af1 /bootloaders/caterina_LUFA/Caterina.c | |
parent | 924e5a48465cf8a9ba3af38e6cf4c2e1a2c0733c (diff) |
Leonardo bootloader jumps straight to sketch for a power-on reset.
Disconnect programmer after burning bootloader to get the full effect. ICSP and JTAG programmers do a hardware reset after any reset condition, confusing the firmware a little.
Diffstat (limited to 'bootloaders/caterina_LUFA/Caterina.c')
-rwxr-xr-x | bootloaders/caterina_LUFA/Caterina.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/bootloaders/caterina_LUFA/Caterina.c b/bootloaders/caterina_LUFA/Caterina.c index 11404a7..b6fbd9b 100755 --- a/bootloaders/caterina_LUFA/Caterina.c +++ b/bootloaders/caterina_LUFA/Caterina.c @@ -110,6 +110,15 @@ int main(void) /* Watchdog may be configured with a 15 ms period so must disable it before doing anything else */
wdt_disable();
+ /* Check the reason for the reset and act accordingly */
+ uint8_t mcusr_state = MCUSR; // store the initial state of the Status register
+ MCUSR = 0; // clear all reset flags
+ // After a power-on reset skip the bootloader and jump straight to sketch
+ // if one exists.
+ if (mcusr_state & (1<<PORF) && pgm_read_word(0) != 0xFFFF) {
+ StartSketch();
+ }
+
/* Setup hardware required for the bootloader */
SetupHardware();
@@ -121,7 +130,7 @@ int main(void) CDC_Task();
USB_USBTask();
/* Time out and start the sketch if one is present */
- if (Timeout > 16000)
+ if (Timeout > 16000 && pgm_read_word(0) != 0xFFFF)
RunBootloader = false;
LEDPulse();
|