uint16_t ConfigDescriptorSize,
void* ConfigDescriptorData)
{
- USB_Descriptor_Interface_t* CurrentHIDInterface;
-
USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;
USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;
+ USB_Descriptor_Interface_t* HIDInterface = NULL;
+ USB_HID_Descriptor_HID_t* HIDDescriptor = NULL;
memset(&HIDInterfaceInfo->State, 0x00, sizeof(HIDInterfaceInfo->State));
if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)
return HID_ENUMERROR_InvalidConfigDescriptor;
-
- do
- {
- if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
- DCOMP_HID_Host_NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found)
- {
- return HID_ENUMERROR_NoCompatibleInterfaceFound;
- }
-
- CurrentHIDInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);
- } while (HIDInterfaceInfo->Config.HIDInterfaceProtocol &&
- (CurrentHIDInterface->Protocol != HIDInterfaceInfo->Config.HIDInterfaceProtocol));
-
- HIDInterfaceInfo->State.InterfaceNumber = CurrentHIDInterface->InterfaceNumber;
- HIDInterfaceInfo->State.SupportsBootProtocol = (CurrentHIDInterface->SubClass != HID_BOOTP_NonBootProtocol);
-
- if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, DCOMP_HID_NextHID) != DESCRIPTOR_SEARCH_COMP_Found)
- return HID_ENUMERROR_NoCompatibleInterfaceFound;
-
- HIDInterfaceInfo->State.HIDReportSize = DESCRIPTOR_PCAST(ConfigDescriptorData,
- USB_HID_Descriptor_HID_t)->HIDReportLength;
while (!(DataINEndpoint) || !(DataOUTEndpoint))
{
- if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
+ if (!(HIDInterface) ||
+ USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
DCOMP_HID_Host_NextHIDInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{
if (DataINEndpoint || DataOUTEndpoint)
do
{
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
- DCOMP_HID_Host_NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found)
+ DCOMP_HID_Host_NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{
return HID_ENUMERROR_NoCompatibleInterfaceFound;
}
- CurrentHIDInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);
+ HIDInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);
} while (HIDInterfaceInfo->Config.HIDInterfaceProtocol &&
- (CurrentHIDInterface->Protocol != HIDInterfaceInfo->Config.HIDInterfaceProtocol));
+ (HIDInterface->Protocol != HIDInterfaceInfo->Config.HIDInterfaceProtocol));
- HIDInterfaceInfo->State.InterfaceNumber = CurrentHIDInterface->InterfaceNumber;
- HIDInterfaceInfo->State.SupportsBootProtocol = (CurrentHIDInterface->SubClass != HID_BOOTP_NonBootProtocol);
-
- if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, DCOMP_HID_NextHID) != DESCRIPTOR_SEARCH_COMP_Found)
- return HID_ENUMERROR_NoCompatibleInterfaceFound;
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
+ DCOMP_HID_Host_NextHID) != DESCRIPTOR_SEARCH_COMP_Found)
+ {
+ return HID_ENUMERROR_NoCompatibleInterfaceFound;
+ }
- HIDInterfaceInfo->State.HIDReportSize = DESCRIPTOR_PCAST(ConfigDescriptorData,
- USB_HID_Descriptor_HID_t)->HIDReportLength;
+ HIDDescriptor = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_HID_Descriptor_HID_t);
DataINEndpoint = NULL;
DataOUTEndpoint = NULL;
if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
DataINEndpoint = EndpointData;
else
- DataOUTEndpoint = EndpointData;
+ DataOUTEndpoint = EndpointData;
}
for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
if (PipeNum == HIDInterfaceInfo->Config.DataINPipeNumber)
{
Pipe_ConfigurePipe(PipeNum, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
- DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
- HIDInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
+ DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
+ HIDInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
Pipe_SetInterruptPeriod(DataINEndpoint->PollingIntervalMS);
- HIDInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
+ HIDInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
}
else if (PipeNum == HIDInterfaceInfo->Config.DataOUTPipeNumber)
{
Pipe_ConfigurePipe(PipeNum, EP_TYPE_INTERRUPT, PIPE_TOKEN_OUT,
- DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize,
- HIDInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
+ DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize,
+ HIDInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
Pipe_SetInterruptPeriod(DataOUTEndpoint->PollingIntervalMS);
HIDInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
}
}
- HIDInterfaceInfo->State.LargestReportSize = 8;
+ HIDInterfaceInfo->State.InterfaceNumber = HIDInterface->InterfaceNumber;
+ HIDInterfaceInfo->State.HIDReportSize = HIDDescriptor->HIDReportLength;
+ HIDInterfaceInfo->State.SupportsBootProtocol = (HIDInterface->SubClass != HID_BOOTP_NonBootProtocol);
+ HIDInterfaceInfo->State.LargestReportSize = 8;
HIDInterfaceInfo->State.IsActive = true;
return HID_ENUMERROR_NoError;
return DESCRIPTOR_SEARCH_NotFound;
}
-static uint8_t DCOMP_HID_NextHID(void* const CurrentDescriptor)
+static uint8_t DCOMP_HID_Host_NextHID(void* const CurrentDescriptor)
{
if (DESCRIPTOR_TYPE(CurrentDescriptor) == HID_DTYPE_HID)
return DESCRIPTOR_SEARCH_Found;
else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
return DESCRIPTOR_SEARCH_Fail;
else
- return DESCRIPTOR_SEARCH_NotFound;
+ return DESCRIPTOR_SEARCH_NotFound;
}
static uint8_t DCOMP_HID_Host_NextHIDInterfaceEndpoint(void* const CurrentDescriptor)
Pipe_SelectPipe(PIPE_CONTROLPIPE);
return USB_Host_SendControlRequest(Buffer);
-}
+}
#endif
-
+
uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,
void* Buffer)
{
if ((ErrorCode = Pipe_Read_Stream_LE(BufferPos, ReportSize, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
- Pipe_ClearIN();
+ Pipe_ClearIN();
Pipe_Freeze();
return PIPE_RWSTREAM_NoError;