Removed specialized Endpoint_ClearControl* and Pipe_ClearControl* macros in favour of the standard Endpoint_Clear* and Pipe_Clear* macros (Atmel have confirmed no effect from setting FIFOCON on control endpoints).

pull/1469/head
Dean Camera 16 years ago
parent ba7cd3f22e
commit e5e7eaee7a

@ -160,45 +160,45 @@ 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))
{ {
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
for (uint8_t i = 0; i < sizeof(LineCoding); i++) for (uint8_t i = 0; i < sizeof(LineCoding); i++)
Endpoint_Write_Byte(*(LineCodingData++)); Endpoint_Write_Byte(*(LineCodingData++));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
break; break;
case REQ_SetLineEncoding: case REQ_SetLineEncoding:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
for (uint8_t i = 0; i < sizeof(LineCoding); i++) for (uint8_t i = 0; i < sizeof(LineCoding); i++)
*(LineCodingData++) = Endpoint_Read_Byte(); *(LineCodingData++) = Endpoint_Read_Byte();
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;
case REQ_SetControlLineState: case REQ_SetControlLineState:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;

@ -163,7 +163,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
switch (bRequest) switch (bRequest)
{ {
case DFU_DNLOAD: case DFU_DNLOAD:
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Check if bootloader is waiting to terminate */ /* Check if bootloader is waiting to terminate */
if (WaitForExit) if (WaitForExit)
@ -235,7 +235,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */ /* Check if endpoint is empty - if so clear it and wait until ready for next packet */
if (!(Endpoint_BytesInEndpoint())) if (!(Endpoint_BytesInEndpoint()))
{ {
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
} }
@ -279,7 +279,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */ /* Check if endpoint is empty - if so clear it and wait until ready for next packet */
if (!(Endpoint_BytesInEndpoint())) if (!(Endpoint_BytesInEndpoint()))
{ {
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
} }
@ -296,15 +296,15 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
} }
} }
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
break; break;
case DFU_UPLOAD: case DFU_UPLOAD:
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
@ -343,7 +343,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Check if endpoint is full - if so clear it and wait until ready for next packet */ /* Check if endpoint is full - if so clear it and wait until ready for next packet */
if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE) if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE)
{ {
Endpoint_ClearControlIN(); Endpoint_ClearIN();
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
} }
@ -368,7 +368,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Check if endpoint is full - if so clear it and wait until ready for next packet */ /* Check if endpoint is full - if so clear it and wait until ready for next packet */
if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE) if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE)
{ {
Endpoint_ClearControlIN(); Endpoint_ClearIN();
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
} }
@ -384,15 +384,15 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
DFU_State = dfuIDLE; DFU_State = dfuIDLE;
} }
Endpoint_ClearControlIN(); Endpoint_ClearIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
break; break;
case DFU_GETSTATUS: case DFU_GETSTATUS:
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Write 8-bit status value */ /* Write 8-bit status value */
Endpoint_Write_Byte(DFU_Status); Endpoint_Write_Byte(DFU_Status);
@ -407,46 +407,46 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Write 8-bit state string ID number */ /* Write 8-bit state string ID number */
Endpoint_Write_Byte(0); Endpoint_Write_Byte(0);
Endpoint_ClearControlIN(); Endpoint_ClearIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
break; break;
case DFU_CLRSTATUS: case DFU_CLRSTATUS:
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* 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;
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
break; break;
case DFU_GETSTATE: case DFU_GETSTATE:
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Write the current device state to the endpoint */ /* Write the current device state to the endpoint */
Endpoint_Write_Byte(DFU_State); Endpoint_Write_Byte(DFU_State);
Endpoint_ClearControlIN(); Endpoint_ClearIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
break; break;
case DFU_ABORT: case DFU_ABORT:
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* 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 */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
break; break;
} }
@ -463,7 +463,7 @@ static void DiscardFillerBytes(uint8_t NumberOfBytes)
{ {
if (!(Endpoint_BytesInEndpoint())) if (!(Endpoint_BytesInEndpoint()))
{ {
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
/* Wait until next data packet received */ /* Wait until next data packet received */
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));

@ -101,7 +101,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_SetReport: case REQ_SetReport:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Wait until the command (report) has been sent by the host */ /* Wait until the command (report) has been sent by the host */
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
@ -126,7 +126,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */ /* Check if endpoint is empty - if so clear it and wait until ready for next packet */
if (!(Endpoint_BytesInEndpoint())) if (!(Endpoint_BytesInEndpoint()))
{ {
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
} }
@ -142,11 +142,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
boot_rww_enable(); boot_rww_enable();
} }
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;

@ -139,7 +139,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
{ {
uint16_t wValue = Endpoint_Read_Word_LE(); uint16_t wValue = Endpoint_Read_Word_LE();
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */ /* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */
if (wValue) if (wValue)
@ -155,7 +155,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;

@ -166,7 +166,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
{ {
uint16_t wValue = Endpoint_Read_Word_LE(); uint16_t wValue = Endpoint_Read_Word_LE();
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */ /* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */
if (wValue) if (wValue)
@ -182,7 +182,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;

@ -166,13 +166,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Write the line coding data to the control endpoint */ /* Write the line coding data to the control endpoint */
Endpoint_Write_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t)); Endpoint_Write_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t));
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
break; break;
@ -180,13 +180,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* 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 */
Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t)); Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t));
/* Finalize the stream transfer to clear the last packet from the host */ /* Finalize the stream transfer to clear the last packet from the host */
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;
@ -205,11 +205,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
#endif #endif
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;

