Commit 7166c7ba authored by Dean Camera's avatar Dean Camera
Browse files

Fix low level host mode demos not correctly fetching the next endpoint when an...

Fix low level host mode demos not correctly fetching the next endpoint when an invalid interface is discarded.

Update the pipe configuration routines in the host mode class drivers so that they use the same new code to enumerate compatible devices to increase reliability. Add support to the host mode class drivers for non-sequential (but non-overlapping with other interface) pipe numbers.
parent 158afe91
...@@ -96,6 +96,9 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -96,6 +96,9 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoCompatibleInterfaceFound; return NoCompatibleInterfaceFound;
} }
/* Skip the remainder of the loop as we have not found an endpoint yet */
continue;
} }
/* Retrieve the endpoint address from the endpoint descriptor */ /* Retrieve the endpoint address from the endpoint descriptor */
......
...@@ -87,6 +87,9 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -87,6 +87,9 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoCompatibleInterfaceFound; return NoCompatibleInterfaceFound;
} }
/* Skip the remainder of the loop as we have not found an endpoint yet */
continue;
} }
/* Retrieve the endpoint address from the endpoint descriptor */ /* Retrieve the endpoint address from the endpoint descriptor */
......
...@@ -87,6 +87,9 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -87,6 +87,9 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoCompatibleInterfaceFound; return NoCompatibleInterfaceFound;
} }
/* Skip the remainder of the loop as we have not found an endpoint yet */
continue;
} }
/* Retrieve the endpoint address from the endpoint descriptor */ /* Retrieve the endpoint address from the endpoint descriptor */
......
...@@ -83,7 +83,7 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -83,7 +83,7 @@ uint8_t ProcessConfigurationDescriptor(void)
} }
/* Save the HID report size for later use */ /* Save the HID report size for later use */
HIDReportSize = DESCRIPTOR_CAST(CurrConfigLocation, USB_Descriptor_HID_t).HIDReportLength; HIDReportSize = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_HID_t)->HIDReportLength;
while (!(DataINEndpoint)) while (!(DataINEndpoint))
{ {
...@@ -108,7 +108,10 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -108,7 +108,10 @@ uint8_t ProcessConfigurationDescriptor(void)
} }
/* Save the HID report size for later use */ /* Save the HID report size for later use */
HIDReportSize = DESCRIPTOR_CAST(CurrConfigLocation, USB_Descriptor_HID_t).HIDReportLength; HIDReportSize = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_HID_t)->HIDReportLength;
/* Skip the remainder of the loop as we have not found an endpoint yet */
continue;
} }
/* Retrieve the endpoint address from the endpoint descriptor */ /* Retrieve the endpoint address from the endpoint descriptor */
......
...@@ -92,6 +92,9 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -92,6 +92,9 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoCompatibleInterfaceFound; return NoCompatibleInterfaceFound;
} }
/* Skip the remainder of the loop as we have not found an endpoint yet */
continue;
} }
/* Retrieve the endpoint address from the endpoint descriptor */ /* Retrieve the endpoint address from the endpoint descriptor */
......
...@@ -92,6 +92,9 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -92,6 +92,9 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoCompatibleInterfaceFound; return NoCompatibleInterfaceFound;
} }
/* Skip the remainder of the loop as we have not found an endpoint yet */
continue;
} }
/* Retrieve the endpoint address from the endpoint descriptor */ /* Retrieve the endpoint address from the endpoint descriptor */
......
...@@ -87,6 +87,9 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -87,6 +87,9 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoCompatibleInterfaceFound; return NoCompatibleInterfaceFound;
} }
/* Skip the remainder of the loop as we have not found an endpoint yet */
continue;
} }
/* Retrieve the endpoint address from the endpoint descriptor */ /* Retrieve the endpoint address from the endpoint descriptor */
......
...@@ -83,7 +83,7 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -83,7 +83,7 @@ uint8_t ProcessConfigurationDescriptor(void)
} }
/* Save the HID report size for later use */ /* Save the HID report size for later use */
HIDReportSize = DESCRIPTOR_CAST(CurrConfigLocation, USB_Descriptor_HID_t).HIDReportLength; HIDReportSize = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_HID_t)->HIDReportLength;
while (!(DataINEndpoint)) while (!(DataINEndpoint))
{ {
...@@ -108,7 +108,10 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -108,7 +108,10 @@ uint8_t ProcessConfigurationDescriptor(void)
} }
/* Save the HID report size for later use */ /* Save the HID report size for later use */
HIDReportSize = DESCRIPTOR_CAST(CurrConfigLocation, USB_Descriptor_HID_t).HIDReportLength; HIDReportSize = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_HID_t)->HIDReportLength;
/* Skip the remainder of the loop as we have not found an endpoint yet */
continue;
} }
/* Retrieve the endpoint address from the endpoint descriptor */ /* Retrieve the endpoint address from the endpoint descriptor */
......
...@@ -75,8 +75,8 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -75,8 +75,8 @@ uint8_t ProcessConfigurationDescriptor(void)
} }
/* Save Printer interface details for later use */ /* Save Printer interface details for later use */
PrinterInterfaceNumber = DESCRIPTOR_CAST(CurrConfigLocation, USB_Descriptor_Interface_t).InterfaceNumber; PrinterInterfaceNumber = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Interface_t)->InterfaceNumber;
PrinterAltSetting = DESCRIPTOR_CAST(CurrConfigLocation, USB_Descriptor_Interface_t).AlternateSetting; PrinterAltSetting = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Interface_t)->AlternateSetting;
while (!(DataINEndpoint) || !(DataOUTEndpoint)) while (!(DataINEndpoint) || !(DataOUTEndpoint))
{ {
...@@ -97,8 +97,11 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -97,8 +97,11 @@ uint8_t ProcessConfigurationDescriptor(void)
} }
/* Save Printer interface details for later use */ /* Save Printer interface details for later use */
PrinterInterfaceNumber = DESCRIPTOR_CAST(CurrConfigLocation, USB_Descriptor_Interface_t).InterfaceNumber; PrinterInterfaceNumber = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Interface_t)->InterfaceNumber;
PrinterAltSetting = DESCRIPTOR_CAST(CurrConfigLocation, USB_Descriptor_Interface_t).AlternateSetting; PrinterAltSetting = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Interface_t)->AlternateSetting;
/* Skip the remainder of the loop as we have not found an endpoint yet */
continue;
} }
/* Retrieve the endpoint address from the endpoint descriptor */ /* Retrieve the endpoint address from the endpoint descriptor */
...@@ -106,7 +109,7 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -106,7 +109,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* If the endpoint is a IN type endpoint */ /* If the endpoint is a IN type endpoint */
if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
DataINEndpoint = EndpointData; DataINEndpoint = EndpointData;
else else
DataOUTEndpoint = EndpointData; DataOUTEndpoint = EndpointData;
} }
......
...@@ -110,6 +110,9 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -110,6 +110,9 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Clear any found endpoints */ /* Clear any found endpoints */
NotificationEndpoint = NULL; NotificationEndpoint = NULL;
} }
/* Skip the remainder of the loop as we have not found an endpoint yet */
continue;
} }
/* Retrieve the endpoint address from the endpoint descriptor */ /* Retrieve the endpoint address from the endpoint descriptor */
......
...@@ -94,6 +94,9 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -94,6 +94,9 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoCompatibleInterfaceFound; return NoCompatibleInterfaceFound;
} }
/* Skip the remainder of the loop as we have not found an endpoint yet */
continue;
} }
/* Retrieve the endpoint address from the endpoint descriptor */ /* Retrieve the endpoint address from the endpoint descriptor */
......
...@@ -110,6 +110,9 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -110,6 +110,9 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Clear any found endpoints */ /* Clear any found endpoints */
NotificationEndpoint = NULL; NotificationEndpoint = NULL;
} }
/* Skip the remainder of the loop as we have not found an endpoint yet */
continue;
} }
/* Retrieve the endpoint address from the endpoint descriptor */ /* Retrieve the endpoint address from the endpoint descriptor */
......
...@@ -116,6 +116,10 @@ ...@@ -116,6 +116,10 @@
* \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the
* given Audio interface is selected. * given Audio interface is selected.
* *
* \note The endpoint index numbers as given in the interface's configuration structure must not overlap with any other
* interface, or endpoint bank corruption will occur. Gaps in the allocated endpoint numbers or non-sequential indexes
* within a single interface is allowed, but no two interfaces of any type have have interleaved endpoint indexes.
*
* \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
* *
* \return Boolean true if the endpoints were successfully configured, false otherwise. * \return Boolean true if the endpoints were successfully configured, false otherwise.
......
...@@ -151,6 +151,10 @@ ...@@ -151,6 +151,10 @@
* \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration containing * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration containing
* the given CDC interface is selected. * the given CDC interface is selected.
* *
* \note The endpoint index numbers as given in the interface's configuration structure must not overlap with any other
* interface, or endpoint bank corruption will occur. Gaps in the allocated endpoint numbers or non-sequential indexes
* within a single interface is allowed, but no two interfaces of any type have have interleaved endpoint indexes.
*
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
* *
* \return Boolean true if the endpoints were successfully configured, false otherwise. * \return Boolean true if the endpoints were successfully configured, false otherwise.
......
...@@ -128,6 +128,10 @@ ...@@ -128,6 +128,10 @@
* \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration
* containing the given HID interface is selected. * containing the given HID interface is selected.
* *
* \note The endpoint index numbers as given in the interface's configuration structure must not overlap with any other
* interface, or endpoint bank corruption will occur. Gaps in the allocated endpoint numbers or non-sequential indexes
* within a single interface is allowed, but no two interfaces of any type have have interleaved endpoint indexes.
*
* \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.
* *
* \return Boolean true if the endpoints were successfully configured, false otherwise. * \return Boolean true if the endpoints were successfully configured, false otherwise.
......
...@@ -106,6 +106,10 @@ ...@@ -106,6 +106,10 @@
* \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration
* containing the given MIDI interface is selected. * containing the given MIDI interface is selected.
* *
* \note The endpoint index numbers as given in the interface's configuration structure must not overlap with any other
* interface, or endpoint bank corruption will occur. Gaps in the allocated endpoint numbers or non-sequential indexes
* within a single interface is allowed, but no two interfaces of any type have have interleaved endpoint indexes.
*
* \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.
* *
* \return Boolean true if the endpoints were successfully configured, false otherwise. * \return Boolean true if the endpoints were successfully configured, false otherwise.
......
...@@ -116,6 +116,10 @@ ...@@ -116,6 +116,10 @@
* \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration
* containing the given Mass Storage interface is selected. * containing the given Mass Storage interface is selected.
* *
* \note The endpoint index numbers as given in the interface's configuration structure must not overlap with any other
* interface, or endpoint bank corruption will occur. Gaps in the allocated endpoint numbers or non-sequential indexes
* within a single interface is allowed, but no two interfaces of any type have have interleaved endpoint indexes.
*
* \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state. * \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.
* *
* \return Boolean true if the endpoints were successfully configured, false otherwise. * \return Boolean true if the endpoints were successfully configured, false otherwise.
......
...@@ -124,6 +124,10 @@ ...@@ -124,6 +124,10 @@
* \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration
* containing the given HID interface is selected. * containing the given HID interface is selected.
* *
* \note The endpoint index numbers as given in the interface's configuration structure must not overlap with any other
* interface, or endpoint bank corruption will occur. Gaps in the allocated endpoint numbers or non-sequential indexes
* within a single interface is allowed, but no two interfaces of any type have have interleaved endpoint indexes.
*
* \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state. * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state.
* *
* \return Boolean true if the endpoints were successfully configured, false otherwise. * \return Boolean true if the endpoints were successfully configured, false otherwise.
......
...@@ -40,103 +40,105 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo ...@@ -40,103 +40,105 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
uint16_t ConfigDescriptorSize, uint16_t ConfigDescriptorSize,
void* ConfigDescriptorData) void* ConfigDescriptorData)
{ {
uint8_t FoundEndpoints = 0; USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;
USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;
USB_Descriptor_Endpoint_t* NotificationEndpoint = NULL;
memset(&CDCInterfaceInfo->State, 0x00, sizeof(CDCInterfaceInfo->State)); memset(&CDCInterfaceInfo->State, 0x00, sizeof(CDCInterfaceInfo->State));
if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration) if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)
return CDC_ENUMERROR_InvalidConfigDescriptor; return CDC_ENUMERROR_InvalidConfigDescriptor;
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
DCOMP_CDC_Host_NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found) DCOMP_CDC_Host_NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
return CDC_ENUMERROR_NoCDCInterfaceFound; return CDC_ENUMERROR_NoCompatibleInterfaceFound;
} }
CDCInterfaceInfo->State.ControlInterfaceNumber = DESCRIPTOR_CAST(ConfigDescriptorData, USB_Descriptor_Interface_t).InterfaceNumber; CDCInterfaceInfo->State.ControlInterfaceNumber = DESCRIPTOR_PCAST(ConfigDescriptorData,
USB_Descriptor_Interface_t)->InterfaceNumber;
while (FoundEndpoints != (CDC_FOUND_NOTIFICATION_IN | CDC_FOUND_DATAPIPE_IN | CDC_FOUND_DATAPIPE_OUT)) while (!(DataINEndpoint) || !(DataOUTEndpoint) || !(NotificationEndpoint))
{ {
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
DCOMP_CDC_Host_NextCDCInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) DCOMP_CDC_Host_NextCDCInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
if (FoundEndpoints & CDC_FOUND_NOTIFICATION_IN) if (NotificationEndpoint)
{ {
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
DCOMP_CDC_Host_NextCDCDataInterface) != DESCRIPTOR_SEARCH_COMP_Found) DCOMP_CDC_Host_NextCDCDataInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
return CDC_ENUMERROR_NoCDCInterfaceFound; return CDC_ENUMERROR_NoCompatibleInterfaceFound;
} }
DataINEndpoint = NULL;
DataOUTEndpoint = NULL;
} }
else else
{ {
FoundEndpoints = 0;
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);
Pipe_DisablePipe();
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_DisablePipe();
Pipe_SelectPipe(CDCInterfaceInfo->Config.NotificationPipeNumber);
Pipe_DisablePipe();
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
DCOMP_CDC_Host_NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found) DCOMP_CDC_Host_NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
return CDC_ENUMERROR_NoCDCInterfaceFound; return CDC_ENUMERROR_NoCompatibleInterfaceFound;
} }
}
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, CDCInterfaceInfo->State.ControlInterfaceNumber = DESCRIPTOR_PCAST(ConfigDescriptorData,
DCOMP_CDC_Host_NextCDCInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) USB_Descriptor_Interface_t)->InterfaceNumber;
{
return CDC_ENUMERROR_EndpointsNotFound; NotificationEndpoint = NULL;
} }
continue;
} }
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);
if ((EndpointData->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT) if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
{ {
if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) if ((EndpointData->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT)
{ NotificationEndpoint = EndpointData;
Pipe_ConfigurePipe(CDCInterfaceInfo->Config.NotificationPipeNumber, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN, else
EndpointData->EndpointAddress, EndpointData->EndpointSize, DataINEndpoint = EndpointData;
CDCInterfaceInfo->Config.NotificationPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
CDCInterfaceInfo->State.NotificationPipeSize = EndpointData->EndpointSize;
Pipe_SetInterruptPeriod(EndpointData->PollingIntervalMS);
FoundEndpoints |= CDC_FOUND_NOTIFICATION_IN;
}
} }
else else
{ {
if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) DataOUTEndpoint = EndpointData;
{ }
Pipe_ConfigurePipe(CDCInterfaceInfo->Config.DataINPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_IN, }
EndpointData->EndpointAddress, EndpointData->EndpointSize,
CDCInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
{
if (PipeNum == CDCInterfaceInfo->Config.DataINPipeNumber)
{
Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN,
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
CDCInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
CDCInterfaceInfo->State.DataINPipeSize = EndpointData->EndpointSize; CDCInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
}
else if (PipeNum == CDCInterfaceInfo->Config.DataOUTPipeNumber)
{
Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT,
DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize,
CDCInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
FoundEndpoints |= CDC_FOUND_DATAPIPE_IN; CDCInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
} }
else else if (PipeNum == CDCInterfaceInfo->Config.NotificationPipeNumber)
{ {
Pipe_ConfigurePipe(CDCInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT, Pipe_ConfigurePipe(PipeNum, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
EndpointData->EndpointAddress, EndpointData->EndpointSize, NotificationEndpoint->EndpointAddress, NotificationEndpoint->EndpointSize,
CDCInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); CDCInterfaceInfo->Config.NotificationPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
Pipe_SetInterruptPeriod(NotificationEndpoint->PollingIntervalMS);
CDCInterfaceInfo->State.DataOUTPipeSize = EndpointData->EndpointSize;
CDCInterfaceInfo->State.NotificationPipeSize = NotificationEndpoint->EndpointSize;
FoundEndpoints |= CDC_FOUND_DATAPIPE_OUT;
}
} }
} }
CDCInterfaceInfo->State.ControlLineStates.HostToDevice = (CDC_CONTROL_LINE_OUT_RTS | CDC_CONTROL_LINE_OUT_DTR); CDCInterfaceInfo->State.ControlLineStates.HostToDevice = (CDC_CONTROL_LINE_OUT_RTS | CDC_CONTROL_LINE_OUT_DTR);
CDCInterfaceInfo->State.ControlLineStates.DeviceToHost = (CDC_CONTROL_LINE_IN_DCD | CDC_CONTROL_LINE_IN_DSR); CDCInterfaceInfo->State.ControlLineStates.DeviceToHost = (CDC_CONTROL_LINE_IN_DCD | CDC_CONTROL_LINE_IN_DSR);
CDCInterfaceInfo->State.IsActive = true; CDCInterfaceInfo->State.IsActive = true;
return CDC_ENUMERROR_NoError; return CDC_ENUMERROR_NoError;
} }
......
...@@ -143,8 +143,7 @@ ...@@ -143,8 +143,7 @@
{ {
CDC_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */ CDC_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */
CDC_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */ CDC_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */
CDC_ENUMERROR_NoCDCInterfaceFound = 2, /**< A compatible CDC interface was not found in the device's Configuration Descriptor. */ CDC_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible CDC interface was not found in the device's Configuration Descriptor. */
CDC_ENUMERROR_EndpointsNotFound = 3, /**< Compatible CDC endpoints were not found in the device's CDC interface. */
}; };
/* Function Prototypes: */ /* Function Prototypes: */
...@@ -161,6 +160,10 @@ ...@@ -161,6 +160,10 @@
* This should be called once after the stack has enumerated the attached device, while the host state machine is in * This should be called once after the stack has enumerated the attached device, while the host state machine is in
* the Addressed state. * the Addressed state.
* *
* \note The pipe index numbers as given in the interface's configuration structure must not overlap with any other
* interface, or pipe bank corruption will occur. Gaps in the allocated pipe numbers or non-sequential indexes
* within a single interface is allowed, but no two interfaces of any type have have interleaved pipe indexes.
*
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing an CDC Class host configuration and state. * \param[in,out] CDCInterfaceInfo Pointer to a structure containing an CDC Class host configuration and state.
* \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor. * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor.
* \param[in] DeviceConfigDescriptor Pointer to a buffer containing the attached device's Configuration Descriptor. * \param[in] DeviceConfigDescriptor Pointer to a buffer containing the attached device's Configuration Descriptor.
...@@ -315,10 +318,6 @@ ...@@ -315,10 +318,6 @@
#define CDC_DATA_CLASS 0x0A #define CDC_DATA_CLASS 0x0A
#define CDC_DATA_SUBCLASS 0x00 #define CDC_DATA_SUBCLASS 0x00
#define CDC_DATA_PROTOCOL 0x00 #define CDC_DATA_PROTOCOL 0x00
#define CDC_FOUND_DATAPIPE_IN (1 << 0)
#define CDC_FOUND_DATAPIPE_OUT (1 << 1)
#define CDC_FOUND_NOTIFICATION_IN (1 << 2)
/* Function Prototypes: */ /* Function Prototypes: */
#if defined(__INCLUDE_FROM_CDC_CLASS_HOST_C) #if defined(__INCLUDE_FROM_CDC_CLASS_HOST_C)
......
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