17 #if !defined(__CONFDESCPARSER_H__)
18 #define __CONFDESCPARSER_H__
22 #include <avr/pgmspace.h>
35 #define CP_MASK_COMPARE_CLASS 1
36 #define CP_MASK_COMPARE_SUBCLASS 2
37 #define CP_MASK_COMPARE_PROTOCOL 4
38 #define CP_MASK_COMPARE_ALL 7
42 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
48 uint8_t varBuffer[16 ];
50 uint8_t stateParseDescr;
61 bool ParseDescriptor(uint8_t **pp, uint16_t *pcntdn);
67 virtual void Parse(
const uint16_t len,
const uint8_t *pbuf,
const uint16_t &offset);
70 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
72 theXtractor(xtractor),
76 theBuffer.
pValue = varBuffer;
81 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
83 uint16_t cntdn = (uint16_t) len;
84 uint8_t *p = (uint8_t*) pbuf;
87 if(!ParseDescriptor(&p, &cntdn))
93 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
95 switch(stateParseDescr) {
97 theBuffer.valueSize = 2;
98 valParser.Initialize(&theBuffer);
101 if(!valParser.Parse(pp, pcntdn))
103 dscrLen = *((uint8_t*) theBuffer.pValue);
104 dscrType = *((uint8_t*) theBuffer.pValue + 1);
112 theBuffer.pValue = varBuffer + 2;
117 isGoodInterface =
false;
125 theBuffer.valueSize = dscrLen - 2;
128 valParser.Initialize(&theBuffer);
133 if(!valParser.Parse(pp, pcntdn))
138 if(!valParser.Parse(pp, pcntdn))
147 isGoodInterface =
true;
153 if(!valParser.Parse(pp, pcntdn))
157 theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (
USB_ENDPOINT_DESCRIPTOR*) varBuffer);
165 if(!theSkipper.Skip(pp, pcntdn, dscrLen - 2))
168 theBuffer.pValue = varBuffer;
174 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
176 Notify(PSTR(
"\r\n\r\nHID Descriptor:\r\n"), 0x80);
177 Notify(PSTR(
"bDescLength:\t\t"), 0x80);
178 PrintHex<uint8_t > (pDesc->
bLength, 0x80);
180 Notify(PSTR(
"\r\nbDescriptorType:\t"), 0x80);
183 Notify(PSTR(
"\r\nbcdHID:\t\t\t"), 0x80);
184 PrintHex<uint16_t > (pDesc->
bcdHID, 0x80);
186 Notify(PSTR(
"\r\nbCountryCode:\t\t"), 0x80);
189 Notify(PSTR(
"\r\nbNumDescriptors:\t"), 0x80);
201 Notify(PSTR(
"\r\nbDescrType:\t\t"), 0x80);
204 Notify(PSTR(
"\r\nwDescriptorLength:\t"), 0x80);
207 Notify(PSTR(
"\r\n"), 0x80);
211 #endif // __CONFDESCPARSER_H__