LPC1768的USB-相关结构体定义

#ifndef __USB_H__

#define __USB_H__

//usb传输数据的宏定义描述

#include "sys.h"

typedef __packed union {

U16 W;

__packed struct {

U8 L;

U8 H;

} WB;

} U16_8;//定义一个16位长度的结构体并且内部分成两个八位,因为wvalue windex经常要做分开处理

//请求类型方向定义

#define REQUEST_HOST_TO_DEVICE     0    //主机到设备的请求

#define REQUEST_DEVICE_TO_HOST     1    //设备到主机的请求

/*请求类型的具体类型定义*/

#define REQUEST_STANDARD           0    //标准请求

#define REQUEST_CLASS              1    //类请求

#define REQUEST_VENDOR             2    //厂商请求

#define REQUEST_RESERVED           3    //保留请求

/* 请求的接受者定义 */

#define REQUEST_TO_DEVICE          0    //请求设备

#define REQUEST_TO_INTERFACE       1    //请求接口

#define REQUEST_TO_ENDPOINT        2    //请求端点

#define REQUEST_TO_OTHER           3    //3-41保留请求

/* 请求类型字节定义*/

typedef __packed union _REQUEST_TYPE {

__packed struct _BM {

U8 Recipient : 5;   //请求的对象,接受者 0-4

U8 Type      : 2;   //请求的类型 5-6

U8 Dir       : 1;   //请求的方向 7位

} BM;

U8 B;

} REQUEST_TYPE;

/* usb标准请求的请求代码 brequest */

#define USB_REQUEST_GET_STATUS                 0    //获取设备状态

#define USB_REQUEST_CLEAR_FEATURE              1    //清除设备特性

#define USB_REQUEST_SET_FEATURE                3    //设置设备特性

#define USB_REQUEST_SET_ADDRESS                5    //设置设备地址(地址是带方向的)

#define USB_REQUEST_GET_DESCRIPTOR             6    //获取描述符

#define USB_REQUEST_SET_DESCRIPTOR             7    //设置描述符

#define USB_REQUEST_GET_CONFIGURATION          8    //获取配置

#define USB_REQUEST_SET_CONFIGURATION          9    //设置配置

#define USB_REQUEST_GET_INTERFACE              10   //获取接口

#define USB_REQUEST_SET_INTERFACE              11   //设置接口

#define USB_REQUEST_SYNC_FRAME                 12   //同步帧请求

/* usb获取状态的命令描述 */

#define USB_GETSTATUS_SELF_POWERED             0x01 //电源状态

#define USB_GETSTATUS_REMOTE_WAKEUP            0x02 //远程唤醒设备

#define USB_GETSTATUS_ENDPOINT_STALL           0x01 //端点stall(休眠,暂停,知道下一个setup包发送)

/* usb标准特性请求 */

#define USB_FEATURE_ENDPOINT_STALL             0    //端点暂停

#define USB_FEATURE_REMOTE_WAKEUP              1    //远程唤醒

/* usb setup包的数据定义 */

typedef __packed struct _USB_SETUP_PACKET {

REQUEST_TYPE bmRequestType;   //请求类型

U8           bRequest;    //请求代码

U16_8        wValue;

U16_8        wIndex;

U16          wLength; //这个数据长度需要注意(获取描述符中过程中,这个代表我们能返回的最大包长度,不得超过这个值)

} USB_SETUP_PACKET;

/* wvalue的低字节 获取描述符的分类 */

#define USB_DEVICE_DESCRIPTOR_TYPE                  1   //获取设备描述符

#define USB_CONFIGURATION_DESCRIPTOR_TYPE           2   //获取配置描述符

#define USB_STRING_DESCRIPTOR_TYPE                  3   //获取字符串描述符

#define USB_INTERFACE_DESCRIPTOR_TYPE               4   //获取接口描述符

#define USB_ENDPOINT_DESCRIPTOR_TYPE                5   //获取端点描述符

#define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE        6   //不知道是啥

#define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE      7   //不知道是啥

#define USB_INTERFACE_POWER_DESCRIPTOR_TYPE         8   //不知道是啥

