www.pudn.com > pCom.rar > p2k_usb_defines.h


#ifndef __NexTest_P2K_USB_DEFINES__ 
#define __NexTest_P2K_USB_DEFINES__ 
 
#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers 
 
//#include          // MFC core and standard components 
//#include          // MFC extensions 
//#include          // MFC  
//#include  
#include  
#include  
#include  
#include  
//#include  
 
 
//--------------------------------------- 
// USB packet types 
enum PCKTYPE 
{ 
	PCK_DATA_CONTROL		= 0, 
	PCK_DATA_ISOCHRONOUS	= 1, 
	PCK_DATA_BULK			= 2, 
	PCK_DATA_INTERRUPT		= 3, 
	PCK_COMMAND 
}; 
 
// USB descriptor type 
enum DESCRTYPE 
{ 
	// Device String Descriptor 
	DESCR_DEVICE_MANUFACTURER	=0x0000,	// Device String Descriptor: Manufacturer 
	DESCR_DEVICE_PRODUCT		=0x0001,	// Device String Descriptor: Product 
	DESCR_DEVICE_SERIAL_NUMBER	=0x0002,	// Device String Descriptor: Serial Number 
	DESCR_CONFIGURATION			=0x0100,	// Configuration String Descriptor 
	DESCR_INTERFACE				=0x0200,	// Interface String Descriptor 
	DESCR_DIRECT_STRING			=0x0300,	// Direct String 
}; 
//--------------------------------------- 
 
//class CConfig 
//{ 
//public: 
//	CConfig(){m_lConfig=-1;m_bInterfaceNumber	= -1;m_sInterfaceName= "";} 
//	virtual ~CConfig(){m_lConfig=-1;m_bInterfaceNumber	= -1;m_sInterfaceName= "";} 
//	 
//	long	m_lConfig; 
//	BYTE	m_bInterfaceNumber; 
//	CString	m_sInterfaceName; 
//}; 
//typedef CArray CConfigArray; 
// 
//class CInterface 
//{ 
//public: 
//	CInterface(){m_sInterfaceName	= "";m_hInterface= NULL;} 
//	virtual ~CInterface(){m_sInterfaceName	= "";m_hInterface= NULL;} 
// 
//	 
//	CString	m_sInterfaceName; 
//	HANDLE	m_hInterface; 
//}; 
//typedef CArray CInterfaceArray; 
 
//CConfigArray		m_ConfigArray;		// all interfaces in all configurations 
//CInterfaceArray		m_InterfaceArray;	// interfaces and their handles (for current configuration) 
 
//---------------------------------------------- 
 
//-------------------------------------------- 
#define USBWALLY_DEVICE_TYPE            0x8000 
#define USBWALLY_MAKE_IOCTL(t,c)\ 
        (ULONG)CTL_CODE((t), 0x800+(c), METHOD_BUFFERED, FILE_ANY_ACCESS) 
 
#define IOCTL_MOTUSB_GET_DRIVER_VERSION\ 
            USBWALLY_MAKE_IOCTL(USBWALLY_DEVICE_TYPE, 0) 
 
#define IOCTL_MOTUSB_SET_CONFIGURATION\ 
            USBWALLY_MAKE_IOCTL(USBWALLY_DEVICE_TYPE, 1) 
 
#define IOCTL_MOTUSB_GET_CONFIG_NUMBER\ 
            USBWALLY_MAKE_IOCTL(USBWALLY_DEVICE_TYPE, 2) 
 
#define IOCTL_MOTUSB_GET_CONFIG_DESCRIPTOR\ 
            USBWALLY_MAKE_IOCTL(USBWALLY_DEVICE_TYPE, 3) 
 
#define IOCTL_MOTUSB_GET_STRING_DESCRIPTOR\ 
            USBWALLY_MAKE_IOCTL(USBWALLY_DEVICE_TYPE, 4) 
 
#define IOCTL_MOTUSB_CLASS_OR_VENDOR_REQUEST\ 
            USBWALLY_MAKE_IOCTL(USBWALLY_DEVICE_TYPE, 5) 
 
#define IOCTL_MOTUSB_WRITE_ASYNC_DATA\ 
            USBWALLY_MAKE_IOCTL(USBWALLY_DEVICE_TYPE, 6) 
 
#define IOCTL_MOTUSB_READ_ASYNC_DATA\ 
            USBWALLY_MAKE_IOCTL(USBWALLY_DEVICE_TYPE, 7) 
 
#define IOCTL_MOTUSB_SELECT_ALTERNATE_SETTING\ 
            USBWALLY_MAKE_IOCTL   (USBWALLY_DEVICE_TYPE, 8) 
 
#define IOCTL_MOTUSB_INTERFACE_DESCRIPTOR\ 
            USBWALLY_MAKE_IOCTL(USBWALLY_DEVICE_TYPE, 9) 
 
 
    // Read GET_STRING_DESCRIPTOR_OUT data structure 
