USB "Device – Audio MIDI" Demo

Post
wannabe
Super Member
2010/04/15 11:57:10
Hi,
 
I tried the Midi demo with success.
 
But I can't find the descriptor entry to change the firmware to simulate more than 1 cable. Does anybody know, where I can tell the firmware to be an 8 cable MIDI interface?
chinzei
Super Member
RE: USB "Device – Audio MIDI" Demo 2010/04/15 14:40:08
where I can tell the firmware to be an 8 cable MIDI interface?

What is the direction of the cables,
- 8 IN or 8 OUT
- 4 IN and 4 OUT
etc.

Tsuneo
wannabe
Super Member
RE: USB "Device – Audio MIDI" Demo 2010/04/15 15:15:27
Yes, eg. 8 IN and 8 OUT. But how do I need to modify the descriptors?
chinzei
Super Member
RE: USB "Device – Audio MIDI" Demo 2010/04/15 16:50:25
eg. 8 IN and 8 OUT.

Umm..
It's too bulky to show an example wink
This is 2 IN & 2 OUT descriptors.
Extend it to 8 by 8

In this example, the connection and IDs of Jacks are as follows.
On-chip patchboard connection of Jacks 

External Embedded
OUT Jack 0x00 ----- IN Jack 0x01 ----+
+----- bulk OUT endpoint
OUT Jack 0x02 ----- IN Jack 0x03 ----+


IN Jack 0x10 ----- OUT Jack 0x11 ----+
+----- bulk IN endpoint
IN Jack 0x12 ----- OUT Jack 0x13 ----+


