14 uint16_t HIDUniversal::GetHidClassDescrLen(uint8_t type, uint8_t num) {
16 if (descrInfo[i].bDescrType == type) {
25 void HIDUniversal::Initialize() {
27 rptParsers[i].rptId = 0;
28 rptParsers[i].rptParser = NULL;
35 hidInterfaces[i].bmInterface = 0;
36 hidInterfaces[i].bmProtocol = 0;
39 hidInterfaces[i].epIndex[j] = 0;
51 ZeroMemory(constBuffLen, prevBuf);
56 if (rptParsers[i].rptId == 0 && rptParsers[i].rptParser == NULL) {
57 rptParsers[i].rptId = id;
58 rptParsers[i].rptParser = prs;
67 return ((rptParsers[0].rptParser) ? rptParsers[0].rptParser : NULL);
70 if (rptParsers[i].rptId ==
id)
71 return rptParsers[i].rptParser;
79 uint8_t buf[constBufSize];
118 len = (buf[0] > constBufSize) ? constBufSize : buf[0];
124 goto FailGetDevDescr;
165 goto FailGetDevDescr;
173 goto FailSetDevTblEntry;
177 for (uint8_t i = 0; i < num_of_conf; i++) {
186 goto FailGetConfDescr;
204 goto FailSetConfDescr;
206 for (uint8_t i = 0; i < bNumIface; i++) {
210 rcode =
SetIdle(hidInterfaces[i].bmInterface, 0, 0);
249 HIDUniversal::HIDInterface* HIDUniversal::FindInterface(uint8_t iface, uint8_t alt, uint8_t proto) {
251 if (hidInterfaces[i].bmInterface == iface && hidInterfaces[i].bmAltSet == alt
252 && hidInterfaces[i].bmProtocol == proto)
253 return hidInterfaces + i;
259 if (bNumEP > 1 && conf != bConfNum)
269 HIDInterface *piface = FindInterface(iface, alt, proto);
273 piface = hidInterfaces + bNumIface;
274 piface->bmInterface = iface;
275 piface->bmAltSet = alt;
276 piface->bmProtocol = proto;
293 piface->epIndex[index] = bNumEP;
310 bool HIDUniversal::BuffersIdentical(uint8_t len, uint8_t *buf1, uint8_t *buf2) {
311 for (uint8_t i = 0; i < len; i++)
312 if (buf1[i] != buf2[i])
317 void HIDUniversal::ZeroMemory(uint8_t len, uint8_t *buf) {
318 for (uint8_t i = 0; i < len; i++)
322 void HIDUniversal::SaveBuffer(uint8_t len, uint8_t *src, uint8_t *dest) {
323 for (uint8_t i = 0; i < len; i++)
333 if (qNextPollTime <= millis()) {
334 qNextPollTime = millis() + 50;
336 uint8_t buf[constBuffLen];
338 for (uint8_t i = 0; i < bNumIface; i++) {
340 uint16_t read = (uint16_t)epInfo[index].maxPktSize;
342 ZeroMemory(constBuffLen, buf);
352 if (read > constBuffLen)
355 bool identical = BuffersIdentical(read, buf, prevBuf);
357 SaveBuffer(read, buf, prevBuf);
362 Notify(PSTR(
"\r\nBuf: "), 0x80);
364 for (uint8_t i = 0; i < read; i++)
365 PrintHex<uint8_t > (buf[i], 0x80);
367 Notify(PSTR(
"\r\n"), 0x80);