aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2018-01-22 16:27:39 +1100
committerDean Camera <dean@fourwalledcubicle.com>2018-01-22 16:27:39 +1100
commitd6a528f9a03fe338e30d93f306e0482612e02e3e (patch)
tree69ae2773614b99df8b8a3cdbc944178236cea5b7
parentba6d9c1a971db3c42bf0b054ebb64f72b3e3ddba (diff)
downloadlufa-d6a528f9a03fe338e30d93f306e0482612e02e3e.tar.gz
lufa-d6a528f9a03fe338e30d93f306e0482612e02e3e.tar.bz2
lufa-d6a528f9a03fe338e30d93f306e0482612e02e3e.zip
Add short delays before detaching from the USB bus in the bootloaders (thanks to NicoHood).
-rw-r--r--Bootloaders/CDC/BootloaderCDC.h1
-rw-r--r--Bootloaders/DFU/BootloaderDFU.c3
-rw-r--r--Bootloaders/HID/BootloaderHID.c3
-rw-r--r--Bootloaders/HID/BootloaderHID.h1
-rw-r--r--Bootloaders/MassStorage/BootloaderMassStorage.c3
-rw-r--r--Bootloaders/MassStorage/BootloaderMassStorage.h1
-rw-r--r--Bootloaders/Printer/BootloaderPrinter.c3
-rw-r--r--Bootloaders/Printer/BootloaderPrinter.h1
8 files changed, 16 insertions, 0 deletions
diff --git a/Bootloaders/CDC/BootloaderCDC.h b/Bootloaders/CDC/BootloaderCDC.h
index 0d31c99c4..3c19bdfd5 100644
--- a/Bootloaders/CDC/BootloaderCDC.h
+++ b/Bootloaders/CDC/BootloaderCDC.h
@@ -43,6 +43,7 @@
#include <avr/eeprom.h>
#include <avr/power.h>
#include <avr/interrupt.h>
+ #include <util/delay.h>
#include <stdbool.h>
#include "Descriptors.h"
diff --git a/Bootloaders/DFU/BootloaderDFU.c b/Bootloaders/DFU/BootloaderDFU.c
index b13917f45..cafbd572b 100644
--- a/Bootloaders/DFU/BootloaderDFU.c
+++ b/Bootloaders/DFU/BootloaderDFU.c
@@ -191,6 +191,9 @@ int main(void)
while (RunBootloader || WaitForExit)
USB_USBTask();
+ /* Wait a short time to end all USB transactions and then disconnect */
+ _delay_us(1000);
+
/* Reset configured hardware back to their original states for the user application */
ResetHardware();
diff --git a/Bootloaders/HID/BootloaderHID.c b/Bootloaders/HID/BootloaderHID.c
index e5b7d3258..a1f3e6718 100644
--- a/Bootloaders/HID/BootloaderHID.c
+++ b/Bootloaders/HID/BootloaderHID.c
@@ -84,6 +84,9 @@ int main(void)
while (RunBootloader)
USB_USBTask();
+ /* Wait a short time to end all USB transactions and then disconnect */
+ _delay_us(1000);
+
/* Disconnect from the host - USB interface will be reset later along with the AVR */
USB_Detach();
diff --git a/Bootloaders/HID/BootloaderHID.h b/Bootloaders/HID/BootloaderHID.h
index 63f89a622..1984af893 100644
--- a/Bootloaders/HID/BootloaderHID.h
+++ b/Bootloaders/HID/BootloaderHID.h
@@ -43,6 +43,7 @@
#include <avr/power.h>
#include <avr/interrupt.h>
#include <util/atomic.h>
+ #include <util/delay.h>
#include <stdbool.h>
#include "Descriptors.h"
diff --git a/Bootloaders/MassStorage/BootloaderMassStorage.c b/Bootloaders/MassStorage/BootloaderMassStorage.c
index 071e86bba..81a8dc424 100644
--- a/Bootloaders/MassStorage/BootloaderMassStorage.c
+++ b/Bootloaders/MassStorage/BootloaderMassStorage.c
@@ -169,6 +169,9 @@ int main(void)
USB_USBTask();
}
+ /* Wait a short time to end all USB transactions and then disconnect */
+ _delay_us(1000);
+
/* Disconnect from the host - USB interface will be reset later along with the AVR */
USB_Detach();
diff --git a/Bootloaders/MassStorage/BootloaderMassStorage.h b/Bootloaders/MassStorage/BootloaderMassStorage.h
index 30a3164ef..3241e81a4 100644
--- a/Bootloaders/MassStorage/BootloaderMassStorage.h
+++ b/Bootloaders/MassStorage/BootloaderMassStorage.h
@@ -41,6 +41,7 @@
#include <avr/wdt.h>
#include <avr/power.h>
#include <avr/interrupt.h>
+ #include <util/delay.h>
#include <string.h>
#include "Descriptors.h"
diff --git a/Bootloaders/Printer/BootloaderPrinter.c b/Bootloaders/Printer/BootloaderPrinter.c
index 6fde80290..da4162172 100644
--- a/Bootloaders/Printer/BootloaderPrinter.c
+++ b/Bootloaders/Printer/BootloaderPrinter.c
@@ -401,6 +401,9 @@ int main(void)
USB_USBTask();
}
+ /* Wait a short time to end all USB transactions and then disconnect */
+ _delay_us(1000);
+
/* Disconnect from the host - USB interface will be reset later along with the AVR */
USB_Detach();
diff --git a/Bootloaders/Printer/BootloaderPrinter.h b/Bootloaders/Printer/BootloaderPrinter.h
index 54d96e0bc..78f938c68 100644
--- a/Bootloaders/Printer/BootloaderPrinter.h
+++ b/Bootloaders/Printer/BootloaderPrinter.h
@@ -41,6 +41,7 @@
#include <avr/wdt.h>
#include <avr/power.h>
#include <avr/interrupt.h>
+ #include <util/delay.h>
#include "Descriptors.h"
#include "BootloaderAPI.h"