I show the field to be changed with arrow mark "<---------"
The descriptors without change is not shown, to make this post short.

 
/* Configuration 1 Descriptor */
/* copied from the midi10.pdf USB Device Class Specification for MIDI Devices */
ROM BYTE configDescriptor1[]={
/* Configuration Descriptor */
0x09,//sizeof(USB_CFG_DSC), // Size of this descriptor in bytes
USB_DESCRIPTOR_CONFIGURATION, // CONFIGURATION descriptor type

// Total length of data for this cfg <---------
9 + 9 + 9 + 9 // config, AC interface, CS-AC interface, MS interface
+ 7 + 30 + 30 + 30, // same as wTotalLength of CS-MS interface

0x00, // MSB of Total length
2, // Number of interfaces in this cfg
1, // Index value of this configuration
0, // Configuration string index
_DEFAULT | _SELF, // Attributes, see usb_device.h
50, // Max power consumption (2X mA)

/* Interface Descriptor */
// --- no change ---

/* MIDI Adapter Class-specific AC Interface Descriptor */
// --- no change ---

/* MIDI Adapter Standard MS Interface Descriptor */
// --- no change ---

/* MIDI Adapter Class-specific MS Interface Descriptor */
0x07, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x01, //bDescriptorSubtype - MS_HEADER
0x00,0x01, //BcdADC

//wTotalLength - sum up the size of
// IN and OUT Jack descriptors,
// and endpoint descriptors
7 // this descriptor <---------
+ (9+6) * 2 // Ext OUT - Emb IN
+ (6+9) * 2 // Ext IN - Emb OUT
+ (9+6) * 2, // End point descriptors

0x00, //MSB of wTotalLength

// MIDI on-chip patch board

//
// Ext OUT Jack 0x00 ----- Emb IN Jack 0x01 ----+
//
/* MIDI Adapter MIDI OUT Jack Descriptor (External) */
0x09, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x03, //bDescriptorSubtype - MIDI_OUT_JACK
0x02, //bJackType - EXTERNAL
0x00, //bJackID <---------
0x01, //bNrInputPins
0x01, //BaSourceID(1) <---------
0x01, //BaSourcePin(1)
0x00, //iJack

/* MIDI Adapter MIDI IN Jack Descriptor (Embedded) */
0x06, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x02, //bDescriptorSubtype - MIDI_IN_JACK
0x01, //bJackType - EMBEDDED
0x01, //bJackID <---------
0x00, //iJack
//
// Ext OUT Jack 0x02 ----- Emb IN Jack 0x03 ----+
//
/* MIDI Adapter MIDI OUT Jack Descriptor (External) */
0x09, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x03, //bDescriptorSubtype - MIDI_OUT_JACK
0x02, //bJackType - EXTERNAL
0x02, //bJackID <---------
0x01, //bNrInputPins
0x03, //BaSourceID(1) <---------
0x01, //BaSourcePin(1)
0x00, //iJack

/* MIDI Adapter MIDI IN Jack Descriptor (Embedded) */
0x06, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x02, //bDescriptorSubtype - MIDI_IN_JACK
0x01, //bJackType - EMBEDDED
0x03, //bJackID <---------
0x00, //iJack
//
// Ext IN Jack 0x10 ----- Emb OUT Jack 0x11 ----+
//
/* MIDI Adapter MIDI IN Jack Descriptor (External) */
0x06, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x02, //bDescriptorSubtype - MIDI_IN_JACK
0x02, //bJackType - EXTERNAL
0x10, //bJackID <---------
0x00, //iJack

/* MIDI Adapter MIDI OUT Jack Descriptor (Embedded) */
0x09, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x03, //bDescriptorSubtype - MIDI_OUT_JACK
0x01, //bJackType - EMBEDDED
0x11, //bJackID <---------
0x01, //bNrInputPins
0x10, //BaSourceID(1) <---------
0x01, //BaSourcePin(1)
0x00, //iJack
//
// Ext IN Jack 0x12 ----- Emb OUT Jack 0x13 ----+
//
/* MIDI Adapter MIDI IN Jack Descriptor (External) */
0x06, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x02, //bDescriptorSubtype - MIDI_IN_JACK
0x02, //bJackType - EXTERNAL
0x12, //bJackID <---------
0x00, //iJack

/* MIDI Adapter MIDI OUT Jack Descriptor (Embedded) */
0x09, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x03, //bDescriptorSubtype - MIDI_OUT_JACK
0x01, //bJackType - EMBEDDED
0x13, //bJackID <---------
0x01, //bNrInputPins
0x12, //BaSourceID(1) <---------
0x01, //BaSourcePin(1)
0x00, //iJack


/* MIDI Adapter Standard Bulk OUT Endpoint Descriptor */
// --- no change ---
//
// Emb IN Jack 0x01 ----+
// +----- bulk OUT endpoint
// Emb IN Jack 0x03 ----+
//
/* MIDI Adapter Class-specific Bulk OUT Endpoint Descriptor */
0x06, //bLength <---------
0x25, //bDescriptorType - CS_ENDPOINT
0x01, //bDescriptorSubtype - MS_GENERAL
0x02, //bNumEmbMIDIJack <---------
0x01, //BaAssocJackID(1) <---------
0x03, //BaAssocJackID(2) <---------


/* MIDI Adapter Standard Bulk IN Endpoint Descriptor */
// --- no change ---
//
// Emb OUT Jack 0x11 ----+
// +----- bulk IN endpoint
// Emb OUT Jack 0x13 ----+
//
/* MIDI Adapter Class-specific Bulk IN Endpoint Descriptor */
0x06, //bLength <---------
0x25, //bDescriptorType - CS_ENDPOINT
0x01, //bDescriptorSubtype - MS_GENERAL
0x02, //bNumEmbMIDIJack <---------
0x11, //BaAssocJackID(1) <---------
0x13, //BaAssocJackID(2) <---------
};


Tsuneo

[edit]
Revised: wTotalLength of Config, and Streaming IF class-specific descriptor
post edited by chinzei - 2012/01/11 23:34:59
chinzei
Super Member
RE: USB "Device – Audio MIDI" Demo 2010/04/15 18:54:52
Ah, I remember.
In above post, 0x00 is used for JackID,
but it is restricted by the spec.
midi10.pdf
http://www.usb.org/developers/devclass_docs/midi10.pdf

6.1.2.1 Class-Specific MS Interface Header Descriptor
Each Jack and Element within the USB-MIDI function is assigned a unique identification number, the JackID or ElementID, contained in the bJackID or bElementID field of the descriptor. The value 0x00 is reserved for undefined ID, effectively restricting the total number of addressable Entities in the USB-MIDI function (both Jacks and Elements) to 255.



