Skip to main content
mak1308
Associate III
February 8, 2016
Question

USB Host and Composite device..

  • February 8, 2016
  • 5 replies
  • 4910 views
Posted on February 08, 2016 at 12:03

How to make on STM32F4 USB a host with support of the Composite device?

I made the project in CubeMX, but in this project there is a support of different classes of devices, but there is no support of the Composite device.

#host #usb
This topic has been closed for replies.

5 replies

Walid FTITI_O
Visitor II
February 9, 2016
Posted on February 09, 2016 at 11:56

Hi g.marat,

Could you specify which version of CubeMx you are using ?

-Hannibal-

mak1308
mak1308Author
Associate III
February 9, 2016
Posted on February 09, 2016 at 13:18

Version 4.12.0

Walid FTITI_O
Visitor II
March 10, 2016
Posted on March 10, 2016 at 18:57

Hi g.marat, 

Try the new version 4.13.0

-Hannibal-

tsuneo
Associate II
March 11, 2016
Posted on March 11, 2016 at 14:23

Regardless of CubeMX version,

STM32_USB_Host_Library V3.2.2 / 07-July-2015 (included in the latest STM32Cube_FW_F4_V1.11.0) doesn't support composite device yet.

It is obvious when you see this code in usbh_core.c

USBH_StatusTypeDef  USBH_Process(USBH_HandleTypeDef *phost)

{

  ...  

  switch (phost->gState)

  {

  ...

  case HOST_CHECK_CLASS:

    

    if(phost->ClassNumber == 0)

    {

      USBH_UsrLog (''No Class has been registered.'');

    }

    else

    {

      phost->pActiveClass = NULL;

      

      for (idx = 0; idx < USBH_MAX_NUM_SUPPORTED_CLASS ; idx ++)

      {

        if(phost->pClass[idx]->ClassCode == phost->device.CfgDesc.Itf_Desc[0].bInterfaceClass)  // <----

        {

          phost->pActiveClass = phost->pClass[idx];

        }

      }

Just the first interface (Itf_Desc[0]) is hard-coded, here.

To support a composite device,

''case HOST_CHECK_CLASS:'',''case HOST_CLASS_REQUEST:'', and ''case HOST_CLASS:'' should be modified so that these cases do their job for each interface.

Tsuneo

Liêm Lê
Visitor II
January 19, 2017
Posted on January 19, 2017 at 08:12

Hi, i'm trying to do the similar thing to g.marat.

I used stm32f4 discovery board to communicate with Dualshock4 (PS4's controller) which has 4 interface (bNumInterfaces) but there are 6

element

s in the Itf_Desc[] array.

After i connected then read the CfgDesc i found that only Itf_Desc[5] is HID class. So now i'm trying to communicate with that interface.

Here is what i had done:

in case HOST_CHECK_CLASS: hard-coded Itf_Desc[5]

in function: USBH_HID_InterfaceInit, i set phost->Control.pipe_in=HID_Handle->InPipe and phost->Control.pipe_out = HID_Handle->OutPipe .

but then i got stuck at USBH_HID_GetHIDDescriptor because USBH_HandleEnum 's state is USBH_BUSY and URB_Status is USBH_URB_NOTREADY.

hope you could help my case.

tsuneo
Associate II
January 19, 2017
Posted on January 19, 2017 at 17:06

Liêm Lê wrote:

Dualshock4 (PS4's controller) which has 4 interface (bNumInterfaces) but there are 6

element

s in the Itf_Desc[] array.

It sounds odd.

I don't have Dualshock 4. I've searched for its descriptors on the net, found them on these sites.

http://www.psdevwiki.com/ps4/DS4-USB

http://eleccelerator.com/wiki/index.php?title=DualShock_4

According to these sites, Dualshock 4 exposes just single HID interface.

A couple of more sites also show the same descriptors.

Once on your PC, read out the descriptors of your Dualshock4.

You may have a variant of Dualshock4 ;)

Here are utilities for each OS,

Windows - USBView

http://www.ftdichip.com/Support/Utilities.htm ♯ MicrosoftUSBView

Linux - lsusb command

MacOSX - USBProber

http://superuser.com/questions/781982/how-can-i-install-usb-prober-from-the-developer-sdk-on-mac-os-x

If your Dualshock4 would be the standard one (single HID I/F), you may start with HID host example, generated by CubeMX.

Tsuneo

Liêm Lê
Visitor II
January 21, 2017
Posted on January 21, 2017 at 19:03

Hi Tsuneo, i had replied to you for a day but it said 'Currently being moderated.'...