help with USB

I’m building a USB HID device with a black pill (stm32f103) and I’m trying to decide if RIOT is a feasible alternative to STM32Cube and the ST HAL. I’ve got a couple of questions/issues.

I started with the tests/leds and was able to build and flash to the board so I know my setup is working. I tried to build the usbus_minimal example with “make BOARD=blackpill” and get undefined errors for “usbdev_init_lowlevel” and “usbdev_get_ctx”.

Second question is about HID support. Specifically I’m trying to create a game controller HID device. I’m not sure where to start looking for documentation or examples. Is there a HID specific API?

Hi Trevor, Unfortunately, RIOT doesn’t support yet the lowlevel USB driver for STM32 nor HID yet. The first task to do should be to write lowlevel driver for USB for your MCU. You could refer to nrf52 or SAM0 driver to have a rough idea but the STM32 USB IP is quite different. Koen (@bergzand) wanted to start working on it but I don’t know if he had time to do something.

As of today, RIOT started to support CDC/ECM and CDC/ACM is ongoing. So there is no HID support yet.

If there is any person interested by adding more USB features to RIOT, the mailing list is the perfect place to synchronize this effort ! Cheers,

Hi Trevor,

As Dylan mentioned below, the low level STM32 USB driver is not yet implemented. As far as I know there are three different USB peripherals used in the STM32 products: The shared USB/CAN peripheral, an USB OTG full speed peripheral and an USB OTG high speed peripheral. These last two are very similar and the high speed version looks like an extended version of the full speed peripheral. The shared USB/CAN has a different register organization compared to the other two. This USB/CAN peripheral is the peripheral found on the blackpill boards if I remember correctly.

I haven’t attempted a driver for this peripheral yet (I’ve only put some initial work in the USB OTG FS periph). Any contribution here is welcome. Also please let me know if there is implementation-related documentation missing.

HID support is not implemented yet and I haven’t put much thought into how to organize code for that yet. Your best help here is probably the USB-IF documentation on the HID spec. While it would be nice to have a generic USB HID module, I can imagine any HID descriptor generator becoming too complex for a quick implementation. If you only require a simple, PoC-like, implementation, I would recommend creating a custom handler with a constant pre-build HID descriptor and some functions to read and report the game controller state to the host.

Cheers, Koen