The Jack IDs are changed as follows.
On-chip patchboard connection of Jacks  

External Embedded
OUT Jack 0x01 ----- IN Jack 0x02 ----+
+----- bulk OUT endpoint
OUT Jack 0x03 ----- IN Jack 0x04 ----+


IN Jack 0x21 ----- OUT Jack 0x22 ----+
+----- bulk IN endpoint
IN Jack 0x23 ----- OUT Jack 0x24 ----+


Revised descriptor set is as follows.
  
/* Configuration 1 Descriptor */
/* copied from the midi10.pdf USB Device Class Specification for MIDI Devices */
ROM BYTE configDescriptor1[]={
/* Configuration Descriptor */
0x09,//sizeof(USB_CFG_DSC), // Size of this descriptor in bytes
USB_DESCRIPTOR_CONFIGURATION, // CONFIGURATION descriptor type

// Total length of data for this cfg <---------
9 + 9 + 9 + 9 // config, AC interface, CS-AC interface, MS interface
+ 7 + 30 + 30 + 30, // same as wTotalLength of CS-MS interface

0x00, // MSB of Total length
2, // Number of interfaces in this cfg
1, // Index value of this configuration
0, // Configuration string index
_DEFAULT | _SELF, // Attributes, see usb_device.h
50, // Max power consumption (2X mA)

/* Interface Descriptor */
// --- no change ---

/* MIDI Adapter Class-specific AC Interface Descriptor */
// --- no change ---

/* MIDI Adapter Standard MS Interface Descriptor */
// --- no change ---

/* MIDI Adapter Class-specific MS Interface Descriptor */
0x07, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x01, //bDescriptorSubtype - MS_HEADER
0x00,0x01, //BcdADC

//wTotalLength - sum up the size of
// IN and OUT Jack descriptors,
// and endpoint descriptors
7 // this descriptor <---------
+ (9+6) * 2 // Ext OUT - Emb IN
+ (6+9) * 2 // Ext IN - Emb OUT
+ (9+6) * 2, // End point descriptors

0x00, //MSB of wTotalLength

// MIDI on-chip patch board

//
// Ext OUT Jack 0x01 ----- Emb IN Jack 0x02
//
/* MIDI Adapter MIDI OUT Jack Descriptor (External) */
0x09, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x03, //bDescriptorSubtype - MIDI_OUT_JACK
0x02, //bJackType - EXTERNAL
0x01, //bJackID <---------
0x01, //bNrInputPins
0x02, //BaSourceID(1) <---------
0x01, //BaSourcePin(1)
0x00, //iJack

/* MIDI Adapter MIDI IN Jack Descriptor (Embedded) */
0x06, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x02, //bDescriptorSubtype - MIDI_IN_JACK
0x01, //bJackType - EMBEDDED
0x02, //bJackID <---------         <========  revised
0x00, //iJack
//
// Ext OUT Jack 0x03 ----- Emb IN Jack 0x04
//
/* MIDI Adapter MIDI OUT Jack Descriptor (External) */
0x09, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x03, //bDescriptorSubtype - MIDI_OUT_JACK
0x02, //bJackType - EXTERNAL
0x03, //bJackID <---------
0x01, //bNrInputPins
0x04, //BaSourceID(1) <---------
0x01, //BaSourcePin(1)
0x00, //iJack

/* MIDI Adapter MIDI IN Jack Descriptor (Embedded) */
0x06, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x02, //bDescriptorSubtype - MIDI_IN_JACK
0x01, //bJackType - EMBEDDED
0x04, //bJackID <---------
0x00, //iJack
//
// Ext IN Jack 0x21 ----- Emb OUT Jack 0x22
//
/* MIDI Adapter MIDI IN Jack Descriptor (External) */
0x06, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x02, //bDescriptorSubtype - MIDI_IN_JACK
0x02, //bJackType - EXTERNAL
0x21, //bJackID <---------
0x00, //iJack

/* MIDI Adapter MIDI OUT Jack Descriptor (Embedded) */
0x09, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x03, //bDescriptorSubtype - MIDI_OUT_JACK
0x01, //bJackType - EMBEDDED
0x22, //bJackID <---------
0x01, //bNrInputPins
0x21, //BaSourceID(1) <---------
0x01, //BaSourcePin(1)
0x00, //iJack
//
// Ext IN Jack 0x23 ----- Emb OUT Jack 0x24
//
/* MIDI Adapter MIDI IN Jack Descriptor (External) */
0x06, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x02, //bDescriptorSubtype - MIDI_IN_JACK
0x02, //bJackType - EXTERNAL
0x23, //bJackID <---------
0x00, //iJack

/* MIDI Adapter MIDI OUT Jack Descriptor (Embedded) */
0x09, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x03, //bDescriptorSubtype - MIDI_OUT_JACK
0x01, //bJackType - EMBEDDED
0x24, //bJackID <---------
0x01, //bNrInputPins
0x23, //BaSourceID(1) <---------
0x01, //BaSourcePin(1)
0x00, //iJack


/* MIDI Adapter Standard Bulk OUT Endpoint Descriptor */
// --- no change ---
//
// Emb IN Jack 0x02 ----+
// +----- bulk OUT endpoint
// Emb IN Jack 0x04 ----+
//
/* MIDI Adapter Class-specific Bulk OUT Endpoint Descriptor */
0x06, //bLength <---------
0x25, //bDescriptorType - CS_ENDPOINT
0x01, //bDescriptorSubtype - MS_GENERAL
0x02, //bNumEmbMIDIJack <---------
0x02, //BaAssocJackID(1) <---------
0x04, //BaAssocJackID(2) <---------


/* MIDI Adapter Standard Bulk IN Endpoint Descriptor */
// --- no change ---
//
// Emb OUT Jack 0x22 ----+
// +----- bulk IN endpoint
// Emb OUT Jack 0x24 ----+
//
/* MIDI Adapter Class-specific Bulk IN Endpoint Descriptor */
0x06, //bLength <---------
0x25, //bDescriptorType - CS_ENDPOINT
0x01, //bDescriptorSubtype - MS_GENERAL
0x02, //bNumEmbMIDIJack <---------
0x22, //BaAssocJackID(1) <---------
0x24, //BaAssocJackID(2) <---------
};