typedef struct _GET_STRING_DESCRIPTOR_OUT_STRUCT { 
    ULONG   dwTotalSize;         // Size of the string in bytes  
    UCHAR   StringData[1];       // Buffer space for the string data  
} GET_STRING_DESCRIPTOR_OUT_STRUCT, *PGET_STRING_DESCRIPTOR_OUT_STRUCT; 
 
    // Read GET_DRIVER_VERSION data structure 
typedef struct _GET_DRIVER_VERSION_STRUCT { 
    UCHAR  bcdMajor;    // Current driver verson 
    UCHAR  bcdMinor;    //  
} GET_DRIVER_VERSION_STRUCT, *PGET_DRIVER_VERSION_STRUCT; 
 
    // Write SET_CONFIGURATION data structure 
typedef struct _SET_CONFIGURATION_STRUCT { 
    UCHAR  bConfigurationNum;   // Configuration number 
} SET_CONFIGURATION_STRUCT, *PSET_CONFIGURATION_STRUCT; 
 
    // Read GET_CONFIG_DESCRIPTOR_OUT data structure 
typedef struct _GET_CONFIG_DESCRIPTOR_OUT_STRUCT { 
    ULONG   dwTotalSize;         // Size of the Config descriptor in bytes 
    UCHAR   DescriptorData[1];   // Buffer space for the descriptor data  
} GET_CONFIG_DESCRIPTOR_OUT_STRUCT, *PGET_CONFIG_DESCRIPTOR_OUT_STRUCT; 
 
    // Write GET_CONFIG_DESCRIPTOR_IN data structure 
typedef struct _GET_CONFIG_DESCRIPTOR_IN_STRUCT { 
    UCHAR  bConfigurationNum;   // Configuration number 
} GET_CONFIG_DESCRIPTOR_IN_STRUCT, *PGET_CONFIG_DESCRIPTOR_IN_STRUCT; 
 
    // Write CLASS_OR_VENDOR_REQUEST_IN data structure 
typedef struct _CLASS_OR_VENDOR_REQUEST_IN_STRUCT { 
    UCHAR  bmRequestType;       //  
    UCHAR  bRequest;            //  
    USHORT wValue;              //  
    USHORT wIndex;              //  
    USHORT wLength;             // Size of data in bytes 
	UCHAR  DataBuf[1];          // data  
} CLASS_OR_VENDOR_REQUEST_IN_STRUCT, *PCLASS_OR_VENDOR_REQUEST_IN_STRUCT; 
 
    // Write CLASS_OR_VENDOR_REQUEST_IN data structure 
typedef struct _CP2K_COMMAND_STRUCT { 
    UCHAR  bmRequestType;       //  
    UCHAR  bRequest;            //  
    USHORT wValue;              //  
    USHORT wIndex;              //  
    USHORT wLength;             // Size of data in bytes 
 
	USHORT wSequenceTag;         //  
	USHORT wOpcode;             //  
	USHORT wDataBufLen;     //  
	USHORT wReserved;           //  
 
	UCHAR  DataBuf[1];          // data  
 
   	//BYTE data[]={0x00,0x29, 0x00,0x36, 0x00,0x01, 0x00,0x00,   0x00}; 
} CP2K_COMMAND_STRUCT, *PCP2K_COMMAND_STRUCT; 
 
    // Write GET_STRING_DESCRIPTOR_IN data structure 
typedef struct _GET_STRING_DESCRIPTOR_IN_STRUCT { 
    UCHAR  bDescriptorType;     // 0x00 = Device String Descriptor 
                                // 0x01 = Configuration String Descriptor 
                                // 0x02 = Interface String Descriptor 
                                // 0x03 = Direct String 
    UCHAR  bDescriptorSubType;  //  
                                // For Device String Descriptor (0x00) 
                                //     0x00 = Manufacturer 
                                //     0x01 = Product 
                                //     0x02 = Serial Number 
                                // For Configuration String Descriptor (0x01) 
                                //     0xnn = Desired configuration number 
                                // For Interface String Descriptor (0x02) 
                                //     0xnn = Desired interface number 
                                // For Direct String (0x03) 
                                //     0xnn = Index in string descriptor array 
} GET_STRING_DESCRIPTOR_IN_STRUCT, *PGET_STRING_DESCRIPTOR_IN_STRUCT; 
 
    // Write CLASS_OR_VENDOR_REQUEST_OUT data structure 
typedef struct _CLASS_OR_VENDOR_REQUEST_OUT_STRUCT { 
    ULONG  dwLength;             // Size of data in bytes 
    UCHAR  DataBuf[1];          // data  
} CLASS_OR_VENDOR_REQUEST_OUT_STRUCT, *PCLASS_OR_VENDOR_REQUEST_OUT_STRUCT; 
 
    // Write READ_ASYNC_DATA_IN data structure 
