Whitespace corrections.

Make Printer Host mode Class driver interface descriptor search routine pre-cast the current interface descriptor to simplify the value checks.
pull/1469/head
Dean Camera 14 years ago
parent a1e453e900
commit 383d167125

@ -59,7 +59,7 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
if (NotificationEndpoint) 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_NoCompatibleInterfaceFound; return CDC_ENUMERROR_NoCompatibleInterfaceFound;
} }
@ -70,7 +70,7 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
else else
{ {
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_NoCompatibleInterfaceFound; return CDC_ENUMERROR_NoCompatibleInterfaceFound;
} }
@ -103,7 +103,7 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
if (PipeNum == CDCInterfaceInfo->Config.DataINPipeNumber) if (PipeNum == CDCInterfaceInfo->Config.DataINPipeNumber)
{ {
Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN, Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN,
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
CDCInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); CDCInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
CDCInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize; CDCInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
@ -144,7 +144,7 @@ static uint8_t DCOMP_CDC_Host_NextCDCControlInterface(void* const CurrentDescrip
if ((CurrentInterface->Class == CDC_CONTROL_CLASS) && if ((CurrentInterface->Class == CDC_CONTROL_CLASS) &&
(CurrentInterface->SubClass == CDC_CONTROL_SUBCLASS) && (CurrentInterface->SubClass == CDC_CONTROL_SUBCLASS) &&
(CurrentInterface->Protocol == CDC_CONTROL_PROTOCOL)) (CurrentInterface->Protocol == CDC_CONTROL_PROTOCOL))
{ {
return DESCRIPTOR_SEARCH_Found; return DESCRIPTOR_SEARCH_Found;
} }
@ -162,7 +162,7 @@ static uint8_t DCOMP_CDC_Host_NextCDCDataInterface(void* const CurrentDescriptor
if ((CurrentInterface->Class == CDC_DATA_CLASS) && if ((CurrentInterface->Class == CDC_DATA_CLASS) &&
(CurrentInterface->SubClass == CDC_DATA_SUBCLASS) && (CurrentInterface->SubClass == CDC_DATA_SUBCLASS) &&
(CurrentInterface->Protocol == CDC_DATA_PROTOCOL)) (CurrentInterface->Protocol == CDC_DATA_PROTOCOL))
{ {
return DESCRIPTOR_SEARCH_Found; return DESCRIPTOR_SEARCH_Found;
} }

@ -62,7 +62,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
do do
{ {
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, 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; return HID_ENUMERROR_NoCompatibleInterfaceFound;
} }
@ -90,7 +90,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
DataINEndpoint = EndpointData; DataINEndpoint = EndpointData;
else else
DataOUTEndpoint = EndpointData; DataOUTEndpoint = EndpointData;
} }
for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++) for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
@ -98,17 +98,17 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
if (PipeNum == HIDInterfaceInfo->Config.DataINPipeNumber) if (PipeNum == HIDInterfaceInfo->Config.DataINPipeNumber)
{ {
Pipe_ConfigurePipe(PipeNum, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN, Pipe_ConfigurePipe(PipeNum, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
HIDInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); HIDInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
Pipe_SetInterruptPeriod(DataINEndpoint->PollingIntervalMS); Pipe_SetInterruptPeriod(DataINEndpoint->PollingIntervalMS);
HIDInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize; HIDInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
} }
else if (PipeNum == HIDInterfaceInfo->Config.DataOUTPipeNumber) else if (PipeNum == HIDInterfaceInfo->Config.DataOUTPipeNumber)
{ {
Pipe_ConfigurePipe(PipeNum, EP_TYPE_INTERRUPT, PIPE_TOKEN_OUT, Pipe_ConfigurePipe(PipeNum, EP_TYPE_INTERRUPT, PIPE_TOKEN_OUT,
DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize, DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize,
HIDInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); HIDInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
Pipe_SetInterruptPeriod(DataOUTEndpoint->PollingIntervalMS); Pipe_SetInterruptPeriod(DataOUTEndpoint->PollingIntervalMS);
HIDInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize; HIDInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
@ -146,7 +146,7 @@ static uint8_t DCOMP_HID_Host_NextHID(void* const CurrentDescriptor)
else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
return DESCRIPTOR_SEARCH_Fail; return DESCRIPTOR_SEARCH_Fail;
else else
return DESCRIPTOR_SEARCH_NotFound; return DESCRIPTOR_SEARCH_NotFound;
} }
static uint8_t DCOMP_HID_Host_NextHIDInterfaceEndpoint(void* const CurrentDescriptor) static uint8_t DCOMP_HID_Host_NextHIDInterfaceEndpoint(void* const CurrentDescriptor)
@ -184,9 +184,9 @@ uint8_t HID_Host_ReceiveReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceI
Pipe_SelectPipe(PIPE_CONTROLPIPE); Pipe_SelectPipe(PIPE_CONTROLPIPE);
return USB_Host_SendControlRequest(Buffer); return USB_Host_SendControlRequest(Buffer);
} }
#endif #endif
uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,
void* Buffer) void* Buffer)
{ {
@ -223,7 +223,7 @@ uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,
if ((ErrorCode = Pipe_Read_Stream_LE(BufferPos, ReportSize, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError) if ((ErrorCode = Pipe_Read_Stream_LE(BufferPos, ReportSize, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
return ErrorCode; return ErrorCode;
Pipe_ClearIN(); Pipe_ClearIN();
Pipe_Freeze(); Pipe_Freeze();
return PIPE_RWSTREAM_NoError; return PIPE_RWSTREAM_NoError;

@ -149,9 +149,9 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
memset(CurrReportIDInfo, 0x00, sizeof(HID_ReportSizeInfo_t)); memset(CurrReportIDInfo, 0x00, sizeof(HID_ReportSizeInfo_t));
} }
} }
ParserData->UsingReportIDs = true; ParserData->UsingReportIDs = true;
CurrReportIDInfo->ReportID = CurrStateTable->ReportID; CurrReportIDInfo->ReportID = CurrStateTable->ReportID;
break; break;
case (TYPE_LOCAL | TAG_LOCAL_USAGE): case (TYPE_LOCAL | TAG_LOCAL_USAGE):
@ -176,7 +176,7 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
HID_CollectionPath_t* ParentCollectionPath = CurrCollectionPath; HID_CollectionPath_t* ParentCollectionPath = CurrCollectionPath;
CurrCollectionPath = &ParserData->CollectionPaths[1]; CurrCollectionPath = &ParserData->CollectionPaths[1];
while (CurrCollectionPath->Parent != NULL) while (CurrCollectionPath->Parent != NULL)
{ {
if (CurrCollectionPath == &ParserData->CollectionPaths[HID_MAX_COLLECTIONS - 1]) if (CurrCollectionPath == &ParserData->CollectionPaths[HID_MAX_COLLECTIONS - 1])
@ -184,7 +184,7 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
CurrCollectionPath++; CurrCollectionPath++;
} }
CurrCollectionPath->Parent = ParentCollectionPath; CurrCollectionPath->Parent = ParentCollectionPath;
} }
@ -222,15 +222,15 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
memcpy(&NewReportItem.Attributes, memcpy(&NewReportItem.Attributes,
&CurrStateTable->Attributes, &CurrStateTable->Attributes,
sizeof(HID_ReportItem_Attributes_t)); sizeof(HID_ReportItem_Attributes_t));
NewReportItem.ItemFlags = ReportItemData; NewReportItem.ItemFlags = ReportItemData;
NewReportItem.CollectionPath = CurrCollectionPath; NewReportItem.CollectionPath = CurrCollectionPath;
NewReportItem.ReportID = CurrStateTable->ReportID; NewReportItem.ReportID = CurrStateTable->ReportID;
if (UsageListSize) if (UsageListSize)
{ {
NewReportItem.Attributes.Usage.Usage = UsageList[0]; NewReportItem.Attributes.Usage.Usage = UsageList[0];
for (uint8_t i = 0; i < UsageListSize; i++) for (uint8_t i = 0; i < UsageListSize; i++)
UsageList[i] = UsageList[i + 1]; UsageList[i] = UsageList[i + 1];
@ -242,7 +242,7 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
} }
uint8_t ItemTag = (HIDReportItem & TAG_MASK); uint8_t ItemTag = (HIDReportItem & TAG_MASK);
if (ItemTag == TAG_MAIN_INPUT) if (ItemTag == TAG_MAIN_INPUT)
NewReportItem.ItemType = HID_REPORT_ITEM_In; NewReportItem.ItemType = HID_REPORT_ITEM_In;
else if (ItemTag == TAG_MAIN_OUTPUT) else if (ItemTag == TAG_MAIN_OUTPUT)
@ -251,14 +251,14 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
NewReportItem.ItemType = HID_REPORT_ITEM_Feature; NewReportItem.ItemType = HID_REPORT_ITEM_Feature;
NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType]; NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType];
CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType] += CurrStateTable->Attributes.BitSize; CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType] += CurrStateTable->Attributes.BitSize;
if (ParserData->LargestReportSizeBits < NewReportItem.BitOffset) if (ParserData->LargestReportSizeBits < NewReportItem.BitOffset)
ParserData->LargestReportSizeBits = NewReportItem.BitOffset; ParserData->LargestReportSizeBits = NewReportItem.BitOffset;
if (!(ReportItemData & IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&NewReportItem)) if (!(ReportItemData & IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&NewReportItem))
{ {
if (ParserData->TotalReportItems == HID_MAX_REPORTITEMS) if (ParserData->TotalReportItems == HID_MAX_REPORTITEMS)
return HID_PARSE_InsufficientReportItems; return HID_PARSE_InsufficientReportItems;
@ -297,13 +297,13 @@ bool USB_GetHIDReportItemInfo(const uint8_t* ReportData,
{ {
if (ReportItem->ReportID != ReportData[0]) if (ReportItem->ReportID != ReportData[0])
return false; return false;
ReportData++; ReportData++;
} }
ReportItem->PreviousValue = ReportItem->Value; ReportItem->PreviousValue = ReportItem->Value;
ReportItem->Value = 0; ReportItem->Value = 0;
while (DataBitsRem--) while (DataBitsRem--)
{ {
if (ReportData[CurrentBit / 8] & (1 << (CurrentBit % 8))) if (ReportData[CurrentBit / 8] & (1 << (CurrentBit % 8)))
@ -322,20 +322,20 @@ void USB_SetHIDReportItemInfo(uint8_t* ReportData,
uint16_t DataBitsRem = ReportItem->Attributes.BitSize; uint16_t DataBitsRem = ReportItem->Attributes.BitSize;
uint16_t CurrentBit = ReportItem->BitOffset; uint16_t CurrentBit = ReportItem->BitOffset;
uint32_t BitMask = (1 << 0); uint32_t BitMask = (1 << 0);
if (ReportItem->ReportID) if (ReportItem->ReportID)
{ {
ReportData[0] = ReportItem->ReportID; ReportData[0] = ReportItem->ReportID;
ReportData++; ReportData++;
} }
ReportItem->PreviousValue = ReportItem->Value; ReportItem->PreviousValue = ReportItem->Value;
while (DataBitsRem--) while (DataBitsRem--)
{ {
if (ReportItem->Value & (1 << (CurrentBit % 8))) if (ReportItem->Value & (1 << (CurrentBit % 8)))
ReportData[CurrentBit / 8] |= BitMask; ReportData[CurrentBit / 8] |= BitMask;
CurrentBit++; CurrentBit++;
BitMask <<= 1; BitMask <<= 1;
} }

@ -56,7 +56,7 @@ uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceI
DCOMP_MIDI_Host_NextMIDIStreamingDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) DCOMP_MIDI_Host_NextMIDIStreamingDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
DCOMP_MIDI_Host_NextMIDIStreamingInterface) != DESCRIPTOR_SEARCH_COMP_Found) DCOMP_MIDI_Host_NextMIDIStreamingInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
return MIDI_ENUMERROR_NoCompatibleInterfaceFound; return MIDI_ENUMERROR_NoCompatibleInterfaceFound;
} }
@ -82,16 +82,16 @@ uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceI
if (PipeNum == MIDIInterfaceInfo->Config.DataINPipeNumber) if (PipeNum == MIDIInterfaceInfo->Config.DataINPipeNumber)
{ {
Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN, Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN,
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
MIDIInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); MIDIInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
MIDIInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize; MIDIInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
} }
else if (PipeNum == MIDIInterfaceInfo->Config.DataOUTPipeNumber) else if (PipeNum == MIDIInterfaceInfo->Config.DataOUTPipeNumber)
{ {
Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT, Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT,
DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize, DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize,
MIDIInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); MIDIInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
MIDIInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize; MIDIInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
} }

