9#include <USB/PluggableUSBDevice.h>
10#include <drivers/Timeout.h>
11#include <platform/Callback.h>
14#include <Settings/NamespaceSettings.hpp>
44 void write(
const uint32_t *msgs, uint32_t num_msgs);
48 void write(
const uint32_t (&msgs)[N]) {
88 void init(EndpointResolver &resolver)
override;
91 USBDevice::RequestResult *result,
92 uint8_t **data)
override;
94 bool aborted)
override;
#define BEGIN_CS_NAMESPACE
static constexpr uint32_t NumRxPackets
void write(const uint32_t(&msgs)[N])
Send multiple MIDI USB messages. May block.
static constexpr uint32_t PacketSize
USB packet size.
uint32_t active_writebuffer
The index of the buffer that is currently being written to.
bool ready_to_send
Indicates that this buffer can be sent as soon as the previous one has been sent.
void setErrorTimeout(microseconds timeout)
void send_in_callback(uint32_t activebuf_idx)
static constexpr uint32_t SizeReserved
struct PluggableUSBMIDI::Reading reading
USBDevice::setup_packet_t setup_packet_t
struct PluggableUSBMIDI::Writing writing
uint32_t write_nonblock(const uint32_t *msgs, uint32_t num_msgs)
Send multiple MIDI USB messages without blocking.
uint8_t getProductVersion() override
microseconds error_timeout_duration
USBDevice::DeviceState DeviceState
uint32_t read()
Try reading a 4-byte MIDI USB message.
void callback_state_change(DeviceState new_state) override
uint8_t config_descriptor[0x65]
void send_now()
Try sending the buffered data now.
void write_start_sync(uint8_t *buffer, uint32_t size)
uint8_t buffer[PacketSize]
Buffer * send_timeout
Buffer to be sent in the timeout callback.
uint32_t getWriteError() const
Count how many USB packets were dropped.
const uint8_t * configuration_desc(uint8_t index) override
microseconds timeout_duration
void callback_set_interface(uint16_t interface, uint8_t alternate) override
void setTimeout(microseconds timeout)
Set the timeout, the number of microseconds to buffer the outgoing MIDI messages.
uint32_t write_impl(const uint32_t *msgs, uint32_t num_msgs, bool nonblocking)
Buffer * sending
Buffer that is being sent.
bool callback_set_configuration(uint8_t configuration) override
bool connected() const
Check if this class is connected and ready.
void init(EndpointResolver &resolver) override
struct PluggableUSBMIDI::Reading::Buffer buffers[NumRxPackets]
void write(const uint32_t *msgs, uint32_t num_msgs)
Send multiple MIDI USB messages.
std::tuple< uint32_t, wbuffer_t *, uint32_t > read_writebuf_size()
std::atomic< bool > usb_connected
bool send_now_impl_nonblock(uint32_t activebuf_idx)
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
const uint8_t * string_iinterface_desc() override
struct PluggableUSBMIDI::Writing::Buffer buffers[2]
void write(uint32_t msg)
Send a MIDI USB message.
std::chrono::microseconds microseconds
void clearWriteError()
Clear the counter of how many USB packets were dropped.
State for writing outgoing USB-MIDI data.