USB Host Shield 2.0
Loading...
Searching...
No Matches
hidcomposite.h
Go to the documentation of this file.
1/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2
3This software may be distributed and modified under the terms of the GNU
4General Public License version 2 (GPL2) as published by the Free Software
5Foundation and appearing in the file GPL2.TXT included in the packaging of
6this file. Please note that GPL2 Section 2[b] requires that all works based
7on this software must also be made publicly available under the terms of
8the GPL2 ("Copyleft").
9
10Contact information
11-------------------
12
13Circuits At Home, LTD
14Web : http://www.circuitsathome.com
15e-mail : support@circuitsathome.com
16 */
17
18#if !defined(__HIDCOMPOSITE_H__)
19#define __HIDCOMPOSITE_H__
20
21#include "usbhid.h"
22//#include "hidescriptorparser.h"
23
24class HIDComposite : public USBHID {
25
26protected:
27
32
33 // HID class specific descriptor type and length info obtained from HID descriptor
35
36 // Returns HID class specific descriptor length by its type and order number
38
39 struct HIDInterface {
40 struct {
44 };
45 uint8_t epIndex[maxEpPerInterface + 1]; // We need to make room for the control endpoint as well
46 };
47
48 uint8_t bConfNum; // configuration number
49 uint8_t bNumIface; // number of interfaces in the configuration
50 uint8_t bNumEP; // total number of EP in the configuration
51 uint32_t qNextPollTime; // next poll time
53 bool bPollEnable; // poll enable flag
54
55 static const uint16_t constBuffLen = 64; // event buffer length
56
57 void Initialize();
59
61
62
65
66 // FIXME: bHasReportId is never set (except to false in constructor)
67 // should probably be in EpInfo, /maybe/ in HIDInterface
68 // but setting it isn't that easy (requires parsing report descriptors)
70
71 uint16_t PID, VID; // PID and VID of connected device
72
73 // HID implementation
75
77 return 0;
78 };
79
80 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))) {
81 return;
82 };
83
84public:
86
87 // HID implementation
89
90 // USBDeviceConfig implementation
91 uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
93 uint8_t Poll();
94
95 virtual uint8_t GetAddress() {
96 return bAddress;
97 };
98
99 virtual bool isReady() {
100 return bPollEnable;
101 };
102
103 // UsbConfigXtracter implementation
105
106 // Send report - do not mix with SetReport()!
108
109 // Returns true if we should listen on an interface, false if not
111};
112
113#endif // __HIDCOMPOSITE_H__
virtual uint8_t OnInitSuccessful()
uint16_t PID
uint32_t qNextPollTime
HIDReportParser * GetReportParser(uint8_t id)
uint8_t Release()
static const uint16_t constBuffLen
HIDInterface hidInterfaces[maxHidInterfaces]
virtual bool isReady()
EpInfo epInfo[totalEndpoints]
HIDInterface * FindInterface(uint8_t iface, uint8_t alt, uint8_t proto)
struct HIDComposite::ReportParser rptParsers[MAX_REPORT_PARSERS]
uint8_t SndRpt(uint16_t nbytes, uint8_t *dataptr)
HID_CLASS_DESCRIPTOR_LEN_AND_TYPE descrInfo[HID_MAX_HID_CLASS_DESCRIPTORS]
virtual uint8_t GetAddress()
uint8_t bConfNum
bool SetReportParser(uint8_t id, HIDReportParser *prs)
void ZeroMemory(uint8_t len, uint8_t *buf)
uint16_t GetHidClassDescrLen(uint8_t type, uint8_t num)
void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
virtual void ParseHIDData(USBHID *hid, uint8_t ep, bool is_rpt_id, uint8_t len, uint8_t *buf)
uint8_t bNumIface
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
uint16_t VID
virtual bool SelectInterface(uint8_t iface, uint8_t proto)=0
uint8_t pollInterval
uint8_t bNumEP
static const uint8_t totalEndpoints
Definition usbhid.h:154
uint8_t bAddress
Definition usbhid.h:146
static const uint8_t maxHidInterfaces
Definition usbhid.h:152
static const uint8_t maxEpPerInterface
Definition usbhid.h:153
Definition UsbCore.h:220
uint8_t epIndex[maxEpPerInterface+1]
HIDReportParser * rptParser
#define HID_MAX_HID_CLASS_DESCRIPTORS
Definition usbhid.h:24
#define MAX_REPORT_PARSERS
Definition usbhid.h:23