X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/071e02c6b6b4837fa9cf0b6d4c749994e02638d7..bea72a8412f99b294c00341fa16a8308bcc66f15:/Bootloaders/DFU/BootloaderDFU.c diff --git a/Bootloaders/DFU/BootloaderDFU.c b/Bootloaders/DFU/BootloaderDFU.c index 752c32009..6f8acc80d 100644 --- a/Bootloaders/DFU/BootloaderDFU.c +++ b/Bootloaders/DFU/BootloaderDFU.c @@ -156,7 +156,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void) switch (USB_ControlRequest.bRequest) { - case DFU_DNLOAD: + case REQ_DFU_DNLOAD: Endpoint_ClearSETUP(); /* Check if bootloader is waiting to terminate */ @@ -309,7 +309,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void) Endpoint_ClearStatusStage(); break; - case DFU_UPLOAD: + case REQ_DFU_UPLOAD: Endpoint_ClearSETUP(); while (!(Endpoint_IsINReady())) @@ -408,7 +408,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void) Endpoint_ClearStatusStage(); break; - case DFU_GETSTATUS: + case REQ_DFU_GETSTATUS: Endpoint_ClearSETUP(); /* Write 8-bit status value */ @@ -428,7 +428,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void) Endpoint_ClearStatusStage(); break; - case DFU_CLRSTATUS: + case REQ_DFU_CLRSTATUS: Endpoint_ClearSETUP(); /* Reset the status value variable to the default OK status */ @@ -436,7 +436,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void) Endpoint_ClearStatusStage(); break; - case DFU_GETSTATE: + case REQ_DFU_GETSTATE: Endpoint_ClearSETUP(); /* Write the current device state to the endpoint */ @@ -446,7 +446,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void) Endpoint_ClearStatusStage(); break; - case DFU_ABORT: + case REQ_DFU_ABORT: Endpoint_ClearSETUP(); /* Reset the current state variable to the default idle state */ @@ -634,26 +634,30 @@ static void ProcessWriteCommand(void) /* Indicate that the bootloader is terminating */ WaitForExit = true; - /* Check if empty request data array - an empty request after a filled request retains the - previous valid request data, but initializes the reset */ - if (!(SentCommand.DataSize)) + /* Check if data supplied for the Start Program command - no data executes the program */ + if (SentCommand.DataSize) { - if (SentCommand.Data[1] == 0x00) // Start via watchdog - { - /* Start the watchdog to reset the AVR once the communications are finalized */ - wdt_enable(WDTO_250MS); - } - else // Start via jump + if (SentCommand.Data[1] == 0x01) // Start via jump { - /* Load in the jump address into the application start address pointer */ union { uint8_t Bytes[2]; AppPtr_t FuncPtr; } Address = {.Bytes = {SentCommand.Data[4], SentCommand.Data[3]}}; + /* Load in the jump address into the application start address pointer */ AppStartPtr = Address.FuncPtr; - + } + } + else + { + if (SentCommand.Data[1] == 0x00) // Start via watchdog + { + /* Start the watchdog to reset the AVR once the communications are finalized */ + wdt_enable(WDTO_250MS); + } + else // Start via jump + { /* Set the flag to terminate the bootloader at next opportunity */ RunBootloader = false; }