Switch StaticAnalysisTest build test to use the new build system CPPCHECK module...
[pub/USBasp.git] / Bootloaders / DFU / BootloaderDFU.c
index 233e145..f5c8d17 100644 (file)
@@ -106,11 +106,18 @@ uint32_t MagicBootKey ATTR_NO_INIT;
  */
 void Application_Jump_Check(void)
 {
  */
 void Application_Jump_Check(void)
 {
-       // If the reset source was the bootloader and the key is correct, clear it and jump to the application
+       /* 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))
        {
        if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
        {
+               /* Turn off the watchdog */
+               MCUSR &= ~(1<<WDRF);
+               wdt_disable(); 
+
+               /* Clear the boot key and jump to the user application */
                MagicBootKey = 0;
                MagicBootKey = 0;
-               AppStartPtr();
+
+               // cppcheck-suppress constStatement
+               ((void (*)(void))0x0000)();
        }
 }
 
        }
 }
 
@@ -186,6 +193,10 @@ static void ResetHardware(void)
        /* Shut down the USB and other board hardware drivers */
        USB_Disable();
        LEDs_Disable();
        /* Shut down the USB and other board hardware drivers */
        USB_Disable();
        LEDs_Disable();
+       
+       /* Disable Bootloader active LED toggle timer */
+       TIMSK1 = 0;
+       TCCR1B = 0;
 
        /* Relocate the interrupt vector table back to the application section */
        MCUCR = (1 << IVCE);
 
        /* Relocate the interrupt vector table back to the application section */
        MCUCR = (1 << IVCE);
@@ -662,7 +673,7 @@ static void ProcessMemReadCommand(void)
        {
                uint32_t CurrFlashAddress = 0;
 
        {
                uint32_t CurrFlashAddress = 0;
 
-               while (CurrFlashAddress < BOOT_START_ADDR)
+               while (CurrFlashAddress < (uint32_t)BOOT_START_ADDR)
                {
                        /* Check if the current byte is not blank */
                        #if (FLASHEND > 0xFFFF)
                {
                        /* Check if the current byte is not blank */
                        #if (FLASHEND > 0xFFFF)
@@ -734,7 +745,7 @@ static void ProcessWriteCommand(void)
                uint32_t CurrFlashAddress = 0;
 
                /* Clear the application section of flash */
                uint32_t CurrFlashAddress = 0;
 
                /* Clear the application section of flash */
-               while (CurrFlashAddress < BOOT_START_ADDR)
+               while (CurrFlashAddress < (uint32_t)BOOT_START_ADDR)
                {
                        boot_page_erase(CurrFlashAddress);
                        boot_spm_busy_wait();
                {
                        boot_page_erase(CurrFlashAddress);
                        boot_spm_busy_wait();