Instantiate two MIDI I/F's on one embedded USB port

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
StGr_4575901
Level 2
Level 2

I am trying to instantiate two MIDI I/F's on one USB physical port and am not finding success. I have seen other posts on composite devices here, read them and tried to make it work but no success with or without an association descriptor or different endpoint numbers.

AND ...what I do have working with the single I/F will often lose connection with the host when disconnected, reconnected or client is reset.  Any hints on how to make the USB connection robust and automatic? I am obviously not ending something I should to identify as the same MIDI device back on line. Thanks

0 Likes
1 Solution

All is well now.  The descriptor needs to look like this:

pastedImage_5.png

Be sure the endpoints are different when defined i.e., EP1, EP2, EP3, EP4

AND... in USBxx_descr.c    (usually named USBFS_descr.c but the user can change that.  I did, mins is just USB)

In USBxx_descr.c the descriptor(s) are defined as data.

  1. Make sure yur descriptor is OK as above
  2. Turn ON the 'generate source' option  in build options (skip=false)
  3. compile the project
  4. Turn OFF the 'generate source' option  in build options (skip=true)
  5. open USB_descr.c
  6. there will be two instances (one for each control interface) of    baInerfaceNr   both with a value of 0x01 This is incorrect.  Change the second instance to 0x03 for the 2nd interface 
  7. recompile. Remember, generate source is off, we don't want to overwrite that change just made.

The two MIDI interfaces will now enumerate properly in the USB attached host as a composite device with two interfaces

After that you will have to adjust the supplied MIDI service and initialization routines to work with two sets of endpoints and local buffers.

The supplied code uses GLOBAL VARIABLES (USB_midi_out_ep and  USB_midi_in_ep) to define  single fixed set of endpoints.... boo...hiss.... 

Routines to look at re endpoint support (arguments not shown): 

MIDI_Init()

USB_PutUsbMidiIn()   

USB_PrepareInBuffer

USB_MIDI_IN_Service()

USB_MIDI_OUT_Service()

USB_callbackLocalMidiEvent()

View solution in original post

0 Likes
12 Replies
YatheeshD_36
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello,

Can you please let me know which Cypress Device you are using?

Refer to this KBA FX2LP: Dual Virtual COM Port Descriptors - KBA229819  where FX2LP descriptors is configured to enumerate as a dual COM port device.

Please note that KBA only makes the device enumerate as multiple devices each with a COM port, only the descriptor file is modified in this KBA, the functionality needs to be implemented in the firmware.

Thanks,

Yatheesh

0 Likes

Hello Raheesh,

The part number is CY8C5468AXI-LP106

Thanks,

Steve

Steve Gray

Peavey Commercial Audio - A Division of Peavey Electronics Corporation

+1 720 378 8941

Steve.Gray@Peavey.com

