17 #if !defined(__CONFDESCPARSER_H__)
18 #define __CONFDESCPARSER_H__
22 #include <avr/pgmspace.h>
38 #define CP_MASK_COMPARE_CLASS 1
39 #define CP_MASK_COMPARE_SUBCLASS 2
40 #define CP_MASK_COMPARE_PROTOCOL 4
41 #define CP_MASK_COMPARE_ALL 7
44 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
51 uint8_t varBuffer[16 ];
53 uint8_t stateParseDescr;
64 bool ParseDescriptor(uint8_t **pp, uint16_t *pcntdn);
70 virtual void Parse(
const uint16_t len,
const uint8_t *pbuf,
const uint16_t &offset);
73 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
80 theBuffer.
pValue = varBuffer;
85 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
88 uint16_t cntdn = (uint16_t)len;
89 uint8_t *p = (uint8_t*)pbuf;
92 if (!ParseDescriptor(&p, &cntdn))
97 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 switch (stateParseDescr)
103 theBuffer.valueSize = 2;
104 valParser.Initialize(&theBuffer);
107 if (!valParser.Parse(pp, pcntdn))
109 dscrLen = *((uint8_t*)theBuffer.pValue);
110 dscrType = *((uint8_t*)theBuffer.pValue + 1);
118 theBuffer.pValue = varBuffer + 2;
124 isGoodInterface =
false;
132 theBuffer.valueSize = dscrLen - 2;
135 valParser.Initialize(&theBuffer);
141 if (!valParser.Parse(pp, pcntdn))
146 if (!valParser.Parse(pp, pcntdn))
155 isGoodInterface =
true;
161 if (!valParser.Parse(pp, pcntdn))
165 theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (
USB_ENDPOINT_DESCRIPTOR*)varBuffer);
173 if (!theSkipper.Skip(pp, pcntdn, dscrLen-2))
176 theBuffer.pValue = varBuffer;
182 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
185 Notify(PSTR(
"\r\n\r\nHID Descriptor:\r\n"));
186 Notify(PSTR(
"bDescLength:\t\t"));
187 PrintHex<uint8_t>(pDesc->
bLength);
189 Notify(PSTR(
"\r\nbDescriptorType:\t"));
192 Notify(PSTR(
"\r\nbcdHID:\t\t\t"));
193 PrintHex<uint16_t>(pDesc->
bcdHID);
195 Notify(PSTR(
"\r\nbCountryCode:\t\t"));
198 Notify(PSTR(
"\r\nbNumDescriptors:\t"));
211 Notify(PSTR(
"\r\nbDescrType:\t\t"));
214 Notify(PSTR(
"\r\nwDescriptorLength:\t"));
221 #endif // __CONFDESCPARSER_H__