rsta2 / uspi

A bare metal USB driver for Raspberry Pi 1-3 written in C
GNU General Public License v3.0
282 stars 51 forks source link

Add support for the USB-MIDI device class. #11

Closed jtotto closed 7 years ago

jtotto commented 7 years ago

This patch adds support for the USB-MIDI device class (for musical instruments) as specified by http://www.usb.org/developers/docs/devclass_docs/midi10.pdf. The class driver is based on the mouse and gamepad drivers - all it does is find the right bulk-in endpoint at configuration time and read MIDI packets from it.

I did have to make some slight modifications to the core library to get it working - endpoint descriptors for devices in the audio class annoyingly extend the standard USB endpoint descriptors with two extra members (see page 25 of the linked USB-MIDI spec), so various assertions about the size of endpoint descriptors needed to be relaxed. The audio class (and MIDI within it) also add a number of other class-specific descriptors.

I've tried to be consistent with the rest of the codebase with respect to style, but if I've gotten any of it wrong please let me know. Thanks for the fantastic library!

rsta2 commented 7 years ago

Thanks for this great contribution! I need some time to check it.

rsta2 commented 7 years ago

I have merged your code with only two small additions. Please have a look at the diff from the latest commit for info. Thanks again!

jtotto commented 7 years ago

Cheers, thanks for the CR!