Add static keyword to all project globals whose scope should be restricted to the...
[pub/lufa.git] / Bootloaders / HID / BootloaderHID.c
index 9c6b3e0..174041e 100644 (file)
@@ -39,7 +39,7 @@
  *  via a soft reset. When cleared, the bootloader will abort, the USB interface will shut down and the application\r
  *  started via a forced watchdog reset.\r
  */\r
-bool RunBootloader = true;\r
+static bool RunBootloader = true;\r
 \r
 /** Main program entry point. This routine configures the hardware required by the bootloader, then continuously \r
  *  runs the bootloader processing routine until instructed to soft-exit.\r
@@ -127,7 +127,7 @@ void EVENT_USB_Device_ControlRequest(void)
                                boot_spm_busy_wait();\r
                                \r
                                /* Write each of the FLASH page's bytes in sequence */\r
-                               for (uint16_t PageByte = 0; PageByte < SPM_PAGESIZE; PageByte += 2)                             \r
+                               for (uint8_t PageWord = 0; PageWord < (SPM_PAGESIZE / 2); PageWord++)                           \r
                                {\r
                                        /* Check if endpoint is empty - if so clear it and wait until ready for next packet */\r
                                        if (!(Endpoint_BytesInEndpoint()))\r
@@ -137,7 +137,7 @@ void EVENT_USB_Device_ControlRequest(void)
                                        }\r
 \r
                                        /* Write the next data word to the FLASH page */\r
-                                       boot_page_fill(PageAddress + PageByte, Endpoint_Read_Word_LE());\r
+                                       boot_page_fill(PageAddress + ((uint16_t)PageWord << 1), Endpoint_Read_Word_LE());\r
                                }\r
 \r
                                /* Write the filled FLASH page to memory */\r