@ -56,7 +56,7 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
DCOMP_MS_Host_NextMSInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) DCOMP_MS_Host_NextMSInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
DCOMP_MS_Host_NextMSInterface) != DESCRIPTOR_SEARCH_COMP_Found) DCOMP_MS_Host_NextMSInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
return MS_ENUMERROR_NoCompatibleInterfaceFound; return MS_ENUMERROR_NoCompatibleInterfaceFound;
} }
@ -82,16 +82,16 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
if (PipeNum == MSInterfaceInfo->Config.DataINPipeNumber) if (PipeNum == MSInterfaceInfo->Config.DataINPipeNumber)
{ {
Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN, Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN,
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
MSInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); MSInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
MSInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize; MSInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
} }
else if (PipeNum == MSInterfaceInfo->Config.DataOUTPipeNumber) else if (PipeNum == MSInterfaceInfo->Config.DataOUTPipeNumber)
{ {
Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT, Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT,
DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize, DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize,
MSInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); MSInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
MSInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize; MSInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
} }
@ -388,7 +388,7 @@ uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive)) if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))
return HOST_SENDCONTROL_DeviceDisconnected; return HOST_SENDCONTROL_DeviceDisconnected;
uint8_t ErrorCode; uint8_t ErrorCode;
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{ {

@ -56,7 +56,7 @@ uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI
DCOMP_PRNT_Host_NextPRNTInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) DCOMP_PRNT_Host_NextPRNTInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &DeviceConfigDescriptor, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &DeviceConfigDescriptor,
DCOMP_PRNT_Host_NextPRNTInterface) != DESCRIPTOR_SEARCH_COMP_Found) DCOMP_PRNT_Host_NextPRNTInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
return PRNT_ENUMERROR_NoCompatibleInterfaceFound; return PRNT_ENUMERROR_NoCompatibleInterfaceFound;
} }
@ -82,16 +82,16 @@ uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI
if (PipeNum == PRNTInterfaceInfo->Config.DataINPipeNumber) if (PipeNum == PRNTInterfaceInfo->Config.DataINPipeNumber)
{ {
Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN, Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN,
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
PRNTInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); PRNTInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
PRNTInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize; PRNTInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
} }
else if (PipeNum == PRNTInterfaceInfo->Config.DataOUTPipeNumber) else if (PipeNum == PRNTInterfaceInfo->Config.DataOUTPipeNumber)
{ {
Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT, Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT,
DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize, DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize,
PRNTInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); PRNTInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
PRNTInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize; PRNTInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
} }
@ -108,9 +108,12 @@ static uint8_t DCOMP_PRNT_Host_NextPRNTInterface(void* CurrentDescriptor)
{ {
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
{ {
if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == PRINTER_CLASS) && USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
(DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).SubClass == PRINTER_SUBCLASS) && USB_Descriptor_Interface_t);
(DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == PRINTER_PROTOCOL))
if ((CurrentInterface->Class == PRINTER_CLASS) &&
(CurrentInterface->SubClass == PRINTER_SUBCLASS) &&
(CurrentInterface->Protocol == PRINTER_PROTOCOL))
{ {
return DESCRIPTOR_SEARCH_Found; return DESCRIPTOR_SEARCH_Found;
} }

