17 #if !defined(_usb_h_) || defined(__CONFDESCPARSER_H__)
18 #error "Never include confdescparser.h directly; include Usb.h instead"
21 #define __CONFDESCPARSER_H__
32 #define CP_MASK_COMPARE_CLASS 1
33 #define CP_MASK_COMPARE_SUBCLASS 2
34 #define CP_MASK_COMPARE_PROTOCOL 4
35 #define CP_MASK_COMPARE_ALL 7
39 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
45 uint8_t varBuffer[16 ];
47 uint8_t stateParseDescr;
59 bool ParseDescriptor(uint8_t **pp, uint16_t *pcntdn);
68 void Parse(
const uint16_t len,
const uint8_t *pbuf,
const uint16_t &offset);
71 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
73 theXtractor(xtractor),
78 theBuffer.
pValue = varBuffer;
83 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
85 uint16_t cntdn = (uint16_t)len;
86 uint8_t *p = (uint8_t*)pbuf;
89 if(!ParseDescriptor(&p, &cntdn))
95 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
99 switch(stateParseDescr) {
101 theBuffer.valueSize = 2;
102 valParser.Initialize(&theBuffer);
105 if(!valParser.Parse(pp, pcntdn))
107 dscrLen = *((uint8_t*)theBuffer.pValue);
108 dscrType = *((uint8_t*)theBuffer.pValue + 1);
116 theBuffer.pValue = varBuffer + 2;
121 isGoodInterface =
false;
129 theBuffer.valueSize = dscrLen - 2;
132 valParser.Initialize(&theBuffer);
137 if(!valParser.Parse(pp, pcntdn))
142 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>
184 Notify(
PSTR(
"\r\n\r\nHID Descriptor:\r\n"), 0x80);
186 PrintHex<uint8_t > (pDesc->
bLength, 0x80);
192 PrintHex<uint16_t > (pDesc->
bcdHID, 0x80);
206 Notify(
PSTR(
"\r\nwDescriptorLength:\t"), 0x80);
213 #endif // __CONFDESCPARSER_H__
#define CP_MASK_COMPARE_PROTOCOL
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
#define USB_DESCRIPTOR_ENDPOINT
uint8_t bConfigurationValue
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
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