USB Host Shield 2.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
hiduniversal.h
Go to the documentation of this file.
1 #if !defined(__HIDUNIVERSAL_H__)
2 #define __HIDUNIVERSAL_H__
3 
4 #include "hid.h"
5 //#include "hidescriptorparser.h"
6 
7 class HIDUniversal : public HID {
8 
9  struct ReportParser {
10  uint8_t rptId;
11  HIDReportParser *rptParser;
12  } rptParsers[MAX_REPORT_PARSERS];
13 
14  // HID class specific descriptor type and length info obtained from HID descriptor
16 
17  // Returns HID class specific descriptor length by its type and order number
18  uint16_t GetHidClassDescrLen(uint8_t type, uint8_t num);
19 
20  EpInfo epInfo[totalEndpoints];
21 
22  struct HIDInterface {
23 
24  struct {
25  uint8_t bmInterface : 3;
26  uint8_t bmAltSet : 3;
27  uint8_t bmProtocol : 2;
28  };
29  uint8_t epIndex[maxEpPerInterface];
30  };
31 
32  HIDInterface hidInterfaces[maxHidInterfaces];
33 
34  uint8_t bConfNum; // configuration number
35  uint8_t bNumIface; // number of interfaces in the configuration
36  uint8_t bNumEP; // total number of EP in the configuration
37  uint32_t qNextPollTime; // next poll time
38  bool bPollEnable; // poll enable flag
39 
40  static const uint16_t constBuffLen = 64; // event buffer length
41  uint8_t prevBuf[constBuffLen]; // previous event buffer
42 
43  void Initialize();
44  HIDInterface* FindInterface(uint8_t iface, uint8_t alt, uint8_t proto);
45 
46  void ZeroMemory(uint8_t len, uint8_t *buf);
47  bool BuffersIdentical(uint8_t len, uint8_t *buf1, uint8_t *buf2);
48  void SaveBuffer(uint8_t len, uint8_t *src, uint8_t *dest);
49 
50 protected:
52 
53  // HID implementation
54  virtual HIDReportParser* GetReportParser(uint8_t id);
55 
56  virtual uint8_t OnInitSuccessful() {
57  return 0;
58  };
59 
60 public:
61  HIDUniversal(USB *p);
62 
63  // HID implementation
64  virtual bool SetReportParser(uint8_t id, HIDReportParser *prs);
65 
66  // USBDeviceConfig implementation
67  virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
68  virtual uint8_t Release();
69  virtual uint8_t Poll();
70 
71  virtual uint8_t GetAddress() {
72  return bAddress;
73  };
74 
75  // UsbConfigXtracter implementation
76  virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
77 };
78 
79 #endif // __HIDUNIVERSAL_H__
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
bool bHasReportId
Definition: hiduniversal.h:51
uint8_t bAddress
Definition: hid.h:146
virtual uint8_t Release()
virtual uint8_t OnInitSuccessful()
Definition: hiduniversal.h:56
virtual uint8_t Poll()
virtual HIDReportParser * GetReportParser(uint8_t id)
Definition: address.h:32
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
HIDUniversal(USB *p)
Definition: hiduniversal.cpp:3
Definition: hid.h:143
#define MAX_REPORT_PARSERS
Definition: hid.h:23
Definition: UsbCore.h:176
virtual uint8_t GetAddress()
Definition: hiduniversal.h:71
static const uint8_t totalEndpoints
Definition: hid.h:154
#define HID_MAX_HID_CLASS_DESCRIPTORS
Definition: hid.h:24
static const uint8_t maxEpPerInterface
Definition: hid.h:153
virtual bool SetReportParser(uint8_t id, HIDReportParser *prs)
static const uint8_t maxHidInterfaces
Definition: hid.h:152