aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Device/USBtoSerial/USBtoSerial.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-04-16 08:50:34 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-04-16 08:50:34 +0000
commit8f6b4ddf764c3a54e42d00a7502c82c5c3e71b1c (patch)
tree65c37548f19c26de3971639067d6f290095f5843 /Demos/Device/USBtoSerial/USBtoSerial.c
parentef06bfd1c0ef5272c32808e23d0fd60d2d1bca9c (diff)
downloadlufa-8f6b4ddf764c3a54e42d00a7502c82c5c3e71b1c.tar.gz
lufa-8f6b4ddf764c3a54e42d00a7502c82c5c3e71b1c.tar.bz2
lufa-8f6b4ddf764c3a54e42d00a7502c82c5c3e71b1c.zip
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(), Endpoint_ClearControlIN(), Endpoint_ClearControlOUT(), Pipe_ClearIN(), Pipe_ClearOUT(), Pipe_ClearControlIN() and 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. 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 Pipe_ClearSetupSent() macro is no longer applicable and should be removed - changes made to compliment the new endpoint and pipe bank management API. Updated all demos, bootloaders and projects to use the new endpoint and pipe management APIs (thanks to Roman Thiel). 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 the ButtLoadTag.h header file, as no one used for its intended purpose anyway.
Diffstat (limited to 'Demos/Device/USBtoSerial/USBtoSerial.c')
-rw-r--r--Demos/Device/USBtoSerial/USBtoSerial.c45
1 files changed, 16 insertions, 29 deletions
diff --git a/Demos/Device/USBtoSerial/USBtoSerial.c b/Demos/Device/USBtoSerial/USBtoSerial.c
index a9f0434cb..87d531c4d 100644
--- a/Demos/Device/USBtoSerial/USBtoSerial.c
+++ b/Demos/Device/USBtoSerial/USBtoSerial.c
@@ -30,12 +30,6 @@
#include "USBtoSerial.h"
-/* Project Tags, for reading out using the ButtLoad project */
-BUTTLOADTAG(ProjName, "LUFA USB RS232 App");
-BUTTLOADTAG(BuildTime, __TIME__);
-BUTTLOADTAG(BuildDate, __DATE__);
-BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
-
/* Scheduler Task List */
TASK_LIST
{
@@ -165,13 +159,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(LineCoding));
/* Finalize the stream transfer to send the last packet or clear the host abort */
- Endpoint_ClearSetupOUT();
+ Endpoint_ClearControlOUT();
}
break;
@@ -179,13 +173,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(LineCoding));
/* Finalize the stream transfer to clear the last packet from the host */
- Endpoint_ClearSetupIN();
+ Endpoint_ClearControlIN();
/* Reconfigure the USART with the new settings */
ReconfigureUSART();
@@ -207,11 +201,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;
@@ -244,13 +238,13 @@ 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
/* Select the Serial Rx Endpoint */
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
- if (Endpoint_ReadWriteAllowed())
+ if (Endpoint_IsOUTReceived())
{
/* Read the received data endpoint into the transmission buffer */
while (Endpoint_BytesInEndpoint())
@@ -263,7 +257,7 @@ TASK(CDC_Task)
}
/* Clear the endpoint buffer */
- Endpoint_ClearCurrentBank();
+ Endpoint_ClearOUT();
}
/* Check if Rx buffer contains data */
@@ -284,27 +278,20 @@ TASK(CDC_Task)
if (Tx_Buffer.Elements)
{
/* Wait until Serial Tx Endpoint Ready for Read/Write */
- while (!(Endpoint_ReadWriteAllowed()));
-
- /* Check before sending the data if the endpoint is completely full */
- bool IsFull = (Endpoint_BytesInEndpoint() == CDC_TXRX_EPSIZE);
+ while (!(Endpoint_IsReadWriteAllowed()));
/* Write the transmission buffer contents to the received data endpoint */
while (Tx_Buffer.Elements && (Endpoint_BytesInEndpoint() < CDC_TXRX_EPSIZE))
Endpoint_Write_Byte(Buffer_GetElement(&Tx_Buffer));
/* Send the data */
- Endpoint_ClearCurrentBank();
+ Endpoint_ClearIN();
- /* If a full endpoint was sent, we need to send an empty packet afterwards to terminate the transfer */
- if (IsFull)
- {
- /* Wait until Serial Tx Endpoint Ready for Read/Write */
- while (!(Endpoint_ReadWriteAllowed()));
+ /* Wait until Serial Tx Endpoint Ready for Read/Write */
+ while (!(Endpoint_IsReadWriteAllowed()));
- /* Send an empty packet to terminate the transfer */
- Endpoint_ClearCurrentBank();
- }
+ /* Send an empty packet to terminate the transfer */
+ Endpoint_ClearIN();
}
}
}