X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/c5038f1bf44aea75f1ae1ed035cb7d523ccfdacb..bb3879331211a19c3adc3927cac870cc7e36b775:/Bootloaders/TeensyHID/TeensyHID.c diff --git a/Bootloaders/TeensyHID/TeensyHID.c b/Bootloaders/TeensyHID/TeensyHID.c index bb5a0c708..84ec7aac7 100644 --- a/Bootloaders/TeensyHID/TeensyHID.c +++ b/Bootloaders/TeensyHID/TeensyHID.c @@ -35,14 +35,12 @@ #include "TeensyHID.h" -/* Global Variables: */ /** Flag to indicate if the bootloader should be running, or should exit and allow the application code to run * via a soft reset. When cleared, the bootloader will abort, the USB interface will shut down and the application * started via a forced watchdog reset. */ bool RunBootloader = true; - /** Main program entry point. This routine configures the hardware required by the bootloader, then continuously * runs the bootloader processing routine until instructed to soft-exit. */ @@ -53,9 +51,9 @@ int main(void) while (RunBootloader) USB_USBTask(); - - /* Wait 100ms to give the host time to register the disconnection */ - _delay_ms(100); + + /* Turn off the USB interface, disconnect from the host */ + USB_ShutDown(); /* Enable the watchdog and force a timeout to reset the AVR */ wdt_enable(WDTO_250MS); @@ -106,7 +104,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void) { Endpoint_ClearSETUP(); - /* Wait until the command (report) has been sent by the host */ + /* Wait until the command has been sent by the host */ while (!(Endpoint_IsOUTReceived())); /* Read in the write destination address */ @@ -124,7 +122,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void) boot_spm_busy_wait(); /* Write each of the FLASH page's bytes in sequence */ - for (uint8_t PageByte = 0; PageByte < 128; PageByte += 2) + for (uint8_t PageByte = 0; PageByte < SPM_PAGESIZE; PageByte += 2) { /* Check if endpoint is empty - if so clear it and wait until ready for next packet */ if (!(Endpoint_BytesInEndpoint()))