1 /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
3 This software may be distributed and modified under the terms of the GNU
4 General Public License version 2 (GPL2) as published by the Free Software
5 Foundation and appearing in the file GPL2.TXT included in the packaging of
6 this file. Please note that GPL2 Section 2[b] requires that all works based
7 on this software must also be made publicly available under the terms of
14 Web : http://www.circuitsathome.com
15 e-mail : support@circuitsathome.com
18 #if !defined(__HIDUNIVERSAL_H__)
19 #define __HIDUNIVERSAL_H__
22 //#include "hidescriptorparser.h"
24 class HIDUniversal : public HID {
28 HIDReportParser *rptParser;
29 } rptParsers[MAX_REPORT_PARSERS];
31 // HID class specific descriptor type and length info obtained from HID descriptor
32 HID_CLASS_DESCRIPTOR_LEN_AND_TYPE descrInfo[HID_MAX_HID_CLASS_DESCRIPTORS];
34 // Returns HID class specific descriptor length by its type and order number
35 uint16_t GetHidClassDescrLen(uint8_t type, uint8_t num);
39 uint8_t bmInterface : 3;
41 uint8_t bmProtocol : 2;
43 uint8_t epIndex[maxEpPerInterface];
46 uint8_t bConfNum; // configuration number
47 uint8_t bNumIface; // number of interfaces in the configuration
48 uint8_t bNumEP; // total number of EP in the configuration
49 uint32_t qNextPollTime; // next poll time
51 bool bPollEnable; // poll enable flag
53 static const uint16_t constBuffLen = 64; // event buffer length
54 uint8_t prevBuf[constBuffLen]; // previous event buffer
57 HIDInterface* FindInterface(uint8_t iface, uint8_t alt, uint8_t proto);
59 void ZeroMemory(uint8_t len, uint8_t *buf);
60 bool BuffersIdentical(uint8_t len, uint8_t *buf1, uint8_t *buf2);
61 void SaveBuffer(uint8_t len, uint8_t *src, uint8_t *dest);
64 EpInfo epInfo[totalEndpoints];
65 HIDInterface hidInterfaces[maxHidInterfaces];
69 uint16_t PID, VID; // PID and VID of connected device
72 HIDReportParser* GetReportParser(uint8_t id);
74 virtual uint8_t OnInitSuccessful() {
78 virtual void ParseHIDData(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {
86 bool SetReportParser(uint8_t id, HIDReportParser *prs);
88 // USBDeviceConfig implementation
89 uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
93 virtual uint8_t GetAddress() {
97 virtual bool isReady() {
101 // UsbConfigXtracter implementation
102 void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
104 // Send report - do not mix with SetReport()!
105 uint8_t SndRpt(uint16_t nbytes, uint8_t *dataptr);
108 #endif // __HIDUNIVERSAL_H__