This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

STM32F4 USB composite HID+MSC

Hi all!

Does anyone have an experience with making multi-interface (multi-class) USB with STM32F4 device? I am using STM32F4-discovery kit and usb library STM32_USB-Host-Device_Lib_V2.1.0. I have made my HID and MSC applications and now I wanna make a composite device with this classes.

The biggest problem is to set the callback functions for both interfaces. I tried to make one set of universal callbacks (for example one function USBD_HID_MSC_DataOut operating with both interfaces. The code inside the function is divided by endpoint number) but only HID is working. Windows recognize also Mass Storage device but cannot operate with it.
I thing the USR_desc (User descriptors: SerialStrDescriptor, ConfigStrDescriptor, InterfaceStrDescriptor and so on) has also some impact.
Does anyone made some USB composite application with this library?
Thanks for comments.

Jan

Parents
  • Thanks, Tsuneo!
    I have done some progress and I haven't modified usbd_core.c. I have made the set of universal callbacks for both interfaces. The functions Init and Deinit can contain code for both classes without any branching. There was problem only that MSC calls DeInit in Init function. So I call special function for MSC_Deinit (only MSC).
    Now there is problem only with callback function USBD_HID_MSC_Setup. There are routines for interface requests. The requests are used by both classes.

    case USB_REQ_GET_INTERFACE :
    USBD_CtlSendData (pdev,(uint8_t *)&USBD_HID_AltSet, 1);
    //USBD_CtlSendData (pdev,&USBD_MSC_AltSet, 1);
    break;

    case USB_REQ_SET_INTERFACE :
    USBD_HID_AltSet = (uint8_t)(req->wValue);
    //USBD_MSC_AltSet = (uint8_t)(req->wValue); //MSC
    break;

    I used the routines only for HID. Maybe it is interfering because of that.

    In windows everything seems fine. SD card works fine with MSC. But there is always something sending and receiving via MSC endpoint. Even when SD card isn't plug-in. Thanks to this fact it seems the program doesn't have a time to serve buttons, LEDs, ADCs,... it serve only MSC and HID. So now only USB is working :D
    Can that be because of the things in Setup function? Why do you think I should touch the code in usbd_core.c?
    Sorry, if I described that unintelligibly.
    Thank you :)

Reply
  • Thanks, Tsuneo!
    I have done some progress and I haven't modified usbd_core.c. I have made the set of universal callbacks for both interfaces. The functions Init and Deinit can contain code for both classes without any branching. There was problem only that MSC calls DeInit in Init function. So I call special function for MSC_Deinit (only MSC).
    Now there is problem only with callback function USBD_HID_MSC_Setup. There are routines for interface requests. The requests are used by both classes.

    case USB_REQ_GET_INTERFACE :
    USBD_CtlSendData (pdev,(uint8_t *)&USBD_HID_AltSet, 1);
    //USBD_CtlSendData (pdev,&USBD_MSC_AltSet, 1);
    break;

    case USB_REQ_SET_INTERFACE :
    USBD_HID_AltSet = (uint8_t)(req->wValue);
    //USBD_MSC_AltSet = (uint8_t)(req->wValue); //MSC
    break;

    I used the routines only for HID. Maybe it is interfering because of that.

    In windows everything seems fine. SD card works fine with MSC. But there is always something sending and receiving via MSC endpoint. Even when SD card isn't plug-in. Thanks to this fact it seems the program doesn't have a time to serve buttons, LEDs, ADCs,... it serve only MSC and HID. So now only USB is working :D
    Can that be because of the things in Setup function? Why do you think I should touch the code in usbd_core.c?
    Sorry, if I described that unintelligibly.
    Thank you :)

Children
No data