fix bootloader enable routine

This commit is contained in:
optixx 2009-09-02 21:50:47 +02:00
parent a6e8d7e033
commit 3a1f58ce18

View File

@ -460,6 +460,18 @@ int __attribute__ ((noreturn, OS_main)) main(void)
DDRC &= ~(1 << AVR_BTLDR_EN_PIN);
PORTC &= ~(1 << AVR_BTLDR_EN_PIN);
/*
* if watchdog reset, disable watchdog and jump to app
*/
if (reset & _BV(WDRF)) {
uart_puts("Found watchdog reset\n\r");
MCUSR = 0;
wdt_disable();
uart_puts("Jump to 0x0000\n\r");
jump_to_app();
}
if ((AVR_BTLDR_EN_IN & ( 1 << AVR_BTLDR_EN_PIN)) == 0){
banner();
uart_puts("Bootloader flashing is disabled\n\r");
@ -467,8 +479,6 @@ int __attribute__ ((noreturn, OS_main)) main(void)
leave_bootloader();
}
/*
* if power-on reset, quit bootloader via watchdog reset
@ -479,17 +489,6 @@ int __attribute__ ((noreturn, OS_main)) main(void)
MCUSR = 0;
leave_bootloader();
}
/*
* if watchdog reset, disable watchdog and jump to app
*/
else if (reset & _BV(WDRF)) {
uart_puts("Found watchdog reset\n\r");
MCUSR = 0;
wdt_disable();
uart_puts("Jump to 0x0000\n\r");
jump_to_app();
}
banner();
uart_puts("Enter programming mode\n\r");
/*