@ -204,13 +204,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Write the line coding data to the control endpoint */ /* Write the line coding data to the control endpoint */
Endpoint_Write_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t)); Endpoint_Write_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t));
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
break; break;
@ -218,13 +218,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* 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 */
Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t)); Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t));
/* Finalize the stream transfer to clear the last packet from the host */ /* Finalize the stream transfer to clear the last packet from the host */
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;
@ -232,11 +232,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;

@ -165,7 +165,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_GetReport: case REQ_GetReport:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
uint8_t GenericData[GENERIC_REPORT_SIZE]; uint8_t GenericData[GENERIC_REPORT_SIZE];
@ -175,14 +175,14 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
Endpoint_Write_Control_Stream_LE(&GenericData, sizeof(GenericData)); Endpoint_Write_Control_Stream_LE(&GenericData, sizeof(GenericData));
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
break; break;
case REQ_SetReport: case REQ_SetReport:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Wait until the generic report has been sent by the host */ /* Wait until the generic report has been sent by the host */
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
@ -194,13 +194,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
ProcessGenericHIDReport(GenericData); ProcessGenericHIDReport(GenericData);
/* Clear the endpoint data */ /* Clear the endpoint data */
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
/* Wait until the host is ready to receive the request confirmation */ /* Wait until the host is ready to receive the request confirmation */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
/* Handshake the request by sending an empty IN packet */ /* Handshake the request by sending an empty IN packet */
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;

@ -145,13 +145,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (wLength > sizeof(JoystickReportData)) if (wLength > sizeof(JoystickReportData))
wLength = sizeof(JoystickReportData); wLength = sizeof(JoystickReportData);
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Write the report data to the control endpoint */ /* Write the report data to the control endpoint */
Endpoint_Write_Control_Stream_LE(&JoystickReportData, wLength); Endpoint_Write_Control_Stream_LE(&JoystickReportData, wLength);
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
break; break;

@ -216,20 +216,20 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (wLength > sizeof(KeyboardReportData)) if (wLength > sizeof(KeyboardReportData))
wLength = sizeof(KeyboardReportData); wLength = sizeof(KeyboardReportData);
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Write the report data to the control endpoint */ /* Write the report data to the control endpoint */
Endpoint_Write_Control_Stream_LE(&KeyboardReportData, wLength); Endpoint_Write_Control_Stream_LE(&KeyboardReportData, wLength);
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
break; break;
case REQ_SetReport: case REQ_SetReport:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Wait until the LED report has been sent by the host */ /* Wait until the LED report has been sent by the host */
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
@ -241,28 +241,28 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
ProcessLEDReport(LEDStatus); ProcessLEDReport(LEDStatus);
/* Clear the endpoint data */ /* Clear the endpoint data */
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;
case REQ_GetProtocol: case REQ_GetProtocol:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Write the current protocol flag to the host */ /* Write the current protocol flag to the host */
Endpoint_Write_Byte(UsingReportProtocol); Endpoint_Write_Byte(UsingReportProtocol);
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearControlIN(); Endpoint_ClearIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
break; break;
@ -272,14 +272,14 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Read in the wValue parameter containing the new protocol mode */ /* Read in the wValue parameter containing the new protocol mode */
uint16_t wValue = Endpoint_Read_Word_LE(); uint16_t wValue = Endpoint_Read_Word_LE();
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* 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);
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;
@ -289,31 +289,31 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Read in the wValue parameter containing the idle period */ /* Read in the wValue parameter containing the idle period */
uint16_t wValue = Endpoint_Read_Word_LE(); uint16_t wValue = Endpoint_Read_Word_LE();
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Get idle period in MSB */ /* Get idle period in MSB */
IdleCount = (wValue >> 8); IdleCount = (wValue >> 8);
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;
case REQ_GetIdle: case REQ_GetIdle:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Write the current idle duration to the host */ /* Write the current idle duration to the host */
Endpoint_Write_Byte(IdleCount); Endpoint_Write_Byte(IdleCount);
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearControlIN(); Endpoint_ClearIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
break; break;

@ -167,7 +167,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (wLength > ReportSize) if (wLength > ReportSize)
wLength = ReportSize; wLength = ReportSize;
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Write the report data to the control endpoint */ /* Write the report data to the control endpoint */
Endpoint_Write_Control_Stream_LE(ReportData, wLength); Endpoint_Write_Control_Stream_LE(ReportData, wLength);
@ -176,14 +176,14 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
memset(ReportData, 0, ReportSize); memset(ReportData, 0, ReportSize);
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
break; break;
case REQ_SetReport: case REQ_SetReport:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Wait until the LED report has been sent by the host */ /* Wait until the LED report has been sent by the host */
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
@ -205,11 +205,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
LEDs_SetAllLEDs(LEDMask); LEDs_SetAllLEDs(LEDMask);
/* Clear the endpoint data */ /* Clear the endpoint data */
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;

