MIDI: Add packet interface
This changes the internal buffering to the raw 4-byte messages. The conversion of the messages to a byte-stream moved to the read/write methods. It adds a raw packet interface to send and retrieve the raw 4-byte USB MIDI message: static inline bool tud_midi_receive (uint8_t packet[4]); static inline bool tud_midi_send (uint8_t const packet[4]); MIDI USB packets carry virtual cable/wire/plug data in the packet header, which cannot be exported in the byte-stream interface. The raw packet interface allows to send and and receive the complete USB message.
This commit is contained in:
@@ -62,6 +62,9 @@ uint32_t tud_midi_n_write (uint8_t itf, uint8_t jack_id, uint8_t const* buf
|
||||
static inline
|
||||
uint32_t tud_midi_n_write24 (uint8_t itf, uint8_t jack_id, uint8_t b1, uint8_t b2, uint8_t b3);
|
||||
|
||||
bool tud_midi_n_receive (uint8_t itf, uint8_t packet[4]);
|
||||
bool tud_midi_n_send (uint8_t itf, uint8_t const packet[4]);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Application API (Interface0)
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -71,6 +74,8 @@ static inline uint32_t tud_midi_read (void* buffer, uint32_t bufsize);
|
||||
static inline void tud_midi_read_flush (void);
|
||||
static inline uint32_t tud_midi_write (uint8_t jack_id, uint8_t const* buffer, uint32_t bufsize);
|
||||
static inline uint32_t tudi_midi_write24 (uint8_t jack_id, uint8_t b1, uint8_t b2, uint8_t b3);
|
||||
static inline bool tud_midi_receive (uint8_t packet[4]);
|
||||
static inline bool tud_midi_send (uint8_t const packet[4]);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Application Callback API (weak is optional)
|
||||
@@ -118,6 +123,16 @@ static inline uint32_t tudi_midi_write24 (uint8_t jack_id, uint8_t b1, uint8_t b
|
||||
return tud_midi_write(jack_id, msg, 3);
|
||||
}
|
||||
|
||||
static inline bool tud_midi_receive (uint8_t packet[4])
|
||||
{
|
||||
return tud_midi_n_receive(0, packet);
|
||||
}
|
||||
|
||||
static inline bool tud_midi_send (uint8_t const packet[4])
|
||||
{
|
||||
return tud_midi_n_send(0, packet);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Internal Class Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
|
Reference in New Issue
Block a user