#define USB_OTG_DESCRIPTOR_TYPE                     9   //获取otg描述符

#define USB_DEBUG_DESCRIPTOR_TYPE                  10   //获取调试描述符

#define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE  11   //不知道

/* usb的设备类定义(在描述符中有用) */

#define USB_DEVICE_CLASS_RESERVED              0x00 //保留设备类型

#define USB_DEVICE_CLASS_AUDIO                 0x01 //音频设备

#define USB_DEVICE_CLASS_COMMUNICATIONS        0x02 //通讯设备

#define USB_DEVICE_CLASS_HUMAN_INTERFACE       0x03 //HID设备

#define USB_DEVICE_CLASS_MONITOR               0x04 //驱动设备

#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE    0x05 //物理接口设备

#define USB_DEVICE_CLASS_POWER                 0x06 //电源设备

#define USB_DEVICE_CLASS_PRINTER               0x07 //打印设备

#define USB_DEVICE_CLASS_STORAGE               0x08 //存储设备

#define USB_DEVICE_CLASS_HUB                   0x09 //hub设备

#define USB_DEVICE_CLASS_MISCELLANEOUS         0xEF //

#define USB_DEVICE_CLASS_VENDOR_SPECIFIC       0xFF

/* 设备属性值定义*/

#define USB_CONFIG_POWERED_MASK                0x40 //开机状态?

#define USB_CONFIG_BUS_POWERED                 0x80 //总线供电

#define USB_CONFIG_SELF_POWERED                0xC0 //自身带电

#define USB_CONFIG_REMOTE_WAKEUP               0x20 //使能远程唤醒

/* 最大总线需求电流(未识别的情况下统一是100MA,识别之后才根据实际配置选择电流,不大于800MA) */

#define USB_CONFIG_POWER_MA(mA)                ((mA)/2)

/* 端点地址描述 */

#define USB_ENDPOINT_DIRECTION_MASK            0x80

#define USB_ENDPOINT_OUT(addr)                 ((addr) | 0x00)

#define USB_ENDPOINT_IN(addr)                  ((addr) | 0x80)  //输入端点,最高位应该为1,用于向主机输入数据

/* 端点特性描述*/

#define USB_ENDPOINT_TYPE_MASK                 0x03 //端点类型掩码

#define USB_ENDPOINT_TYPE_CONTROL              0x00 //控制端点

#define USB_ENDPOINT_TYPE_ISOCHRONOUS          0x01 //同步端点

#define USB_ENDPOINT_TYPE_BULK                 0x02 //批量端点

#define USB_ENDPOINT_TYPE_INTERRUPT            0x03 //中断端点

#define USB_ENDPOINT_SYNC_MASK                 0x0C //同步传输类型掩码

#define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION   0x00

#define USB_ENDPOINT_SYNC_ASYNCHRONOUS         0x04

#define USB_ENDPOINT_SYNC_ADAPTIVE             0x08

#define USB_ENDPOINT_SYNC_SYNCHRONOUS          0x0C

#define USB_ENDPOINT_USAGE_MASK                0x30 //端点用途掩码

#define USB_ENDPOINT_USAGE_DATA                0x00

#define USB_ENDPOINT_USAGE_FEEDBACK            0x10 //反馈类型

#define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK   0x20

#define USB_ENDPOINT_USAGE_RESERVED            0x30

/* usb标准设备描述符,一般为18字节 */

typedef __packed struct _USB_DEVICE_DESCRIPTOR {

U8  bLength;//设备描述符长度

U8  bDescriptorType;//设备描述符编号

U16 bcdUSB;//使用的usb版本,小端结构 低字节在前

U8  bDeviceClass;//设备类(可以不定义设备类为0,在配置描述符中定义)

U8  bDeviceSubClass;//设备子类

U8  bDeviceProtocol;//设备protocal

U8  bMaxPacketSize0;//控制端点0的最大长度

U16 idVendor; //VID,厂商ID号码

U16 idProduct;//PID 产品id号码

U16 bcdDevice;//设备的版本

U8  iManufacturer;//厂商字符串的索引值

U8  iProduct; //产品字符串的索引值

U8  iSerialNumber;//产品序列号的索引值

U8  bNumConfigurations;//usb的配置数量

} USB_DEVICE_DESCRIPTOR;