@ -153,30 +153,30 @@ 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))
{ {
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Indicate that the current transfer should be aborted */ /* Indicate that the current transfer should be aborted */
IsMassStoreReset = true; IsMassStoreReset = true;
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;
case REQ_GetMaxLUN: case REQ_GetMaxLUN:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* 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_Write_Byte(TOTAL_LUNS - 1); Endpoint_Write_Byte(TOTAL_LUNS - 1);
Endpoint_ClearControlIN(); Endpoint_ClearIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
break; break;

@ -206,7 +206,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (wLength > sizeof(MouseReportData)) if (wLength > sizeof(MouseReportData))
wLength = sizeof(MouseReportData); wLength = sizeof(MouseReportData);
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Write the report data to the control endpoint */ /* Write the report data to the control endpoint */
Endpoint_Write_Control_Stream_LE(&MouseReportData, wLength); Endpoint_Write_Control_Stream_LE(&MouseReportData, wLength);
@ -215,24 +215,24 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
memset(&MouseReportData, 0, sizeof(MouseReportData)); memset(&MouseReportData, 0, sizeof(MouseReportData));
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
break; break;
case REQ_GetProtocol: case REQ_GetProtocol:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Write the current protocol flag to the host */ /* Write the current protocol flag to the host */
Endpoint_Write_Byte(UsingReportProtocol); Endpoint_Write_Byte(UsingReportProtocol);
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearControlIN(); Endpoint_ClearIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
break; break;
@ -242,14 +242,14 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Read in the wValue parameter containing the new protocol mode */ /* Read in the wValue parameter containing the new protocol mode */
uint16_t wValue = Endpoint_Read_Word_LE(); uint16_t wValue = Endpoint_Read_Word_LE();
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* 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);
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;
@ -259,31 +259,31 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Read in the wValue parameter containing the idle period */ /* Read in the wValue parameter containing the idle period */
uint16_t wValue = Endpoint_Read_Word_LE(); uint16_t wValue = Endpoint_Read_Word_LE();
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Get idle period in MSB */ /* Get idle period in MSB */
IdleCount = (wValue >> 8); IdleCount = (wValue >> 8);
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;
case REQ_GetIdle: case REQ_GetIdle:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Write the current idle duration to the host */ /* Write the current idle duration to the host */
Endpoint_Write_Byte(IdleCount); Endpoint_Write_Byte(IdleCount);
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearControlIN(); Endpoint_ClearIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
break; break;

@ -156,13 +156,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Clear the SETUP packet, ready for data transfer */ /* Clear the SETUP packet, ready for data transfer */
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Read in the RNDIS message into the message buffer */ /* Read in the RNDIS message into the message buffer */
Endpoint_Read_Control_Stream_LE(RNDISMessageBuffer, wLength); Endpoint_Read_Control_Stream_LE(RNDISMessageBuffer, wLength);
/* Finalize the stream transfer to clear the last packet from the host */ /* Finalize the stream transfer to clear the last packet from the host */
Endpoint_ClearControlIN(); Endpoint_ClearIN();
/* Process the RNDIS message */ /* Process the RNDIS message */
ProcessRNDISControlMessage(); ProcessRNDISControlMessage();
@ -185,13 +185,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
wLength = MessageHeader->MessageLength; wLength = MessageHeader->MessageLength;
/* Clear the SETUP packet, ready for data transfer */ /* Clear the SETUP packet, ready for data transfer */
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Write the message response data to the endpoint */ /* Write the message response data to the endpoint */
Endpoint_Write_Control_Stream_LE(RNDISMessageBuffer, wLength); Endpoint_Write_Control_Stream_LE(RNDISMessageBuffer, wLength);
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
/* Reset the message header once again after transmission */ /* Reset the message header once again after transmission */
MessageHeader->MessageLength = 0; MessageHeader->MessageLength = 0;

@ -159,13 +159,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Write the line coding data to the control endpoint */ /* Write the line coding data to the control endpoint */
Endpoint_Write_Control_Stream_LE(LineCodingData, sizeof(LineCoding)); Endpoint_Write_Control_Stream_LE(LineCodingData, sizeof(LineCoding));
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
break; break;
@ -173,13 +173,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* 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 */
Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(LineCoding)); Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(LineCoding));
/* Finalize the stream transfer to clear the last packet from the host */ /* Finalize the stream transfer to clear the last packet from the host */
Endpoint_ClearControlIN(); Endpoint_ClearIN();
/* Reconfigure the USART with the new settings */ /* Reconfigure the USART with the new settings */
ReconfigureUSART(); ReconfigureUSART();
@ -201,11 +201,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
#endif #endif
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;

