X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/37b2130fb2767a39f3d95414c6aca75a67c26298..b9b03aadb219d06fbad9d110e508db93e45461af:/Bootloaders/DFU/BootloaderDFU.c?ds=inline diff --git a/Bootloaders/DFU/BootloaderDFU.c b/Bootloaders/DFU/BootloaderDFU.c index 00c1ea54b..11177c5a6 100644 --- a/Bootloaders/DFU/BootloaderDFU.c +++ b/Bootloaders/DFU/BootloaderDFU.c @@ -139,7 +139,7 @@ int main (void) /** Event handler for the USB_Disconnect event. This indicates that the bootloader should exit and the user * application started. */ -EVENT_HANDLER(USB_Disconnect) +void EVENT_USB_Disconnect(void) { /* Upon disconnection, run user application */ RunBootloader = false; @@ -149,21 +149,15 @@ EVENT_HANDLER(USB_Disconnect) * control requests that are not handled internally by the USB library (including the DFU commands, which are * all issued via the control endpoint), so that they can be handled appropriately for the application. */ -EVENT_HANDLER(USB_UnhandledControlPacket) +void EVENT_USB_UnhandledControlPacket(void) { - /* Discard unused wIndex value */ - Endpoint_Discard_Word(); - - /* Discard unused wValue value */ - Endpoint_Discard_Word(); - /* Get the size of the command and data from the wLength value */ - SentCommand.DataSize = Endpoint_Read_Word_LE(); + SentCommand.DataSize = USB_ControlRequest.wLength; - switch (bRequest) + switch (USB_ControlRequest.bRequest) { case DFU_DNLOAD: - Endpoint_ClearControlSETUP(); + Endpoint_ClearSETUP(); /* Check if bootloader is waiting to terminate */ if (WaitForExit) @@ -235,7 +229,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) /* Check if endpoint is empty - if so clear it and wait until ready for next packet */ if (!(Endpoint_BytesInEndpoint())) { - Endpoint_ClearControlOUT(); + Endpoint_ClearOUT(); while (!(Endpoint_IsOUTReceived())); } @@ -279,7 +273,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) /* Check if endpoint is empty - if so clear it and wait until ready for next packet */ if (!(Endpoint_BytesInEndpoint())) { - Endpoint_ClearControlOUT(); + Endpoint_ClearOUT(); while (!(Endpoint_IsOUTReceived())); } @@ -296,15 +290,15 @@ EVENT_HANDLER(USB_UnhandledControlPacket) } } - Endpoint_ClearControlOUT(); + Endpoint_ClearOUT(); /* Acknowledge status stage */ while (!(Endpoint_IsINReady())); - Endpoint_ClearControlIN(); + Endpoint_ClearIN(); break; case DFU_UPLOAD: - Endpoint_ClearControlSETUP(); + Endpoint_ClearSETUP(); while (!(Endpoint_IsINReady())); @@ -343,7 +337,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) /* Check if endpoint is full - if so clear it and wait until ready for next packet */ if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE) { - Endpoint_ClearControlIN(); + Endpoint_ClearIN(); while (!(Endpoint_IsINReady())); } @@ -368,7 +362,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) /* Check if endpoint is full - if so clear it and wait until ready for next packet */ if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE) { - Endpoint_ClearControlIN(); + Endpoint_ClearIN(); while (!(Endpoint_IsINReady())); } @@ -384,15 +378,15 @@ EVENT_HANDLER(USB_UnhandledControlPacket) DFU_State = dfuIDLE; } - Endpoint_ClearControlIN(); + Endpoint_ClearIN(); /* Acknowledge status stage */ while (!(Endpoint_IsOUTReceived())); - Endpoint_ClearControlOUT(); + Endpoint_ClearOUT(); break; case DFU_GETSTATUS: - Endpoint_ClearControlSETUP(); + Endpoint_ClearSETUP(); /* Write 8-bit status value */ Endpoint_Write_Byte(DFU_Status); @@ -407,46 +401,46 @@ EVENT_HANDLER(USB_UnhandledControlPacket) /* Write 8-bit state string ID number */ Endpoint_Write_Byte(0); - Endpoint_ClearControlIN(); + Endpoint_ClearIN(); /* Acknowledge status stage */ while (!(Endpoint_IsOUTReceived())); - Endpoint_ClearControlOUT(); + Endpoint_ClearOUT(); break; case DFU_CLRSTATUS: - Endpoint_ClearControlSETUP(); + Endpoint_ClearSETUP(); /* Reset the status value variable to the default OK status */ DFU_Status = OK; /* Acknowledge status stage */ while (!(Endpoint_IsINReady())); - Endpoint_ClearControlIN(); + Endpoint_ClearIN(); break; case DFU_GETSTATE: - Endpoint_ClearControlSETUP(); + Endpoint_ClearSETUP(); /* Write the current device state to the endpoint */ Endpoint_Write_Byte(DFU_State); - Endpoint_ClearControlIN(); + Endpoint_ClearIN(); /* Acknowledge status stage */ while (!(Endpoint_IsOUTReceived())); - Endpoint_ClearControlOUT(); + Endpoint_ClearOUT(); break; case DFU_ABORT: - Endpoint_ClearControlSETUP(); + Endpoint_ClearSETUP(); /* Reset the current state variable to the default idle state */ DFU_State = dfuIDLE; /* Acknowledge status stage */ while (!(Endpoint_IsINReady())); - Endpoint_ClearControlIN(); + Endpoint_ClearIN(); break; } @@ -463,7 +457,7 @@ static void DiscardFillerBytes(uint8_t NumberOfBytes) { if (!(Endpoint_BytesInEndpoint())) { - Endpoint_ClearControlOUT(); + Endpoint_ClearOUT(); /* Wait until next data packet received */ while (!(Endpoint_IsOUTReceived()));