#define INCLUDE_FROM_CDC_CLASS_HOST_C\r
#include "CDC.h"\r
\r
-static uint8_t CDC_Host_ProcessConfigDescriptor(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)\r
+uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint16_t MaxConfigBufferSize)\r
{\r
uint8_t* ConfigDescriptorData;\r
uint16_t ConfigDescriptorSize;\r
uint8_t FoundEndpoints = 0;\r
- \r
+\r
if (USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful)\r
return CDC_ENUMERROR_ControlError;\r
\r
- if (ConfigDescriptorSize > 512)\r
+ if (ConfigDescriptorSize > MaxConfigBufferSize)\r
return CDC_ENUMERROR_DescriptorTooLarge;\r
\r
ConfigDescriptorData = alloca(ConfigDescriptorSize);\r
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
DComp_CDC_Host_NextInterfaceCDCDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
{\r
- /* Check to see if the control interface's notification pipe has been found, if so search for the data interface */\r
if (FoundEndpoints & CDC_FOUND_DATAPIPE_NOTIFICATION)\r
{\r
- /* Get the next CDC data interface from the configuration descriptor (CDC class has two CDC interfaces) */\r
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, \r
DComp_CDC_Host_NextCDCDataInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
{\r
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)\r
{\r
USB_Descriptor_Endpoint_t* CurrentEndpoint = DESCRIPTOR_PCAST(CurrentDescriptor,\r
- USB_Descriptor_Endpoint_t)\r
+ USB_Descriptor_Endpoint_t);\r
\r
uint8_t EndpointType = (CurrentEndpoint->Attributes & EP_TYPE_MASK);\r
\r
- if ((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT))\r
- return DESCRIPTOR_SEARCH_Found;\r
+ if (((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) &&\r
+ !(Pipe_IsEndpointBound(CurrentEndpoint->EndpointAddress)))\r
+ {\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
}\r
else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)\r
{\r
\r
void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)\r
{\r
- uint8_t ErrorCode;\r
\r
- switch (USB_HostState)\r
- {\r
- case HOST_STATE_Addressed:\r
- if ((ErrorCode = CDC_Host_ProcessConfigDescriptor(CDCInterfaceInfo)) != CDC_ENUMERROR_NoError)\r
- {\r
- USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
- }\r
-\r
- if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful)\r
- {\r
- USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
- }\r
- \r
- USB_HostState = HOST_STATE_Configured;\r
- break;\r
- case HOST_STATE_Configured:\r
- USB_HostState = HOST_STATE_Ready;\r
- break;\r
- }\r
}\r
\r
#endif\r