@ -36,14 +36,13 @@
* - The USB Host management task now saves and restores the currently selected pipe before and after the task completes * - The USB Host management task now saves and restores the currently selected pipe before and after the task completes
* - Fixed GenericHIDHost demo report write routine incorrect for control type requests (thanks to Andrei Krainev) * - Fixed GenericHIDHost demo report write routine incorrect for control type requests (thanks to Andrei Krainev)
* - Removed Endpoint_ClearCurrentBank() and Pipe_ClearCurrentBank() in favour of new Endpoint_ClearIN(), Endpoint_ClearOUT(), * - Removed Endpoint_ClearCurrentBank() and Pipe_ClearCurrentBank() in favour of new Endpoint_ClearIN(), Endpoint_ClearOUT(),
* Endpoint_ClearControlIN(), Endpoint_ClearControlOUT(), Pipe_ClearIN(), Pipe_ClearOUT(), Pipe_ClearControlIN() and * Pipe_ClearIN() and Pipe_ClearOUT() macros (done to allow for the detection of packets of zero length)
* Pipe_ClearControlOUT() macros (done to allow for the detection of packets of zero length)
* - Renamed *_ReadWriteAllowed() macros to *_IsReadWriteAllowed() to remain consistent with the rest of the LUFA API * - Renamed *_ReadWriteAllowed() macros to *_IsReadWriteAllowed() to remain consistent with the rest of the LUFA API
* - Endpoint_IsSetupReceived() macro has been renamed to Endpoint_IsSETUPReceived(), Endpoint_ClearSetupReceived() macro has been * - Endpoint_IsSetupReceived() macro has been renamed to Endpoint_IsSETUPReceived(), Endpoint_ClearSetupReceived() macro has been
* renamed to Endpoint_ClearControlSETUP(), the Pipe_IsSetupSent() macro has been renamed to Pipe_IsSETUPSent() and the * renamed to Endpoint_ClearSETUP(), the Pipe_IsSetupSent() macro has been renamed to Pipe_IsSETUPSent() and the
* Pipe_ClearSetupSent() macro is no longer applicable and should be removed - changes made to compliment the new endpoint and pipe * Pipe_ClearSetupSent() macro is no longer applicable and should be removed - changes made to compliment the new endpoint and pipe
* bank management API * bank management API
* - Updated all demos, bootloaders and projects to use the new endpoint and pipe management APIs (thanks to Roman Thiel) * - Updated all demos, bootloaders and projects to use the new endpoint and pipe management APIs (thanks to Roman Thiel (Curetis AG))
* - Updated library doxygen documentation, added groups, changed documentation macro functions to real functions for clarity * - Updated library doxygen documentation, added groups, changed documentation macro functions to real functions for clarity
* - Removed old endpoint and pipe aliased read/write/discard routines which did not have an explicit endian specifier for clarity * - Removed old endpoint and pipe aliased read/write/discard routines which did not have an explicit endian specifier for clarity
* - Removed the ButtLoadTag.h header file, as no one used for its intended purpose anyway * - Removed the ButtLoadTag.h header file, as no one used for its intended purpose anyway

@ -108,7 +108,7 @@ void USB_Device_ProcessControlPacket(void)
if (Endpoint_IsSETUPReceived()) if (Endpoint_IsSETUPReceived())
{ {
Endpoint_StallTransaction(); Endpoint_StallTransaction();
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
} }
} }
@ -116,11 +116,11 @@ static void USB_Device_SetAddress(void)
{ {
uint8_t wValue_LSB = Endpoint_Read_Byte(); uint8_t wValue_LSB = Endpoint_Read_Byte();
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
@ -152,11 +152,11 @@ static void USB_Device_SetConfiguration(void)
return; return;
} }
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
USB_ConfigurationNumber = wValue_LSB; USB_ConfigurationNumber = wValue_LSB;
Endpoint_ClearControlIN(); Endpoint_ClearIN();
if (!(AlreadyConfigured) && USB_ConfigurationNumber) if (!(AlreadyConfigured) && USB_ConfigurationNumber)
RAISE_EVENT(USB_DeviceEnumerationComplete); RAISE_EVENT(USB_DeviceEnumerationComplete);
@ -166,14 +166,14 @@ static void USB_Device_SetConfiguration(void)
void USB_Device_GetConfiguration(void) void USB_Device_GetConfiguration(void)
{ {
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
Endpoint_Write_Byte(USB_ConfigurationNumber); Endpoint_Write_Byte(USB_ConfigurationNumber);
Endpoint_ClearControlIN(); Endpoint_ClearIN();
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
static void USB_Device_GetDescriptor(void) static void USB_Device_GetDescriptor(void)
@ -190,7 +190,7 @@ static void USB_Device_GetDescriptor(void)
if ((DescriptorSize = USB_GetDescriptor(wValue, wIndex, &DescriptorPointer)) == NO_DESCRIPTOR) if ((DescriptorSize = USB_GetDescriptor(wValue, wIndex, &DescriptorPointer)) == NO_DESCRIPTOR)
return; return;
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
if (wLength > DescriptorSize) if (wLength > DescriptorSize)
wLength = DescriptorSize; wLength = DescriptorSize;
@ -201,7 +201,7 @@ static void USB_Device_GetDescriptor(void)
{ {
if (Endpoint_IsOUTReceived()) if (Endpoint_IsOUTReceived())
{ {
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
return; return;
} }
} }
@ -220,17 +220,17 @@ static void USB_Device_GetDescriptor(void)
} }
SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize); SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
if (SendZLP) if (SendZLP)
{ {
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
static void USB_Device_GetStatus(const uint8_t bmRequestType) static void USB_Device_GetStatus(const uint8_t bmRequestType)
@ -264,14 +264,14 @@ static void USB_Device_GetStatus(const uint8_t bmRequestType)
} }
Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
Endpoint_Write_Word_LE(CurrentStatus); Endpoint_Write_Word_LE(CurrentStatus);
Endpoint_ClearControlIN(); Endpoint_ClearIN();
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
#if !defined(FEATURELESS_CONTROL_ONLY_DEVICE) #if !defined(FEATURELESS_CONTROL_ONLY_DEVICE)
@ -306,8 +306,8 @@ static void USB_Device_ClearSetFeature(const uint8_t bRequest, const uint8_t bmR
} }
Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
} }

