hid.h
1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef __HID_H__
#define __HID_H__
#define HID_CLASS_DESPT_HID 0x21
#define HID_CLASS_DESPT_REPORT 0x22
#define HID_CLASS_DESPT_PHYSICAL 0x23
#define HID_CLASSREQ_GET_DESCRIPTOR ( (0x81 << 8) | 0x06 )
#define HID_CLASSREQ_TYPE_H2D 0x21
#define HID_CLASSREQ_TYPE_D2H 0xa1
#define HID_BREQ_GET_RPT 0x01
#define HID_BREQ_GET_IDLE 0x02
#define HID_BREQ_GET_PROTOCOL 0x03
#define HID_BREQ_SET_RPT 0x09
#define HID_BREQ_SET_IDLE 0x0a
#define HID_BREQ_SET_PROTOCOL 0x0b
#define HID_CLASSREQ_GET_RPT ( (HID_CLASSREQ_TYPE_D2H << 8) | HID_BREQ_GET_RPT )
#define HID_CLASSREQ_SET_RPT ( (HID_CLASSREQ_TYPE_H2D << 8) | HID_BREQ_SET_RPT )
typedef struct {
U8 bLength;
U8 bDesptType;
U16 bcdHID;
U8 bCountry;
U8 bNumClassDespt;
U8 bClassDesptType;
U16 wDesptLengh;
U8 bClassDesptType1;
U16 wDesptLengh1;
// more ?
} __attribute__((packed)) HID_DESCRIPTOR ;
#define HID_DESCRIPTOR_MIN_SIZE 9
typedef struct {
USB_INTERFACE_DESCRIPTOR *intf;
HID_DESCRIPTOR *hid;
USB_ENDPOINT_DESCRIPTOR *intIn;
USB_ENDPOINT_DESCRIPTOR *intOut;
U8 *report;
int reportSize;
//ignore physical descriptor
} HID_INTF;
int hid_init(void);
int hid_open(USB_DEVICE *usbdev, HID_INTF *intf);
int hid_close(void);
int hid_submitIntIn( void );
int hid_removeIntIn( void );
int hid_parseReportDespt( U8 *rptBuf, int buflen );
#endif //__HID_H__