Tsuneo

[Revised]
Jan 13, 2011  On the first MIDI IN Jack Descriptor (Embedded), bJackID was revised from 0x01 to 0x02, as pointed out by PhillipJ
Jan 12, 2012  wTotallength of Config, and Streaming IF class-specific descriptor
post edited by chinzei - 2012/01/11 23:57:20
wannabe
Super Member
RE: USB "Device – Audio MIDI" Demo 2010/04/16 08:02:36
Hi Tsuneo,
 
many thanks to you for this in-depth example [8D]. I think I will need some time to walk through the code.
PhilipJ
Junior Member
Re:USB "Device – Audio MIDI" Demo 2011/01/12 07:38:20
Hi,
 
my apologies for jumping on this thread months later but I have also been puzzling over an extended descriptor to add more MIDI ports.
 
I understand most of what you have shown but I have one query: The entry bJackID is the same (0x01) for the MIDI OUT Jack Descriptor (External) and for the MIDI IN Jack Descriptor (Embedded). Is this intentional or a typing error? I read the USB spec. midi10.pdf and it says this is a "constant uniquely identifying..."
 
All the other Jack Descriptors that you have put in are different numbers, hence why I am puzzled by these two having the same number!!
 
Any clarification would be gratefully received
PhilipJ
 
chinzei
Super Member
Re:USB "Device – Audio MIDI" Demo 2011/01/12 21:40:41
Auuu, thanks. You are right. It's my mistake.
I revised above post.

Tsuneo
PhilipJ
Junior Member
Re:USB "Device – Audio MIDI" Demo 2011/01/13 02:21:23
 
Thanks for the update.
 
