22#include "USBDescriptor.h"
23#include "USBDevice_Types.h"
26#include "MIDIMessage.h"
27#include "EventFlags.h"
28#include "rtos/Mutex.h"
31#define DEFAULT_CONFIGURATION (1)
75 USBMIDI(
bool connect_blocking =
true, uint16_t vendor_id = 0x0700, uint16_t product_id = 0x0101, uint16_t product_release = 0x0001);
93 USBMIDI(
USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release);
155 virtual void callback_set_configuration(uint8_t configuration);
157 virtual void callback_set_interface(uint16_t interface, uint8_t alternate);
159 virtual const uint8_t *string_iproduct_desc();
161 virtual const uint8_t *string_iinterface_desc();
163 virtual const uint8_t *configuration_desc(uint8_t index);
166 static const uint32_t MaxSize = 64;
168 uint8_t _bulk_buf[MaxSize];
169 uint32_t _bulk_buf_pos;
170 uint32_t _bulk_buf_size;
173 uint8_t _data[MAX_MIDI_MESSAGE_SIZE + 1];
181 uint8_t _config_descriptor[0x65];
187 void _out_callback();
188 bool _next_message();
A MIDI message container.
virtual void callback_request(const setup_packet_t *setup)
Called by USBDevice on Endpoint0 request.
virtual void callback_request_xfer_done(const setup_packet_t *setup, bool aborted)
Called by USBDevice on data stage completion.
virtual void callback_state_change(DeviceState new_state)
Called when USB changes state.
USBMIDI(bool connect_blocking=true, uint16_t vendor_id=0x0700, uint16_t product_id=0x0101, uint16_t product_release=0x0001)
Basic constructor.
USBMIDI(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release)
Fully featured constructor.
void attach(mbed::Callback< void()> callback)
Attach a callback for when a MIDIEvent is received.
bool read(MIDIMessage *m)
Read a message.
bool ready()
Check if this class is ready.
virtual ~USBMIDI()
Destroy this object.
bool readable()
Check if a message can be read.
void wait_ready()
Block until this device is configured.
bool write(MIDIMessage m)
Send a MIDIMessage.
Abstract interface to physical USB hardware.
Callback class based on template specialization.
The EventFlags class is used to control event flags or wait for event flags other threads control.
The Mutex class is used to synchronize the execution of threads.