Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: UsbHostMAX3421E_Hello
hiduniversal.h
00001 /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 00002 00003 This software may be distributed and modified under the terms of the GNU 00004 General Public License version 2 (GPL2) as published by the Free Software 00005 Foundation and appearing in the file GPL2.TXT included in the packaging of 00006 this file. Please note that GPL2 Section 2[b] requires that all works based 00007 on this software must also be made publicly available under the terms of 00008 the GPL2 ("Copyleft"). 00009 00010 Contact information 00011 ------------------- 00012 00013 Circuits At Home, LTD 00014 Web : http://www.circuitsathome.com 00015 e-mail : support@circuitsathome.com 00016 */ 00017 00018 #if !defined(__HIDUNIVERSAL_H__) 00019 #define __HIDUNIVERSAL_H__ 00020 00021 #include "usbhid.h" 00022 //#include "hidescriptorparser.h" 00023 00024 class HIDUniversal : public USBHID { 00025 00026 struct ReportParser { 00027 uint8_t rptId; 00028 HIDReportParser *rptParser; 00029 } rptParsers[MAX_REPORT_PARSERS]; 00030 00031 // HID class specific descriptor type and length info obtained from HID descriptor 00032 HID_CLASS_DESCRIPTOR_LEN_AND_TYPE descrInfo[HID_MAX_HID_CLASS_DESCRIPTORS]; 00033 00034 // Returns HID class specific descriptor length by its type and order number 00035 uint16_t GetHidClassDescrLen(uint8_t type, uint8_t num); 00036 00037 struct HIDInterface { 00038 struct { 00039 uint8_t bmInterface : 3; 00040 uint8_t bmAltSet : 3; 00041 uint8_t bmProtocol : 2; 00042 }; 00043 uint8_t epIndex[maxEpPerInterface + 1]; // We need to make room for the control endpoint as well 00044 }; 00045 00046 uint8_t bConfNum; // configuration number 00047 uint8_t bNumIface; // number of interfaces in the configuration 00048 uint8_t bNumEP; // total number of EP in the configuration 00049 uint32_t qNextPollTime; // next poll time 00050 uint8_t pollInterval; 00051 bool bPollEnable; // poll enable flag 00052 00053 static const uint16_t constBuffLen = 64; // event buffer length 00054 uint8_t prevBuf[constBuffLen]; // previous event buffer 00055 00056 void Initialize(); 00057 HIDInterface* FindInterface(uint8_t iface, uint8_t alt, uint8_t proto); 00058 00059 void ZeroMemory(uint8_t len, uint8_t *buf); 00060 bool BuffersIdentical(uint8_t len, uint8_t *buf1, uint8_t *buf2); 00061 void SaveBuffer(uint8_t len, uint8_t *src, uint8_t *dest); 00062 00063 protected: 00064 EpInfo epInfo[totalEndpoints]; 00065 HIDInterface hidInterfaces[maxHidInterfaces]; 00066 00067 bool bHasReportId; 00068 00069 uint16_t PID, VID; // PID and VID of connected device 00070 00071 // HID implementation 00072 HIDReportParser* GetReportParser(uint8_t id); 00073 00074 virtual uint8_t OnInitSuccessful() { 00075 return 0; 00076 }; 00077 00078 virtual void ParseHIDData(USBHID *hid __attribute__((unused)), bool is_rpt_id __attribute__((unused)), uint8_t len __attribute__((unused)), uint8_t *buf __attribute__((unused))) { 00079 return; 00080 }; 00081 00082 public: 00083 HIDUniversal(Usb *p); 00084 00085 // HID implementation 00086 bool SetReportParser(uint8_t id, HIDReportParser *prs); 00087 00088 // USBDeviceConfig implementation 00089 uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); 00090 uint8_t Release(); 00091 uint8_t Poll(); 00092 00093 virtual uint8_t GetAddress() { 00094 return bAddress; 00095 }; 00096 00097 virtual bool isReady() { 00098 return bPollEnable; 00099 }; 00100 00101 // UsbConfigXtracter implementation 00102 void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); 00103 00104 // Send report - do not mix with SetReport()! 00105 uint8_t SndRpt(uint16_t nbytes, uint8_t *dataptr); 00106 }; 00107 00108 #endif // __HIDUNIVERSAL_H__
Generated on Tue Jul 12 2022 18:12:04 by
1.7.2