IOCTL_ADAPT_SEND_EP0_CONTROL_TRANSFER

CYUSB3

IOCTL_ADAPT_SEND_EP0_CONTROL_TRANSFER

Top Previous Next

IOCTL_ADAPT_SEND_EP0_CONTROL_TRANSFER

Previous Top Next

 

Description

 

This command sends a control request to the default Control endpoint, endpoint zero.

 

DeviceIoControl( ) is passed a pointer to a two-part structure as both the lpInBuffer and lpOutBuffer parameters. This two-part structure contains a SINGLE_TRANSFER structure followed by a data buffer.

 

The SINGLE_TRANSFER structure contains all the parameters for the control request.

 

The buffer contains the transfer data.

 

NOTE : Please note that this IOCTL return device configuration inclusive of both interface for USB3.0 composite device. This is the limitation due to the USBDI bus interface. The USBDI doesn't support USB3.0 specific device configuration.

 

Example

 

union  {

struct   {

UCHAR Recipient:5;

UCHAR  Type:2;

UCHAR Direction:1;

} bmRequest;

 

UCHAR bmReq;

};

 

bmRequest.Recipient = 0; //  Device

bmRequest.Type      = 2; //  Vendor

bmRequest.Direction = 1; // IN command (from  Device to Host)

 

int iXmitBufSize = sizeof(SINGLE_TRANSFER) + bufLen; //  The size of the two-part structure

UCHAR *pXmitBuf = new UCHAR[iXmitBufSize];           //  Allocate the memory

ZeroMemory(pXmitBuf, iXmitBufSize);

 

PSINGLE_TRANSFER pTransfer = (PSINGLE_TRANSFER)pXmitBuf; //  The SINGLE_TRANSFER comes first

pTransfer->SetupPacket.bmRequest = bmReq;

pTransfer->SetupPacket.bRequest = ReqCode;

pTransfer->SetupPacket.wValue = Value;

pTransfer->SetupPacket.wIndex = Index;

pTransfer->SetupPacket.wLength = bufLen;

pTransfer->SetupPacket.ulTimeOut = TimeOut / 1000;

pTransfer->Reserved = 0;

pTransfer->ucEndpointAddress = 0x00;     //  Control pipe

pTransfer->IsoPacketLength = 0;

pTransfer->BufferOffset = sizeof (SINGLE_TRANSFER);

pTransfer->BufferLength = bufLen;

DWORD dwReturnBytes;

 

DeviceIoControl (hDevice, IOCTL_ADAPT_SEND_EP0_CONTROL_TRANSFER,

            pXmitBuf,  iXmitBufSize,

            pXmitBuf,  iXmitBufSize,

            &dwReturnBytes,  NULL);

 

// Copy data into  buf

UCHAR *ptr = pXmitBuf + sizeof (SINGLE_TRANSFER);

memcpy(buf, ptr, dwReturnBytes);