00001
00007 #ifndef _USBSTRUCT_H_
00008 #define _USBSTRUCT_H_
00009
00010
00011 #include "type.h"
00012
00013
00015 typedef struct {
00016 U8 bmRequestType;
00017 U8 bRequest;
00018 U16 wValue;
00019 U16 wIndex;
00020 U16 wLength;
00021 } TSetupPacket;
00022
00023
00024 #define REQTYPE_GET_DIR(x) (((x)>>7)&0x01)
00025 #define REQTYPE_GET_TYPE(x) (((x)>>5)&0x03)
00026 #define REQTYPE_GET_RECIP(x) ((x)&0x1F)
00027
00028 #define REQTYPE_DIR_TO_DEVICE 0
00029 #define REQTYPE_DIR_TO_HOST 1
00030
00031 #define REQTYPE_TYPE_STANDARD 0
00032 #define REQTYPE_TYPE_CLASS 1
00033 #define REQTYPE_TYPE_VENDOR 2
00034 #define REQTYPE_TYPE_RESERVED 3
00035
00036 #define REQTYPE_RECIP_DEVICE 0
00037 #define REQTYPE_RECIP_INTERFACE 1
00038 #define REQTYPE_RECIP_ENDPOINT 2
00039 #define REQTYPE_RECIP_OTHER 3
00040
00041
00042 #define REQ_GET_STATUS 0x00
00043 #define REQ_CLEAR_FEATURE 0x01
00044 #define REQ_SET_FEATURE 0x03
00045 #define REQ_SET_ADDRESS 0x05
00046 #define REQ_GET_DESCRIPTOR 0x06
00047 #define REQ_SET_DESCRIPTOR 0x07
00048 #define REQ_GET_CONFIGURATION 0x08
00049 #define REQ_SET_CONFIGURATION 0x09
00050 #define REQ_GET_INTERFACE 0x0A
00051 #define REQ_SET_INTERFACE 0x0B
00052 #define REQ_SYNCH_FRAME 0x0C
00053
00054
00055 #define HID_GET_REPORT 0x01
00056 #define HID_GET_IDLE 0x02
00057 #define HID_GET_PROTOCOL 0x03
00058 #define HID_SET_REPORT 0x09
00059 #define HID_SET_IDLE 0x0A
00060 #define HID_SET_PROTOCOL 0x0B
00061
00062
00063 #define FEA_ENDPOINT_HALT 0x00
00064 #define FEA_REMOTE_WAKEUP 0x01
00065 #define FEA_TEST_MODE 0x02
00066
00067
00068
00069
00070
00072 typedef struct {
00073 U8 bLength;
00074 U8 bDescriptorType;
00075 } TUSBDescHeader;
00076
00077 #define DESC_DEVICE 1
00078 #define DESC_CONFIGURATION 2
00079 #define DESC_STRING 3
00080 #define DESC_INTERFACE 4
00081 #define DESC_ENDPOINT 5
00082 #define DESC_DEVICE_QUALIFIER 6
00083 #define DESC_OTHER_SPEED 7
00084 #define DESC_INTERFACE_POWER 8
00085
00086 #define DESC_HID_HID 0x21
00087 #define DESC_HID_REPORT 0x22
00088 #define DESC_HID_PHYSICAL 0x23
00089
00090 #define GET_DESC_TYPE(x) (((x)>>8)&0xFF)
00091 #define GET_DESC_INDEX(x) ((x)&0xFF)
00092
00093 #endif
00094