/* USB 2.0 Device Qualifier Descriptor usb2.0的东西,不知道做什么的*/

typedef __packed struct _USB_DEVICE_QUALIFIER_DESCRIPTOR {

U8  bLength;

U8  bDescriptorType;

U16 bcdUSB;

U8  bDeviceClass;

U8  bDeviceSubClass;

U8  bDeviceProtocol;

U8  bMaxPacketSize0;

U8  bNumConfigurations;

U8  bReserved;

} USB_DEVICE_QUALIFIER_DESCRIPTOR;

/*usb标准配置描述符*/

typedef __packed struct _USB_CONFIGURATION_DESCRIPTOR {

U8  bLength;//描述符长度

U8  bDescriptorType;//配置描述符的编号

U16 wTotalLength;//配置描述符集合的总长度,包括配置描述符本身、接口描述符、类描述符、端点描述符等

U8  bNumInterfaces;//配置包含的接口数

U8  bConfigurationValue;//配置的值

U8  iConfiguration;//配置的字符串索引

U8  bmAttributes;//设备属性

U8  bMaxPower;//设备需要的最大电流

} USB_CONFIGURATION_DESCRIPTOR;//配置描述符

/* usb标准接口描述符 */

typedef __packed struct _USB_INTERFACE_DESCRIPTOR {

U8  bLength;//接口描述符长度

U8  bDescriptorType;//接口描述符的类型,也就是编号 固定为04

U8  bInterfaceNumber;//该接口的编号

U8  bAlternateSetting;//该接口的备用编号

U8  bNumEndpoints;//接口包含的非0端点数目

U8  bInterfaceClass;//接口使用的类

U8  bInterfaceSubClass;//接口使用的子类

U8  bInterfaceProtocol;//接口使用的协议

U8  iInterface;//接口的字符串索引值

} USB_INTERFACE_DESCRIPTOR;

/* usb标准端点描述符 */

typedef __packed struct _USB_ENDPOINT_DESCRIPTOR {

U8  bLength;//端点描述符长度

U8  bDescriptorType;//端点描述符编号,固定为5

U8  bEndpointAddress;//端点地址,注意输入输出

U8  bmAttributes;//端点特性(是哪一类端点)

U16 wMaxPacketSize;//端点最大包长度

U8  bInterval;//端点查询时间帧时间 usb1.1 一帧1ms

} USB_ENDPOINT_DESCRIPTOR;

/* usb字符串描述符 */

typedef __packed struct _USB_STRING_DESCRIPTOR {

U8  bLength;//字符串描述符长度

U8  bDescriptorType;//字符串描述符类型,固定为3

U16 bString/*[]*/;//描述字符串的数组,指针?

} USB_STRING_DESCRIPTOR;

/* USB通用描述符(usb描述符通常都是以这样的格式开头 长度+描述符类型(描述符类型上面有))*/

typedef __packed struct _USB_COMMON_DESCRIPTOR {

U8  bLength;

U8  bDescriptorType;

} USB_COMMON_DESCRIPTOR;

#endif  /* __USB_H__ */

#ifndef __HID_H__

#define __HID_H__

/* HID Subclass Codes */

#define HID_SUBCLASS_NONE               0x00

#define HID_SUBCLASS_BOOT               0x01

/* HID Protocol Codes */

#define HID_PROTOCOL_NONE               0x00

#define HID_PROTOCOL_KEYBOARD           0x01

#define HID_PROTOCOL_MOUSE              0x02

/* HID Descriptor Types */

#define HID_HID_DESCRIPTOR_TYPE         0x21

#define HID_REPORT_DESCRIPTOR_TYPE      0x22

#define HID_PHYSICAL_DESCRIPTOR_TYPE    0x23

/* HID Descriptor */

typedef __packed struct _HID_DESCRIPTOR

