#include <MIDI_Interfaces/USBMIDI/mbed-m0/PluggableUSBMIDI.hpp>
Definition at line 18 of file mbed-m0/PluggableUSBMIDI.hpp.
Inheritance diagram for PluggableUSBMIDI:
Collaboration diagram for PluggableUSBMIDI:Classes | |
| struct | Reading |
| State for reading incoming USB-MIDI data. More... | |
| struct | Writing |
| State for writing outgoing USB-MIDI data. More... | |
Public Types | |
| using | setup_packet_t = USBDevice::setup_packet_t |
| using | DeviceState = USBDevice::DeviceState |
| using | microseconds = std::chrono::microseconds |
| using | setup_packet_t = USBDevice::setup_packet_t |
| using | DeviceState = USBDevice::DeviceState |
| using | microseconds = std::chrono::microseconds |
Public Member Functions | |
| PluggableUSBMIDI () | |
| ~PluggableUSBMIDI () | |
| bool | connected () const |
| Check if this class is connected and ready. More... | |
| void | write (uint32_t msg) |
| Send a MIDI USB message. More... | |
| void | write (const uint32_t *msgs, uint32_t num_msgs) |
| Send multiple MIDI USB messages. More... | |
| template<size_t N> | |
| void | write (const uint32_t(&msgs)[N]) |
| Send multiple MIDI USB messages. May block. More... | |
| uint32_t | write_nonblock (const uint32_t *msgs, uint32_t num_msgs) |
| Send multiple MIDI USB messages without blocking. More... | |
| uint32_t | read () |
| Try reading a 4-byte MIDI USB message. More... | |
| void | send_now () |
| Try sending the buffered data now. More... | |
| void | setTimeout (microseconds timeout) |
| Set the timeout, the number of microseconds to buffer the outgoing MIDI messages. More... | |
| void | setErrorTimeout (microseconds timeout) |
| uint32_t | getWriteError () const |
| Count how many USB packets were dropped. More... | |
| void | clearWriteError () |
| Clear the counter of how many USB packets were dropped. More... | |
| PluggableUSBMIDI () | |
| ~PluggableUSBMIDI () | |
| bool | connected () const |
| Check if this class is connected and ready. More... | |
| void | write (uint32_t msg) |
| Send a MIDI USB message. More... | |
| void | write (const uint32_t *msgs, uint32_t num_msgs) |
| Send multiple MIDI USB messages. More... | |
| template<size_t N> | |
| void | write (const uint32_t(&msgs)[N]) |
| Send multiple MIDI USB messages. May block. More... | |
| uint32_t | write_nonblock (const uint32_t *msgs, uint32_t num_msgs) |
| Send multiple MIDI USB messages without blocking. More... | |
| uint32_t | read () |
| Try reading a 4-byte MIDI USB message. More... | |
| void | send_now () |
| Try sending the buffered data now. More... | |
| void | setTimeout (microseconds timeout) |
| Set the timeout, the number of microseconds to buffer the outgoing MIDI messages. More... | |
| void | setErrorTimeout (microseconds timeout) |
| uint32_t | getWriteError () const |
| Count how many USB packets were dropped. More... | |
| void | clearWriteError () |
| Clear the counter of how many USB packets were dropped. More... | |
Static Public Attributes | |
| static constexpr uint32_t | PacketSize = 64 |
| USB packet size. More... | |
Protected Types | |
| using | rbuffer_t = Reading::Buffer |
| using | wbuffer_t = Writing::Buffer |
| using | rbuffer_t = std::remove_reference_t< decltype(reading.buffers[0])> |
| using | wbuffer_t = std::remove_reference_t< decltype(writing.buffers[0])> |
Protected Member Functions | |
| void | init (EndpointResolver &resolver) override |
| void | callback_state_change (DeviceState new_state) override |
| uint32_t | callback_request (const setup_packet_t *setup, USBDevice::RequestResult *result, uint8_t **data) override |
| bool | callback_request_xfer_done (const setup_packet_t *setup, bool aborted) override |
| bool | callback_set_configuration (uint8_t configuration) override |
| void | callback_set_interface (uint16_t interface, uint8_t alternate) override |
| const uint8_t * | string_iinterface_desc () override |
| const uint8_t * | configuration_desc (uint8_t index) override |
| uint8_t | getProductVersion () override |
| uint32_t | write_impl (const uint32_t *msgs, uint32_t num_msgs, bool nonblocking) |
| std::tuple< uint32_t, wbuffer_t *, uint32_t > | read_writebuf_size () |
| void | write_start_sync (uint8_t *buffer, uint32_t size) |
| void | send_in_callback (uint32_t activebuf_idx) |
| bool | send_now_impl_nonblock (uint32_t activebuf_idx) |
| void | timeout_callback () |
| void | in_callback () |
| void | out_callback () |
| void | init (EndpointResolver &resolver) override |
| void | callback_state_change (DeviceState new_state) override |
| uint32_t | callback_request (const setup_packet_t *setup, USBDevice::RequestResult *result, uint8_t **data) override |
| bool | callback_request_xfer_done (const setup_packet_t *setup, bool aborted) override |
| bool | callback_set_configuration (uint8_t configuration) override |
| void | callback_set_interface (uint16_t interface, uint8_t alternate) override |
| const uint8_t * | string_iinterface_desc () override |
| const uint8_t * | configuration_desc (uint8_t index) override |
| uint8_t | getProductVersion () override |
| uint32_t | write_impl (const uint32_t *msgs, uint32_t num_msgs, bool nonblocking) |
| std::tuple< uint32_t, wbuffer_t *, uint32_t > | read_writebuf_size () |
| void | write_start_sync (uint8_t *buffer, uint32_t size) |
| void | send_in_callback (uint32_t activebuf_idx) |
| bool | send_now_impl_nonblock (uint32_t activebuf_idx) |
| void | timeout_callback () |
| void | in_callback () |
| void | out_callback () |
Protected Attributes | |
| std::atomic< bool > | usb_connected {false} |
| struct PluggableUSBMIDI::Reading | reading |
| struct PluggableUSBMIDI::Writing | writing |
| usb_ep_t | bulk_in_ep |
| usb_ep_t | bulk_out_ep |
| uint8_t | config_descriptor [0x65] |
Static Protected Attributes | |
| static constexpr uint32_t | SizeReserved = PacketSize + 1 |
| static constexpr uint32_t | NumRxPackets = 2 |
| struct PluggableUSBMIDI::Reading |
Collaboration diagram for PluggableUSBMIDI::Reading:| Class Members | ||
|---|---|---|
| struct Buffer | buffers[NumRxPackets] | |
| uint32_t | available | |
| uint32_t | read_idx | |
| uint32_t | write_idx | |
| bool | reading | |
| atomic< uint32_t > | available | |
| atomic< uint32_t > | read_idx | |
| atomic< uint32_t > | write_idx | |
| atomic< bool > | reading | |
| struct PluggableUSBMIDI::Writing |
Collaboration diagram for PluggableUSBMIDI::Writing:| Class Members | ||
|---|---|---|
| struct Buffer | buffers[2] | |
| uint32_t | active_writebuffer | The index of the buffer that is currently being written to. |
| Buffer * | sending | Buffer that is being sent. |
| Buffer * | send_timeout | Buffer to be sent in the timeout callback. |
| microseconds | timeout_duration | |
| microseconds | error_timeout_duration | |
| Timeout | timeout | |
| uint32_t | errors | |
| atomic< uint32_t > | active_writebuffer | |
| atomic< Buffer * > | sending | |
| atomic< Buffer * > | send_timeout | |
| using setup_packet_t = USBDevice::setup_packet_t |
Definition at line 24 of file mbed-m0/PluggableUSBMIDI.hpp.
| using DeviceState = USBDevice::DeviceState |
Definition at line 25 of file mbed-m0/PluggableUSBMIDI.hpp.
| using microseconds = std::chrono::microseconds |
Definition at line 26 of file mbed-m0/PluggableUSBMIDI.hpp.
|
protected |
Definition at line 126 of file mbed-m0/PluggableUSBMIDI.hpp.
|
protected |
Definition at line 154 of file mbed-m0/PluggableUSBMIDI.hpp.
| using setup_packet_t = USBDevice::setup_packet_t |
Definition at line 24 of file mbed/PluggableUSBMIDI.hpp.
| using DeviceState = USBDevice::DeviceState |
Definition at line 25 of file mbed/PluggableUSBMIDI.hpp.
| using microseconds = std::chrono::microseconds |
Definition at line 26 of file mbed/PluggableUSBMIDI.hpp.
|
protected |
Definition at line 126 of file mbed/PluggableUSBMIDI.hpp.
|
protected |
Definition at line 143 of file mbed/PluggableUSBMIDI.hpp.
| PluggableUSBMIDI | ( | ) |
| ~PluggableUSBMIDI | ( | ) |
| PluggableUSBMIDI | ( | ) |
| ~PluggableUSBMIDI | ( | ) |
| bool connected | ( | ) | const |
Check if this class is connected and ready.
| void write | ( | uint32_t | msg | ) |
Send a MIDI USB message.
May block.
| msg | The 4-byte MIDI USB message to send. |
| void write | ( | const uint32_t * | msgs, |
| uint32_t | num_msgs | ||
| ) |
Send multiple MIDI USB messages.
May block.
| msgs | An array of 4-byte MIDI USB messages to send. |
| num_msgs | The number of messages in the array. |
|
inline |
Send multiple MIDI USB messages. May block.
Definition at line 48 of file mbed-m0/PluggableUSBMIDI.hpp.
| uint32_t write_nonblock | ( | const uint32_t * | msgs, |
| uint32_t | num_msgs | ||
| ) |
Send multiple MIDI USB messages without blocking.
| msgs | An array of 4-byte MIDI USB messages to send. |
| num_msgs | The number of messages in the array. |
| uint32_t read | ( | ) |
Try reading a 4-byte MIDI USB message.
| void send_now | ( | ) |
Try sending the buffered data now.
Start transmitting the latest packet if possible, even if it isn't full yet. If the latest packet is empty, this function has no effect.
|
inline |
Set the timeout, the number of microseconds to buffer the outgoing MIDI messages.
A shorter timeout usually results in lower latency, but also causes more overhead, because more packets might be required.
Definition at line 74 of file mbed-m0/PluggableUSBMIDI.hpp.
|
inline |
Definition at line 78 of file mbed-m0/PluggableUSBMIDI.hpp.
|
inline |
Count how many USB packets were dropped.
Definition at line 83 of file mbed-m0/PluggableUSBMIDI.hpp.
|
inline |
Clear the counter of how many USB packets were dropped.
Definition at line 85 of file mbed-m0/PluggableUSBMIDI.hpp.
|
overrideprotected |
|
overrideprotected |
|
overrideprotected |
|
overrideprotected |
|
overrideprotected |
|
overrideprotected |
|
overrideprotected |
|
overrideprotected |
|
inlineoverrideprotected |
Definition at line 100 of file mbed-m0/PluggableUSBMIDI.hpp.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
| bool connected | ( | ) | const |
Check if this class is connected and ready.
| void write | ( | uint32_t | msg | ) |
Send a MIDI USB message.
May block.
| msg | The 4-byte MIDI USB message to send. |
| void write | ( | const uint32_t * | msgs, |
| uint32_t | num_msgs | ||
| ) |
Send multiple MIDI USB messages.
May block.
| msgs | An array of 4-byte MIDI USB messages to send. |
| num_msgs | The number of messages in the array. |
|
inline |
Send multiple MIDI USB messages. May block.
Definition at line 48 of file mbed/PluggableUSBMIDI.hpp.
| uint32_t write_nonblock | ( | const uint32_t * | msgs, |
| uint32_t | num_msgs | ||
| ) |
Send multiple MIDI USB messages without blocking.
| msgs | An array of 4-byte MIDI USB messages to send. |
| num_msgs | The number of messages in the array. |
| uint32_t read | ( | ) |
Try reading a 4-byte MIDI USB message.
| void send_now | ( | ) |
Try sending the buffered data now.
Start transmitting the latest packet if possible, even if it isn't full yet. If the latest packet is empty, this function has no effect.
|
inline |
Set the timeout, the number of microseconds to buffer the outgoing MIDI messages.
A shorter timeout usually results in lower latency, but also causes more overhead, because more packets might be required.
Definition at line 74 of file mbed/PluggableUSBMIDI.hpp.
|
inline |
Definition at line 78 of file mbed/PluggableUSBMIDI.hpp.
|
inline |
Count how many USB packets were dropped.
Definition at line 83 of file mbed/PluggableUSBMIDI.hpp.
|
inline |
Clear the counter of how many USB packets were dropped.
Definition at line 85 of file mbed/PluggableUSBMIDI.hpp.
|
overrideprotected |
|
overrideprotected |
|
overrideprotected |
|
overrideprotected |
|
overrideprotected |
|
overrideprotected |
|
overrideprotected |
|
overrideprotected |
|
inlineoverrideprotected |
Definition at line 100 of file mbed/PluggableUSBMIDI.hpp.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Definition at line 103 of file mbed-m0/PluggableUSBMIDI.hpp.
|
staticconstexpr |
USB packet size.
Must be a power of two.
Must be a power of two.
Definition at line 108 of file mbed-m0/PluggableUSBMIDI.hpp.
|
staticconstexprprotected |
Definition at line 111 of file mbed-m0/PluggableUSBMIDI.hpp.
|
staticconstexprprotected |
Definition at line 112 of file mbed-m0/PluggableUSBMIDI.hpp.
|
protected |
|
protected |
|
protected |
Definition at line 156 of file mbed-m0/PluggableUSBMIDI.hpp.
|
protected |
Definition at line 157 of file mbed-m0/PluggableUSBMIDI.hpp.
|
protected |
Definition at line 158 of file mbed-m0/PluggableUSBMIDI.hpp.