Commit 38039765 authored by Dean Camera's avatar Dean Camera
Browse files

Fixed incorrect/missing control status stage transfers on demos, bootloaders...

Fixed incorrect/missing control status stage transfers on demos, bootloaders and applications (thanks to Nate Lawson).
parent 4a09da20
...@@ -167,6 +167,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -167,6 +167,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
/* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsSetupOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearSetupOUT();
} }
...@@ -184,6 +185,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -184,6 +185,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
Endpoint_ClearSetupOUT(); Endpoint_ClearSetupOUT();
/* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
...@@ -194,6 +196,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -194,6 +196,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
{ {
Endpoint_ClearSetupReceived(); Endpoint_ClearSetupReceived();
/* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
......
...@@ -57,7 +57,7 @@ bool RunBootloader = true; ...@@ -57,7 +57,7 @@ bool RunBootloader = true;
/** Flag to indicate if the bootloader is waiting to exit. When the host requests the bootloader to exit and /** Flag to indicate if the bootloader is waiting to exit. When the host requests the bootloader to exit and
* jump to the application address it specifies, it sends two sequential commands which must be properly * jump to the application address it specifies, it sends two sequential commands which must be properly
* acknowedged. Upon reception of the first the RunBootloader flag is cleared and the WaitForExit flag is set, * acknowledged. Upon reception of the first the RunBootloader flag is cleared and the WaitForExit flag is set,
* causing the bootloader to wait for the final exit command before shutting down. * causing the bootloader to wait for the final exit command before shutting down.
*/ */
bool WaitForExit = false; bool WaitForExit = false;
...@@ -305,7 +305,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -305,7 +305,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
Endpoint_ClearSetupOUT(); Endpoint_ClearSetupOUT();
/* Send ZLP to the host to acknowedge the request */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
break; break;
...@@ -392,7 +393,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -392,7 +393,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
/* Send ZLP to the host to acknowedge the request */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsSetupOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearSetupOUT();
...@@ -415,6 +416,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -415,6 +416,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
/* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsSetupOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearSetupOUT();
...@@ -424,9 +426,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -424,9 +426,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Reset the status value variable to the default OK status */ /* Reset the status value variable to the default OK status */
DFU_Status = OK; DFU_Status = OK;
Endpoint_ClearSetupIN();
/* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN();
break; break;
case DFU_GETSTATE: case DFU_GETSTATE:
Endpoint_ClearSetupReceived(); Endpoint_ClearSetupReceived();
...@@ -436,6 +440,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -436,6 +440,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
/* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsSetupOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearSetupOUT();
...@@ -446,6 +451,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -446,6 +451,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Reset the current state variable to the default idle state */ /* Reset the current state variable to the default idle state */
DFU_State = dfuIDLE; DFU_State = dfuIDLE;
/* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
break; break;
......
...@@ -144,10 +144,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -144,10 +144,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
Endpoint_ClearSetupOUT(); Endpoint_ClearSetupOUT();
/* Wait until the host is ready to receive the request confirmation */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsSetupINReady()));
/* Handshake the request by sending an empty IN packet */
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
......
...@@ -163,7 +163,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -163,7 +163,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
Scheduler_SetTaskMode(USB_Audio_Task, TASK_STOP); Scheduler_SetTaskMode(USB_Audio_Task, TASK_STOP);
} }
/* Handshake the request */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
......
...@@ -193,7 +193,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -193,7 +193,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
Scheduler_SetTaskMode(USB_Audio_Task, TASK_STOP); Scheduler_SetTaskMode(USB_Audio_Task, TASK_STOP);
} }
/* Handshake the request */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
...@@ -249,7 +250,7 @@ TASK(USB_Audio_Task) ...@@ -249,7 +250,7 @@ TASK(USB_Audio_Task)
/* Check to see if the bank is now empty */ /* Check to see if the bank is now empty */
if (!(Endpoint_ReadWriteAllowed())) if (!(Endpoint_ReadWriteAllowed()))
{ {
/* Acknowedge the packet, clear the bank ready for the next packet */ /* Acknowledge the packet, clear the bank ready for the next packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearCurrentBank();
} }
......
...@@ -171,7 +171,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -171,7 +171,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_GetLineEncoding: case REQ_GetLineEncoding:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowedge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearSetupReceived();
/* Write the line coding data to the control endpoint */ /* Write the line coding data to the control endpoint */
...@@ -185,7 +185,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -185,7 +185,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_SetLineEncoding: case REQ_SetLineEncoding:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowedge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearSetupReceived();
/* Read the line coding data in from the host into the global struct */ /* Read the line coding data in from the host into the global struct */
...@@ -210,10 +210,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -210,10 +210,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
// Do something with the given line states in wIndex // Do something with the given line states in wIndex
#endif #endif
/* Acknowedge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearSetupReceived();
/* Send an empty packet to acknowedge the command */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
......
...@@ -209,7 +209,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -209,7 +209,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_GetLineEncoding: case REQ_GetLineEncoding:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowedge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearSetupReceived();
/* Write the line coding data to the control endpoint */ /* Write the line coding data to the control endpoint */
...@@ -223,7 +223,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -223,7 +223,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_SetLineEncoding: case REQ_SetLineEncoding:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowedge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearSetupReceived();
/* Read the line coding data in from the host into the global struct */ /* Read the line coding data in from the host into the global struct */
...@@ -237,10 +237,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -237,10 +237,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_SetControlLineState: case REQ_SetControlLineState:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowedge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearSetupReceived();
/* Send an empty packet to acknowedge the command (currently unused) */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
......
...@@ -210,10 +210,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -210,10 +210,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Clear the endpoint data */ /* Clear the endpoint data */
Endpoint_ClearSetupOUT(); Endpoint_ClearSetupOUT();
/* Wait until the host is ready to receive the request confirmation */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsSetupINReady()));
/* Handshake the request by sending an empty IN packet */
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
...@@ -228,6 +226,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -228,6 +226,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
/* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived()));
Endpoint_ClearSetupOUT();
} }
break; break;
...@@ -242,7 +244,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -242,7 +244,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Set or clear the flag depending on what the host indicates that the current Protocol should be */ /* Set or clear the flag depending on what the host indicates that the current Protocol should be */
UsingReportProtocol = (wValue != 0x0000); UsingReportProtocol = (wValue != 0x0000);
/* Send an empty packet to acknowedge the command */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
...@@ -258,7 +261,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -258,7 +261,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Get idle period in MSB */ /* Get idle period in MSB */
IdleCount = (wValue >> 8); IdleCount = (wValue >> 8);
/* Send an empty packet to acknowedge the command */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
...@@ -273,6 +277,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -273,6 +277,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
/* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived()));
Endpoint_ClearSetupOUT();
} }
break; break;
......
...@@ -212,10 +212,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -212,10 +212,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Clear the endpoint data */ /* Clear the endpoint data */
Endpoint_ClearSetupOUT(); Endpoint_ClearSetupOUT();
/* Wait until the host is ready to receive the request confirmation */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsSetupINReady()));
/* Handshake the request by sending an empty IN packet */
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
...@@ -230,6 +228,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -230,6 +228,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
/* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived()));
Endpoint_ClearSetupOUT();
} }
break; break;
...@@ -244,7 +246,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -244,7 +246,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Set or clear the flag depending on what the host indicates that the current Protocol should be */ /* Set or clear the flag depending on what the host indicates that the current Protocol should be */
UsingReportProtocol = (wValue != 0x0000); UsingReportProtocol = (wValue != 0x0000);
/* Send an empty packet to acknowedge the command */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
...@@ -260,7 +263,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -260,7 +263,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Get idle period in MSB */ /* Get idle period in MSB */
IdleCount = (wValue >> 8); IdleCount = (wValue >> 8);
/* Send an empty packet to acknowedge the command */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
...@@ -275,6 +279,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -275,6 +279,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
/* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived()));
Endpoint_ClearSetupOUT();
} }
break; break;
......
...@@ -213,10 +213,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -213,10 +213,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Clear the endpoint data */ /* Clear the endpoint data */
Endpoint_ClearSetupOUT(); Endpoint_ClearSetupOUT();
/* Wait until the host is ready to receive the request confirmation */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsSetupINReady()));
/* Handshake the request by sending an empty IN packet */
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
......
...@@ -211,10 +211,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -211,10 +211,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Clear the endpoint data */ /* Clear the endpoint data */
Endpoint_ClearSetupOUT(); Endpoint_ClearSetupOUT();
/* Wait until the host is ready to receive the request confirmation */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsSetupINReady()));
/* Handshake the request by sending an empty IN packet */
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
...@@ -229,6 +227,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -229,6 +227,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
/* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived()));
Endpoint_ClearSetupOUT();
} }
break; break;
...@@ -243,7 +245,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -243,7 +245,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Set or clear the flag depending on what the host indicates that the current Protocol should be */ /* Set or clear the flag depending on what the host indicates that the current Protocol should be */
UsingReportProtocol = (wValue != 0x0000); UsingReportProtocol = (wValue != 0x0000);
/* Send an empty packet to acknowedge the command */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
...@@ -259,7 +262,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -259,7 +262,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Get idle period in MSB */ /* Get idle period in MSB */
IdleCount = (wValue >> 8); IdleCount = (wValue >> 8);
/* Send an empty packet to acknowedge the command */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
...@@ -274,6 +278,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -274,6 +278,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
/* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived()));
Endpoint_ClearSetupOUT();
} }
break; break;
......
...@@ -159,10 +159,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -159,10 +159,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_MassStorageReset: case REQ_MassStorageReset:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Indicate that the current transfer should be aborted */
IsMassStoreReset = true;
Endpoint_ClearSetupReceived(); Endpoint_ClearSetupReceived();
/* Indicate that the current transfer should be aborted */
IsMassStoreReset = true;
/* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
...@@ -171,9 +174,15 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -171,9 +174,15 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Indicate to the host the number of supported LUNs (virtual disks) on the device */ /* Indicate to the host the number of supported LUNs (virtual disks) on the device */
Endpoint_ClearSetupReceived(); Endpoint_ClearSetupReceived();
Endpoint_Write_Byte(TOTAL_LUNS - 1); Endpoint_Write_Byte(TOTAL_LUNS - 1);
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
/* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived()));
Endpoint_ClearSetupOUT();
} }
break; break;
......
...@@ -201,6 +201,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -201,6 +201,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
/* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived()));
Endpoint_ClearSetupOUT();
} }
break; break;
...@@ -215,7 +219,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -215,7 +219,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Set or clear the flag depending on what the host indicates that the current Protocol should be */ /* Set or clear the flag depending on what the host indicates that the current Protocol should be */
UsingReportProtocol = (wValue != 0x0000); UsingReportProtocol = (wValue != 0x0000);
/* Send an empty packet to acknowedge the command */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
} }
...@@ -231,7 +236,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -231,7 +236,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Get idle period in MSB */ /* Get idle period in MSB */
IdleCount = (wValue >> 8); IdleCount = (wValue >> 8);
/* Send an empty packet to acknowedge the command */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearSetupIN();
}