Add Adafruit's Atmega32u4 breakout board
[pub/USBasp.git] / Bootloaders / Printer / BootloaderAPI.c
index 2be1568..5e8083e 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2017.
+     Copyright (C) Dean Camera, 2018.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2017  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2018  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
 
 void BootloaderAPI_ErasePage(const uint32_t Address)
 {
 
 void BootloaderAPI_ErasePage(const uint32_t Address)
 {
-       boot_page_erase_safe(Address);
-       boot_spm_busy_wait();
-       boot_rww_enable();
+       ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
+       {
+               boot_page_erase_safe(Address);
+               boot_spm_busy_wait();
+               boot_rww_enable();
+       }
 }
 
 void BootloaderAPI_WritePage(const uint32_t Address)
 {
 }
 
 void BootloaderAPI_WritePage(const uint32_t Address)
 {
-       boot_page_write_safe(Address);
-       boot_spm_busy_wait();
-       boot_rww_enable();
+       ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
+       {
+               boot_page_write_safe(Address);
+               boot_spm_busy_wait();
+               boot_rww_enable();
+       }
 }
 
 void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word)
 }
 
 void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word)
@@ -71,5 +77,8 @@ uint8_t BootloaderAPI_ReadLock(void)
 
 void BootloaderAPI_WriteLock(const uint8_t LockBits)
 {
 
 void BootloaderAPI_WriteLock(const uint8_t LockBits)
 {
-       boot_lock_bits_set_safe(LockBits);
+       ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
+       {
+               boot_lock_bits_set_safe(LockBits);
+       }
 }
 }