Adding USB-MIDI support to stmhal port?

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
Post Reply
SpotlightKid
Posts: 463
Joined: Wed Apr 08, 2015 5:19 am

Adding USB-MIDI support to stmhal port?

Post by SpotlightKid » Mon May 02, 2016 2:30 pm

Hi MicroPython developers,

a mid-term goal of mine is to add support to the stmhal port to act as a USB-MIDI device. This can be done in C already and there are example projects that show how to do it for the old STM32 firmware library and for libopencm3.

I am not a good C programmer though and I only started my foray into the ARM/STM32 world a little more than a year ago. I looked at how some of the simpler modules (e.g. leds) are implemented in upy and had no trouble understanding them (with the excellent hints from @dhylands on this forum). But the details of the STMCube USB driver are still a bit foggy to me. I have a basic understanding how USB communication works and I successfully used the usbmidi example projects by STM and adapted them to my needs, but currently I have no clue how they could be integrated into upy and turned into a generic usbmidi module. The STMCube package also doesn't mention support for USB-MIDI specifically, though it lists USB Audio support (which USB-MIDI builds on). Does this mean USB-MIDI is not supported by Cube directly?

Any hints on how I should go about this task? Which source code to look at, which documents to read? Would the USB_VCP class be a good model to structure the code after? What is the current situation regarding the USB VID/PID?


Chris

PinkInk
Posts: 65
Joined: Tue Mar 11, 2014 3:42 pm

Re: Adding USB-MIDI support to stmhal port?

Post by PinkInk » Tue May 03, 2016 1:20 am

I looked at this on a pyboard a while ago, this thread https://github.com/micropython/micropython/pull/955 suggests you should be able to set up usb as a midi hid device in pure micropython.

But the pyb functions described are undocumented, may have been removed.

Tim

SpotlightKid
Posts: 463
Joined: Wed Apr 08, 2015 5:19 am

Re: Adding USB-MIDI support to stmhal port?

Post by SpotlightKid » Tue May 03, 2016 10:02 am

I don't think this would work. USB-MIDI is a configuration of the USB Audio class and not a HID device.

SpotlightKid
Posts: 463
Joined: Wed Apr 08, 2015 5:19 am

Re: Adding USB-MIDI support to stmhal port?

Post by SpotlightKid » Sat May 07, 2016 2:06 pm

Any further hints from anyone?

Thomas_T
Posts: 1
Joined: Tue Feb 16, 2021 5:39 am

Re: Adding USB-MIDI support to stmhal port?

Post by Thomas_T » Mon Sep 20, 2021 1:02 pm

Hi,
Is this thread still reflecting the current situation?

I'm using an STM32 for a musical instrument, and would love to add USB MIDI out; but it seems non-trivial at this point (well, except for sending thourgh a USB Serial port, as in: https://github.com/cjbarnes18/micropython-midi).

Also, apparently, CircuitPython has USB MIDI support on STM32F405 (https://circuitpython.readthedocs.io/en ... index.html).


Thanks!

Post Reply