@ -59,7 +59,7 @@ bool Endpoint_ConfigureEndpointStatic(const uint8_t Number, const uint8_t UECFG0
Endpoint_SelectEndpoint(Number); Endpoint_SelectEndpoint(Number);
Endpoint_EnableEndpoint(); Endpoint_EnableEndpoint();
UECFG1X = 0; UECFG1X = 0;
UECFG0X = UECFG0XData; UECFG0X = UECFG0XData;
UECFG1X = UECFG1XData; UECFG1X = UECFG1XData;
@ -307,7 +307,7 @@ uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length)
} }
SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize); SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
if (Endpoint_IsOUTReceived()) if (Endpoint_IsOUTReceived())
@ -316,7 +316,7 @@ uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length)
if (SendZLP) if (SendZLP)
{ {
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
@ -341,7 +341,7 @@ uint8_t Endpoint_Write_Control_Stream_BE(const void* Buffer, uint16_t Length)
} }
SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize); SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
if (Endpoint_IsOUTReceived()) if (Endpoint_IsOUTReceived())
@ -350,7 +350,7 @@ uint8_t Endpoint_Write_Control_Stream_BE(const void* Buffer, uint16_t Length)
if (SendZLP) if (SendZLP)
{ {
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
@ -373,7 +373,7 @@ uint8_t Endpoint_Read_Control_Stream_LE(void* Buffer, uint16_t Length)
Length--; Length--;
} }
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
@ -396,7 +396,7 @@ uint8_t Endpoint_Read_Control_Stream_BE(void* Buffer, uint16_t Length)
Length--; Length--;
} }
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));

