15 uint16_t HIDUniversal::GetHidClassDescrLen(uint8_t type, uint8_t num) {
17 if(descrInfo[i].bDescrType == type) {
26 void HIDUniversal::Initialize() {
28 rptParsers[i].rptId = 0;
29 rptParsers[i].rptParser = NULL;
36 hidInterfaces[i].bmInterface = 0;
37 hidInterfaces[i].bmProtocol = 0;
40 hidInterfaces[i].epIndex[j] = 0;
53 ZeroMemory(constBuffLen, prevBuf);
58 if(rptParsers[i].rptId == 0 && rptParsers[i].rptParser == NULL) {
59 rptParsers[i].rptId = id;
60 rptParsers[i].rptParser = prs;
69 return ((rptParsers[0].rptParser) ? rptParsers[0].rptParser : NULL);
72 if(rptParsers[i].rptId ==
id)
73 return rptParsers[i].rptParser;
81 uint8_t buf[constBufSize];
121 len = (buf[0] > constBufSize) ? constBufSize : buf[0];
127 goto FailGetDevDescr;
170 goto FailGetDevDescr;
181 goto FailSetDevTblEntry;
185 for(uint8_t i = 0; i < num_of_conf; i++) {
194 goto FailGetConfDescr;
212 goto FailSetConfDescr;
214 for(uint8_t i = 0; i < bNumIface; i++) {
218 rcode =
SetIdle(hidInterfaces[i].bmInterface, 0, 0);
232 #ifdef DEBUG_USB_HOST
238 #ifdef DEBUG_USB_HOST
244 #ifdef DEBUG_USB_HOST
250 #ifdef DEBUG_USB_HOST
257 #ifdef DEBUG_USB_HOST
261 #ifdef DEBUG_USB_HOST
269 HIDUniversal::HIDInterface* HIDUniversal::FindInterface(uint8_t iface, uint8_t alt, uint8_t proto) {
271 if(hidInterfaces[i].bmInterface == iface && hidInterfaces[i].bmAltSet == alt
272 && hidInterfaces[i].bmProtocol == proto)
273 return hidInterfaces + i;
279 if(bNumEP > 1 && conf != bConfNum)
289 HIDInterface *piface = FindInterface(iface, alt, proto);
293 piface = hidInterfaces + bNumIface;
294 piface->bmInterface = iface;
295 piface->bmAltSet = alt;
296 piface->bmProtocol = proto;
313 piface->epIndex[index] = bNumEP;
315 if(pollInterval < pep->bInterval)
333 bool HIDUniversal::BuffersIdentical(uint8_t len, uint8_t *buf1, uint8_t *buf2) {
334 for(uint8_t i = 0; i < len; i++)
335 if(buf1[i] != buf2[i])
340 void HIDUniversal::ZeroMemory(uint8_t len, uint8_t *buf) {
341 for(uint8_t i = 0; i < len; i++)
345 void HIDUniversal::SaveBuffer(uint8_t len, uint8_t *src, uint8_t *dest) {
346 for(uint8_t i = 0; i < len; i++)
356 if(qNextPollTime <= millis()) {
357 qNextPollTime = millis() + pollInterval;
359 uint8_t buf[constBuffLen];
361 for(uint8_t i = 0; i < bNumIface; i++) {
363 uint16_t read = (uint16_t)epInfo[index].maxPktSize;
365 ZeroMemory(constBuffLen, buf);
371 USBTRACE3(
"(hiduniversal.h) Poll:", rcode, 0x81);
375 if(read > constBuffLen)
378 bool identical = BuffersIdentical(read, buf, prevBuf);
380 SaveBuffer(read, buf, prevBuf);
385 Notify(PSTR(
"\r\nBuf: "), 0x80);
387 for(uint8_t i = 0; i < read; i++)
388 D_PrintHex<uint8_t > (buf[i], 0x80);
390 Notify(PSTR(
"\r\n"), 0x80);
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr)
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
#define USB_ERROR_EPINFO_IS_NULL
static const uint8_t epInterruptOutIndex
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
#define NotifyFailGetDevDescr(...)
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
virtual uint8_t Release()
#define CP_MASK_COMPARE_CLASS
virtual uint8_t OnInitSuccessful()
virtual void FreeAddress(uint8_t addr)=0
uint16_t wDescriptorLength
virtual UsbDevice * GetUsbDevicePtr(uint8_t addr)=0
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
#define NotifyFailGetConfDescr(...)
virtual void ParseHIDData(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
#define USB_NAK_MAX_POWER
virtual HIDReportParser * GetReportParser(uint8_t id)
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)=0
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data)
#define MAX_REPORT_PARSERS
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED
uint8_t SetIdle(uint8_t iface, uint8_t reportID, uint8_t duration)
static const uint8_t epInterruptInIndex
uint8_t bNumConfigurations
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
AddressPool & GetAddressPool()
#define USBTRACE3(s, r, l)
uint8_t RegisterDeviceClass(USBDeviceConfig *pdev)
static const uint8_t totalEndpoints
#define NotifyFailSetConfDescr(...)
#define HID_MAX_HID_CLASS_DESCRIPTORS
static const uint8_t maxEpPerInterface
virtual bool SetReportParser(uint8_t id, HIDReportParser *prs)
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
#define NotifyFailSetDevTblEntry(...)
static const uint8_t maxHidInterfaces