28 #error "Never include confdescparser.h directly; include Usb.h instead"
40 #define CP_MASK_COMPARE_CLASS 1
41 #define CP_MASK_COMPARE_SUBCLASS 2
42 #define CP_MASK_COMPARE_PROTOCOL 4
43 #define CP_MASK_COMPARE_ALL 7
47 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
67 bool ParseDescriptor(
uint8_t **pp, uint16_t *pcntdn);
68 void PrintHidDescriptor(
const USB_HID_DESCRIPTOR *pDesc);
77 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
79 theXtractor(xtractor),
84 theBuffer.
pValue = varBuffer;
89 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
91 uint16_t cntdn = (uint16_t)len;
93 while (cntdn)
if (!ParseDescriptor(&p, &cntdn))
return;
98 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
100 USB_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR*>(varBuffer);
101 USB_INTERFACE_DESCRIPTOR* uid = reinterpret_cast<USB_INTERFACE_DESCRIPTOR*>(varBuffer);
102 switch (stateParseDescr) {
104 theBuffer.valueSize = 2;
105 valParser.Initialize(&theBuffer);
108 if (!valParser.Parse(pp, pcntdn))
return false;
109 dscrLen = *((
uint8_t*)theBuffer.pValue);
110 dscrType = *((
uint8_t*)theBuffer.pValue + 1);
118 theBuffer.pValue = varBuffer + 2;
123 isGoodInterface =
false;
130 theBuffer.valueSize = dscrLen - 2;
131 valParser.Initialize(&theBuffer);
136 if (!valParser.Parse(pp, pcntdn))
return false;
137 confValue = ucd->bConfigurationValue;
140 if (!valParser.Parse(pp, pcntdn))
return false;
150 isGoodInterface =
true;
151 ifaceNumber = uid->bInterfaceNumber;
152 ifaceAltSet = uid->bAlternateSetting;
153 protoValue = uid->bInterfaceProtocol;
156 if (!valParser.Parse(pp, pcntdn))
return false;
157 if (isGoodInterface && theXtractor)
158 theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_ENDPOINT_DESCRIPTOR*)varBuffer);
165 if (!theSkipper.Skip(pp, pcntdn, dscrLen - 2))
return false;
167 theBuffer.pValue = varBuffer;
173 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
175 Notify(
PSTR(
"\r\n\r\nHID Descriptor:\r\n"), 0x80);
177 PrintHex<uint8_t > (pDesc->bLength, 0x80);
180 PrintHex<uint8_t > (pDesc->bDescriptorType, 0x80);
183 PrintHex<uint16_t > (pDesc->bcdHID, 0x80);
186 PrintHex<uint8_t > (pDesc->bCountryCode, 0x80);
189 PrintHex<uint8_t > (pDesc->bNumDescriptors, 0x80);
191 for (
uint8_t i = 0;
i < pDesc->bNumDescriptors;
i++) {
192 HID_CLASS_DESCRIPTOR_LEN_AND_TYPE *pLT = (HID_CLASS_DESCRIPTOR_LEN_AND_TYPE*)&(pDesc->bDescrType);
195 PrintHex<uint8_t > (pLT[
i].bDescrType, 0x80);
197 Notify(
PSTR(
"\r\nwDescriptorLength:\t"), 0x80);
198 PrintHex<uint16_t > (pLT[
i].wDescriptorLength, 0x80);