Added new Printer Host mode Class driver.
Added new Printer Host mode ClassDriver demo. Added table of supported classes and modes to the main USB Class Driver documentation.
This commit is contained in:
parent
4670b39070
commit
8ba51f090f
22 changed files with 3138 additions and 47 deletions
|
@ -39,8 +39,8 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
|
|||
HID_StateTable_t* CurrStateTable = &StateTable[0];
|
||||
HID_CollectionPath_t* CurrCollectionPath = NULL;
|
||||
HID_ReportSizeInfo_t* CurrReportIDInfo = &ParserData->ReportIDSizes[0];
|
||||
uint16_t UsageStack[HID_USAGE_STACK_DEPTH];
|
||||
uint8_t UsageStackSize = 0;
|
||||
uint16_t UsageList[HID_USAGE_STACK_DEPTH];
|
||||
uint8_t UsageListSize = 0;
|
||||
|
||||
memset(ParserData, 0x00, sizeof(HID_ReportInfo_t));
|
||||
memset(CurrStateTable, 0x00, sizeof(HID_StateTable_t));
|
||||
|
@ -138,23 +138,23 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
|
|||
|
||||
if (CurrReportIDInfo == NULL)
|
||||
{
|
||||
if (ParserData->TotalDeviceReports++ > HID_MAX_REPORT_IDS)
|
||||
if (ParserData->TotalDeviceReports == HID_MAX_REPORT_IDS)
|
||||
return HID_PARSE_InsufficientReportIDItems;
|
||||
|
||||
CurrReportIDInfo = &ParserData->ReportIDSizes[ParserData->TotalDeviceReports - 1];
|
||||
CurrReportIDInfo = &ParserData->ReportIDSizes[ParserData->TotalDeviceReports++];
|
||||
memset(CurrReportIDInfo, 0x00, sizeof(HID_ReportSizeInfo_t));
|
||||
}
|
||||
}
|
||||
|
||||
ParserData->UsingReportIDs = true;
|
||||
|
||||
CurrReportIDInfo->ReportID = CurrStateTable->ReportID;
|
||||
CurrReportIDInfo->ReportID = CurrStateTable->ReportID;
|
||||
break;
|
||||
case (TYPE_LOCAL | TAG_LOCAL_USAGE):
|
||||
if (UsageStackSize == HID_USAGE_STACK_DEPTH)
|
||||
return HID_PARSE_UsageStackOverflow;
|
||||
if (UsageListSize == HID_USAGE_STACK_DEPTH)
|
||||
return HID_PARSE_UsageListOverflow;
|
||||
|
||||
UsageStack[UsageStackSize++] = ReportItemData;
|
||||
UsageList[UsageListSize++] = ReportItemData;
|
||||
break;
|
||||
case (TYPE_LOCAL | TAG_LOCAL_USAGEMIN):
|
||||
CurrStateTable->Attributes.Usage.MinMax.Minimum = ReportItemData;
|
||||
|
@ -187,14 +187,14 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
|
|||
CurrCollectionPath->Type = ReportItemData;
|
||||
CurrCollectionPath->Usage.Page = CurrStateTable->Attributes.Usage.Page;
|
||||
|
||||
if (UsageStackSize)
|
||||
if (UsageListSize)
|
||||
{
|
||||
CurrCollectionPath->Usage.Usage = UsageStack[0];
|
||||
CurrCollectionPath->Usage.Usage = UsageList[0];
|
||||
|
||||
for (uint8_t i = 0; i < UsageStackSize; i++)
|
||||
UsageStack[i] = UsageStack[i + 1];
|
||||
for (uint8_t i = 0; i < UsageListSize; i++)
|
||||
UsageList[i] = UsageList[i + 1];
|
||||
|
||||
UsageStackSize--;
|
||||
UsageListSize--;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -219,28 +219,24 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
|
|||
NewReportItem.CollectionPath = CurrCollectionPath;
|
||||
NewReportItem.ReportID = CurrStateTable->ReportID;
|
||||
|
||||
if (UsageStackSize)
|
||||
if (UsageListSize)
|
||||
{
|
||||
NewReportItem.Attributes.Usage.Usage = UsageStack[0];
|
||||
NewReportItem.Attributes.Usage.Usage = UsageList[0];
|
||||
|
||||
for (uint8_t i = 0; i < UsageStackSize; i++)
|
||||
UsageStack[i] = UsageStack[i + 1];
|
||||
for (uint8_t i = 0; i < UsageListSize; i++)
|
||||
UsageList[i] = UsageList[i + 1];
|
||||
|
||||
UsageStackSize--;
|
||||
UsageListSize--;
|
||||
}
|
||||
|
||||
switch (HIDReportItem & TAG_MASK)
|
||||
{
|
||||
case TAG_MAIN_INPUT:
|
||||
NewReportItem.ItemType = REPORT_ITEM_TYPE_In;
|
||||
break;
|
||||
case TAG_MAIN_OUTPUT:
|
||||
NewReportItem.ItemType = REPORT_ITEM_TYPE_Out;
|
||||
break;
|
||||
case TAG_MAIN_FEATURE:
|
||||
NewReportItem.ItemType = REPORT_ITEM_TYPE_Feature;
|
||||
break;
|
||||
}
|
||||
uint8_t ItemTag = (HIDReportItem & TAG_MASK);
|
||||
|
||||
if (ItemTag == TAG_MAIN_INPUT)
|
||||
NewReportItem.ItemType = REPORT_ITEM_TYPE_In;
|
||||
else if (ItemTag == TAG_MAIN_OUTPUT)
|
||||
NewReportItem.ItemType = REPORT_ITEM_TYPE_Out;
|
||||
else
|
||||
NewReportItem.ItemType = REPORT_ITEM_TYPE_Feature;
|
||||
|
||||
NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType];
|
||||
|
||||
|
@ -268,7 +264,7 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
|
|||
{
|
||||
CurrStateTable->Attributes.Usage.MinMax.Minimum = 0;
|
||||
CurrStateTable->Attributes.Usage.MinMax.Maximum = 0;
|
||||
UsageStackSize = 0;
|
||||
UsageListSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue