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  {
11  uint8_t rptId;
12  HIDReportParser *rptParser;
13  } rptParsers[MAX_REPORT_PARSERS];
14 
15  // HID class specific descriptor type and length info obtained from HID descriptor
17 
18  // Returns HID class specific descriptor length by its type and order number
19  uint16_t GetHidClassDescrLen(uint8_t type, uint8_t num);
20 
21  EpInfo epInfo[totalEndpoints];
22 
23  struct HIDInterface
24  {
25  struct
26  {
27  uint8_t bmInterface : 3;
28  uint8_t bmAltSet : 3;
29  uint8_t bmProtocol : 2;
30  };
31  uint8_t epIndex[maxEpPerInterface];
32  };
33 
34  HIDInterface hidInterfaces[maxHidInterfaces];
35 
36  uint8_t bConfNum; // configuration number
37  uint8_t bNumIface; // number of interfaces in the configuration
38  uint8_t bNumEP; // total number of EP in the configuration
39  uint32_t qNextPollTime; // next poll time
40  bool bPollEnable; // poll enable flag
41 
42  static const uint16_t constBuffLen = 64; // event buffer length
43  uint8_t prevBuf[constBuffLen]; // previous event buffer
44 
45  void Initialize();
46  HIDInterface* FindInterface(uint8_t iface, uint8_t alt, uint8_t proto);
47 
48  void ZeroMemory(uint8_t len, uint8_t *buf);
49  bool BuffersIdentical(uint8_t len, uint8_t *buf1, uint8_t *buf2);
50  void SaveBuffer(uint8_t len, uint8_t *src, uint8_t *dest);
51 
52 protected:
54 
55  // HID implementation
56  virtual HIDReportParser* GetReportParser(uint8_t id);
57  virtual uint8_t OnInitSuccessful() { return 0; };
58 
59 public:
60  HIDUniversal(USB *p);
61 
62  // HID implementation
63  virtual bool SetReportParser(uint8_t id, HIDReportParser *prs);
64 
65  // USBDeviceConfig implementation
66  virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
67  virtual uint8_t Release();
68  virtual uint8_t Poll();
69  virtual uint8_t GetAddress() { return bAddress; };
70 
71  // UsbConfigXtracter implementation
72  virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
73 };
74 
75 #endif // __HIDUNIVERSAL_H__