{

U8 bLength;

U8 bDescriptorType;

U16 bcdHID;

U8 bCountryCode;

U8 bNumDescriptors;

/* Array of one or more descriptors */

__packed struct _HID_DESCRIPTOR_LIST

{

U8 bDescriptorType;

U16 wDescriptorLength;

}DescriptorList[1];

} HID_DESCRIPTOR;

/* HID Request Codes */

#define HID_REQUEST_GET_REPORT          0x01

#define HID_REQUEST_GET_IDLE            0x02

#define HID_REQUEST_GET_PROTOCOL        0x03

#define HID_REQUEST_SET_REPORT          0x09

#define HID_REQUEST_SET_IDLE            0x0A

#define HID_REQUEST_SET_PROTOCOL        0x0B

/* HID Report Types */

#define HID_REPORT_INPUT                0x01

#define HID_REPORT_OUTPUT               0x02

#define HID_REPORT_FEATURE              0x03

/* Usage Pages */

#define HID_USAGE_PAGE_UNDEFINED        0x00

#define HID_USAGE_PAGE_GENERIC          0x01

#define HID_USAGE_PAGE_SIMULATION       0x02

#define HID_USAGE_PAGE_VR               0x03

#define HID_USAGE_PAGE_SPORT            0x04

#define HID_USAGE_PAGE_GAME             0x05

#define HID_USAGE_PAGE_DEV_CONTROLS     0x06

#define HID_USAGE_PAGE_KEYBOARD         0x07

#define HID_USAGE_PAGE_LED              0x08

#define HID_USAGE_PAGE_BUTTON           0x09

#define HID_USAGE_PAGE_ORDINAL          0x0A

#define HID_USAGE_PAGE_TELEPHONY        0x0B

#define HID_USAGE_PAGE_CONSUMER         0x0C

#define HID_USAGE_PAGE_DIGITIZER        0x0D

#define HID_USAGE_PAGE_UNICODE          0x10

#define HID_USAGE_PAGE_ALPHANUMERIC     0x14

/* ... */

/* Generic Desktop Page (0x01) */

#define HID_USAGE_GENERIC_POINTER               0x01

#define HID_USAGE_GENERIC_MOUSE                 0x02

#define HID_USAGE_GENERIC_JOYSTICK              0x04

#define HID_USAGE_GENERIC_GAMEPAD               0x05

#define HID_USAGE_GENERIC_KEYBOARD              0x06

#define HID_USAGE_GENERIC_KEYPAD                0x07

#define HID_USAGE_GENERIC_X                     0x30

#define HID_USAGE_GENERIC_Y                     0x31

#define HID_USAGE_GENERIC_Z                     0x32

#define HID_USAGE_GENERIC_RX                    0x33

#define HID_USAGE_GENERIC_RY                    0x34

#define HID_USAGE_GENERIC_RZ                    0x35

#define HID_USAGE_GENERIC_SLIDER                0x36

#define HID_USAGE_GENERIC_DIAL                  0x37

#define HID_USAGE_GENERIC_WHEEL                 0x38

#define HID_USAGE_GENERIC_HATSWITCH             0x39

#define HID_USAGE_GENERIC_COUNTED_BUFFER        0x3A

#define HID_USAGE_GENERIC_BYTE_COUNT            0x3B

#define HID_USAGE_GENERIC_MOTION_WAKEUP         0x3C

#define HID_USAGE_GENERIC_VX                    0x40

#define HID_USAGE_GENERIC_VY                    0x41

#define HID_USAGE_GENERIC_VZ                    0x42

#define HID_USAGE_GENERIC_VBRX                  0x43

#define HID_USAGE_GENERIC_VBRY                  0x44

#define HID_USAGE_GENERIC_VBRZ                  0x45

#define HID_USAGE_GENERIC_VNO                   0x46

#define HID_USAGE_GENERIC_SYSTEM_CTL            0x80

#define HID_USAGE_GENERIC_SYSCTL_POWER          0x81

#define HID_USAGE_GENERIC_SYSCTL_SLEEP          0x82

#define HID_USAGE_GENERIC_SYSCTL_WAKE           0x83

#define HID_USAGE_GENERIC_SYSCTL_CONTEXT_MENU   0x84

