cancel
Showing results for 
Search instead for 
Did you mean: 

USB Host Library: Interrupt Transfers

Posted on January 28, 2011 at 18:07

USB Host Library: Interrupt Transfers

#usb-host-control-transfer
2 REPLIES 2
Posted on May 17, 2011 at 14:23

About (b): The URB_IDLE state is returned when the device did not send any data. I connected a usb mouse and it returns URB_DONE when I moved it or clicked a button.

I still have no idea why I need to call CtlReq twice, nor does it seem to work (I do not get any response, although I should).

How do I initiate a control transfer with a data packet?

Thanks in advance.

Posted on May 17, 2011 at 14:23

I've been able to get it to work. There are some things which seem to be not necessary for HID or MSC devices and these are probably untested.

USBH_CtlReq() (the high-level function doing a control transfer) does not work if you want to actually send data to the device. It works only when you want to fetch some data. So I did some ugly workaround and sent the ControlSetup and ControlData packets myself using host channel zero:

buf[0] = 0x21; buf[1] = 0x09; buf[2] = 0x00; buf[3] = 0x02; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x08; buf[7] = 0x00; status = USBH_CtlSendSetup(pdev, buf, 0);

buf[0] = 0x05; buf[1] = 0xAF; buf[2] = 0x01; buf[3] = 0x00; buf[4] = 0x02; buf[5] =  buf[1] ^ buf[2] ^ buf[3] ^ buf[4]; buf[6] = 0xAF; buf[7] = 0xFE;

status = USBH_CtlSendData(pdev, buf, 8, 0);

In both cases I only need to call the function once and I immediately get a USBH_OK back.

Although the packets are sent correctly most of the time, quite often the station does not repeat anything back. If it doesn't respond almost immediately, I can send as many request packets as I want, I will never get an answer.

The only workaround seems to return USBH_UNRECOVERED_ERROR, which reconnects the usb device, causing a complete new enumeration and initialization. Then it may work, although the chance of failing is the same as before (3 out of 10 times it won't).

I suspect the control packet is sent wrongly, but I do not have the equipment to check things on the wire.

I hope this helps someone facing the same problem.

Best regards