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);
224 #ifdef DEBUG_USB_HOST
230 #ifdef DEBUG_USB_HOST
236 #ifdef DEBUG_USB_HOST
242 #ifdef DEBUG_USB_HOST
249 #ifdef DEBUG_USB_HOST
254 #ifdef DEBUG_USB_HOST
261 HIDUniversal::HIDInterface* HIDUniversal::FindInterface(uint8_t iface, uint8_t alt, uint8_t proto) {
263 if (hidInterfaces[i].bmInterface == iface && hidInterfaces[i].bmAltSet == alt
264 && hidInterfaces[i].bmProtocol == proto)
265 return hidInterfaces + i;
271 if (bNumEP > 1 && conf != bConfNum)
281 HIDInterface *piface = FindInterface(iface, alt, proto);
285 piface = hidInterfaces + bNumIface;
286 piface->bmInterface = iface;
287 piface->bmAltSet = alt;
288 piface->bmProtocol = proto;
305 piface->epIndex[index] = bNumEP;
322 bool HIDUniversal::BuffersIdentical(uint8_t len, uint8_t *buf1, uint8_t *buf2) {
323 for (uint8_t i = 0; i < len; i++)
324 if (buf1[i] != buf2[i])
329 void HIDUniversal::ZeroMemory(uint8_t len, uint8_t *buf) {
330 for (uint8_t i = 0; i < len; i++)
334 void HIDUniversal::SaveBuffer(uint8_t len, uint8_t *src, uint8_t *dest) {
335 for (uint8_t i = 0; i < len; i++)
345 if (qNextPollTime <= millis()) {
346 qNextPollTime = millis() + 50;
348 uint8_t buf[constBuffLen];
350 for (uint8_t i = 0; i < bNumIface; i++) {
352 uint16_t read = (uint16_t)epInfo[index].maxPktSize;
354 ZeroMemory(constBuffLen, buf);
364 if (read > constBuffLen)
367 bool identical = BuffersIdentical(read, buf, prevBuf);
369 SaveBuffer(read, buf, prevBuf);
374 Notify(PSTR(
"\r\nBuf: "), 0x80);
376 for (uint8_t i = 0; i < read; i++)
377 PrintHex<uint8_t > (buf[i], 0x80);
379 Notify(PSTR(
"\r\n"), 0x80);