#define HID_USAGE_GENERIC_SYSCTL_MAIN_MENU      0x85

#define HID_USAGE_GENERIC_SYSCTL_APP_MENU       0x86

#define HID_USAGE_GENERIC_SYSCTL_HELP_MENU      0x87

#define HID_USAGE_GENERIC_SYSCTL_MENU_EXIT      0x88

#define HID_USAGE_GENERIC_SYSCTL_MENU_SELECT    0x89

#define HID_USAGE_GENERIC_SYSCTL_MENU_RIGHT     0x8A

#define HID_USAGE_GENERIC_SYSCTL_MENU_LEFT      0x8B

#define HID_USAGE_GENERIC_SYSCTL_MENU_UP        0x8C

#define HID_USAGE_GENERIC_SYSCTL_MENU_DOWN      0x8D

/* ... */

/* Simulation Controls Page (0x02) */

/* ... */

#define HID_USAGE_SIMULATION_RUDDER             0xBA

#define HID_USAGE_SIMULATION_THROTTLE           0xBB

/* ... */

/* Virtual Reality Controls Page (0x03) */

/* ... */

/* Sport Controls Page (0x04) */

/* ... */

/* Game Controls Page (0x05) */

/* ... */

/* Generic Device Controls Page (0x06) */

/* ... */

/* Keyboard/Keypad Page (0x07) */

/* Error "keys" */

#define HID_USAGE_KEYBOARD_NOEVENT              0x00

#define HID_USAGE_KEYBOARD_ROLLOVER             0x01

#define HID_USAGE_KEYBOARD_POSTFAIL             0x02

#define HID_USAGE_KEYBOARD_UNDEFINED            0x03

/* Letters */

#define HID_USAGE_KEYBOARD_aA                   0x04

#define HID_USAGE_KEYBOARD_zZ                   0x1D

/* Numbers */

#define HID_USAGE_KEYBOARD_ONE                  0x1E

#define HID_USAGE_KEYBOARD_ZERO                 0x27

#define HID_USAGE_KEYBOARD_RETURN               0x28

#define HID_USAGE_KEYBOARD_ESCAPE               0x29

#define HID_USAGE_KEYBOARD_DELETE               0x2A

/* Funtion keys */

#define HID_USAGE_KEYBOARD_F1                   0x3A

#define HID_USAGE_KEYBOARD_F12                  0x45

#define HID_USAGE_KEYBOARD_PRINT_SCREEN         0x46

/* Modifier Keys */

#define HID_USAGE_KEYBOARD_LCTRL                0xE0

#define HID_USAGE_KEYBOARD_LSHFT                0xE1

#define HID_USAGE_KEYBOARD_LALT                 0xE2

#define HID_USAGE_KEYBOARD_LGUI                 0xE3

#define HID_USAGE_KEYBOARD_RCTRL                0xE4

#define HID_USAGE_KEYBOARD_RSHFT                0xE5

#define HID_USAGE_KEYBOARD_RALT                 0xE6

#define HID_USAGE_KEYBOARD_RGUI                 0xE7

#define HID_USAGE_KEYBOARD_SCROLL_LOCK          0x47

#define HID_USAGE_KEYBOARD_NUM_LOCK             0x53

#define HID_USAGE_KEYBOARD_CAPS_LOCK            0x39

/* ... */

/* LED Page (0x08) */

#define HID_USAGE_LED_NUM_LOCK                  0x01

#define HID_USAGE_LED_CAPS_LOCK                 0x02

#define HID_USAGE_LED_SCROLL_LOCK               0x03

#define HID_USAGE_LED_COMPOSE                   0x04

#define HID_USAGE_LED_KANA                      0x05

#define HID_USAGE_LED_POWER                     0x06

#define HID_USAGE_LED_SHIFT                     0x07

#define HID_USAGE_LED_DO_NOT_DISTURB            0x08

#define HID_USAGE_LED_MUTE                      0x09

#define HID_USAGE_LED_TONE_ENABLE               0x0A

#define HID_USAGE_LED_HIGH_CUT_FILTER           0x0B

#define HID_USAGE_LED_LOW_CUT_FILTER            0x0C

