diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2017-10-01 16:25:36 +1100 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2017-10-01 16:25:36 +1100 |
commit | 06f53eed83b4ad639698aeb9bcc1a3702e2ac7c4 (patch) | |
tree | 9fb860d93b67d36eed9de55bdd691581d5389960 /Bootloaders/HID/BootloaderHID.c | |
parent | 544c4dc9e18d56768be11dd16e3cad693e7cff46 (diff) | |
download | lufa-06f53eed83b4ad639698aeb9bcc1a3702e2ac7c4.tar.gz lufa-06f53eed83b4ad639698aeb9bcc1a3702e2ac7c4.tar.bz2 lufa-06f53eed83b4ad639698aeb9bcc1a3702e2ac7c4.zip |
Fixed bootloaders not disabling global interrupts during erase and write operations (thanks to Zoltan).
Diffstat (limited to 'Bootloaders/HID/BootloaderHID.c')
-rw-r--r-- | Bootloaders/HID/BootloaderHID.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Bootloaders/HID/BootloaderHID.c b/Bootloaders/HID/BootloaderHID.c index fa1dd5873..58c9b3b6f 100644 --- a/Bootloaders/HID/BootloaderHID.c +++ b/Bootloaders/HID/BootloaderHID.c @@ -164,8 +164,11 @@ void EVENT_USB_Device_ControlRequest(void) else if (PageAddress < BOOT_START_ADDR) { /* Erase the given FLASH page, ready to be programmed */ - boot_page_erase(PageAddress); - boot_spm_busy_wait(); + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) + { + boot_page_erase(PageAddress); + boot_spm_busy_wait(); + } /* Write each of the FLASH page's bytes in sequence */ for (uint8_t PageWord = 0; PageWord < (SPM_PAGESIZE / 2); PageWord++) @@ -182,8 +185,11 @@ void EVENT_USB_Device_ControlRequest(void) } /* Write the filled FLASH page to memory */ - boot_page_write(PageAddress); - boot_spm_busy_wait(); + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) + { + boot_page_write(PageAddress); + boot_spm_busy_wait(); + } /* Re-enable RWW section */ boot_rww_enable(); |