Add short delays before detaching from the USB bus in the bootloaders (thanks to...
authorDean Camera <dean@fourwalledcubicle.com>
Mon, 22 Jan 2018 05:27:39 +0000 (16:27 +1100)
committerDean Camera <dean@fourwalledcubicle.com>
Mon, 22 Jan 2018 05:27:39 +0000 (16:27 +1100)
Bootloaders/CDC/BootloaderCDC.h
Bootloaders/DFU/BootloaderDFU.c
Bootloaders/HID/BootloaderHID.c
Bootloaders/HID/BootloaderHID.h
Bootloaders/MassStorage/BootloaderMassStorage.c
Bootloaders/MassStorage/BootloaderMassStorage.h
Bootloaders/Printer/BootloaderPrinter.c
Bootloaders/Printer/BootloaderPrinter.h

index 0d31c99..3c19bdf 100644 (file)
@@ -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"
index b13917f..cafbd57 100644 (file)
@@ -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();
 
index e5b7d32..a1f3e67 100644 (file)
@@ -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();
 
index 63f89a6..1984af8 100644 (file)
@@ -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"
index 071e86b..81a8dc4 100644 (file)
@@ -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();
 
index 30a3164..3241e81 100644 (file)
@@ -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"
index 6fde802..da41621 100644 (file)
@@ -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();
 
index 54d96e0..78f938c 100644 (file)
@@ -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"