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.
hidcomposite.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(__HIDCOMPOSITE_H__) 00019 #define __HIDCOMPOSITE_H__ 00020 00021 #include "usbhid.h" 00022 //#include "hidescriptorparser.h" 00023 00024 class HIDComposite : 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]; 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 00055 void Initialize(); 00056 HIDInterface* FindInterface(uint8_t iface, uint8_t alt, uint8_t proto); 00057 00058 void ZeroMemory(uint8_t len, uint8_t *buf); 00059 00060 protected: 00061 EpInfo epInfo[totalEndpoints]; 00062 HIDInterface hidInterfaces[maxHidInterfaces]; 00063 00064 bool bHasReportId; 00065 00066 uint16_t PID, VID; // PID and VID of connected device 00067 00068 // HID implementation 00069 HIDReportParser* GetReportParser(uint8_t id); 00070 00071 virtual uint8_t OnInitSuccessful() { 00072 return 0; 00073 }; 00074 00075 virtual void ParseHIDData(USBHID *hid __attribute__((unused)), uint8_t ep __attribute__((unused)), bool is_rpt_id __attribute__((unused)), uint8_t len __attribute__((unused)), uint8_t *buf __attribute__((unused))) { 00076 return; 00077 }; 00078 00079 public: 00080 HIDComposite(USB *p); 00081 00082 // HID implementation 00083 bool SetReportParser(uint8_t id, HIDReportParser *prs); 00084 00085 // USBDeviceConfig implementation 00086 uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); 00087 uint8_t Release(); 00088 uint8_t Poll(); 00089 00090 virtual uint8_t GetAddress() { 00091 return bAddress; 00092 }; 00093 00094 virtual bool isReady() { 00095 return bPollEnable; 00096 }; 00097 00098 // UsbConfigXtracter implementation 00099 void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); 00100 00101 // Send report - do not mix with SetReport()! 00102 uint8_t SndRpt(uint16_t nbytes, uint8_t *dataptr); 00103 00104 // Returns true if we should listen on an interface, false if not 00105 virtual bool SelectInterface(uint8_t iface, uint8_t proto) = 0; 00106 }; 00107 00108 #endif // __HIDCOMPOSITE_H__ 00109
Generated on Thu Jul 14 2022 08:33:41 by
1.7.2