17 #if !defined(_usb_h_) || defined(__CONFDESCPARSER_H__)
18 #error "Never include confdescparser.h directly; include Usb.h instead"
21 #define __CONFDESCPARSER_H__
30 #define CP_MASK_COMPARE_CLASS 1
31 #define CP_MASK_COMPARE_SUBCLASS 2
32 #define CP_MASK_COMPARE_PROTOCOL 4
33 #define CP_MASK_COMPARE_ALL 7
37 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
43 uint8_t varBuffer[16 ];
45 uint8_t stateParseDescr;
57 bool ParseDescriptor(uint8_t **pp, uint16_t *pcntdn);
66 virtual void Parse(
const uint16_t len,
const uint8_t *pbuf,
const uint16_t &offset);
69 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
71 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>
97 switch(stateParseDescr) {
99 theBuffer.valueSize = 2;
100 valParser.Initialize(&theBuffer);
103 if(!valParser.Parse(pp, pcntdn))
105 dscrLen = *((uint8_t*)theBuffer.pValue);
106 dscrType = *((uint8_t*)theBuffer.pValue + 1);
114 theBuffer.pValue = varBuffer + 2;
119 isGoodInterface =
false;
127 theBuffer.valueSize = dscrLen - 2;
130 valParser.Initialize(&theBuffer);
135 if(!valParser.Parse(pp, pcntdn))
140 if(!valParser.Parse(pp, pcntdn))
153 isGoodInterface =
true;
159 if(!valParser.Parse(pp, pcntdn))
163 theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (
USB_ENDPOINT_DESCRIPTOR*)varBuffer);
171 if(!theSkipper.Skip(pp, pcntdn, dscrLen - 2))
174 theBuffer.pValue = varBuffer;
180 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
182 Notify(PSTR(
"\r\n\r\nHID Descriptor:\r\n"), 0x80);
183 Notify(PSTR(
"bDescLength:\t\t"), 0x80);
184 PrintHex<uint8_t > (pDesc->
bLength, 0x80);
186 Notify(PSTR(
"\r\nbDescriptorType:\t"), 0x80);
189 Notify(PSTR(
"\r\nbcdHID:\t\t\t"), 0x80);
190 PrintHex<uint16_t > (pDesc->
bcdHID, 0x80);
192 Notify(PSTR(
"\r\nbCountryCode:\t\t"), 0x80);
195 Notify(PSTR(
"\r\nbNumDescriptors:\t"), 0x80);
207 Notify(PSTR(
"\r\nbDescrType:\t\t"), 0x80);
210 Notify(PSTR(
"\r\nwDescriptorLength:\t"), 0x80);
213 Notify(PSTR(
"\r\n"), 0x80);
217 #endif // __CONFDESCPARSER_H__
#define CP_MASK_COMPARE_PROTOCOL
#define USB_DESCRIPTOR_ENDPOINT
uint8_t bConfigurationValue
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
uint8_t bAlternateSetting
ConfigDescParser(UsbConfigXtracter *xtractor)
void Initialize(MultiValueBuffer *const pbuf)
uint8_t bInterfaceSubClass
uint8_t bInterfaceProtocol
#define USB_DESCRIPTOR_INTERFACE