typedef struct _READ_ASYNC_DATA_IN_STRUCT { 
    UCHAR  bTransferType;       // 0x00 = Control 
                                // 0x01 = Isochronous 
                                // 0x02 = Bulk 
                                // 0x03 = Interrupt 
    ULONG  dwLength;            // Length of the buffer to read in bytes  
} READ_ASYNC_DATA_IN_STRUCT, *PREAD_ASYNC_DATA_IN_STRUCT; 
 
    // Read READ_ASYNC_DATA data structure 
typedef struct _READ_ASYNC_DATA_OUT_STRUCT { 
    ULONG  dwLength;            // Length of the buffer to write  
    UCHAR  DataBuf[1];          // data  
} READ_ASYNC_DATA_OUT_STRUCT, *PREAD_ASYNC_DATA_OUT_STRUCT; 
 
// POLL_RESPONSE_DATA_PACKET data structure (max 12 bytes) 
typedef struct _POLL_RESPONSE_DATA_PACKET { 
    ULONG	dwLength;           // Size of following data in bytes 
    BYTE	nStatus;            // Status Byte 
	BYTE	nMessages;			// number of messages (max 3) 
	WORD	nSizeMsg1;			// size of message buffered in phone 
	WORD	nSizeMsg2;			// size of message buffered in phone 
	WORD	nSizeMsg3;			// size of message buffered in phone 
} POLL_RESPONSE_DATA_PACKET, *PPOLL_RESPONSE_DATA_PACKET; 
 
// QUEUED_MESSAGE_RESPONSE_DATA_PACKET data structure 
typedef struct _QUEUED_MESSAGE_RESPONSE_DATA_PACKET { 
    ULONG	dwLength;           // Size of following data in bytes 
	BYTE	nMessages;			// number of messages returned in this data stage 
	BYTE	nQueuedMsgs;		// number of messages still queued in phone 
	WORD	nQueuedBytes;		// total number of bytes queued in phone 
	WORD	nSizeMsg1;			// size of message 1 buffered in phone 
    BYTE	message1[1];        // message 1  
} QUEUED_MESSAGE_RESPONSE_DATA_PACKET, *PQUEUED_MESSAGE_RESPONSE_DATA_PACKET; 
 
// ACCESSORY_MESSAGE_RESPONSE_DATA_PACKET data structure 
typedef struct _ACCESSORY_MESSAGE_RESPONSE_DATA_PACKET { 
    BYTE	message[512];        // message  
} ACCESSORY_MESSAGE_RESPONSE_DATA_PACKET, *PACCESSORY_MESSAGE_RESPONSE_DATA_PACKET; 
 
typedef struct _WRITE_ASYNC_DATA_STRUCT { 
    UCHAR  bTransferType;       // 0x00 = Control 
                                // 0x01 = Isochronous 
                                // 0x02 = Bulk 
                                // 0x03 = Interrupt 
    ULONG  dwLength;            // Length of the buffer to write in bytes 
    UCHAR  DataBuf[1];          // data  
} WRITE_ASYNC_DATA_STRUCT, *PWRITE_ASYNC_DATA_STRUCT; 
 
 
typedef struct GET_INTERFACE_DESCRIPTOR_OUT_STRUCT { 
    ULONG   dwTotalSize;         // Size of the string in bytes  
    UCHAR   StringData[1];       // Buffer space for the string data  
} GET_INTERFACE_DESCRIPTOR_OUT_STRUCT, *PGET_INTERFACE_DESCRIPTOR_OUT_STRUCT; 
 
 
typedef struct GET_INTERFACE_DESCRIPTOR_IN_STRUCT { 
	UCHAR	bLength; 
	UCHAR	bDescriptorType; 
	UCHAR	bInterfaceNumber; 
	UCHAR	bAlternateSetting; 
	UCHAR	bNumEndpoints; 
	UCHAR	bInterfaceClass; 
	UCHAR	bInterfaceSubClass; 
	UCHAR	bInterfaceProtocol; 
	UCHAR	iInterface; 
	ULONG  dwTotalSize ; 
 
} GET_INTERFACE_DESCRIPTOR_IN_STRUCT, *PGET_INTERFACE_DESCRIPTOR_IN_STRUCT;  
 
struct MSD_CMD_FORMAT 
{ 
	UCHAR ucOpCode; 
	UCHAR ucLogUnitNum; 
	UCHAR ucReserve1; 
	UCHAR ucReserve2; 
	UCHAR ucReserve3; 
	UCHAR ucReserve4; 
	UCHAR ucReserve5; 
	UCHAR ucReserve6; 
	UCHAR ucReserve7; 
	UCHAR ucReserve8; 
	UCHAR ucTargetMode; 
	UCHAR ucControl; 
}; 
 
 
 
#endif //__NexTest_CUsbPort__