Skip to content

USB MIDI for Arduino #2943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update USBCore.h
  • Loading branch information
gurbrinder committed Apr 8, 2015
commit b50c9b6703c5c700aa314f33f6d5a371b070097a
115 changes: 114 additions & 1 deletion hardware/arduino/sam/cores/arduino/USB/USBCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@
#define HID_REPORT_DESCRIPTOR_TYPE 0x22
#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23

#define MIDI_AUDIO 0x01
#define MIDI_AUDIO_CONTROL 0x01
#define MIDI_CS_INTERFACE 0x24
#define MIDI_CS_ENDPOINT 0x25
#define MIDI_STREAMING 0x3
#define MIDI_JACK_EMD 0x01
#define MIDI_JACK_EXT 0X02


_Pragma("pack(1)")

// Device
Expand Down Expand Up @@ -279,6 +288,91 @@ typedef struct
EndpointDescriptor in;
} HIDDescriptor;


typedef struct
{
uint8_t len; // 9
uint8_t dtype; // 4
uint8_t dsubType;
uint16_t bcdADc;
uint16_t wTotalLength;
uint8_t bInCollection;
uint8_t interfaceNumbers;
} MIDI_ACInterfaceDescriptor;

typedef struct
{
uint8_t len; // 9
uint8_t dtype; // 4
uint8_t dsubType;
uint8_t jackType;
uint8_t jackID;
uint8_t jackStrIndex;
} MIDIJackinDescriptor;

typedef struct
{
uint8_t len; // 9
uint8_t dtype; // 4
uint8_t dsubType;
uint8_t jackType;
uint8_t jackID;
uint8_t nPins;
uint8_t srcJackID;
uint8_t srcPinID;
uint8_t jackStrIndex;
} MIDIJackOutDescriptor;

typedef struct
{
EndpointDescriptor len; // 9
uint8_t refresh; // 4
uint8_t sync;
} MIDI_EPDescriptor;

typedef struct
{
uint8_t len; // 5
uint8_t dtype; // 0x24
uint8_t subtype;
uint8_t embJacks;
uint8_t jackID;
} MIDI_EP_ACDescriptor;

typedef struct
{
uint8_t len; // 9
uint8_t dtype; // 4
uint8_t dsubType;
uint16_t bcdADc;
uint16_t wTotalLength;
} MIDI_ASInterfaceDescriptor;

typedef struct
{
#ifdef CDC_ENABLED
// IAD
IADDescriptor iad;
#endif
// MIDI Audio Control Interface
InterfaceDescriptor Audio_ControlInterface;
MIDI_ACInterfaceDescriptor Audio_ControlInterface_SPC;

// MIDI Audio Streaming Interface
InterfaceDescriptor Audio_StreamInterface;
MIDI_ASInterfaceDescriptor Audio_StreamInterface_SPC;

MIDIJackinDescriptor MIDI_In_Jack_Emb;
MIDIJackinDescriptor MIDI_In_Jack_Ext;
MIDIJackOutDescriptor MIDI_Out_Jack_Emb;
MIDIJackOutDescriptor MIDI_Out_Jack_Ext;

MIDI_EPDescriptor MIDI_In_Jack_Endpoint;
MIDI_EP_ACDescriptor MIDI_In_Jack_Endpoint_SPC;
MIDI_EPDescriptor MIDI_Out_Jack_Endpoint;
MIDI_EP_ACDescriptor MIDI_Out_Jack_Endpoint_SPC;
} MIDIDescriptor;

_Pragma("pack()")

#define D_DEVICE(_class,_subClass,_proto,_packetSize0,_vid,_pid,_version,_im,_ip,_is,_configs) \
Expand All @@ -304,8 +398,27 @@ _Pragma("pack()")

#define D_HIDREPORT(_descriptorLength) \
{ 9, 0x21, 0x1, 0x1, 0, 1, 0x22, _descriptorLength, 0 }


#define D_AC_INTERFACE(_streamingInterfaces, _MIDIInterface) \
{ 9, MIDI_CS_INTERFACE, 0x1, 0x0100, 0x0009, _streamingInterfaces, _MIDIInterface }

#define D_AS_INTERFACE \
{ 0x7, MIDI_CS_INTERFACE, 0x01,0x0100, 0x0041}

#define D_MIDI_INJACK(jackProp, _jackID) \
{ 0x06, MIDI_CS_INTERFACE, 0x02, jackProp, _jackID, 0 }

#define D_MIDI_OUTJACK(jackProp, _jackID, _nPins, _srcID, _srcPin) \
{ 0x09, MIDI_CS_INTERFACE, 0x3, jackProp, _jackID, _nPins, _srcID, _srcPin, 0 }

#define D_MIDI_JACK_EP(_addr,_attr,_packetSize) \
{ 9, 5, _addr,_attr,_packetSize, 0, 0, 0}

#define D_MIDI_AC_JACK_EP(_nMIDI, _iDMIDI) \
{ 5, MIDI_CS_ENDPOINT, 0x1, _nMIDI, _iDMIDI}

#define D_CDCCS(_subtype,_d0,_d1) { 5, 0x24, _subtype, _d0, _d1 }
#define D_CDCCS4(_subtype,_d0) { 4, 0x24, _subtype, _d0 }


#endif