15 uint16_t HIDUniversal::GetHidClassDescrLen(uint8_t type, uint8_t num)
19 if (descrInfo[i].bDescrType == type)
29 void HIDUniversal::Initialize()
33 rptParsers[i].rptId = 0;
34 rptParsers[i].rptParser = NULL;
43 hidInterfaces[i].bmInterface = 0;
44 hidInterfaces[i].bmProtocol = 0;
47 hidInterfaces[i].epIndex[j] = 0;
60 ZeroMemory(constBuffLen, prevBuf);
67 if (rptParsers[i].rptId == 0 && rptParsers[i].rptParser == NULL)
69 rptParsers[i].rptId = id;
70 rptParsers[i].rptParser = prs;
80 return ((rptParsers[0].rptParser) ? rptParsers[0].rptParser : NULL);
84 if (rptParsers[i].rptId ==
id)
85 return rptParsers[i].rptParser;
94 uint8_t buf[constBufSize];
136 len = (buf[0] > constBufSize) ? constBufSize : buf[0];
143 goto FailGetDevDescr;
187 goto FailGetDevDescr;
195 goto FailSetDevTblEntry;
199 for (uint8_t i=0; i<num_of_conf; i++)
225 goto FailSetConfDescr;
227 for (uint8_t i=0; i<bNumIface; i++)
232 rcode =
SetIdle(hidInterfaces[i].bmInterface, 0, 0);
274 Serial.println(rcode, HEX);
279 HIDUniversal::HIDInterface* HIDUniversal::FindInterface(uint8_t iface, uint8_t alt, uint8_t proto)
282 if (hidInterfaces[i].bmInterface == iface && hidInterfaces[i].bmAltSet == alt
283 && hidInterfaces[i].bmProtocol == proto)
284 return hidInterfaces + i;
291 if (bNumEP > 1 && conf != bConfNum)
301 HIDInterface *piface = FindInterface(iface, alt, proto);
306 piface = hidInterfaces + bNumIface;
307 piface->bmInterface = iface;
308 piface->bmAltSet = alt;
309 piface->bmProtocol = proto;
327 piface->epIndex[index] = bNumEP;
346 bool HIDUniversal::BuffersIdentical(uint8_t len, uint8_t *buf1, uint8_t *buf2)
348 for (uint8_t i=0; i<len; i++)
349 if (buf1[i] != buf2[i])
354 void HIDUniversal::ZeroMemory(uint8_t len, uint8_t *buf)
356 for (uint8_t i=0; i<len; i++)
359 void HIDUniversal::SaveBuffer(uint8_t len, uint8_t *src, uint8_t *dest)
361 for (uint8_t i=0; i<len; i++)
372 if (qNextPollTime <= millis())
374 qNextPollTime = millis() + 50;
376 uint8_t buf[constBuffLen];
378 for (uint8_t i=0; i<bNumIface; i++)
381 uint16_t read = (uint16_t)epInfo[index].maxPktSize;
383 ZeroMemory(constBuffLen, buf);
394 if (read > constBuffLen)
397 bool identical = BuffersIdentical(read, buf, prevBuf);
399 SaveBuffer(read, buf, prevBuf);
404 Serial.print(
"\r\nBuf: ");
406 for (uint8_t i=0; i<read; i++)
407 PrintHex<uint8_t>(buf[i]);