@ -309,41 +309,19 @@
* *
* \note This is not applicable for non CONTROL type endpoints. * \note This is not applicable for non CONTROL type endpoints.
*/ */
static inline void Endpoint_ClearControlSETUP(void); static inline void Endpoint_ClearSETUP(void);
/** Sends an IN packet to the host on the currently selected CONTROL type endpoint, freeing up the /** Sends an IN packet to the host on the currently selected endpoint, freeing up the endpoint for the
* endpoint for the next packet. * next packet and switching to the alternative endpoint bank if double banked.
*
* \ingroup Group_EndpointPacketManagement
*
* \note For non CONTROL type endpoints, use Endpoint_ClearIN() instead.
*/
static inline void Endpoint_ClearControlIN(void);
/** Acknowledges an OUT packet to the host on the currently selected CONTROL type endpoint, freeing
* up the endpoint for the next packet.
* *
* \ingroup Group_EndpointPacketManagement * \ingroup Group_EndpointPacketManagement
*
* \note For non CONTROL type endpoints, use Endpoint_ClearOUT() instead.
*/
static inline void Endpoint_ClearControlOUT(void);
/** Sends an IN packet to the host on the currently selected non CONTROL type endpoint, freeing
* up the endpoint for the next packet and switching to the alternative endpoint bank if double banked.
*
* \ingroup Group_EndpointPacketManagement
*
* \note For CONTROL type endpoints, use Endpoint_ClearControlIN() instead.
*/ */
static inline void Endpoint_ClearIN(void); static inline void Endpoint_ClearIN(void);
/** Acknowledges an OUT packet to the host on the currently selected non CONTROL type endpoint, freeing /** Acknowledges an OUT packet to the host on the currently selected endpoint, freeing up the endpoint
* up the endpoint for the next packet and switching to the alternative endpoint bank if double banked. * for the next packet and switching to the alternative endpoint bank if double banked.
* *
* \ingroup Group_EndpointPacketManagement * \ingroup Group_EndpointPacketManagement
*
* \note For CONTROL type endpoints, use Endpoint_ClearControlOUT() instead.
*/ */
static inline void Endpoint_ClearOUT(void); static inline void Endpoint_ClearOUT(void);
@ -417,11 +395,7 @@
#define Endpoint_IsSETUPReceived() ((UEINTX & (1 << RXSTPI)) ? true : false) #define Endpoint_IsSETUPReceived() ((UEINTX & (1 << RXSTPI)) ? true : false)
#define Endpoint_ClearControlSETUP() MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE #define Endpoint_ClearSETUP() MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE
#define Endpoint_ClearControlIN() MACROS{ UEINTX &= ~(1 << TXINI); }MACROE
#define Endpoint_ClearControlOUT() MACROS{ UEINTX &= ~(1 << RXOUTI); }MACROE
#define Endpoint_ClearIN() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << TXINI)); \ #define Endpoint_ClearIN() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << TXINI)); \
UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE
@ -900,7 +874,7 @@
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian, /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
* in both failure and success states; the user is responsible for manually clearing the setup OUT to * in both failure and success states; the user is responsible for manually clearing the setup OUT to
* finalize the transfer via the Endpoint_ClearControlOUT() macro. * finalize the transfer via the Endpoint_ClearOUT() macro.
* *
* \note This routine should only be used on CONTROL type endpoints. * \note This routine should only be used on CONTROL type endpoints.
* *
@ -919,7 +893,7 @@
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian, /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian,
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
* in both failure and success states; the user is responsible for manually clearing the setup OUT to * in both failure and success states; the user is responsible for manually clearing the setup OUT to
* finalize the transfer via the Endpoint_ClearControlOUT() macro. * finalize the transfer via the Endpoint_ClearOUT() macro.
* *
* \note This routine should only be used on CONTROL type endpoints. * \note This routine should only be used on CONTROL type endpoints.
* *
@ -938,7 +912,7 @@
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian, /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian,
* discarding fully read packets from the host as needed. The device IN acknowledgement is not * discarding fully read packets from the host as needed. The device IN acknowledgement is not
* automatically sent after success or failure states; the user is responsible for manually sending the * automatically sent after success or failure states; the user is responsible for manually sending the
* setup IN to finalize the transfer via the Endpoint_ClearControlIN() macro. * setup IN to finalize the transfer via the Endpoint_ClearIN() macro.
* *
* \note This routine should only be used on CONTROL type endpoints. * \note This routine should only be used on CONTROL type endpoints.
* *
@ -952,12 +926,12 @@
* *
* \return A value from the Endpoint_ControlStream_RW_ErrorCodes_t enum. * \return A value from the Endpoint_ControlStream_RW_ErrorCodes_t enum.
*/ */
uint8_t Endpoint_Read_Control_Stream_LE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); uint8_t Endpoint_Read_Control_Stream_LE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian, /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian,
* discarding fully read packets from the host as needed. The device IN acknowledgement is not * discarding fully read packets from the host as needed. The device IN acknowledgement is not
* automatically sent after success or failure states; the user is responsible for manually sending the * automatically sent after success or failure states; the user is responsible for manually sending the
* setup IN to finalize the transfer via the Endpoint_ClearControlIN() macro. * setup IN to finalize the transfer via the Endpoint_ClearIN() macro.
* *
* \note This routine should only be used on CONTROL type endpoints. * \note This routine should only be used on CONTROL type endpoints.
* *
@ -971,7 +945,7 @@
* *
* \return A value from the Endpoint_ControlStream_RW_ErrorCodes_t enum. * \return A value from the Endpoint_ControlStream_RW_ErrorCodes_t enum.
*/ */
uint8_t Endpoint_Read_Control_Stream_BE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); uint8_t Endpoint_Read_Control_Stream_BE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
/* Private Interface - For use in library only: */ /* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)

@ -58,7 +58,7 @@ uint8_t USB_Host_SendControlRequest(void* BufferPtr)
for (uint8_t HeaderByte = 0; HeaderByte < sizeof(USB_Host_Request_Header_t); HeaderByte++) for (uint8_t HeaderByte = 0; HeaderByte < sizeof(USB_Host_Request_Header_t); HeaderByte++)
Pipe_Write_Byte(*(HeaderStream++)); Pipe_Write_Byte(*(HeaderStream++));
Pipe_ClearControlSETUP(); Pipe_ClearSETUP();
if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_SetupSent))) if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_SetupSent)))
goto End_Of_Control_Send; goto End_Of_Control_Send;
@ -91,7 +91,7 @@ uint8_t USB_Host_SendControlRequest(void* BufferPtr)
} }
Pipe_Freeze(); Pipe_Freeze();
Pipe_ClearControlIN(); Pipe_ClearIN();
} }
} }
@ -101,7 +101,7 @@ uint8_t USB_Host_SendControlRequest(void* BufferPtr)
if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady))) if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady)))
goto End_Of_Control_Send; goto End_Of_Control_Send;
Pipe_ClearControlOUT(); Pipe_ClearOUT();
if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady))) if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady)))
goto End_Of_Control_Send; goto End_Of_Control_Send;
@ -124,7 +124,7 @@ uint8_t USB_Host_SendControlRequest(void* BufferPtr)
DataLen--; DataLen--;
} }
Pipe_ClearControlOUT(); Pipe_ClearOUT();
} }
if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady))) if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady)))
@ -139,7 +139,7 @@ uint8_t USB_Host_SendControlRequest(void* BufferPtr)
if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_InReceived))) if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_InReceived)))
goto End_Of_Control_Send; goto End_Of_Control_Send;
Pipe_ClearControlIN(); Pipe_ClearIN();
} }
End_Of_Control_Send: End_Of_Control_Send:

@ -420,38 +420,16 @@
*/ */
static inline bool Pipe_IsSETUPSent(void); static inline bool Pipe_IsSETUPSent(void);
/** Acknowledges the reception of a setup IN request from the attached device on the currently selected
* CONTROL type pipe, freeing the bank ready for the next packet.
*
* \ingroup Group_PipePacketManagement
*
* \note For non CONTROL type pipes, use Pipe_ClearIN() instead.
*/
static inline void Pipe_ClearControlIN(void);
/** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing
* the bank ready for the next packet.
*
* \ingroup Group_PipePacketManagement
*
* \note For non CONTROL type pipes, use Pipe_ClearOUT() instead.
*/
static inline void Pipe_ClearControlOUT(void);
/** Sends the currently selected CONTROL type pipe's contents to the device as a SETUP packet. /** Sends the currently selected CONTROL type pipe's contents to the device as a SETUP packet.
* *
* \ingroup Group_PipePacketManagement * \ingroup Group_PipePacketManagement
*
* \note This is not applicable for non CONTROL type pipes.
*/ */
static inline void Pipe_ClearControlSETUP(void); static inline void Pipe_ClearSETUP(void);
/** Acknowledges the reception of a setup IN request from the attached device on the currently selected /** Acknowledges the reception of a setup IN request from the attached device on the currently selected
* pipe, freeing the bank ready for the next packet. * pipe, freeing the bank ready for the next packet.
* *
* \ingroup Group_PipePacketManagement * \ingroup Group_PipePacketManagement
*
* \note For CONTROL type pipes, use Pipe_ClearControlIN() instead.
*/ */
static inline void Pipe_ClearIN(void); static inline void Pipe_ClearIN(void);
@ -459,8 +437,6 @@
* the bank ready for the next packet. * the bank ready for the next packet.
* *
* \ingroup Group_PipePacketManagement * \ingroup Group_PipePacketManagement
*
* \note For CONTROL type pipes, use Pipe_ClearControlOUT() instead.
*/ */
static inline void Pipe_ClearOUT(void); static inline void Pipe_ClearOUT(void);
@ -554,16 +530,10 @@
#define Pipe_ClearIN() MACROS{ uint8_t Temp = UPINTX; UPINTX = (Temp & ~(1 << RXINI)); \ #define Pipe_ClearIN() MACROS{ uint8_t Temp = UPINTX; UPINTX = (Temp & ~(1 << RXINI)); \
UPINTX = (Temp & ~(1 << FIFOCON)); }MACROE UPINTX = (Temp & ~(1 << FIFOCON)); }MACROE
#define Pipe_ClearControlIN() MACROS{ uint8_t Temp = UPINTX; UPINTX = (Temp & ~(1 << RXINI)); \
UPINTX = (Temp & ~(1 << FIFOCON)); }MACROE
#define Pipe_ClearOUT() MACROS{ uint8_t Temp = UPINTX; UPINTX = (Temp & ~(1 << TXOUTI)); \ #define Pipe_ClearOUT() MACROS{ uint8_t Temp = UPINTX; UPINTX = (Temp & ~(1 << TXOUTI)); \
UPINTX = (Temp & ~(1 << FIFOCON)); }MACROE UPINTX = (Temp & ~(1 << FIFOCON)); }MACROE
#define Pipe_ClearControlOUT() MACROS{ uint8_t Temp = UPINTX; UPINTX = (Temp & ~(1 << TXOUTI)); \ #define Pipe_ClearSETUP() MACROS{ uint8_t Temp = UPINTX; UPINTX = (Temp & ~(1 << TXSTPI)); \
UPINTX = (Temp & ~(1 << FIFOCON)); }MACROE
#define Pipe_ClearControlSETUP() MACROS{ uint8_t Temp = UPINTX; UPINTX = (Temp & ~(1 << TXSTPI)); \
UPINTX = (Temp & ~(1 << FIFOCON)); }MACROE UPINTX = (Temp & ~(1 << FIFOCON)); }MACROE
#define Pipe_IsNAKReceived() ((UPINTX & (1 << NAKEDI)) ? true : false) #define Pipe_IsNAKReceived() ((UPINTX & (1 << NAKEDI)) ? true : false)