#define HID_USAGE_LED_EQUALIZER_ENABLE          0x0D

#define HID_USAGE_LED_SOUND_FIELD_ON            0x0E

#define HID_USAGE_LED_SURROUND_FIELD_ON         0x0F

#define HID_USAGE_LED_REPEAT                    0x10

#define HID_USAGE_LED_STEREO                    0x11

#define HID_USAGE_LED_SAMPLING_RATE_DETECT      0x12

#define HID_USAGE_LED_SPINNING                  0x13

#define HID_USAGE_LED_CAV                       0x14

#define HID_USAGE_LED_CLV                       0x15

#define HID_USAGE_LED_RECORDING_FORMAT_DET      0x16

#define HID_USAGE_LED_OFF_HOOK                  0x17

#define HID_USAGE_LED_RING                      0x18

#define HID_USAGE_LED_MESSAGE_WAITING           0x19

#define HID_USAGE_LED_DATA_MODE                 0x1A

#define HID_USAGE_LED_BATTERY_OPERATION         0x1B

#define HID_USAGE_LED_BATTERY_OK                0x1C

#define HID_USAGE_LED_BATTERY_LOW               0x1D

#define HID_USAGE_LED_SPEAKER                   0x1E

#define HID_USAGE_LED_HEAD_SET                  0x1F

#define HID_USAGE_LED_HOLD                      0x20

#define HID_USAGE_LED_MICROPHONE                0x21

#define HID_USAGE_LED_COVERAGE                  0x22

#define HID_USAGE_LED_NIGHT_MODE                0x23

#define HID_USAGE_LED_SEND_CALLS                0x24

#define HID_USAGE_LED_CALL_PICKUP               0x25

#define HID_USAGE_LED_CONFERENCE                0x26

#define HID_USAGE_LED_STAND_BY                  0x27

#define HID_USAGE_LED_CAMERA_ON                 0x28

#define HID_USAGE_LED_CAMERA_OFF                0x29

#define HID_USAGE_LED_ON_LINE                   0x2A

#define HID_USAGE_LED_OFF_LINE                  0x2B

#define HID_USAGE_LED_BUSY                      0x2C

#define HID_USAGE_LED_READY                     0x2D

#define HID_USAGE_LED_PAPER_OUT                 0x2E

#define HID_USAGE_LED_PAPER_JAM                 0x2F

#define HID_USAGE_LED_REMOTE                    0x30

#define HID_USAGE_LED_FORWARD                   0x31

#define HID_USAGE_LED_REVERSE                   0x32

#define HID_USAGE_LED_STOP                      0x33

#define HID_USAGE_LED_REWIND                    0x34

#define HID_USAGE_LED_FAST_FORWARD              0x35

#define HID_USAGE_LED_PLAY                      0x36

#define HID_USAGE_LED_PAUSE                     0x37

#define HID_USAGE_LED_RECORD                    0x38

#define HID_USAGE_LED_ERROR                     0x39

#define HID_USAGE_LED_SELECTED_INDICATOR        0x3A

#define HID_USAGE_LED_IN_USE_INDICATOR          0x3B

#define HID_USAGE_LED_MULTI_MODE_INDICATOR      0x3C

#define HID_USAGE_LED_INDICATOR_ON              0x3D

#define HID_USAGE_LED_INDICATOR_FLASH           0x3E

#define HID_USAGE_LED_INDICATOR_SLOW_BLINK      0x3F

#define HID_USAGE_LED_INDICATOR_FAST_BLINK      0x40

#define HID_USAGE_LED_INDICATOR_OFF             0x41

#define HID_USAGE_LED_FLASH_ON_TIME             0x42

#define HID_USAGE_LED_SLOW_BLINK_ON_TIME        0x43

#define HID_USAGE_LED_SLOW_BLINK_OFF_TIME       0x44

#define HID_USAGE_LED_FAST_BLINK_ON_TIME        0x45

#define HID_USAGE_LED_FAST_BLINK_OFF_TIME       0x46

#define HID_USAGE_LED_INDICATOR_COLOR           0x47

#define HID_USAGE_LED_RED                       0x48

