Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
Dieses Repo ist archiviert. Du kannst Dateien sehen und es klonen, kannst aber nicht pushen oder Issues/Pull-Requests öffnen.

hiduniversal.h 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
  2. This software may be distributed and modified under the terms of the GNU
  3. General Public License version 2 (GPL2) as published by the Free Software
  4. Foundation and appearing in the file GPL2.TXT included in the packaging of
  5. this file. Please note that GPL2 Section 2[b] requires that all works based
  6. on this software must also be made publicly available under the terms of
  7. the GPL2 ("Copyleft").
  8. Contact information
  9. -------------------
  10. Circuits At Home, LTD
  11. Web : http://www.circuitsathome.com
  12. e-mail : [email protected]
  13. */
  14. #if !defined(__HIDUNIVERSAL_H__)
  15. #define __HIDUNIVERSAL_H__
  16. #include "hid.h"
  17. //#include "hidescriptorparser.h"
  18. class HIDUniversal : public HID {
  19. struct ReportParser {
  20. uint8_t rptId;
  21. HIDReportParser *rptParser;
  22. } rptParsers[MAX_REPORT_PARSERS];
  23. // HID class specific descriptor type and length info obtained from HID descriptor
  24. HID_CLASS_DESCRIPTOR_LEN_AND_TYPE descrInfo[HID_MAX_HID_CLASS_DESCRIPTORS];
  25. // Returns HID class specific descriptor length by its type and order number
  26. uint16_t GetHidClassDescrLen(uint8_t type, uint8_t num);
  27. struct HIDInterface {
  28. struct {
  29. uint8_t bmInterface : 3;
  30. uint8_t bmAltSet : 3;
  31. uint8_t bmProtocol : 2;
  32. };
  33. uint8_t epIndex[maxEpPerInterface];
  34. };
  35. uint8_t bConfNum; // configuration number
  36. uint8_t bNumIface; // number of interfaces in the configuration
  37. uint8_t bNumEP; // total number of EP in the configuration
  38. uint32_t qNextPollTime; // next poll time
  39. uint8_t pollInterval;
  40. bool bPollEnable; // poll enable flag
  41. static const uint16_t constBuffLen = 64; // event buffer length
  42. uint8_t prevBuf[constBuffLen]; // previous event buffer
  43. void Initialize();
  44. HIDInterface* FindInterface(uint8_t iface, uint8_t alt, uint8_t proto);
  45. void ZeroMemory(uint8_t len, uint8_t *buf);
  46. bool BuffersIdentical(uint8_t len, uint8_t *buf1, uint8_t *buf2);
  47. void SaveBuffer(uint8_t len, uint8_t *src, uint8_t *dest);
  48. protected:
  49. EpInfo epInfo[totalEndpoints];
  50. HIDInterface hidInterfaces[maxHidInterfaces];
  51. bool bHasReportId;
  52. uint16_t PID, VID; // PID and VID of connected device
  53. // HID implementation
  54. HIDReportParser* GetReportParser(uint8_t id);
  55. virtual uint8_t OnInitSuccessful() {
  56. return 0;
  57. };
  58. virtual void ParseHIDData(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {
  59. return;
  60. };
  61. public:
  62. HIDUniversal(USB *p);
  63. // HID implementation
  64. bool SetReportParser(uint8_t id, HIDReportParser *prs);
  65. // USBDeviceConfig implementation
  66. uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
  67. uint8_t Release();
  68. uint8_t Poll();
  69. virtual uint8_t GetAddress() {
  70. return bAddress;
  71. };
  72. virtual bool isReady() {
  73. return bPollEnable;
  74. };
  75. // UsbConfigXtracter implementation
  76. void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
  77. // Send report - do not mix with SetReport()!
  78. uint8_t SndRpt(uint16_t nbytes, uint8_t *dataptr);
  79. };
  80. #endif // __HIDUNIVERSAL_H__