[http://<br/>www.peaveycommercialaudio.com]www.peaveycommercialaudio.com

0 Likes

Hello Yatheesh,

Sorry I previously misspelled your name.

BTW, that previous app note/example (KBA229819<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fcommunity.cypress.com%2fdocs%2fDOC-19267&c=E,1,uazAHdjD_cozMnKZUWOrV12csPN_Q7AJAybUid2i_IVzraP_Dzni5owUzpRtkG1imUeeakyeBPM1buVHrAoiJPmE7eL88KzbfqtyytExrKyrxdBI&typo=1>) does not seem to apply.

Please reply with more info

Thanks,

Steve Gray

Peavey Commercial Audio - A Division of Peavey Electronics Corporation

+1 720 378 8941

Steve.Gray@Peavey.com

[http://<br/>www.peaveycommercialaudio.com]www.peaveycommercialaudio.com

0 Likes

Steve,

Since you are using a PSoC5 the best example to start from would be:

CE95395 - USB MIDI with PSoC 3/5LP

Link: https://www.cypress.com/documentation/code-examples/ce95395-usb-midi-psoc-35lp

This example project demonstrates the MIDI interface device operation.
The project enumerates as a USB Audio Device with the MIDI feature and does not require additional drivers.
The main goal of the USB MIDI interface is to transfer and convert MIDI data between external MIDI devices that use the UART interface, and a PC through the USB bus.

This does control two MIDI Devices – one USB -

You will need to retarget from a PSOC3 device to a PSOC5LP device.


Note:

If you need to have multiple USB MIDI channel interfaces on one USB CABLE – that would be a Composite device.
To add that you will need to edit the USB component and add new Endpoint and descriptors.

Since it already has one USB MIDI configured it is pretty easy to copy and add additional endpoint and descriptors for in and out functions.

Give it a shoot and if you have trouble and need help ,  let me know and if I have time I can modify project for you.

-Mike

0 Likes

Hello MiDa_1966691,

I'm using a PSOC 5. But even if I change the example in the link you provided to target my device, it instantiates two MIDI interfaces as external UARTs either way.  I need them as embedded MIDI ports with one USB physical port. A composite.  i.e. MIDI 1 and MIDI 2, each with its own identifier as defined in the alternate settings identifier string, and endpoints, too I would think. Not as external UARTs if I understand this correctly.  So far no joy... If I add two interfaces under the config descriptor it compiles OK But does not work. But Win 10 that I connect to cannot start the second I/F. It sees it but gets a driver error 10. The first I/F can be selected from my win app but also does not work. Using an association descriptor to associate the 4 components of two MIDI IF's does not work at all either.

This works:

pastedImage_3.png

This does not nor does using a n association descriptor. Any ideas?

pastedImage_6.png

0 Likes

Steve –

A good example of making a USB Composite device in a PSOC5LP:

Knowledge base article -

Implementing USB Composite Device with PSoC 3, PSoC 4L, or PSoC 5LP - KBA223141

Link: https://community.cypress.com/message/229062#229062

Notice how they match , but with different names -

This is for a communication device class (CDC) device , but would be similar for the MIDI interface.

-Mike

0 Likes

Hi Mike,

Can you double check those links? The clickable link given is the thread we are in now and KBA223141 does not appear to be : Implementing USB Composite Device with PSoC 3, PSoC 4L, or PSoC 5LP

Thanks

0 Likes

OK, 223141 actually shows as when searching   Implementing USB Composite Device with PSoC 3, PSoC 4L, or PSoC 5LP - KBA223141 

I've seen that article and tried it.  No joy.

0 Likes

YatheeshK_36.... are you still there?

I'm still flailing on this. I'd love your input, too since I gave you the part number you requested.

Thanks

0 Likes

Steve -

Please find Attached a Baseic Project for a USB Composie with 2 MIDI interface  -
I used a Cypress DVK board - CY8CKIT-059

pastedImage_0.png

There still is an issue with the second interface , but the first one works and looks good.

I believe issue is with Interface Association Descriptor (IAD) .
DOC' from Microsoft -

https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/usb-interface-association-descripto...

Hopefuly this is a good starting point for you .. and maybe someone from the Community or Cypress Apps can help you figure out why the second interace is not showing up in Windows 10.

C:\Users\Mike\Desktop\APRIL\CY_USB_COMPOSITE_MIDI_2.Bundle01.zip

Hope that helps,

MIke

0 Likes

Here is a link to the project that MiDa_1966691 created and wanted to share above.  He's a very knowledgeable, helpful guy with a lot of Cypress experience. Thanks for creating this, Mike.

CY_USB_COMPOSITE_MIDI_2.Bundle01.cywrk.Archive01.zip - Google Drive

This project does not fix the problem but provides a stripped down version of what I am trying to do that is very easy to work with. Both MIDI devices need to enumerate and be useful. So far that has not proven possible.  What is the trick? Endpoint numbers?  Endpoint indices? Association descriptors? Who knows this stuff?  Cypress, where are you?  All of the obvious things have been tried (I think).

0 Likes

All is well now.  The descriptor needs to look like this:

pastedImage_5.png

Be sure the endpoints are different when defined i.e., EP1, EP2, EP3, EP4

AND... in USBxx_descr.c    (usually named USBFS_descr.c but the user can change that.  I did, mins is just USB)

In USBxx_descr.c the descriptor(s) are defined as data.

  1. Make sure yur descriptor is OK as above
  2. Turn ON the 'generate source' option  in build options (skip=false)
  3. compile the project
  4. Turn OFF the 'generate source' option  in build options (skip=true)
  5. open USB_descr.c
  6. there will be two instances (one for each control interface) of    baInerfaceNr   both with a value of 0x01 This is incorrect.  Change the second instance to 0x03 for the 2nd interface 
  7. recompile. Remember, generate source is off, we don't want to overwrite that change just made.

The two MIDI interfaces will now enumerate properly in the USB attached host as a composite device with two interfaces

After that you will have to adjust the supplied MIDI service and initialization routines to work with two sets of endpoints and local buffers.

The supplied code uses GLOBAL VARIABLES (USB_midi_out_ep and  USB_midi_in_ep) to define  single fixed set of endpoints.... boo...hiss.... 

Routines to look at re endpoint support (arguments not shown): 

MIDI_Init()

USB_PutUsbMidiIn()   

USB_PrepareInBuffer

USB_MIDI_IN_Service()

USB_MIDI_OUT_Service()

USB_callbackLocalMidiEvent()

0 Likes