11// ================================================================================
22// ================================================================================
3- // MIDI USB class
43
4+ /* *
5+ MIDI USB class
6+ */
57#ifndef MIDIUSB_h
68#define MIDIUSB_h
79
@@ -88,7 +90,7 @@ typedef struct
8890#define MIDI_JACK_EXT 0X02
8991
9092_Pragma (" pack(1)" )
91-
93+ // / Midi Audio Control Interface Descriptor
9294typedef struct
9395{
9496 uint8_t len; // 9
@@ -123,13 +125,15 @@ typedef struct
123125 uint8_t jackStrIndex;
124126} MIDIJackOutDescriptor;
125127
128+ // / MIDI Jack EndPoint Descriptor, common to midi in and out jacks.
126129typedef struct
127130{
128131 EndpointDescriptor len; // 9
129132 uint8_t refresh; // 4
130133 uint8_t sync;
131134} MIDI_EPDescriptor;
132135
136+ // / MIDI Jack EndPoint AudioControl Descriptor, common to midi in and out ac jacks.
133137typedef struct
134138{
135139 uint8_t len; // 5
@@ -139,6 +143,7 @@ typedef struct
139143 uint8_t jackID;
140144} MIDI_EP_ACDescriptor;
141145
146+ // / MIDI Audio Stream Descriptor Interface
142147typedef struct
143148{
144149 uint8_t len; // 9
@@ -148,6 +153,7 @@ typedef struct
148153 uint16_t wTotalLength;
149154} MIDI_ASInterfaceDescriptor;
150155
156+ // / Top Level MIDI Descriptor used to create a Midi Interface instace \see MIDI_::getInterface()
151157typedef struct
152158{
153159 // IAD
@@ -192,32 +198,53 @@ typedef struct
192198#define D_CDCCS (_subtype,_d0,_d1 ) { 5 , 0x24 , _subtype, _d0, _d1 }
193199#define D_CDCCS4 (_subtype,_d0 ) { 4 , 0x24 , _subtype, _d0 }
194200
201+ #ifndef DOXYGEN_ARD
202+ // the following would confuse doxygen documentation tool, so skip in that case for autodoc build
195203_Pragma (" pack()" )
196204
197205#define WEAK __attribute__ ((weak))
198206
207+ #endif
208+
209+ /* *
210+ Concrete MIDI implementation of a PluggableUSBModule
211+ By default, will define one midi in and one midi out enpoints.
212+ */
199213class MIDI_ : public PluggableUSBModule
200214{
201215// private:
202216// RingBuffer *_midi_rx_buffer;
203217private:
204- void accept (void );
205- EPTYPE_DESCRIPTOR_SIZE epType[2 ];
218+ void accept (void ); // /< Accepts a midi packet, \see MIDI_::read()
219+ EPTYPE_DESCRIPTOR_SIZE epType[2 ]; // /< Container that defines the two bulk MIDI IN/OUT endpoints types
206220
207221protected:
208222 // Implementation of the PUSBListNode
223+
224+ // / Creates a MIDIDescriptor midi interface and sollicit USBDevice to send control to it.
225+ // / \see USBDevice::SendControl()
209226 int getInterface (uint8_t * interfaceNum);
227+ // / Current implementation just returns 0
210228 int getDescriptor (USBSetup& setup);
229+ // / Optional interface usb setup callback, current implementation returns false
211230 bool setup (USBSetup& setup);
231+ // / MIDI Device short name, defaults to "MIDI" and returns a length of 4 chars
212232 uint8_t getShortName (char * name);
213233
214234public:
235+ // / Creates a MIDI USB device with 2 endpoints
215236 MIDI_ (void );
237+ // / Returns the number of bytes currently available from RX
216238 uint32_t available (void );
239+ // / Reads a new MIDI message from USB
217240 midiEventPacket_t read (void );
241+ // / Flushes TX midi channel
218242 void flush (void );
243+ // / Sends a MIDI message to USB
219244 void sendMIDI (midiEventPacket_t event);
245+ // / Sends a MIDI buffer of length size to USB
220246 size_t write (const uint8_t *buffer, size_t size);
247+ // / NIY
221248 operator bool ();
222249};
223250extern MIDI_ MidiUSB;
0 commit comments