Anonymous
Not applicable
Jan 05, 2010
02:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jan 05, 2010
02:03 AM
hello,
My tast is transfer code using ezusb to cyusb. But I don't know how to do that.
Example:
bool writegpifsingleword(unsigned short da)
{
bool Success=0 ;
long lLen = 2;
unsigned long nBytes;
if (hUsbDevice != INVALID_HANDLE_VALUE )
{
/* The old code are following:
VR.direction = 0; // (0=host to device, 1=device to host)
VR.requestType = 2;
VR.recepient = 0;
VR.request = VX_GPIFSINGLEWRITE;
VR.requestTypeReservedBits = 0;
Success = DeviceIoControl (hUsbDevice,
IOCTL_EZUSB_VENDOR_OR_CLASS_REQUEST,
&VR,
sizeof(VENDOR_OR_CLASS_REQUEST_CONTROL),
(UCHAR*)&da,
2,
&nBytes,
NULL);
*/
// I change them to following:
CCyUSBDevice *USBDevice = new CCyUSBDevice();
CCyControlEndPoint *ept = USBDevice->ControlEndPt;
ept->Direction = DIR_TO_DEVICE;
ept->ReqType = REQ_VENDOR;
ept->Target = TGT_DEVICE;
ept->ReqCode = VX_GPIFSINGLEWRITE;
ept->Value = 1;
ept->Index = 0;
Success = ept->Write((UCHAR*)da,lLen);
return Success;
}
Is that transplant right?
Q1: How to transfer VR.requestTypeReservedBits = 0?
Q2: The function DeviceIoControl can return the data count after run Read or Write,
how to get the count when I use ept->Read(buf, len), or Write, Is there some
equivalent function can get the real transfer data count in cyusb.sys?
Q3: ezusb there is a defination of BULK_TRANSFER_CONTROL, it can set pipenum,
How to do it in cyusb?
Q4: How to transfer this to cyusb:
Success = DeviceIoControl (hUsbDevice,
IOCTL_EZUSB_BULK_READ,
&BR,
sizeof(BULK_TRANSFER_CONTROL),
inbuf,
bc,
&nBytes,
NULL);
Q5: Is following transplant right?
bool ClearStatus()
{
bool Success ;
// VENDOR_OR_CLASS_REQUEST_CONTROL VR;
// unsigned long nBytes;
long lLen = 0;
if (hUsbDevice != INVALID_HANDLE_VALUE )
{
/*
VR.direction = 0; // (0=host to device, 1=device to host)
VR.requestType = 2;
VR.recepient = 0;
VR.request = VR_ClearStatus;
VR.requestTypeReservedBits = 0;
Success = DeviceIoControl (hUsbDevice,
IOCTL_EZUSB_VENDOR_OR_CLASS_REQUEST,
&VR,
sizeof(VENDOR_OR_CLASS_REQUEST_CONTROL),
NULL,
0,
&nBytes,
NULL);
*/
}
ept->Direction = DIR_TO_DEVICE;
ept->ReqType = REQ_VENDOR;
ept->Target = TGT_DEVICE;
ept->ReqCode = VR_ClearStatus;
ept->Write(NULL,lLen);
return Success;
}
0 Replies