@ -23,15 +23,14 @@
* library demos should update to the latest versions. * library demos should update to the latest versions.
* *
* <b>Device Mode</b> * <b>Device Mode</b>
* - The Endpoint_ClearCurrentBank() macro has been removed, and is now replaced with the Endpoint_ClearIN(), Endpoint_ClearOUT(), * - The Endpoint_ClearCurrentBank() macro has been removed, and is now replaced with the Endpoint_ClearIN(), Endpoint_ClearOUT()
* Endpoint_ClearControlIN(), Endpoint_ClearControlOUT() and other related macros. See Endpoint.h documentation for more details * macros. See Endpoint.h documentation for more details on the new endpoint management macros.
* on the new endpoint management macros.
* - The Endpoint_ReadWriteAllowed() macro has been renamed to Endpoint_IsReadWriteAllowed() to be more consistent with the rest of * - The Endpoint_ReadWriteAllowed() macro has been renamed to Endpoint_IsReadWriteAllowed() to be more consistent with the rest of
* the API naming scheme. * the API naming scheme.
* - The Endpoint_IsSetupINReady() and Endpoint_IsSetupOutReceived() macros have been renamed to Endpoint_IsINReady() and * - The Endpoint_IsSetupINReady() and Endpoint_IsSetupOutReceived() macros have been renamed to Endpoint_IsINReady() and
* Endpoint_IsOUTReceived() respectively. * Endpoint_IsOUTReceived() respectively.
* - The Endpoint_IsSetupReceived() macro has been renamed to Endpoint_IsSETUPReceived(). * - The Endpoint_IsSetupReceived() macro has been renamed to Endpoint_IsSETUPReceived().
* - The Endpoint_ClearSetupReceived() macro has been renamed to Endpoint_ClearControlSETUP(). * - The Endpoint_ClearSetupReceived() macro has been renamed to Endpoint_ClearSETUP().
* - All endpoint read/write/discard aliases which did not have an explicitly endianness specifier (such as Endpoint_Read_Word()) have * - All endpoint read/write/discard aliases which did not have an explicitly endianness specifier (such as Endpoint_Read_Word()) have
* been removed for clarity. Existing projects should use the "_LE" suffix on such calls to use the explicit Little Endian versions. * been removed for clarity. Existing projects should use the "_LE" suffix on such calls to use the explicit Little Endian versions.
* *
@ -41,14 +40,13 @@
* in existing projects where the Control pipe is to be operated on. * in existing projects where the Control pipe is to be operated on.
* - The USB Host management task now saves and restores the currently selected pipe before and after the task runs. Projects no longer * - The USB Host management task now saves and restores the currently selected pipe before and after the task runs. Projects no longer
* need to manage this manually when calling the USB management task. * need to manage this manually when calling the USB management task.
* - The Pipe_ClearCurrentBank() macro has been removed, and is now replaced with the Pipe_ClearIN(), Pipe_ClearOUT(), * - The Pipe_ClearCurrentBank() macro has been removed, and is now replaced with the Pipe_ClearIN(), Pipe_ClearOUT() macros. See
* Pipe_ClearControlIN(), Pipe_ClearControlOUT() and other related macros. See Pipe.h documentation for more details on the new pipe * Pipe.h documentation for more details on the new pipe management macros.
* management macros.
* - The Pipe_ReadWriteAllowed() macro has been renamed to Pipe_IsReadWriteAllowed() to be more consistent with the rest of the API * - The Pipe_ReadWriteAllowed() macro has been renamed to Pipe_IsReadWriteAllowed() to be more consistent with the rest of the API
* naming scheme. * naming scheme.
* - The Pipe_IsSetupINReceived() and Pipe_IsOutReady() macros have been renamed to Pipe_IsINReceived() and Pipe_IsOUTReady() * - The Pipe_IsSetupINReceived() and Pipe_IsOutReady() macros have been renamed to Pipe_IsINReceived() and Pipe_IsOUTReady()
* respectively. * respectively.
* - The new Pipe_ClearControlSETUP() macro should be used to send CONTROL transactions, rather than the previous Pipe_ClearSetupOUT() macro. * - The new Pipe_ClearSETUP() macro should be used to send SETUP transactions, rather than the previous Pipe_ClearSetupOUT() macro.
* - The Pipe_IsSetupSent() macro has been renamed to Pipe_IsSETUPSent(). * - The Pipe_IsSetupSent() macro has been renamed to Pipe_IsSETUPSent().
* - The Pipe_ClearSetupSent() macro is no longer applicable and should be removed. * - The Pipe_ClearSetupSent() macro is no longer applicable and should be removed.
* - All pipe read/write/discard aliases which did not have an explicitly endianness specifier (such as Pipe_Read_Word()) have * - All pipe read/write/discard aliases which did not have an explicitly endianness specifier (such as Pipe_Read_Word()) have