PhilipJ
Junior Member
Re:USB "Device – Audio MIDI" Demo 2011/01/20 08:03:33
I now have a 3 'port' MIDI interface working on the PIC32 USB Starter Kit II board, which is great. When I plug a USB cable in using the 5-pin micro-USB connector (J5) on the underside of the board the PC sees the device and enumerates it.
 
My problem is I want to build something with a normal USB 'B' connector so I wired one up to the correct pins but when I plug it in, nothing happens!! I'm obviously missing something obvious, I have 'scoped the extra pin (USBID) on RF3 of the PIC but it just sits high all the time. Does anyone have any suggestions of where I'm going wrong?
 
thanks for any advice
PhilipJ 
 
[EDIT] I should have carried on my experiments a bit longer! It's just because the +5v on the 4 pin USB sockets wasn't connecting to the VBUS pin on the PIC. I've strapped it across and now it works fine.
 
post edited by PhilipJ - 2011/01/20 10:19:24
Snake
Super Member
Re:USB "Device – Audio MIDI" Demo 2012/01/11 13:25:47
Hi,
 
I got here through another thread: http://www.microchip.com/forums/tm.aspx?high=&m=623209&mpage=1#623511
...and I have a problem with the code here.
 
I copied the code you posted but I cannot make it work. Here is my complete descriptor:
 
           /* Configuration 1 Descriptor */
