Browse Source

Merge pull request #271 from vjmuzik/master

Configurable Midi Port Names
main
Paul Stoffregen 4 years ago
parent
commit
abeb92884e
No account linked to committer's email address
3 changed files with 268 additions and 24 deletions
  1. +250
    -24
      teensy3/usb_desc.c
  2. +16
    -0
      teensy3/usb_names.h
  3. +2
    -0
      teensy4/usb.c

+ 250
- 24
teensy3/usb_desc.c View File

@@ -865,14 +865,14 @@ static uint8_t config_descriptor[CONFIG_DESC_SIZE] = {
0x02, // bDescriptorSubtype = MIDI_IN_JACK
0x01, // bJackType = EMBEDDED
1, // bJackID, ID = 1
0, // iJack
0x05, // iJack
// MIDI IN Jack Descriptor, B.4.3, Table B-8 (external), page 40
6, // bLength
0x24, // bDescriptorType = CS_INTERFACE
0x02, // bDescriptorSubtype = MIDI_IN_JACK
0x02, // bJackType = EXTERNAL
2, // bJackID, ID = 2
0, // iJack
0x05, // iJack
// MIDI OUT Jack Descriptor, B.4.4, Table B-9, page 41
9,
0x24, // bDescriptorType = CS_INTERFACE
@@ -882,7 +882,7 @@ static uint8_t config_descriptor[CONFIG_DESC_SIZE] = {
1, // bNrInputPins = 1 pin
2, // BaSourceID(1) = 2
1, // BaSourcePin(1) = first pin
0, // iJack
0x05, // iJack
// MIDI OUT Jack Descriptor, B.4.4, Table B-10, page 41
9,
0x24, // bDescriptorType = CS_INTERFACE
@@ -892,56 +892,56 @@ static uint8_t config_descriptor[CONFIG_DESC_SIZE] = {
1, // bNrInputPins = 1 pin
1, // BaSourceID(1) = 1
1, // BaSourcePin(1) = first pin
0, // iJack
0x05, // iJack
#if MIDI_NUM_CABLES >= 2
#define MIDI_INTERFACE_JACK_PAIR(a, b, c, d) \
6, 0x24, 0x02, 0x01, (a), 0, \
6, 0x24, 0x02, 0x02, (b), 0, \
9, 0x24, 0x03, 0x01, (c), 1, (b), 1, 0, \
9, 0x24, 0x03, 0x02, (d), 1, (a), 1, 0,
MIDI_INTERFACE_JACK_PAIR(5, 6, 7, 8)
#define MIDI_INTERFACE_JACK_PAIR(a, b, c, d, e) \
6, 0x24, 0x02, 0x01, (a), (e), \
6, 0x24, 0x02, 0x02, (b), (e), \
9, 0x24, 0x03, 0x01, (c), 1, (b), 1, (e), \
9, 0x24, 0x03, 0x02, (d), 1, (a), 1, (e),
MIDI_INTERFACE_JACK_PAIR(5, 6, 7, 8, 0x06)
#endif
#if MIDI_NUM_CABLES >= 3
MIDI_INTERFACE_JACK_PAIR(9, 10, 11, 12)
MIDI_INTERFACE_JACK_PAIR(9, 10, 11, 12, 0x07)
#endif
#if MIDI_NUM_CABLES >= 4
MIDI_INTERFACE_JACK_PAIR(13, 14, 15, 16)
MIDI_INTERFACE_JACK_PAIR(13, 14, 15, 16, 0x08)
#endif
#if MIDI_NUM_CABLES >= 5
MIDI_INTERFACE_JACK_PAIR(17, 18, 19, 20)
MIDI_INTERFACE_JACK_PAIR(17, 18, 19, 20, 0x09)
#endif
#if MIDI_NUM_CABLES >= 6
MIDI_INTERFACE_JACK_PAIR(21, 22, 23, 24)
MIDI_INTERFACE_JACK_PAIR(21, 22, 23, 24, 0x0A)
#endif
#if MIDI_NUM_CABLES >= 7
MIDI_INTERFACE_JACK_PAIR(25, 26, 27, 28)
MIDI_INTERFACE_JACK_PAIR(25, 26, 27, 28, 0x0B)
#endif
#if MIDI_NUM_CABLES >= 8
MIDI_INTERFACE_JACK_PAIR(29, 30, 31, 32)
MIDI_INTERFACE_JACK_PAIR(29, 30, 31, 32, 0x0C)
#endif
#if MIDI_NUM_CABLES >= 9
MIDI_INTERFACE_JACK_PAIR(33, 34, 35, 36)
MIDI_INTERFACE_JACK_PAIR(33, 34, 35, 36, 0x0D)
#endif
#if MIDI_NUM_CABLES >= 10
MIDI_INTERFACE_JACK_PAIR(37, 38, 39, 40)
MIDI_INTERFACE_JACK_PAIR(37, 38, 39, 40, 0x0E)
#endif
#if MIDI_NUM_CABLES >= 11
MIDI_INTERFACE_JACK_PAIR(41, 42, 43, 44)
MIDI_INTERFACE_JACK_PAIR(41, 42, 43, 44, 0x0F)
#endif
#if MIDI_NUM_CABLES >= 12
MIDI_INTERFACE_JACK_PAIR(45, 46, 47, 48)
MIDI_INTERFACE_JACK_PAIR(45, 46, 47, 48, 0x10)
#endif
#if MIDI_NUM_CABLES >= 13
MIDI_INTERFACE_JACK_PAIR(49, 50, 51, 52)
MIDI_INTERFACE_JACK_PAIR(49, 50, 51, 52, 0x11)
#endif
#if MIDI_NUM_CABLES >= 14
MIDI_INTERFACE_JACK_PAIR(53, 54, 55, 56)
MIDI_INTERFACE_JACK_PAIR(53, 54, 55, 56, 0x12)
#endif
#if MIDI_NUM_CABLES >= 15
MIDI_INTERFACE_JACK_PAIR(57, 58, 59, 60)
MIDI_INTERFACE_JACK_PAIR(57, 58, 59, 60, 0x13)
#endif
#if MIDI_NUM_CABLES >= 16
MIDI_INTERFACE_JACK_PAIR(61, 62, 63, 64)
MIDI_INTERFACE_JACK_PAIR(61, 62, 63, 64, 0x14)
#endif
// Standard Bulk OUT Endpoint Descriptor, B.5.1, Table B-11, pae 42
9, // bLength
@@ -1596,6 +1596,71 @@ extern struct usb_string_descriptor_struct usb_string_product_name
extern struct usb_string_descriptor_struct usb_string_serial_number
__attribute__ ((weak, alias("usb_string_serial_number_default")));

#ifdef MIDI_INTERFACE
extern struct usb_string_descriptor_struct usb_string_midi_port1
__attribute__ ((weak, alias("usb_string_midi_port1_default")));
#if MIDI_NUM_CABLES >= 2
extern struct usb_string_descriptor_struct usb_string_midi_port2
__attribute__ ((weak, alias("usb_string_midi_port2_default")));
#endif
#if MIDI_NUM_CABLES >= 3
extern struct usb_string_descriptor_struct usb_string_midi_port3
__attribute__ ((weak, alias("usb_string_midi_port3_default")));
#endif
#if MIDI_NUM_CABLES >= 4
extern struct usb_string_descriptor_struct usb_string_midi_port4
__attribute__ ((weak, alias("usb_string_midi_port4_default")));
#endif
#if MIDI_NUM_CABLES >= 5
extern struct usb_string_descriptor_struct usb_string_midi_port5
__attribute__ ((weak, alias("usb_string_midi_port5_default")));
#endif
#if MIDI_NUM_CABLES >= 6
extern struct usb_string_descriptor_struct usb_string_midi_port6
__attribute__ ((weak, alias("usb_string_midi_port6_default")));
#endif
#if MIDI_NUM_CABLES >= 7
extern struct usb_string_descriptor_struct usb_string_midi_port7
__attribute__ ((weak, alias("usb_string_midi_port7_default")));
#endif
#if MIDI_NUM_CABLES >= 8
extern struct usb_string_descriptor_struct usb_string_midi_port8
__attribute__ ((weak, alias("usb_string_midi_port8_default")));
#endif
#if MIDI_NUM_CABLES >= 9
extern struct usb_string_descriptor_struct usb_string_midi_port9
__attribute__ ((weak, alias("usb_string_midi_port9_default")));
#endif
#if MIDI_NUM_CABLES >= 10
extern struct usb_string_descriptor_struct usb_string_midi_port10
__attribute__ ((weak, alias("usb_string_midi_port10_default")));
#endif
#if MIDI_NUM_CABLES >= 11
extern struct usb_string_descriptor_struct usb_string_midi_port11
__attribute__ ((weak, alias("usb_string_midi_port11_default")));
#endif
#if MIDI_NUM_CABLES >= 12
extern struct usb_string_descriptor_struct usb_string_midi_port12
__attribute__ ((weak, alias("usb_string_midi_port12_default")));
#endif
#if MIDI_NUM_CABLES >= 13
extern struct usb_string_descriptor_struct usb_string_midi_port13
__attribute__ ((weak, alias("usb_string_midi_port13_default")));
#endif
#if MIDI_NUM_CABLES >= 14
extern struct usb_string_descriptor_struct usb_string_midi_port14
__attribute__ ((weak, alias("usb_string_midi_port14_default")));
#endif
#if MIDI_NUM_CABLES >= 15
extern struct usb_string_descriptor_struct usb_string_midi_port15
__attribute__ ((weak, alias("usb_string_midi_port15_default")));
#endif
#if MIDI_NUM_CABLES >= 16
extern struct usb_string_descriptor_struct usb_string_midi_port16
__attribute__ ((weak, alias("usb_string_midi_port16_default")));
#endif
#endif

struct usb_string_descriptor_struct string0 = {
4,
3,
@@ -1617,6 +1682,119 @@ struct usb_string_descriptor_struct usb_string_serial_number_default = {
3,
{0,0,0,0,0,0,0,0,0,0}
};
#ifdef MIDI_INTERFACE
struct usb_string_descriptor_struct usb_string_midi_port1_default = {
14,
3,
{'P','o','r','t',' ','1'}
};
#if MIDI_NUM_CABLES >= 2
struct usb_string_descriptor_struct usb_string_midi_port2_default = {
14,
3,
{'P','o','r','t',' ','2'}
};
#endif
#if MIDI_NUM_CABLES >= 3
struct usb_string_descriptor_struct usb_string_midi_port3_default = {
14,
3,
{'P','o','r','t',' ','3'}
};
#endif
#if MIDI_NUM_CABLES >= 4
struct usb_string_descriptor_struct usb_string_midi_port4_default = {
14,
3,
{'P','o','r','t',' ','4'}
};
#endif
#if MIDI_NUM_CABLES >= 5
struct usb_string_descriptor_struct usb_string_midi_port5_default = {
14,
3,
{'P','o','r','t',' ','5'}
};
#endif
#if MIDI_NUM_CABLES >= 6
struct usb_string_descriptor_struct usb_string_midi_port6_default = {
14,
3,
{'P','o','r','t',' ','6'}
};
#endif
#if MIDI_NUM_CABLES >= 7
struct usb_string_descriptor_struct usb_string_midi_port7_default = {
14,
3,
{'P','o','r','t',' ','7'}
};
#endif
#if MIDI_NUM_CABLES >= 8
struct usb_string_descriptor_struct usb_string_midi_port8_default = {
14,
3,
{'P','o','r','t',' ','8'}
};
#endif
#if MIDI_NUM_CABLES >= 9
struct usb_string_descriptor_struct usb_string_midi_port9_default = {
14,
3,
{'P','o','r','t',' ','9'}
};
#endif
#if MIDI_NUM_CABLES >= 10
struct usb_string_descriptor_struct usb_string_midi_port10_default = {
16,
3,
{'P','o','r','t',' ','1','0'}
};
#endif
#if MIDI_NUM_CABLES >= 11
struct usb_string_descriptor_struct usb_string_midi_port11_default = {
16,
3,
{'P','o','r','t',' ','1','1'}
};
#endif
#if MIDI_NUM_CABLES >= 12
struct usb_string_descriptor_struct usb_string_midi_port12_default = {
16,
3,
{'P','o','r','t',' ','1','2'}
};
#endif
#if MIDI_NUM_CABLES >= 13
struct usb_string_descriptor_struct usb_string_midi_port13_default = {
16,
3,
{'P','o','r','t',' ','1','3'}
};
#endif
#if MIDI_NUM_CABLES >= 14
struct usb_string_descriptor_struct usb_string_midi_port14_default = {
16,
3,
{'P','o','r','t',' ','1','4'}
};
#endif
#if MIDI_NUM_CABLES >= 15
struct usb_string_descriptor_struct usb_string_midi_port15_default = {
16,
3,
{'P','o','r','t',' ','1','5'}
};
#endif
#if MIDI_NUM_CABLES >= 16
struct usb_string_descriptor_struct usb_string_midi_port16_default = {
16,
3,
{'P','o','r','t',' ','1','6'}
};
#endif
#endif

#ifdef MTP_INTERFACE
struct usb_string_descriptor_struct usb_string_mtp = {
2 + 3 * 2,
@@ -1704,6 +1882,54 @@ const usb_descriptor_list_t usb_descriptor_list[] = {
#endif
#ifdef MTP_INTERFACE
{0x0304, 0x0409, (const uint8_t *)&usb_string_mtp, 0},
#endif
#ifdef MIDI_INTERFACE
{0x0305, 0x0409, (const uint8_t *)&usb_string_midi_port1, 0},
#if MIDI_NUM_CABLES >= 2
{0x0306, 0x0409, (const uint8_t *)&usb_string_midi_port2, 0},
#endif
#if MIDI_NUM_CABLES >= 3
{0x0307, 0x0409, (const uint8_t *)&usb_string_midi_port3, 0},
#endif
#if MIDI_NUM_CABLES >= 4
{0x0308, 0x0409, (const uint8_t *)&usb_string_midi_port4, 0},
#endif
#if MIDI_NUM_CABLES >= 5
{0x0309, 0x0409, (const uint8_t *)&usb_string_midi_port5, 0},
#endif
#if MIDI_NUM_CABLES >= 6
{0x030A, 0x0409, (const uint8_t *)&usb_string_midi_port6, 0},
#endif
#if MIDI_NUM_CABLES >= 7
{0x030B, 0x0409, (const uint8_t *)&usb_string_midi_port7, 0},
#endif
#if MIDI_NUM_CABLES >= 8
{0x030C, 0x0409, (const uint8_t *)&usb_string_midi_port8, 0},
#endif
#if MIDI_NUM_CABLES >= 9
{0x030D, 0x0409, (const uint8_t *)&usb_string_midi_port9, 0},
#endif
#if MIDI_NUM_CABLES >= 10
{0x030E, 0x0409, (const uint8_t *)&usb_string_midi_port10, 0},
#endif
#if MIDI_NUM_CABLES >= 11
{0x030F, 0x0409, (const uint8_t *)&usb_string_midi_port11, 0},
#endif
#if MIDI_NUM_CABLES >= 12
{0x0310, 0x0409, (const uint8_t *)&usb_string_midi_port12, 0},
#endif
#if MIDI_NUM_CABLES >= 13
{0x0311, 0x0409, (const uint8_t *)&usb_string_midi_port13, 0},
#endif
#if MIDI_NUM_CABLES >= 14
{0x0312, 0x0409, (const uint8_t *)&usb_string_midi_port14, 0},
#endif
#if MIDI_NUM_CABLES >= 15
{0x0313, 0x0409, (const uint8_t *)&usb_string_midi_port15, 0},
#endif
#if MIDI_NUM_CABLES >= 16
{0x0314, 0x0409, (const uint8_t *)&usb_string_midi_port16, 0},
#endif
#endif
{0x0300, 0x0000, (const uint8_t *)&string0, 0},
{0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0},

+ 16
- 0
teensy3/usb_names.h View File

@@ -49,6 +49,22 @@ struct usb_string_descriptor_struct {
extern struct usb_string_descriptor_struct usb_string_manufacturer_name;
extern struct usb_string_descriptor_struct usb_string_product_name;
extern struct usb_string_descriptor_struct usb_string_serial_number;
extern struct usb_string_descriptor_struct usb_string_midi_port1;
extern struct usb_string_descriptor_struct usb_string_midi_port2;
extern struct usb_string_descriptor_struct usb_string_midi_port3;
extern struct usb_string_descriptor_struct usb_string_midi_port4;
extern struct usb_string_descriptor_struct usb_string_midi_port5;
extern struct usb_string_descriptor_struct usb_string_midi_port6;
extern struct usb_string_descriptor_struct usb_string_midi_port7;
extern struct usb_string_descriptor_struct usb_string_midi_port8;
extern struct usb_string_descriptor_struct usb_string_midi_port9;
extern struct usb_string_descriptor_struct usb_string_midi_port10;
extern struct usb_string_descriptor_struct usb_string_midi_port11;
extern struct usb_string_descriptor_struct usb_string_midi_port12;
extern struct usb_string_descriptor_struct usb_string_midi_port13;
extern struct usb_string_descriptor_struct usb_string_midi_port14;
extern struct usb_string_descriptor_struct usb_string_midi_port15;
extern struct usb_string_descriptor_struct usb_string_midi_port16;

#ifdef __cplusplus
}

+ 2
- 0
teensy4/usb.c View File

@@ -27,6 +27,8 @@

typedef struct endpoint_struct endpoint_t;

#if defined(NUM_ENDPOINTS)

struct endpoint_struct {
uint32_t config;
uint32_t current;

Loading…
Cancel
Save