X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/ed031c1df2f5b053b9cd9f48c63e66a42b7c049e..710d48a48aa3ab5f1c446c9ec04854aceb0820b6:/Demos/Device/CDC/CDC.c diff --git a/Demos/Device/CDC/CDC.c b/Demos/Device/CDC/CDC.c index 6e933d581..3dc624057 100644 --- a/Demos/Device/CDC/CDC.c +++ b/Demos/Device/CDC/CDC.c @@ -36,12 +36,6 @@ #include "CDC.h" -/* Project Tags, for reading out using the ButtLoad project */ -BUTTLOADTAG(ProjName, "LUFA CDC App"); -BUTTLOADTAG(BuildTime, __TIME__); -BUTTLOADTAG(BuildDate, __DATE__); -BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING); - /* Scheduler Task List */ TASK_LIST { @@ -56,7 +50,7 @@ TASK_LIST * * These values are set by the host via a class-specific request, however they are not required to be used accurately. * It is possible to completely ignore these value or use other settings as the host is completely unaware of the physical - * serial link characteristics and instead sends and recieves data in endpoint streams. + * serial link characteristics and instead sends and receives data in endpoint streams. */ CDC_Line_Coding_t LineCoding = { BaudRateBPS: 9600, CharFormat: OneStopBit, @@ -66,7 +60,7 @@ CDC_Line_Coding_t LineCoding = { BaudRateBPS: 9600, /** String to print through the virtual serial port when the joystick is pressed upwards. */ char JoystickUpString[] = "Joystick Up\r\n"; -/** String to print through the virtual serial port when the joystick is pressed downwards. */ +/** String to print through the virtual serial port when the joystick is pressed downward. */ char JoystickDownString[] = "Joystick Down\r\n"; /** String to print through the virtual serial port when the joystick is pressed left. */ @@ -172,13 +166,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) { /* Acknowledge the SETUP packet, ready for data transfer */ - Endpoint_ClearSetupReceived(); + Endpoint_ClearControlSETUP(); /* Write the line coding data to the control endpoint */ 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 */ - Endpoint_ClearSetupOUT(); + Endpoint_ClearControlOUT(); } break; @@ -186,13 +180,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) { /* Acknowledge the SETUP packet, ready for data transfer */ - Endpoint_ClearSetupReceived(); + Endpoint_ClearControlSETUP(); /* Read the line coding data in from the host into the global struct */ Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t)); /* Finalize the stream transfer to clear the last packet from the host */ - Endpoint_ClearSetupIN(); + Endpoint_ClearControlIN(); } break; @@ -211,11 +205,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket) #endif /* Acknowledge the SETUP packet, ready for data transfer */ - Endpoint_ClearSetupReceived(); + Endpoint_ClearControlSETUP(); /* Acknowledge status stage */ - while (!(Endpoint_IsSetupINReady())); - Endpoint_ClearSetupIN(); + while (!(Endpoint_IsINReady())); + Endpoint_ClearControlIN(); } break; @@ -276,7 +270,7 @@ TASK(CDC_Task) Endpoint_SelectEndpoint(CDC_NOTIFICATION_EPNUM); Endpoint_Write_Stream_LE(&Notification, sizeof(Notification)); Endpoint_Write_Stream_LE(&LineStateMask, sizeof(LineStateMask)); - Endpoint_ClearCurrentBank(); + Endpoint_ClearIN(); #endif /* Determine if a joystick action has occurred */ @@ -307,13 +301,19 @@ TASK(CDC_Task) Endpoint_Write_Stream_LE(ReportString, strlen(ReportString)); /* Finalize the stream transfer to send the last packet */ - Endpoint_ClearCurrentBank(); + Endpoint_ClearIN(); + + /* Wait until the endpoint is ready for another packet */ + while (!(Endpoint_IsINReady())); + + /* Send an empty packet to ensure that the host does not buffer data sent to it */ + Endpoint_ClearIN(); } /* Select the Serial Rx Endpoint */ Endpoint_SelectEndpoint(CDC_RX_EPNUM); /* Throw away any received data from the host */ - if (Endpoint_ReadWriteAllowed()) - Endpoint_ClearCurrentBank(); + if (Endpoint_IsOUTReceived()) + Endpoint_ClearOUT(); }