cancel
Showing results for 
Search instead for 
Did you mean: 

USB class implementation - MIDI interface

jean
Senior
Posted on November 13, 2013 at 13:01

Hello everybody !

I'm new here. I'm a musician, I code for 1 year on STM32 for the fun. My project is to create a MIDI controller based on STM32F4discovery (MIDI is a protocol created to allow musical instruments communication). I already program the code for the MIDI UART interface but the speed is quite limited and now I want to implement USB-MIDI, a popular protocol.

So I want to send my MIDI packet (usually composed of 3 bytes) through the USB, and I also want my board to be recognized as a MIDI device. I have only one MIDI IN port IN and one MIDI port OUT.

I try to understand on the internet how to achieve this but my problem is I don't know anything about USB librairies.

Once I add the USB lib ''STM32_USB_Device_Library'' to my project, I don't find where I have to make changes in the source code (declaring 'input/output jacks', ''bulk endpoints'', ''protocol over endpoints'', ...) to implement the USB-MIDI.

Do you know which files of the USB library I have to modify to create a recognized USB-MIDI peripherals ? Thanks for your help !!

Some interresting stuff:

/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Issues%20with%20STM32F4%20USB%20bulk%20transfer%20%28MIDI%29&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=942

http://www.usb.org/developers/devclass_docs/midi10.pdf

#midi-usb
1 REPLY 1
jean
Senior
Posted on November 18, 2013 at 16:50

Hello,

Maybe my question was not so easy or too specific... For the moment I add to my project ''usbd_audio_core.c'' and in this file there is a comment :

//This driver doesn't implement the following aspects of the specification 
//(but it is possible to manage these features with some modifications on this driver):
// - MIDI interfaces and modules

So it means that I need to add the Midi USB descriptor in this file. It looks like easy. I know how to implement the MIDI descriptor thanks to an example ''Appendix B. Example: Simple MIDI Adapter (Informative)'' included in the

http://www.usb.org/developers/devclass_docs/midipdf

page So I need to create a new stucture like

static
uint8_t usbd_audio_CfgDesc[AUDIO_CONFIG_DESC_SIZE] =
{
/* Configuration 1 */
0x09, 
/* bLength */
USB_CONFIGURATION_DESCRIPTOR_TYPE, 
/* bDescriptorType */
LOBYTE(AUDIO_CONFIG_DESC_SIZE), 
/* wTotalLength 109 bytes*/
HIBYTE(AUDIO_CONFIG_DESC_SIZE), 
0x02, 
/* bNumInterfaces */
0x01, 
/* bConfigurationValue */
0x00, 
/* iConfiguration */
0xC0, 
/* bmAttributes BUS Powred*/
0x32, 
/* bMaxPower = 100 mA*/
/* 09 byte*/

but I need to replace theses informations by the description in the example included in the USB MIDI specification ? I'm really not sure of me... Thanks !