AnsweredAssumed Answered

USBH_BulkReceiveData function blocks

Question asked by ln.thierry on Nov 16, 2012


I try to implement a USB Host with 2 Endpoints in Bulk mode on a STM32F107.

I use the lastest library : "STM32 USB On-The-Go Host and Device Library V2.0.0"

I wrote the class driver core like this:

in USBH_InterfaceInit function I check the interface an i open the appropiate pipes like this:


/* Allocate endpoints */

ADB_Machine.hc_num_out = USBH_Alloc_Channel(pdev, ADB_Machine.BulkOutEp);

ADB_Machine.hc_num_in = USBH_Alloc_Channel(pdev, ADB_Machine.BulkInEp);

/* Open the new channels */

USBH_Open_Channel(pdev, ADB_Machine.hc_num_out, pphost->device_prop.address, pphost->device_prop.speed, EP_TYPE_BULK, ADB_Machine.BulkOutEpSize);

USBH_Open_Channel(pdev, ADB_Machine.hc_num_in, pphost->device_prop.address, pphost->device_prop.speed, EP_TYPE_BULK, ADB_Machine.BulkInEpSize);

then on USBH_Handle function I can write to device through the endpoint (EPOUT)

URB_STATE URB_Status = USBH_BulkSendData(pdev, buff, length, ADB_Machine.hc_num_out);

if (URB_Status == USBH_OK)



     URB_Status = URB_IDLE;

     while (URB_Status!=URB_DONE)


          URB_Status = HCD_GetURB_State(pdev , ADB_Machine.hc_num_out);


     printf("USBH_BulkSendData done\n");



     printf("USBH_BulkSendData failed\n");

Ok, it's works!

but when I want to read the device, the USBH_BulkReceiveData function blocks an MCU always goes into an USB-interrupt loop !

USBH_BulkReceiveData(pdev, buff, length, ADB_Machine.hc_num_in);

Thank you in advance for your replies.

by the way, I found a mistake in "usbh_stdreq.c" at the function USBH_ParseCfgDesc

With devices with many inferfaces the "USBH_ParseCfgDesc" function stores the endpoints descritors only on the first interface slot!

so, i changed this line "pep  = &ep_desc[ep_ix];"

by  this one "pep  = &ep_desc[USBH_MAX_NUM_ENDPOINTS*if_ix + ep_ix];"

Best regards, Thierry