cancel
Showing results for 
Search instead for 
Did you mean: 

USBH_BulkReceiveData function blocks

thln47
Associate III
Posted on November 16, 2012 at 12:34

Hello!

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)

{

printf(''-->'');

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'');

}

else

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

#usbh_bulkreceivedata #stm32f107
0 REPLIES 0