/* copied from the midi10.pdf USB Device Class Specification for MIDI Devices */
ROM BYTE configDescriptor1[]={
 /* Configuration Descriptor */
 0x09,//sizeof(USB_CFG_DSC),    // Size of this descriptor in bytes
 USB_DESCRIPTOR_CONFIGURATION,                // CONFIGURATION descriptor type
 
 // Total length of data for this cfg                   <---------
 9 + 9 + 9 + 9         //    config, AC interface, CS-AC interface, MS interface
 + 7 + 30 + 30 + 28,   //    same as wTotalLength of CS-MS interface
 
 0x00,                 // MSB of Total length
 2,                      // Number of interfaces in this cfg
 1,                      // Index value of this configuration
 0,                      // Configuration string index
 _DEFAULT | _SELF,               // Attributes, see usb_device.h
 50,                     // Max power consumption (2X mA)
 
 /* Interface Descriptor */
 0x09,//sizeof(USB_INTF_DSC),   // Size of this descriptor in bytes
 USB_DESCRIPTOR_INTERFACE,               // INTERFACE descriptor type
 0,                      // Interface Number
 0,                      // Alternate Setting Number
 0,                      // Number of endpoints in this intf
 1,                 // Class code
 1,          // Subclass code
 0,          // Protocol code
 0,                      // Interface string index
 
 /* MIDI Adapter Class-specific AC Interface Descriptor */
 0x09,       //bLength
 0x24,       //bDescriptorType - CS_INTERFACE
 0x01,       //bDescriptorSubtype - HEADER
 0x00,0x01,  //bcdADC
 0x09,0x00,  //wTotalLength
 0x01,       //bInCollection
 0x01,       //baInterfaceNr(1)
 
 /* MIDI Adapter Standard MS Interface Descriptor */
 0x09,       //bLength
 0x04,       //bDescriptorType
 0x01,       //bInterfaceNumber
 0x00,       //bAlternateSetting
 0x02,       //bNumEndpoints
 0x01,       //bInterfaceClass
 0x03,       //bInterfaceSubclass
 0x00,       //bInterfaceProtocol
 0x00,       //iInterface
 
 /* MIDI Adapter Class-specific MS Interface Descriptor */
 0x07,       //bLength
 0x24,       //bDescriptorType - CS_INTERFACE
 0x01,       //bDescriptorSubtype - MS_HEADER
 0x00,0x01,  //BcdADC
 
 //wTotalLength - sum up the size of 
 //                 IN and OUT Jack descriptors,
 //                 and endpoint descriptors
 7              // this descriptor                              <---------
 + (9+6) * 2      // Ext OUT - Emb IN
 + (6+9) * 2      // Ext IN - Emb OUT
 + (9+5) * 2,     // End point descriptors
 
 0x00,       //MSB of wTotalLength
 
  
 //
 //  Ext OUT Jack 0x01  -----  Emb IN Jack 0x02
 //
 /* MIDI Adapter MIDI OUT Jack Descriptor (External) */
 0x09,       //bLength
 0x24,       //bDescriptorType - CS_INTERFACE
 0x03,       //bDescriptorSubtype - MIDI_OUT_JACK
 0x02,       //bJackType - EXTERNAL
 0x01,       //bJackID                                             <---------
 0x01,       //bNrInputPins
 0x02,       //BaSourceID(1)                                       <---------
 0x01,       //BaSourcePin(1)
 0x00,       //iJack
 
 /* MIDI Adapter MIDI IN Jack Descriptor (Embedded) */
 0x06,       //bLength
 0x24,       //bDescriptorType - CS_INTERFACE
 0x02,       //bDescriptorSubtype - MIDI_IN_JACK
 0x01,       //bJackType - EMBEDDED
 0x02,       //bJackID                                             <---------
 0x00,       //iJack
 //
 //  Ext OUT Jack 0x03  -----  Emb IN Jack 0x04
 //
 /* MIDI Adapter MIDI OUT Jack Descriptor (External) */
 0x09,       //bLength
 0x24,       //bDescriptorType - CS_INTERFACE
 0x03,       //bDescriptorSubtype - MIDI_OUT_JACK
 0x02,       //bJackType - EXTERNAL
 0x03,       //bJackID                                             <---------
 0x01,       //bNrInputPins
 0x04,       //BaSourceID(1)                                       <---------
 0x01,       //BaSourcePin(1)
 0x00,       //iJack
 
 /* MIDI Adapter MIDI IN Jack Descriptor (Embedded) */
 0x06,       //bLength
 0x24,       //bDescriptorType - CS_INTERFACE
 0x02,       //bDescriptorSubtype - MIDI_IN_JACK
 0x01,       //bJackType - EMBEDDED
 0x04,       //bJackID                                             <---------
 0x00,       //iJack
 //
 //  Ext IN Jack 0x21  -----  Emb OUT Jack 0x22
 //
 /* MIDI Adapter MIDI IN Jack Descriptor (External) */
 0x06,       //bLength
 0x24,       //bDescriptorType - CS_INTERFACE
 0x02,       //bDescriptorSubtype - MIDI_IN_JACK
 0x02,       //bJackType - EXTERNAL
 0x21,       //bJackID                                             <---------
 0x00,       //iJack
 
 /* MIDI Adapter MIDI OUT Jack Descriptor (Embedded) */
 0x09,       //bLength
 0x24,       //bDescriptorType - CS_INTERFACE
 0x03,       //bDescriptorSubtype - MIDI_OUT_JACK
 0x01,       //bJackType - EMBEDDED
 0x22,       //bJackID                                             <---------
 0x01,       //bNrInputPins
 0x21,       //BaSourceID(1)                                       <---------
 0x01,       //BaSourcePin(1)
 0x00,       //iJack
 //
 //  Ext IN Jack 0x23  -----  Emb OUT Jack 0x24
 //
 /* MIDI Adapter MIDI IN Jack Descriptor (External) */
 0x06,       //bLength
 0x24,       //bDescriptorType - CS_INTERFACE
 0x02,       //bDescriptorSubtype - MIDI_IN_JACK
 0x02,       //bJackType - EXTERNAL
 0x23,       //bJackID                                             <---------
 0x00,       //iJack
 
 /* MIDI Adapter MIDI OUT Jack Descriptor (Embedded) */
 0x09,       //bLength
 0x24,       //bDescriptorType - CS_INTERFACE
 0x03,       //bDescriptorSubtype - MIDI_OUT_JACK
 0x01,       //bJackType - EMBEDDED
 0x24,       //bJackID                                             <---------
 0x01,       //bNrInputPins
 0x23,       //BaSourceID(1)                                       <---------
 0x01,       //BaSourcePin(1)
 0x00,       //iJack
 
   /* MIDI Adapter Standard Bulk OUT Endpoint Descriptor */
 0x09,       //bLength
 0x05,       //bDescriptorType - ENDPOINT
 0x01,       //bEndpointAddress - OUT
 0x02,       //bmAttributes
 0x40,0x00,  //wMaxPacketSize
 0x00,       //bInterval
 0x00,       //bRefresh
 0x00,       //bSynchAddress
 
 /* MIDI Adapter Class-specific Bulk OUT Endpoint Descriptor */
 0x06,       //bLength                                             <---------
 0x25,       //bDescriptorType - CS_ENDPOINT
 0x01,       //bDescriptorSubtype - MS_GENERAL
 0x02,       //bNumEmbMIDIJack                                     <---------
 0x02,       //BaAssocJackID(1)                                    <---------
 0x04,       //BaAssocJackID(2)                                    <---------
 
 /* MIDI Adapter Standard Bulk IN Endpoint Descriptor */
 0x09,       //bLength
 0x05,       //bDescriptorType
 0x81,       //bEndpointAddress
 0x02,       //bmAttributes
 0x40,0x00,  //wMaxPacketSize
 0x00,       //bInterval
 0x00,       //bRefresh
 0x00,       //bSynchAddress
 
 /* MIDI Adapter Class-specific Bulk IN Endpoint Descriptor */
 0x06,       //bLength                                             <---------
 0x25,       //bDescriptorType - CS_ENDPOINT
 0x01,       //bDescriptorSubtype - MS_GENERAL
 0x02,       //bNumEmbMIDIJack                                     <---------
 0x22,       //BaAssocJackID(1)                                    <---------
 0x24       //BaAssocJackID(2)                                    <---------
};

 
I did this two times to make sure I did not copy anything wrong.
Could someone please post a complete working sample?
 
