📄 usb.h
字号:
UINT8 serialNumberIndex; /* iSerialNumber */ UINT8 numConfigurations; /* bNumConfigurations */ } WRS_PACK_ALIGN(4) USB_DEVICE_DESCR, *pUSB_DEVICE_DESCR;#define USB_DEVICE_DESCR_LEN 18/* * USB_CONFIG_DESCR */typedef struct usb_config_descr { UINT8 length; /* bLength */ UINT8 descriptorType; /* bDescriptorType */ UINT16 totalLength; /* wTotalLength */ UINT8 numInterfaces; /* bNumInterfaces */ UINT8 configurationValue; /* bConfigurationValue */ UINT8 configurationIndex; /* iConfiguration */ UINT8 attributes; /* bmAttributes */ UINT8 maxPower; /* MaxPower */ } WRS_PACK_ALIGN(4) USB_CONFIG_DESCR, *pUSB_CONFIG_DESCR;#define USB_CONFIG_DESCR_LEN 9/* * USB_INTERFACE_DESCR */typedef struct usb_interface_descr { UINT8 length; /* bLength */ UINT8 descriptorType; /* bDescriptorType */ UINT8 interfaceNumber; /* bInterfaceNumber */ UINT8 alternateSetting; /* bAlternateSetting */ UINT8 numEndpoints; /* bNumEndpoints */ UINT8 interfaceClass; /* bInterfaceClass */ UINT8 interfaceSubClass; /* bInterfaceSubClass */ UINT8 interfaceProtocol; /* bInterfaceProtocol */ UINT8 interfaceIndex; /* iInterface */ } USB_INTERFACE_DESCR, *pUSB_INTERFACE_DESCR;#define USB_INTERFACE_DESCR_LEN 9/* * USB_ENDPOINT_DESCR */typedef struct usb_endpoint_descr { UINT8 length; /* bLength */ UINT8 descriptorType; /* bDescriptorType */ UINT8 endpointAddress; /* bEndpointAddress */ UINT8 attributes; /* bmAttributes */ UINT16 maxPacketSize; /* wMaxPacketSize */ UINT8 interval; /* bInterval */ } WRS_PACK_ALIGN(1) USB_ENDPOINT_DESCR, *pUSB_ENDPOINT_DESCR;#define USB_ENDPOINT_DESCR_LEN 7/* * USB_LANGUAGE_DESCR */typedef struct usb_language_descr { UINT8 length; /* bLength */ UINT8 descriptorType; /* bDescriptorType */ UINT16 langId [1]; /* wLANGID[] - variable len */ } USB_LANGUAGE_DESCR, *pUSB_LANGUAGE_DESCR;/* * USB_STRING_DESCR */typedef struct usb_string_descr { UINT8 length; /* bLength */ UINT8 descriptorType; /* bDescriptorType */ UINT8 string [1]; /* bString - variable len */ } USB_STRING_DESCR, *pUSB_STRING_DESCR;/* * USB_HID_DESCR */typedef struct usb_descr_typlen { UINT8 type; /* bDescriptorType */ UINT16 length; /* wDescriptorLength */ } USB_DESCR_TYPLEN;typedef struct usb_hid_descr { UINT8 length; /* bLength */ UINT8 descriptorType; /* bDescriptorType */ UINT16 bcdHid; /* bcdHID */ UINT8 countryCode; /* bCountryCode */ UINT8 numDescriptors; /* bNumDescriptors */ USB_DESCR_TYPLEN descriptor [1]; /* (variable length) */ } USB_HID_DESCR, *pUSB_HID_DESCR;/* * USB_HUB_DESCR */typedef struct usb_hub_descr { UINT8 length; /* bLength */ UINT8 descriptorType; /* bDescriptorType */ UINT8 nbrPorts; /* bNbrPorts */ UINT16 hubCharacteristics; /* wHubCharacteristics */ UINT8 pwrOn2PwrGood; /* bPwrOn2PwrGood */ UINT8 hubContrCurrent; /* bHubContrCurrent */ UINT8 deviceRemovable [1]; /* DeviceRemovable - variable len */ UINT8 portPwrCtrlMask [1]; /* portPwrCtrlMask - variable len */ } WRS_PACK_ALIGN(4) USB_HUB_DESCR, *pUSB_HUB_DESCR;#define USB_HUB_DESCR_LEN 9/* * USB_STANDARD_STATUS */typedef struct usb_standard_status { UINT16 status; /* status word */ } USB_STANDARD_STATUS, *pUSB_STANDARD_STATUS;/* * USB_HUB_STATUS */typedef struct usb_hub_status { UINT16 status; /* wHubStatus or wPortStatus*/ UINT16 change; /* wHubChange or wPortChange*/ } USB_HUB_STATUS, *pUSB_HUB_STATUS;/* Implementation-specific host definitions *//* defines *//* node types */#define USB_NODETYPE_NONE 0#define USB_NODETYPE_HUB 1#define USB_NODETYPE_DEVICE 2/* node speeds */#define USB_SPEED_FULL 0 /* 12 mbit device */#define USB_SPEED_LOW 1 /* low speed device (1.5 mbit) *//* standard endpoints */#define USB_ENDPOINT_CONTROL 0/* transfer (pipe) types */#define USB_XFRTYPE_CONTROL 1#define USB_XFRTYPE_ISOCH 2#define USB_XFRTYPE_INTERRUPT 3#define USB_XFRTYPE_BULK 4/* direction indicators for IRPs */#define USB_DIR_OUT 1#define USB_DIR_IN 2#define USB_DIR_INOUT 3/* data toggle specifiers for USB_IRP */#define USB_DATA0 0#define USB_DATA1 1/* flags for IRPs */#define USB_FLAG_SHORT_OK 0x00#define USB_FLAG_SHORT_FAIL 0x01#define USB_FLAG_ISO_ASAP 0x02/* IRP timeouts */#define USB_TIMEOUT_DEFAULT 5000 /* 5 seconds */#define USB_TIMEOUT_NONE 0xffffffff /* no timeout *//* typedefs *//* * IRP_CALLBACK */typedef VOID (*IRP_CALLBACK) (pVOID pIrp);/* * USB_BFR_LIST */typedef struct usb_bfr_list { UINT16 pid; /* Specifies packet type as USB_PID_xxxx */ pUINT8 pBfr; /* Pointer to bfr */ UINT32 bfrLen; /* Length of buffer */ UINT32 actLen; /* actual length transferred */ } USB_BFR_LIST, *pUSB_BFR_LIST; /* * USB_IRP * * NOTE: There are certain requirements on the layout of buffers described * in the bfrList[]. * * For control transfers, the first bfrList [] entry must be the Setup packet. * If there is a data stage, the bfrList [] entry for the data stage should * follow. Finally, a zero-length bfrList [] entry must follow which serves * as a place-holder for the status stage. * * For isochronous, interrupt, and bulk transfers there may be one or more * bfrList[] entries. * * If there is more than one bfrList[] entry for an isochronous, interrupt, * or bulk transfers or more than two bfrList [] entries for control * transfers, then each bfrList[].bfrLen (except the last) must be an exact * multiple of the maxPacketSize. The HCD and underlying hardware will * make no attempt to gather (during OUT) or scatter (during IN) a single * USB packet across multiple bfrList[] entries. */typedef struct usb_irp { LINK usbdLink; /* Link field used internally by USBD */ pVOID usbdPtr; /* Ptr field for use by USBD */ LINK hcdLink; /* Link field used internally by USB HCD */ pVOID hcdPtr; /* Ptr field for use by USB HCD */ pVOID userPtr; /* Ptr field for use by client */ UINT16 irpLen; /* Total length of IRP structure */ int result; /* IRP completion result: S_usbHcdLib_xxxx */ IRP_CALLBACK usbdCallback; /* USBD completion callback routine */ IRP_CALLBACK userCallback; /* client's completion callback routine */ UINT16 dataToggle; /* IRP should start with DATA0/DATA1. */ UINT16 flags; /* Defines other IRP processing options */ UINT32 timeout; /* IRP timeout in milliseconds */ UINT16 startFrame; /* Start frame for isoch transfer */ UINT16 dataBlockSize; /* Data granularity for isoch transfer */ UINT32 transferLen; /* Total length of data to be transferred */ UINT16 bfrCount; /* Indicates count of buffers in BfrList */ USB_BFR_LIST bfrList [1]; } USB_IRP, *pUSB_IRP;/* Implementation-specific target definitions *//* * ERP_CALLBACK */typedef VOID (*ERP_CALLBACK) (pVOID pErp);/* * USB_ERP * * The USB_ERP is similar to the USB_IRP, except that it applies to data transfers * as viewed from the perspective of a USB device - as opposed to the USB_IRP, which * is used by the USB host. * * Each USB_ERP (USB Endpoint Request Packet) describes a transfer through a device * endpoint. As with USB_IRPs, the USB_ERP carries a bfrList[] which is an array * of USB_BFR_LIST structures - each describing a block of data to be transferred. * * There are certain limitations on the bfrList[]. If the first entry in a bfrList[] * has a PID of USB_PID_SETUP, then there may be only a single bfrList[] entry. * * bfrList[] entries must be all IN or all OUT. A single ERP cannot describe * transfers in both directions. */typedef struct usb_erp { LINK targLink; /* Link field used internally by usbTargLib */ pVOID targPtr; /* Ptr field for use by usbTargLib */ LINK tcdLink; /* Link field used internally by USB TCD */ pVOID tcdPtr; /* Ptr field for use by USB TCD */ pVOID userPtr; /* Ptr field for use by client */ UINT16 erpLen; /* Total length of ERP structure */ int result; /* ERP completion result: S_usbTcdLib_xxxx */ ERP_CALLBACK targCallback; /* usbTargLib completion callback routine */ ERP_CALLBACK userCallback; /* client's completion callback routine */ UINT16 endpointId; /* device endpoint */ UINT16 transferType; /* Type of ERP: control, bulk, etc. */ UINT16 dataToggle; /* ERP should start with DATA0/DATA1. */ UINT16 bfrCount; /* Indicates count of buffers in BfrList */ USB_BFR_LIST bfrList [1]; } USB_ERP, *pUSB_ERP;#ifdef __cplusplus}#endif#endif /* __INCusbh *//* End of file. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -