USB SETUP请求结构体USB_DEFAULT_PIPE_SETUP_PACKET
2023-10-19
102
0
USB_DEFAULT_PIPE_SETUP_PACKET结构体对应用USB标准请求的SETUP令牌包的8字节。
可以使用该结构体描述符Setup令牌包的详细信息。
//
// Chapter 9 USB Device Framework
//
//
// USB 1.1: 9.3 USB Device Requests, Table 9-2. Format of Setup Data
// USB 2.1: 9.3 USB Device Requests, Table 9-2. Format of Setup Data
// USB 3.0: 9.3 USB Device Requests, Table 9-2. Format of Setup Data
//
typedef union _BM_REQUEST_TYPE {
struct _BM {
UCHAR Recipient:2;
UCHAR Reserved:3;
UCHAR Type:2;
UCHAR Dir:1;
#ifdef __cplusplus
} s;
#else
};
#endif
UCHAR B;
} BM_REQUEST_TYPE, *PBM_REQUEST_TYPE;
typedef struct _USB_DEFAULT_PIPE_SETUP_PACKET {
BM_REQUEST_TYPE bmRequestType;
UCHAR bRequest;
union _wValue {
struct {
UCHAR LowByte;
UCHAR HiByte;
};
USHORT W;
} wValue;
union _wIndex {
struct {
UCHAR LowByte;
UCHAR HiByte;
};
USHORT W;
} wIndex;
USHORT wLength;
} USB_DEFAULT_PIPE_SETUP_PACKET, *PUSB_DEFAULT_PIPE_SETUP_PACKET;
C_ASSERT(sizeof(USB_DEFAULT_PIPE_SETUP_PACKET) == 8);
//
// bmRequestType.Dir
//
#define BMREQUEST_HOST_TO_DEVICE 0
#define BMREQUEST_DEVICE_TO_HOST 1
//
// bmRequestType.Type
#define BMREQUEST_STANDARD 0
#define BMREQUEST_CLASS 1
#define BMREQUEST_VENDOR 2
//
// bmRequestType.Recipient
//
#define BMREQUEST_TO_DEVICE 0
#define BMREQUEST_TO_INTERFACE 1
#define BMREQUEST_TO_ENDPOINT 2
#define BMREQUEST_TO_OTHER 3
//
// wValue for Get Descriptor request
//
#define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) ((USHORT)((USHORT)d<<8 | i))
//
// USB 1.1: 9.4 Standard Device Requests, Table 9-4. Standard Request Codes
// USB 2.0: 9.4 Standard Device Requests, Table 9-4. Standard Request Codes
//
#define USB_REQUEST_GET_STATUS 0x00
#define USB_REQUEST_CLEAR_FEATURE 0x01
#define USB_REQUEST_SET_FEATURE 0x03
#define USB_REQUEST_SET_ADDRESS 0x05
#define USB_REQUEST_GET_DESCRIPTOR 0x06
#define USB_REQUEST_SET_DESCRIPTOR 0x07
#define USB_REQUEST_GET_CONFIGURATION 0x08
#define USB_REQUEST_SET_CONFIGURATION 0x09
#define USB_REQUEST_GET_INTERFACE 0x0A
#define USB_REQUEST_SET_INTERFACE 0x0B
#define USB_REQUEST_SYNC_FRAME 0x0C
#define USB_REQUEST_GET_FIRMWARE_STATUS 0x1A
#define USB_REQUEST_SET_FIRMWARE_STATUS 0x1B
HID人机交互QQ群:564808376
UAC音频QQ群:218581009
UVC相机QQ群:331552032
BOT&UASP大容量存储QQ群:258159197
STC-USB单片机QQ群:315457461
USB技术交流QQ群2:580684376
USB技术交流QQ群:952873936