logo elektroda
logo elektroda
X
logo elektroda

[STM32/USB] Designing Joystick Electronics: Implementing CDC & HID Interfaces in Composite Device

piotrva 6969 8
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 16292359
    piotrva
    VIP Meritorious for electroda.pl
    Welcome!

    This time I share the fruit of my work (well, not quite my own).

    I am currently designing electronics for the joystick with the possibility of implementing more advanced communication (calibration on the hardware side, configuration of e.g. device name or number of channels). The ideal for this purpose seems to be the use of the CDC interface running in a USB composite device next to the HID interface.

    While both of these interfaces can be quickly "clicked" in CubeMX, with a composite device you have to show off (yourself).

    Fortunately, I found an interesting piece of code in the STM32Duino project (https://github.com/danieleff/Arduino_Core_STM32F1/tree/USB_HID_Composite) and by analyzing its creation, I separated the smallest functional part of this concept.

    I hereby share this extracted solution that works.

    An additional problem is that you have to slightly modify the driver's inf file so that it does not "mask" the entire device, but connects only to the CDC interface, leaving the HID interface at the disposal of the operating system.

    Everything is described in the repository:
    https://gitlab.com/piotrva/stm32-composite-hid-cdc
    Do you have a problem with Arduino? Ask question. Visit our forum Arduino.
  • ADVERTISEMENT
  • #2 16292721
    BlueDraco
    MCUs specialist
    Why this .inf? Lnux and Windows 10 support CDC by themselves, as long as you have the correct class and subclass - 2.
  • ADVERTISEMENT
  • ADVERTISEMENT
  • #4 16292984
    piotrva
    VIP Meritorious for electroda.pl
    @BlueDraco I use Windows 7, one or two in composite, the masking of the HID interface is different.
  • #5 16293057
    Anonymous
    Anonymous  
  • ADVERTISEMENT
  • #6 16293067
    BlueDraco
    MCUs specialist
    So far I have 7xCDC, 2xCDC + MSC and CDC + MSC + printer. ;)

    Proprietary USB stacks are generally written for a single class, and the ST stack is a horror in that respect.
  • #7 16293073
    Anonymous
    Anonymous  
  • #8 16293096
    Freddie Chopin
    MCUs specialist
    BlueDraco wrote:
    Proprietary USB stacks are generally written for a single class, and the ST stack is a horror in that respect.

    Did you write yours or did you find any interesting alternative to monsters from ST on the net?
  • #9 16293126
    BlueDraco
    MCUs specialist
    Let's say I modified the ST stack generated by CubeMX quite significantly, but in such a way as to limit the number of modified files - I ended up with perhaps five .c plus headers. This way, in an hour or two, I am able to generate a version for any STM32 (and the USB interfaces are different variations of the STM32 and have quite different ones).
    Previously, on the LPC, I replaced 3/4 of the NXP stack with my own routines and data structures. From this solution I have elegantly defined structures of all possible descriptors and macros for their generation, from which b. Any configuration descriptor for a complex device can be easily assembled.
    By the way - you can define a seriously simplified, but still correct for Windows descriptor set for CDC without notification endpoint (which in most enterprise solutions is, but does not work).

Topic summary

The discussion revolves around designing joystick electronics with advanced communication capabilities using CDC and HID interfaces in a USB composite device. The original poster shares a solution derived from the STM32Duino project, emphasizing the need for modifications to the driver’s INF file to ensure proper connection to the CDC interface without masking the HID interface. Participants discuss the necessity of the INF file for Windows users, particularly those on Windows 7, and share experiences with proprietary USB stacks, highlighting the challenges of using the ST stack. Some users express interest in reviewing the shared code and discuss their own modifications to the ST stack generated by CubeMX, aiming for a simplified and efficient implementation for various STM32 models.
Summary generated by the language model.
ADVERTISEMENT