17 #if !defined(_usb_h_) || defined(__CONFDESCPARSER_H__)
18 #error "Never include confdescparser.h directly; include Usb.h instead"
21 #define __CONFDESCPARSER_H__
31 #define CP_MASK_COMPARE_CLASS 1
32 #define CP_MASK_COMPARE_SUBCLASS 2
33 #define CP_MASK_COMPARE_PROTOCOL 4
34 #define CP_MASK_COMPARE_ALL 7
38 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
44 uint8_t varBuffer[16 ];
46 uint8_t stateParseDescr;
57 bool ParseDescriptor(uint8_t **pp, uint16_t *pcntdn);
63 virtual void Parse(
const uint16_t len,
const uint8_t *pbuf,
const uint16_t &offset);
66 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
68 theXtractor(xtractor),
72 theBuffer.
pValue = varBuffer;
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 uint16_t cntdn = (uint16_t) len;
80 uint8_t *p = (uint8_t*) pbuf;
83 if(!ParseDescriptor(&p, &cntdn))
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 switch(stateParseDescr) {
93 theBuffer.valueSize = 2;
94 valParser.Initialize(&theBuffer);
97 if(!valParser.Parse(pp, pcntdn))
99 dscrLen = *((uint8_t*) theBuffer.pValue);
100 dscrType = *((uint8_t*) theBuffer.pValue + 1);
108 theBuffer.pValue = varBuffer + 2;
113 isGoodInterface =
false;
121 theBuffer.valueSize = dscrLen - 2;
124 valParser.Initialize(&theBuffer);
129 if(!valParser.Parse(pp, pcntdn))
134 if(!valParser.Parse(pp, pcntdn))
143 isGoodInterface =
true;
149 if(!valParser.Parse(pp, pcntdn))
153 theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (
USB_ENDPOINT_DESCRIPTOR*) varBuffer);
161 if(!theSkipper.Skip(pp, pcntdn, dscrLen - 2))
164 theBuffer.pValue = varBuffer;
170 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
172 Notify(PSTR(
"\r\n\r\nHID Descriptor:\r\n"), 0x80);
173 Notify(PSTR(
"bDescLength:\t\t"), 0x80);
174 PrintHex<uint8_t > (pDesc->
bLength, 0x80);
176 Notify(PSTR(
"\r\nbDescriptorType:\t"), 0x80);
179 Notify(PSTR(
"\r\nbcdHID:\t\t\t"), 0x80);
180 PrintHex<uint16_t > (pDesc->
bcdHID, 0x80);
182 Notify(PSTR(
"\r\nbCountryCode:\t\t"), 0x80);
185 Notify(PSTR(
"\r\nbNumDescriptors:\t"), 0x80);
197 Notify(PSTR(
"\r\nbDescrType:\t\t"), 0x80);
200 Notify(PSTR(
"\r\nwDescriptorLength:\t"), 0x80);
203 Notify(PSTR(
"\r\n"), 0x80);
207 #endif // __CONFDESCPARSER_H__
#define CP_MASK_COMPARE_PROTOCOL
#define USB_DESCRIPTOR_ENDPOINT
virtual void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset)
#define CP_MASK_COMPARE_CLASS
uint16_t wDescriptorLength
#define USB_DESCRIPTOR_CONFIGURATION
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)=0
void Initialize(MultiValueBuffer *pbuf)
#define CP_MASK_COMPARE_SUBCLASS
#define HID_DESCRIPTOR_HID
ConfigDescParser(UsbConfigXtracter *xtractor)
void Initialize(MultiValueBuffer *const pbuf)
#define USB_DESCRIPTOR_INTERFACE