diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2012-06-09 13:00:56 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2012-06-09 13:00:56 +0000 |
commit | cd0bd7bf90e7e64a42b1efcee5a60cfdfc91d7a2 (patch) | |
tree | a2d5f03d455543dbf5b383e28a39268e6d2881aa /Bootloaders | |
parent | 7abaafb3cabbe66516b5be2a6708d04604bc2740 (diff) | |
download | lufa-cd0bd7bf90e7e64a42b1efcee5a60cfdfc91d7a2.tar.gz lufa-cd0bd7bf90e7e64a42b1efcee5a60cfdfc91d7a2.tar.bz2 lufa-cd0bd7bf90e7e64a42b1efcee5a60cfdfc91d7a2.zip |
Added new JTAG_ENABLE() macro for the AVR8 architecture. Fixed the JTAG_DISABLE() macro clearing all other bits in MCUSR when called.
Moved the XPLAIN board specific bootloader entry condition code to the Application_Jump_Check() function of the DFU bootloader, added support for the original XPLAIN board to the CDC class bootloader.
Diffstat (limited to 'Bootloaders')
-rw-r--r-- | Bootloaders/CDC/BootloaderCDC.c | 21 | ||||
-rw-r--r-- | Bootloaders/DFU/BootloaderDFU.c | 38 |
2 files changed, 42 insertions, 17 deletions
diff --git a/Bootloaders/CDC/BootloaderCDC.c b/Bootloaders/CDC/BootloaderCDC.c index ef68e148c..dcfa978e3 100644 --- a/Bootloaders/CDC/BootloaderCDC.c +++ b/Bootloaders/CDC/BootloaderCDC.c @@ -70,8 +70,29 @@ uint32_t MagicBootKey ATTR_NO_INIT; */ void Application_Jump_Check(void) { + bool JumpToApplication = false; + + #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1)) + /* Disable JTAG debugging */ + JTAG_DISABLE(); + + /* Enable pull-up on the JTAG TCK pin so we can use it to select the mode */ + PORTF |= (1 << 4); + Delay_MS(10); + + /* If the TCK pin is not jumpered to ground, start the user application instead */ + JumpToApplication |= ((PINF & (1 << 4)) != 0); + + /* Re-enable JTAG debugging */ + JTAG_ENABLE(); + #endif + /* If the reset source was the bootloader and the key is correct, clear it and jump to the application */ if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY)) + JumpToApplication |= true; + + /* If a request has been made to jump to the user application, honor it */ + if (JumpToApplication) { /* Turn off the watchdog */ MCUSR &= ~(1<<WDRF); diff --git a/Bootloaders/DFU/BootloaderDFU.c b/Bootloaders/DFU/BootloaderDFU.c index f5c8d170e..64850e3bb 100644 --- a/Bootloaders/DFU/BootloaderDFU.c +++ b/Bootloaders/DFU/BootloaderDFU.c @@ -106,8 +106,29 @@ uint32_t MagicBootKey ATTR_NO_INIT; */ void Application_Jump_Check(void) { + bool JumpToApplication = false; + + #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1)) + /* Disable JTAG debugging */ + JTAG_DISABLE(); + + /* Enable pull-up on the JTAG TCK pin so we can use it to select the mode */ + PORTF |= (1 << 4); + Delay_MS(10); + + /* If the TCK pin is not jumpered to ground, start the user application instead */ + JumpToApplication |= ((PINF & (1 << 4)) != 0); + + /* Re-enable JTAG debugging */ + JTAG_ENABLE(); + #endif + /* If the reset source was the bootloader and the key is correct, clear it and jump to the application */ if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY)) + JumpToApplication |= true; + + /* If a request has been made to jump to the user application, honor it */ + if (JumpToApplication) { /* Turn off the watchdog */ MCUSR &= ~(1<<WDRF); @@ -130,23 +151,6 @@ int main(void) /* Configure hardware required by the bootloader */ SetupHardware(); - #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1)) - /* Disable JTAG debugging */ - MCUCR |= (1 << JTD); - MCUCR |= (1 << JTD); - - /* Enable pull-up on the JTAG TCK pin so we can use it to select the mode */ - PORTF |= (1 << 4); - Delay_MS(10); - - /* If the TCK pin is not jumpered to ground, start the user application instead */ - RunBootloader = (!(PINF & (1 << 4))); - - /* Re-enable JTAG debugging */ - MCUCR &= ~(1 << JTD); - MCUCR &= ~(1 << JTD); - #endif - /* Turn on first LED on the board to indicate that the bootloader has started */ LEDs_SetAllLEDs(LEDS_LED1); |