@ -105,7 +105,7 @@ uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfa
if (PipeNum == RNDISInterfaceInfo->Config.DataINPipeNumber) if (PipeNum == RNDISInterfaceInfo->Config.DataINPipeNumber)
{ {
Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN, Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN,
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
RNDISInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); RNDISInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
RNDISInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize; RNDISInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
@ -144,7 +144,7 @@ static uint8_t DCOMP_RNDIS_Host_NextRNDISControlInterface(void* const CurrentDes
if ((CurrentInterface->Class == RNDIS_CONTROL_CLASS) && if ((CurrentInterface->Class == RNDIS_CONTROL_CLASS) &&
(CurrentInterface->SubClass == RNDIS_CONTROL_SUBCLASS) && (CurrentInterface->SubClass == RNDIS_CONTROL_SUBCLASS) &&
(CurrentInterface->Protocol == RNDIS_CONTROL_PROTOCOL)) (CurrentInterface->Protocol == RNDIS_CONTROL_PROTOCOL))
{ {
return DESCRIPTOR_SEARCH_Found; return DESCRIPTOR_SEARCH_Found;
} }
@ -162,7 +162,7 @@ static uint8_t DCOMP_RNDIS_Host_NextRNDISDataInterface(void* const CurrentDescri
if ((CurrentInterface->Class == RNDIS_DATA_CLASS) && if ((CurrentInterface->Class == RNDIS_DATA_CLASS) &&
(CurrentInterface->SubClass == RNDIS_DATA_SUBCLASS) && (CurrentInterface->SubClass == RNDIS_DATA_SUBCLASS) &&
(CurrentInterface->Protocol == RNDIS_DATA_PROTOCOL)) (CurrentInterface->Protocol == RNDIS_DATA_PROTOCOL))
{ {
return DESCRIPTOR_SEARCH_Found; return DESCRIPTOR_SEARCH_Found;
} }
@ -307,7 +307,7 @@ uint8_t RNDIS_Host_SetRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInter
SetMessageData.SetMessage.MessageType = REMOTE_NDIS_SET_MSG; SetMessageData.SetMessage.MessageType = REMOTE_NDIS_SET_MSG;
SetMessageData.SetMessage.MessageLength = sizeof(RNDIS_Set_Message_t) + Length; SetMessageData.SetMessage.MessageLength = sizeof(RNDIS_Set_Message_t) + Length;
SetMessageData.SetMessage.RequestId = RNDISInterfaceInfo->State.RequestID++; SetMessageData.SetMessage.RequestId = RNDISInterfaceInfo->State.RequestID++;
SetMessageData.SetMessage.Oid = Oid; SetMessageData.SetMessage.Oid = Oid;
SetMessageData.SetMessage.InformationBufferLength = Length; SetMessageData.SetMessage.InformationBufferLength = Length;
SetMessageData.SetMessage.InformationBufferOffset = (sizeof(RNDIS_Set_Message_t) - sizeof(RNDIS_Message_Header_t)); SetMessageData.SetMessage.InformationBufferOffset = (sizeof(RNDIS_Set_Message_t) - sizeof(RNDIS_Message_Header_t));
@ -351,7 +351,7 @@ uint8_t RNDIS_Host_QueryRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInt
QueryMessage.MessageType = REMOTE_NDIS_QUERY_MSG; QueryMessage.MessageType = REMOTE_NDIS_QUERY_MSG;
QueryMessage.MessageLength = sizeof(RNDIS_Query_Message_t); QueryMessage.MessageLength = sizeof(RNDIS_Query_Message_t);
QueryMessage.RequestId = RNDISInterfaceInfo->State.RequestID++; QueryMessage.RequestId = RNDISInterfaceInfo->State.RequestID++;
QueryMessage.Oid = Oid; QueryMessage.Oid = Oid;
QueryMessage.InformationBufferLength = 0; QueryMessage.InformationBufferLength = 0;
QueryMessage.InformationBufferOffset = 0; QueryMessage.InformationBufferOffset = 0;
@ -427,7 +427,7 @@ uint8_t RNDIS_Host_ReadPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceIn
Pipe_Discard_Stream(DeviceMessage.DataOffset - (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t)), Pipe_Discard_Stream(DeviceMessage.DataOffset - (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t)),
NO_STREAM_CALLBACK); NO_STREAM_CALLBACK);
Pipe_Read_Stream_LE(Buffer, *PacketLength, NO_STREAM_CALLBACK); Pipe_Read_Stream_LE(Buffer, *PacketLength, NO_STREAM_CALLBACK);
if (!(Pipe_BytesInPipe())) if (!(Pipe_BytesInPipe()))

@ -57,7 +57,7 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
DCOMP_SI_Host_NextSIInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) DCOMP_SI_Host_NextSIInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
DCOMP_SI_Host_NextSIInterface) != DESCRIPTOR_SEARCH_COMP_Found) DCOMP_SI_Host_NextSIInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
return SI_ENUMERROR_NoCompatibleInterfaceFound; return SI_ENUMERROR_NoCompatibleInterfaceFound;
} }
@ -91,7 +91,7 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
if (PipeNum == SIInterfaceInfo->Config.DataINPipeNumber) if (PipeNum == SIInterfaceInfo->Config.DataINPipeNumber)
{ {
Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN, Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN,
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
SIInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); SIInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
SIInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize; SIInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
@ -187,7 +187,7 @@ uint8_t SI_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
return ErrorCode; return ErrorCode;
} }
Pipe_ClearOUT(); Pipe_ClearOUT();
Pipe_Freeze(); Pipe_Freeze();
return PIPE_RWSTREAM_NoError; return PIPE_RWSTREAM_NoError;
@ -411,9 +411,9 @@ uint8_t SI_Host_SendCommand(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
.Type = SI_PIMA_CONTAINER_CommandBlock, .Type = SI_PIMA_CONTAINER_CommandBlock,
.Code = Operation, .Code = Operation,
}; };
memcpy(&PIMABlock.Params, Params, sizeof(uint32_t) * TotalParams); memcpy(&PIMABlock.Params, Params, sizeof(uint32_t) * TotalParams);
if ((ErrorCode = SI_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError) if ((ErrorCode = SI_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)
return ErrorCode; return ErrorCode;

Loading…
Cancel
Save