www.pudn.com > CYDEMO.zip > myezusb.h, change:2012-05-28,size:5347b


//--------------------------------------// 
//------------myezusb.h-----------------// 
//--------------------------------------// 
/* 
#include "stdafx.h" 
#include "CYDEMO.h" 
#include "CYDEMODlg.h" 
 
#include <process.h> 
#include <winioctl.h> 
#include "ezusbsys.h" 
*/ 
 
#ifndef __MYEZUSB_H__ 
#define __MYEZUSB_H__ 
 
//Global defs 
#define MAX_IOCTL_BUFF 512 
#define MAX_FILE_SIZE (1024*64) 
#define MAX_EP0_XFER_SIZE (1024*4) // 4K Control EP0 transfer limit imposed by OS  
#define MAX_ISO_SIZE (256*256*16) // 1 Meg Iso buffer 
#define	MAX_BIX_SIZE 8192	//8K = 8192 OR 16K = 16384 
 
typedef struct __usb_Dev_Descriptor__ { 
    UCHAR bLength; 
    UCHAR bDescriptorType; 
    USHORT bcdUSB; 
    UCHAR bDeviceClass; 
    UCHAR bDeviceSubClass; 
    UCHAR bDeviceProtocol; 
    UCHAR bMaxPacketSize0; 
    USHORT idVendor; 
    USHORT idProduct; 
    USHORT bcdDevice; 
    UCHAR iManufacturer; 
    UCHAR iProduct; 
    UCHAR iSerialNumber; 
    UCHAR bNumConfigurations; 
} Usb_Device_Descriptor, *pUsb_Device_Descriptor; 
 
typedef struct __usb_Config_Descriptor__ { 
    UCHAR bLength; 
    UCHAR bDescriptorType; 
    USHORT wTotalLength; 
    UCHAR bNumInterfaces; 
    UCHAR bConfigurationValue; 
    UCHAR iConfiguration; 
    UCHAR bmAttributes; 
    UCHAR MaxPower; 
} Usb_Configuration_Descriptor, *pUsb_Configuration_Descriptor; 
 
typedef struct _USB_INTERFACE_DESCRIPTOR { 
    UCHAR bLength; 
    UCHAR bDescriptorType; 
    UCHAR bInterfaceNumber; 
    UCHAR bAlternateSetting; 
    UCHAR bNumEndpoints; 
    UCHAR bInterfaceClass; 
    UCHAR bInterfaceSubClass; 
    UCHAR bInterfaceProtocol; 
    UCHAR iInterface; 
} Usb_Interface_Descriptor, *pUsb_Interface_Descriptor; 
 
typedef struct _USB_ENDPOINT_DESCRIPTOR { 
    UCHAR bLength; 
    UCHAR bDescriptorType; 
    UCHAR bEndpointAddress; 
    UCHAR bmAttributes; 
    USHORT wMaxPacketSize; 
    UCHAR bInterval; 
} Usb_Endpoint_Descriptor, *pUsb_Endpoint_Descriptor; 
 
 
typedef struct _USB_OTHER_SPEED_CONFIGURATION { 
    UCHAR bLength; 
    UCHAR bDescriptorType; 
    USHORT wTotalLength; 
    UCHAR bNumInterfaces; 
    UCHAR bConfigurationValue; 
    UCHAR iConfiguration; 
    UCHAR bmAttributes; 
    UCHAR MaxPower; 
} USB_OTHER_SPEED_CONFIGURATION, *pUSB_OTHER_SPEED_CONFIGURATION; 
 
 
typedef PVOID USBD_PIPE_HANDLE; 
typedef PVOID USBD_CONFIGURATION_HANDLE; 
typedef PVOID USBD_INTERFACE_HANDLE; 
 
typedef enum _USBD_PIPE_TYPE { 
    UsbdPipeTypeControl, 
    UsbdPipeTypeIsochronous, 
    UsbdPipeTypeBulk, 
    UsbdPipeTypeInterrupt 
} USBD_PIPE_TYPE; 
 