Or do I have to change something else, too?
 
Best Regards
chinzei
Super Member
Re:USB "Device – Audio MIDI" Demo 2012/01/11 23:47:27

Ah, sorry. It's my mistake.
In above post ( http://www.microchip.com/forums/fb.ashx?m=493422 ),
On the calculation of wTotalLength (Config, and Streaming IF class-specific descriptor),
the size of CS Bulk Endpoint Descriptor is wrong.

Change these calculation as follows,

      /* Configuration Descriptor */
      0x09,//sizeof(USB_CFG_DSC),    // Size of this descriptor in bytes
      USB_DESCRIPTOR_CONFIGURATION,                // CONFIGURATION descriptor type
      
      // Total length of data for this cfg
      9 + 9 + 9 + 9         //    config, AC interface, CS-AC interface, MS interface 
//      + 7 + 30 + 30 + 28,   //    same as wTotalLength of CS-MS interface         <--------- 
      + 7 + 30 + 30 + 30,   //    same as wTotalLength of CS-MS interface           <--------- 
      
      0x00,                 // MSB of Total length 
      2,                      // Number of interfaces in this cfg
      1,                      // Index value of this configuration
      0,                      // Configuration string index
      _DEFAULT | _SELF,               // Attributes, see usb_device.h
      50,                     // Max power consumption (2X mA)



      /* MIDI Adapter Class-specific MS Interface Descriptor */
      0x07,       //bLength 
      0x24,       //bDescriptorType - CS_INTERFACE 
      0x01,       //bDescriptorSubtype - MS_HEADER 
      0x00,0x01,  //BcdADC 
      
      //wTotalLength - sum up the size of  
      //                 IN and OUT Jack descriptors, 
      //                 and endpoint descriptors 
      7              // this descriptor
      + (9+6) * 2      // Ext OUT - Emb IN 
      + (6+9) * 2      // Ext IN - Emb OUT 
//      + (9+5) * 2,     // End point descriptors   <------
      + (9+6) * 2,     // End point descriptors     <------


Tsuneo
post edited by chinzei - 2012/01/11 23:59:17
Snake
Super Member
Re:USB "Device – Audio MIDI" Demo 2012/01/12 05:23:42
Thank you, now it works.
 
Now my device is displayed as:
"MyDevice"
"MIDIIN2 (MyDevice)" / "MIDIOUT2 (MyDevice)"
 
Is it possible to change the name?