cancel
Showing results for 
Search instead for 
Did you mean: 

New STM32F105/107xx USB Host library

Nickname12657_O
Associate III
Posted on December 21, 2010 at 18:59

New STM32F105/107xx USB Host library

1 REPLY 1
saulius
Associate
Posted on May 17, 2011 at 14:19

Hello,

 I am trying to simplify and linearize USB hot functionality for specific task. USB Host example (http://www.st.com/internet/com/SOFTWARE_RESOURCES/SW_COMPONENT/FIRMWARE/stm32f105_usb_host_lib.zip -USBH_HID_KBrd_Mouse) in IAR works perfectly with STM32F107 MCU. I traced some commands and put them step by step. Somehow I receive no data from USB device.

Mine C code looks like this:

  uint8_t speed = HCD_GetCurrentSpeed(&USB_OTG_FS_dev); // dummy read

  USB_OTG_BSP_uDelay(5000);

  USBH_Open_Channel(&USB_OTG_FS_dev, 1, 0, 2, 0, 0x40);

  USB_OTG_BSP_uDelay(5000);

  USBH_Open_Channel(&USB_OTG_FS_dev, 0, 0, 2, 0, 0x40);         

  USB_OTG_BSP_uDelay(5000);

  USBH_Get_DevDesc(&USB_OTG_FS_dev, &dev_desc, 8) ;

  USB_OTG_BSP_uDelay(5000);

  USBH_CtlSendSetup(&USB_OTG_FS_dev, buff2, 0);

  USB_OTG_BSP_uDelay(5000);

  USBH_CtlReceiveData(&USB_OTG_FS_dev, buff, 8, 1);

  USB_OTG_BSP_uDelay(5000);

  HCD_GetCurrentFrame(&USB_OTG_FS_dev);

  USB_OTG_BSP_uDelay(5000);

  HCD_GetCurrentFrame(&USB_OTG_FS_dev);

  USB_OTG_BSP_uDelay(5000);

  HCD_GetCurrentFrame(&USB_OTG_FS_dev);

  USB_OTG_BSP_uDelay(5000);

  USBH_CtlSendData(&USB_OTG_FS_dev, buff, 0, 0);

  USB_OTG_BSP_uDelay(5000);

  USBH_Get_DevDesc(&USB_OTG_FS_dev, &dev_desc, 8);

I have inserted some debug information in (1)usbh_hcs.c (2)usbh_stdreq.c (3)usbh_ioreq.c (4)usb_regs.c (5)usb_core.c files. Here is debug output port from my code:

-1- USBH_Alloc_Channel (00)

-1- HC_GetFreeChannel

-1- USBH_Alloc_Channel (80)

-1- HC_GetFreeChannel

-4- USB_OTG_USBH_handle_port_ISR

-4- USB_OTG_USBH_handle_port_ISR

-4- USB_OTG_USBH_handle_port_ISR

-4- USB_OTG_USBH_handle_port_ISR

-1- USBH_Open_Channel (num=1, dev.adr=0, spd=2, ep.t=0, mps=40)

-1- USBH_Open_Channel (num=0, dev.adr=0, spd=2, ep.t=0, mps=40)

-2- .USBH_Get_DevDesc

-2- .USBH_GetDescriptor

-3- CtlReq (8) 80 06 00 01 00 00 08  === 00 00 00 00 00 00 00 00  S=1

-3- CtlSendSetup[0] 80 06 00 01 00 00 08 00

-4- USB_OTG_USBH_handle_hc_ISR

-4- USB_OTG_USBH_handle_hc_ISR

-3- CtlReceiveData[1] 00 00 00 00 00 00 00 00

-4- USB_OTG_USBH_handle_hc_ISR

-4- USB_OTG_USBH_handle_hc_ISR

-4- USB_OTG_USBH_handle_hc_ISR

-4- USB_OTG_USBH_handle_hc_ISR

-4- USB_OTG_USBH_handle_hc_ISR

-3- CtlSendData[0]

-4- USB_OTG_USBH_handle_hc_ISR

-4- USB_OTG_USBH_handle_hc_ISR

-2- .USBH_Get_DevDesc

-2- .USBH_GetDescriptor

-3- CtlReq (8) 80 06 00 01 00 00 08  === 00 00 00 00 00 00 00 00  S=0

-2- .USBH_ParseDevDesc

And there is debug from original example:

-1- USBH_Alloc_Channel (00)

-1- HC_GetFreeChannel

-1- USBH_Alloc_Channel (80)

-1- HC_GetFreeChannel

-4- USB_OTG_USBH_handle_port_ISR

-4- USB_OTG_USBH_handle_port_ISR

-4- USB_OTG_USBH_handle_port_ISR

-4- USB_OTG_USBH_handle_port_ISR

-1- USBH_Open_Channel (num=1, dev.adr=0, spd=2, ep.t=0, mps=40)

-1- USBH_Open_Channel (num=0, dev.adr=0, spd=2, ep.t=0, mps=40)

-2- .USBH_Get_DevDesc

-2- .USBH_GetDescriptor

-3- CtlReq (8) 80 06 00 01 00 00 08  === 00 00 00 00 00 00 00 00  S=1

-3- CtlSendSetup[0] 80 06 00 01 00 00 08 00

-4- USB_OTG_USBH_handle_hc_ISR

-4- USB_OTG_USBH_handle_hc_ISR

-3- CtlReceiveData[1] 00 00 00 00 00 00 00 00

-4- USB_OTG_USBH_handle_hc_ISR

-4- USB_OTG_USBH_handle_hc_ISR

-4- USB_OTG_USBH_handle_hc_ISR

-4- USB_OTG_USBH_handle_hc_ISR

-4- USB_OTG_USBH_handle_hc_ISR

-3- CtlSendData[0]

-4- USB_OTG_USBH_handle_hc_ISR

-4- USB_OTG_USBH_handle_hc_ISR

-2- .USBH_Get_DevDesc

-2- .USBH_GetDescriptor

-3- CtlReq (8) 80 06 00 01 00 00 08  === 12 01 10 01 00 00 00 08  S=0

-2- .USBH_ParseDevDesc

Hardware USB logger shows that there is no difference in USB communication. See screenshots:

http://lukse.lt/failai/2011-05-27/usb_data_modif.png

http://lukse.lt/failai/2011-05-27/usb_data_original.png

So why I receive no data in my application? What else should I debug?