@ -178,30 +178,30 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (wLength > sizeof(KeyboardReportData)) if (wLength > sizeof(KeyboardReportData))
wLength = sizeof(KeyboardReportData); wLength = sizeof(KeyboardReportData);
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Write the report data to the control endpoint */ /* Write the report data to the control endpoint */
Endpoint_Write_Control_Stream_LE(&KeyboardReportData, wLength); Endpoint_Write_Control_Stream_LE(&KeyboardReportData, wLength);
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
break; break;
case REQ_GetProtocol: case REQ_GetProtocol:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Write the current protocol flag to the host */ /* Write the current protocol flag to the host */
Endpoint_Write_Byte(UsingReportProtocol); Endpoint_Write_Byte(UsingReportProtocol);
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearControlIN(); Endpoint_ClearIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
break; break;
@ -211,14 +211,14 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Read in the wValue parameter containing the new protocol mode */ /* Read in the wValue parameter containing the new protocol mode */
uint16_t wValue = Endpoint_Read_Word_LE(); uint16_t wValue = Endpoint_Read_Word_LE();
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* 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);
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;
@ -228,31 +228,31 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Read in the wValue parameter containing the idle period */ /* Read in the wValue parameter containing the idle period */
uint16_t wValue = Endpoint_Read_Word_LE(); uint16_t wValue = Endpoint_Read_Word_LE();
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Get idle period in MSB */ /* Get idle period in MSB */
IdleCount = (wValue >> 8); IdleCount = (wValue >> 8);
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN(); Endpoint_ClearIN();
} }
break; break;
case REQ_GetIdle: case REQ_GetIdle:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearControlSETUP(); Endpoint_ClearSETUP();
/* Write the current idle duration to the host */ /* Write the current idle duration to the host */
Endpoint_Write_Byte(IdleCount); Endpoint_Write_Byte(IdleCount);
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearControlIN(); Endpoint_ClearIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearControlOUT(); Endpoint_ClearOUT();
} }
break; break;

Loading…
Cancel
Save