Commit 8711dc7c authored by Dean Camera's avatar Dean Camera
Browse files

Fix issue in CDC device class driver where received data the size of the data...

Fix issue in CDC device class driver where received data the size of the data endpoint could lock up the driver.

Further work on the new CDC and HID host mode class drivers.

Reset changelog et. al. to reset development information for the new version currently under development.
parent a459f10b
......@@ -103,6 +103,13 @@ int main(void)
USB_HostState = HOST_STATE_Configured;
break;
case HOST_STATE_Configured:
if (CDC_Host_BytesReceived(&VirtualSerial_CDC_Interface))
{
/* Echo received bytes from the attached device through the USART */
while (CDC_Host_BytesReceived(&VirtualSerial_CDC_Interface))
putchar(CDC_Host_ReceiveByte(&VirtualSerial_CDC_Interface));
}
break;
}
......
......@@ -125,7 +125,6 @@ LUFA_PATH = ../../../..
# LUFA library compile-time options
LUFA_OPTS = -D USE_NONSTANDARD_DESCRIPTOR_NAMES
LUFA_OPTS += -D USB_HOST_ONLY
LUFA_OPTS += -D NO_STREAM_CALLBACKS
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
......
......@@ -105,6 +105,11 @@ int main(void)
USB_HostState = HOST_STATE_Configured;
break;
case HOST_STATE_Configured:
if (HID_Host_ReportReceived(&Mouse_HID_Interface))
{
}
break;
}
......
......@@ -31,7 +31,7 @@ PROJECT_NAME = "LUFA (Formerly MyUSB) Library"
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 090810
PROJECT_NUMBER = 000000
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
......
......@@ -161,6 +161,9 @@ uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterface
{
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber);
if (Endpoint_IsOUTReceived() && !(Endpoint_BytesInEndpoint()))
Endpoint_ClearOUT();
return Endpoint_BytesInEndpoint();
}
......
......@@ -51,6 +51,13 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint
{
return CDC_ENUMERROR_NoCDCInterfaceFound;
}
CDCInterfaceInfo->State.ControlInterfaceNumber =
#if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)
DESCRIPTOR_CAST(ConfigDescriptorData, USB_Descriptor_Interface_t).InterfaceNumber;
#else
DESCRIPTOR_CAST(ConfigDescriptorData, USB_Descriptor_Interface_t).bInterfaceNumber;
#endif
while (FoundEndpoints != (CDC_FOUND_DATAPIPE_IN | CDC_FOUND_DATAPIPE_OUT | CDC_FOUND_DATAPIPE_NOTIFICATION))
{
......@@ -126,6 +133,7 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint
}
}
CDCInterfaceInfo->State.Active = true;
return CDC_ENUMERROR_NoError;
}
......@@ -189,6 +197,111 @@ static uint8_t DComp_CDC_Host_NextInterfaceCDCDataEndpoint(void* CurrentDescript
}
void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)
{
EVENT_CDC_Host_ControLineStateChanged(CDCInterfaceInfo);
}
uint8_t CDC_Host_SetLineEncoding(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)
{
USB_ControlRequest = (USB_Request_Header_t)
{
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
.bRequest = REQ_SetControlLineState,
.wValue = 0,
.wIndex = CDCInterfaceInfo->State.ControlInterfaceNumber,
.wLength = sizeof(CDCInterfaceInfo->State.LineEncoding),
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
return USB_Host_SendControlRequest(&CDCInterfaceInfo->State.LineEncoding);
}
uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)
{
USB_ControlRequest = (USB_Request_Header_t)
{
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
.bRequest = REQ_SetControlLineState,
.wValue = CDCInterfaceInfo->State.ControlLineStates.HostToDevice,
.wIndex = CDCInterfaceInfo->State.ControlInterfaceNumber,
.wLength = 0,
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
return USB_Host_SendControlRequest(NULL);
}
void CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Data, uint16_t Length)
{
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))
return;
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
Pipe_Write_Stream_LE(Data, Length, NO_STREAM_CALLBACK);
Pipe_Freeze();
}
void CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Data)
{
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))
return;
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
if (!(Pipe_IsReadWriteAllowed()))
{
Pipe_ClearOUT();
Pipe_WaitUntilReady();
}
Pipe_Write_Byte(Data);
Pipe_Freeze();
}
uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)
{
uint16_t BytesInPipe = 0;
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))
return BytesInPipe;
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);
Pipe_Unfreeze();
if (Pipe_IsINReceived() && !(Pipe_BytesInPipe()))
Pipe_ClearIN();
BytesInPipe = Pipe_BytesInPipe();
Pipe_Freeze();
return BytesInPipe;
}
uint8_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)
{
uint8_t ReceivedByte = 0;
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))
return ReceivedByte;
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);
Pipe_Unfreeze();
ReceivedByte = Pipe_Read_Byte();
if (!(Pipe_BytesInPipe()))
Pipe_ClearIN();
Pipe_Freeze();
return ReceivedByte;
}
void CDC_Host_Event_Stub(void)
{
}
......
......@@ -71,6 +71,10 @@
*/
struct
{
bool Active; /**< Indicates if the current interface instance is connected to an attached device */
uint8_t ControlInterfaceNumber; /**< Interface index of the CDC-ACM control interface within the attached device */
uint16_t DataINPipeSize; /**< Size in bytes of the CDC interface's IN data pipe */
uint16_t DataOUTPipeSize; /**< Size in bytes of the CDC interface's OUT data pipe */
uint16_t NotificationPipeSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used */
......@@ -118,8 +122,6 @@
uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint16_t ConfigDescriptorLength,
uint8_t* DeviceConfigDescriptor);
void EVENT_CDC_Host_ControLineStateChanged(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo);
uint8_t CDC_Host_SetLineEncoding(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo);
uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo);
......@@ -144,6 +146,9 @@
/* Function Prototypes: */
#if defined(INCLUDE_FROM_CDC_CLASS_HOST_C)
void CDC_Host_Event_Stub(void);
void EVENT_CDC_Host_ControLineStateChanged(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)
ATTR_WEAK ATTR_ALIAS(CDC_Host_Event_Stub);
static uint8_t DComp_CDC_Host_NextCDCControlInterface(void* CurrentDescriptor);
static uint8_t DComp_CDC_Host_NextCDCDataInterface(void* CurrentDescriptor);
static uint8_t DComp_CDC_Host_NextInterfaceCDCDataEndpoint(void* CurrentDescriptor);
......
......@@ -86,6 +86,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint
}
}
HIDInterfaceInfo->State.Active = true;
return HID_ENUMERROR_NoError;
}
......@@ -126,4 +127,11 @@ void HID_Host_USBTask(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo)
}
void HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo)
{
Pipe_SelectPipe(HIDInterfaceInfo->Config.DataINPipeNumber);
return Pipe_IsReadWriteAllowed();
}
#endif
......@@ -78,6 +78,8 @@
*/
struct
{
bool Active; /**< Indicates if the current interface instance is connected to an attached device */
uint16_t DataINPipeSize; /**< Size in bytes of the HID interface's IN data pipe */
uint16_t DataOUTPipeSize; /**< Size in bytes of the HID interface's OUT data pipe */
} State; /**< State data for the USB class interface within the device. All elements in this section
......@@ -99,6 +101,8 @@
void HID_Host_USBTask(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo);
uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint16_t ConfigDescriptorLength,
uint8_t* DeviceConfigDescriptor);
void HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo);
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
......
......@@ -5,6 +5,17 @@
*/
/** \page Page_ChangeLog Project Changelog
*
* \section Sec_ChangeLogXXXXXX Version XXXXXX
*
* <b>New:</b>
*
* <b>Changed:</b>
*
* <b>Fixed:</b>
* - Fixed possible lockup in the CDC device class driver, when the host sends data that is a multiple of the
* endpoint's bank
*
*
* \section Sec_ChangeLog090810 Version 090810
*
......
......@@ -12,15 +12,14 @@
* or post your suggestion as an enhancement request to the project bug tracker.
*
* <b>Targeted for This Release:</b>
* - N/A
*
* <b>Targeted for Future Releases:</b>
* - Host Mode Class Drivers
* -# Make new host class drivers
* -# Document new host class drivers
* -# Convert Host mode demos to class drivers
* -# Re-enable Host mode Class driver builds after completion
* -# Update Host mode Class Driver demo .txt files
*
* <b>Targeted for Future Releases:</b>
* - Add standardized descriptor names to device and host class driver structures
* - Remake AVRStudio project files
* - Add detailed overviews of how each demo works
......
......@@ -19,8 +19,8 @@
* are open design, and all are available for purchase as completed development boards suitable for project development.
*
* - AVROpendous, an open design/source set of AVR USB development boards: http://avropendous.org/
* - Benito #7, a no-frills USB board: http://www.dorkbotpdx.org/blog/feurig/benito_7_the_next_big_thing
* - Bumble-B, yet another AT90USB162 development board: http://fletchtronics.net/
* - Benito #7, a no-frills USB board: http://www.dorkbotpdx.org/wiki/benito
* - Bumble-B, yet another AT90USB162 development board: http://fletchtronics.net/bumble-b
* - USB10 AKA "The Ferret", a AT90USB162 development board: http://www.soc-machines.com
* - USBFoo, an AT90USB162 based development board: http://shop.kernelconcepts.de/product_info.php?products_id=102
* - Teensy and Teensy++, two other AVR USB development boards: http://www.pjrc.com/teensy/index.html
......
......@@ -10,6 +10,9 @@
* to the next version released. It does not indicate all new additions to the library in each version change, only
* areas relevant to making older projects compatible with the API changes of each new release.
*
* \section Sec_MigrationXXXXXX Migrating from 090810 to XXXXXX
* No migration information for this version yet.
*
* \section Sec_Migration090810 Migrating from 090605 to 090810
*
* <b>All</b>
......
......@@ -41,9 +41,9 @@
/* Public Interface - May be used in end-application: */
/* Macros: */
/** Indicates the version number of the library, as an integer. */
#define LUFA_VERSION_INTEGER 090810
#define LUFA_VERSION_INTEGER 000000
/** Indicates the version number of the library, as a string. */
#define LUFA_VERSION_STRING "090810"
#define LUFA_VERSION_STRING "XXXXXX"
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment