24 #if !defined(_usb_h_) || defined(__CONFDESCPARSER_H__)
25 #error "Never include confdescparser.h directly; include Usb.h instead"
28 #define __CONFDESCPARSER_H__
35 virtual void EndpointXtract(uint8_t conf __attribute__((unused)), uint8_t iface __attribute__((unused)), uint8_t alt __attribute__((unused)), uint8_t proto __attribute__((unused)),
const USB_ENDPOINT_DESCRIPTOR *ep __attribute__((unused))) {
39 #define CP_MASK_COMPARE_CLASS 1
40 #define CP_MASK_COMPARE_SUBCLASS 2
41 #define CP_MASK_COMPARE_PROTOCOL 4
42 #define CP_MASK_COMPARE_ALL 7
46 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
52 uint8_t varBuffer[16 ];
54 uint8_t stateParseDescr;
66 bool ParseDescriptor(uint8_t **pp, uint16_t *pcntdn);
75 void Parse(
const uint16_t len,
const uint8_t *pbuf,
const uint16_t &offset);
78 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 theXtractor(xtractor),
85 theBuffer.
pValue = varBuffer;
90 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
92 uint16_t cntdn = (uint16_t)len;
93 uint8_t *p = (uint8_t*)pbuf;
96 if(!ParseDescriptor(&p, &cntdn))
102 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
106 switch(stateParseDescr) {
108 theBuffer.valueSize = 2;
109 valParser.Initialize(&theBuffer);
112 if(!valParser.Parse(pp, pcntdn))
114 dscrLen = *((uint8_t*)theBuffer.pValue);
115 dscrType = *((uint8_t*)theBuffer.pValue + 1);
123 theBuffer.pValue = varBuffer + 2;
128 isGoodInterface =
false;
135 theBuffer.valueSize = dscrLen - 2;
136 valParser.Initialize(&theBuffer);
141 if(!valParser.Parse(pp, pcntdn))
146 if(!valParser.Parse(pp, pcntdn))
159 isGoodInterface =
true;
165 if(!valParser.Parse(pp, pcntdn))
169 theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (
USB_ENDPOINT_DESCRIPTOR*)varBuffer);
177 if(!theSkipper.Skip(pp, pcntdn, dscrLen - 2))
180 theBuffer.pValue = varBuffer;
186 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
188 Notify(
PSTR(
"\r\n\r\nHID Descriptor:\r\n"), 0x80);
190 PrintHex<uint8_t > (pDesc->
bLength, 0x80);
196 PrintHex<uint16_t > (pDesc->
bcdHID, 0x80);
210 Notify(
PSTR(
"\r\nwDescriptorLength:\t"), 0x80);
217 #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