#define HID_USAGE_LED_GREEN                     0x49

#define HID_USAGE_LED_AMBER                     0x4A

#define HID_USAGE_LED_GENERIC_INDICATOR         0x4B

/* Button Page (0x09) */

/*   There is no need to label these usages. */

/* Ordinal Page (0x0A) */

/*   There is no need to label these usages. */

/* Telephony Device Page (0x0B) */

#define HID_USAGE_TELEPHONY_PHONE               0x01

#define HID_USAGE_TELEPHONY_ANSWERING_MACHINE   0x02

#define HID_USAGE_TELEPHONY_MESSAGE_CONTROLS    0x03

#define HID_USAGE_TELEPHONY_HANDSET             0x04

#define HID_USAGE_TELEPHONY_HEADSET             0x05

#define HID_USAGE_TELEPHONY_KEYPAD              0x06

#define HID_USAGE_TELEPHONY_PROGRAMMABLE_BUTTON 0x07

/* ... */

/* Consumer Page (0x0C) */

#define HID_USAGE_CONSUMER_CONTROL              0x01

/* ... */

/* and others ... */

/* HID Report Item Macros */

/* Main Items */

#define HID_Input(x)           0x81,x

#define HID_Output(x)          0x91,x

#define HID_Feature(x)         0xB1,x

#define HID_Collection(x)      0xA1,x

#define HID_EndCollection      0xC0

/* Data (Input, Output, Feature) */

#define HID_Data               0<<0

#define HID_Constant           1<<0

#define HID_Array              0<<1

#define HID_Variable           1<<1

#define HID_Absolute           0<<2

#define HID_Relative           1<<2

#define HID_NoWrap             0<<3

#define HID_Wrap               1<<3

#define HID_Linear             0<<4

#define HID_NonLinear          1<<4

#define HID_PreferredState     0<<5

#define HID_NoPreferred        1<<5

#define HID_NoNullPosition     0<<6

#define HID_NullState          1<<6

#define HID_NonVolatile        0<<7

#define HID_Volatile           1<<7

/* Collection Data */

#define HID_Physical           0x00

#define HID_Application        0x01

#define HID_Logical            0x02

#define HID_Report             0x03

#define HID_NamedArray         0x04

#define HID_UsageSwitch        0x05

#define HID_UsageModifier      0x06

/* Global Items */

#define HID_UsagePage(x)       0x05,x

#define HID_UsagePageVendor(x) 0x06,x,0xFF

#define HID_LogicalMin(x)      0x15,x

#define HID_LogicalMinS(x)     0x16,(x&0xFF),((x>>8)&0xFF)

#define HID_LogicalMinL(x)     0x17,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)

#define HID_LogicalMax(x)      0x25,x

#define HID_LogicalMaxS(x)     0x26,(x&0xFF),((x>>8)&0xFF)

#define HID_LogicalMaxL(x)     0x27,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)

#define HID_PhysicalMin(x)     0x35,x

#define HID_PhysicalMinS(x)    0x36,(x&0xFF),((x>>8)&0xFF)

#define HID_PhysicalMinL(x)    0x37,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)

#define HID_PhysicalMax(x)     0x45,x

#define HID_PhysicalMaxS(x)    0x46,(x&0xFF),((x>>8)&0xFF)

#define HID_PhysicalMaxL(x)    0x47,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)

#define HID_UnitExponent(x)    0x55,x

#define HID_Unit(x)            0x65,x

#define HID_UnitS(x)           0x66,(x&0xFF),((x>>8)&0xFF)

#define HID_UnitL(x)           0x67,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)

#define HID_ReportSize(x)      0x75,x

#define HID_ReportID(x)        0x85,x

#define HID_ReportCount(x)     0x95,x

#define HID_Push               0xA0

#define HID_Pop                0xB0

/* Local Items */

#define HID_Usage(x)           0x09,x

#define HID_UsageMin(x)        0x19,x

#define HID_UsageMax(x)        0x29,x

#endif  /* __HID_H__ */

上一篇:React反模式 —— 如何不使用JSX地动态显示组件


下一篇:Linux进程间通信--使用信号量【转】