typedef struct _USBD_PIPE_INFORMATION { 
    // 
    // OUTPUT 
    // These fields are filled in by USBD 
    // 
    USHORT MaximumPacketSize;  // Maximum packet size for this pipe 
    UCHAR EndpointAddress;     // 8 bit USB endpoint address (includes direction) 
                               // taken from endpoint descriptor 
    UCHAR Interval;            // Polling interval in ms if interrupt pipe  
     
    USBD_PIPE_TYPE PipeType;   // PipeType identifies type of transfer valid for this pipe 
    USBD_PIPE_HANDLE PipeHandle; 
     
    // 
    // INPUT 
    // These fields are filled in by the client driver 
    // 
    ULONG MaximumTransferSize; // Maximum size for a single request 
                               // in bytes. 
    ULONG PipeFlags;                                    
} USBD_PIPE_INFORMATION, *PUSBD_PIPE_INFORMATION; 
 
typedef struct _USBD_INTERFACE_INFORMATION { 
    USHORT Length;       // Length of this structure, including 
                         // all pipe information structures that 
                         // follow. 
    // 
    // INPUT 
    // 
    // Interface number and Alternate setting this 
    // structure is associated with 
    // 
    UCHAR InterfaceNumber; 
    UCHAR AlternateSetting; 
     
    // 
    // OUTPUT 
    // These fields are filled in by USBD 
    // 
    UCHAR Class; 
    UCHAR SubClass; 
    UCHAR Protocol; 
    UCHAR Reserved; 
     
    USBD_INTERFACE_HANDLE InterfaceHandle; 
    ULONG NumberOfPipes;  
 
    // 
    // INPUT/OUPUT 
    // see PIPE_INFORMATION 
    USBD_PIPE_INFORMATION Pipes[0]; 
 
} USBD_INTERFACE_INFORMATION, *PUSBD_INTERFACE_INFORMATION; 
 
//typedef LONG USBD_STATUS; 
 
//收发线程参数 
typedef struct _THREAD_CONTROL 
{ 
   HANDLE hThread; 
 
   HANDLE hDevice; 
 
   DWORD Ioctl; 
   PVOID InBuffer; 
   DWORD InBufferSize; 
   PVOID OutBuffer; 
   DWORD OutBufferSize; 
   DWORD BytesReturned; 
 
   HANDLE completionEvent; 
   BOOL  status; 
} THREAD_CONTROL, *PTHREAD_CONTROL; 
 
typedef struct _DATA_BUFFER  
{ 
	UCHAR Databuf[1024][512]; 
	UINT pDatabuf; 
	UINT pDatagrup; 
	BOOL wrDataen; 
	BOOL rdDataen; 
}USBDATA,*USBDATA_CONTROL; 
//*Data2A,*Data4A,*Data6A,*Data8A,Data2B,Data4B,Data6B,Data8B,Data2C,Data4C,Data6C,Data8C; 
 
char PIPE_TYPE_STRINGS[4][4] =  
{ 
	"CTL", 
	"ISO", 
	"BLK", 
	"INT" 
}; 
 
char PIPE_DIRECTION[2][4] =  
{ 
	"OUT", 
	"IN" 
}; 
 
BOOL StopTest; 
BOOL StopSpeedTest; 
BOOL StopIsoTest; 
BOOL StopIoTest; 
BOOL StopUsbToUart; 
BOOL g_KeepGoing; 
 
UCHAR usbdata[20][1024][512]; 
UINT pusbdataframe[5]; 
UINT pusbdataline[5]; 
UINT pusbdatapixel[5]; 
BOOL rdusbdataen[5]; 
BOOL wrusbdataen[5]; 
BOOL usbdatabusy[5]; 
char isobuf[1024000]; 
 
UCHAR uart_rxdata; 
 
 
BOOL bOpenDriver (HANDLE * phDeviceHandle, PCHAR devname); 
 
#endif