Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
PluggableUSBMIDI Class Reference

#include <MIDI_Interfaces/USBMIDI/mbed/PluggableUSBMIDI.hpp>

Detailed Description

Definition at line 18 of file PluggableUSBMIDI.hpp.

+ Inheritance diagram for PluggableUSBMIDI:
+ Collaboration diagram for PluggableUSBMIDI:

Public Types

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.
 
uint32_t read ()
 Try reading a 4-byte MIDI USB message.
 
void setTimeout (microseconds timeout)
 Set the timeout, the number of microseconds to buffer the outgoing MIDI messages.
 
void setErrorTimeout (microseconds timeout)
 
uint32_t getWriteError () const
 Count how many USB packets were dropped.
 
uint32_t clearWriteError ()
 Clear the counter of how many USB packets were dropped.
 

Protected Types

using MessageType
 
using MessageType
 

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
 
void timeout_callback ()
 
void in_callback ()
 
void out_callback ()
 
bool read (MessageType &message)
 Try reading a single message.
 
void reset (uint16_t packet_size=MaxPacketSize)
 
void rx_callback (uint32_t num_bytes_read)
 
void write (MessageType msg)
 Send a MIDI USB message.
 
void write (const MessageType *msgs, uint32_t num_msgs)
 Send multiple MIDI USB messages.
 
void write (const MessageType(&msgs)[N])
 Send multiple MIDI USB messages. May block.
 
uint32_t write_nonblock (const MessageType *msgs, uint32_t num_msgs)
 Send multiple MIDI USB messages without blocking.
 
void send_now ()
 Try sending the buffered data now.
 
bool is_done () const
 Check if all transfers have completed.
 
void reset (uint16_t packet_size=MaxPacketSize)
 
void tx_callback ()
 

Protected Attributes

interrupt_atomic< bool > usb_connected {false}
 
microseconds timeout_duration {1'000}
 
microseconds error_timeout_duration {40'000}
 
mbed::Timeout timeout
 
uint32_t write_errors {0}
 
usb_ep_t bulk_in_ep
 
usb_ep_t bulk_out_ep
 
uint8_t config_descriptor [0x65]
 

Private Types

using rbuffer_t
 
using wbuffer_t
 

Private Member Functions

void start_timeout ()
 
void cancel_timeout ()
 
void tx_start (const void *data, uint32_t size)
 
void tx_start_timeout (const void *data, uint32_t size)
 
void tx_start_isr (const void *data, uint32_t size)
 
void rx_start (void *data, uint32_t size)
 
void rx_start_isr (void *data, uint32_t size)
 
uint32_t index_of (wbuffer_t *p) const
 
wbuffer_tother_buf (wbuffer_t *p)
 
uint32_t write_impl (const MessageType *msgs, uint32_t num_msgs)
 

Static Private Member Functions

static constexpr uint32_t get_packet_size ()
 

Private Attributes

struct BulkRX::Reading reading
 
struct BulkTX::Writing writing
 

Static Private Attributes

static constexpr uint16_t MaxPacketSize
 
static constexpr uint16_t SizeReserved
 
static constexpr uint16_t NumRxPackets
 
static constexpr std::memory_order mo_seq
 
static constexpr std::memory_order mo_rel
 
static constexpr std::memory_order mo_acq
 
static constexpr std::memory_order mo_rlx
 
static constexpr std::memory_order mo_acq_rel
 

Member Typedef Documentation

◆ setup_packet_t

using setup_packet_t = USBDevice::setup_packet_t

Definition at line 26 of file PluggableUSBMIDI.hpp.

◆ DeviceState

using DeviceState = USBDevice::DeviceState

Definition at line 27 of file PluggableUSBMIDI.hpp.

◆ microseconds

using microseconds = std::chrono::microseconds

Definition at line 28 of file PluggableUSBMIDI.hpp.

◆ MessageType [1/2]

using MessageType
inherited

Definition at line 14 of file BulkRX.hpp.

◆ rbuffer_t

using rbuffer_t
privateinherited

Definition at line 56 of file BulkRX.hpp.

◆ MessageType [2/2]

using MessageType
inherited

Definition at line 14 of file BulkTX.hpp.

◆ wbuffer_t

using wbuffer_t
privateinherited

Definition at line 94 of file BulkTX.hpp.

Constructor & Destructor Documentation

◆ PluggableUSBMIDI()

◆ ~PluggableUSBMIDI()

Member Function Documentation

◆ get_packet_size()

static constexpr uint32_t get_packet_size ( )
inlinestaticconstexprprivate

Definition at line 34 of file PluggableUSBMIDI.hpp.

◆ start_timeout()

void start_timeout ( )
inlineprivate

Definition at line 36 of file PluggableUSBMIDI.hpp.

◆ cancel_timeout()

void cancel_timeout ( )
inlineprivate

Definition at line 40 of file PluggableUSBMIDI.hpp.

◆ tx_start()

void tx_start ( const void * data,
uint32_t size )
inlineprivate

Definition at line 41 of file PluggableUSBMIDI.hpp.

◆ tx_start_timeout()

void tx_start_timeout ( const void * data,
uint32_t size )
inlineprivate

Definition at line 45 of file PluggableUSBMIDI.hpp.

◆ tx_start_isr()

void tx_start_isr ( const void * data,
uint32_t size )
inlineprivate

Definition at line 48 of file PluggableUSBMIDI.hpp.

◆ rx_start()

void rx_start ( void * data,
uint32_t size )
inlineprivate

Definition at line 49 of file PluggableUSBMIDI.hpp.

◆ rx_start_isr()

void rx_start_isr ( void * data,
uint32_t size )
inlineprivate

Definition at line 52 of file PluggableUSBMIDI.hpp.

◆ connected()

bool connected ( ) const

Check if this class is connected and ready.

◆ read() [1/2]

uint32_t read ( )
inline

Try reading a 4-byte MIDI USB message.

Returns
The message or 0x00000000 if no messages available.

Definition at line 61 of file PluggableUSBMIDI.hpp.

◆ setTimeout()

void setTimeout ( microseconds timeout)
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 75 of file PluggableUSBMIDI.hpp.

◆ setErrorTimeout()

void setErrorTimeout ( microseconds timeout)
inline

Definition at line 77 of file PluggableUSBMIDI.hpp.

◆ getWriteError()

uint32_t getWriteError ( ) const
inline

Count how many USB packets were dropped.

Definition at line 82 of file PluggableUSBMIDI.hpp.

◆ clearWriteError()

uint32_t clearWriteError ( )
inline

Clear the counter of how many USB packets were dropped.

Definition at line 84 of file PluggableUSBMIDI.hpp.

◆ init()

void init ( EndpointResolver & resolver)
overrideprotected

◆ callback_state_change()

void callback_state_change ( DeviceState new_state)
overrideprotected

◆ callback_request()

uint32_t callback_request ( const setup_packet_t * setup,
USBDevice::RequestResult * result,
uint8_t ** data )
overrideprotected

◆ callback_request_xfer_done()

bool callback_request_xfer_done ( const setup_packet_t * setup,
bool aborted )
overrideprotected

◆ callback_set_configuration()

bool callback_set_configuration ( uint8_t configuration)
overrideprotected

◆ callback_set_interface()

void callback_set_interface ( uint16_t interface,
uint8_t alternate )
overrideprotected

◆ string_iinterface_desc()

const uint8_t * string_iinterface_desc ( )
overrideprotected

◆ configuration_desc()

const uint8_t * configuration_desc ( uint8_t index)
overrideprotected

◆ getProductVersion()

uint8_t getProductVersion ( )
inlineoverrideprotected

Definition at line 99 of file PluggableUSBMIDI.hpp.

◆ timeout_callback()

void timeout_callback ( )
inlineprotected

Definition at line 113 of file PluggableUSBMIDI.hpp.

◆ in_callback()

void in_callback ( )
inlineprotected

Definition at line 116 of file PluggableUSBMIDI.hpp.

◆ out_callback()

void out_callback ( )
inlineprotected

Definition at line 121 of file PluggableUSBMIDI.hpp.

◆ read() [2/2]

bool read ( MessageType & message)
inherited

Try reading a single message.

Returns
Whether a message was available.

◆ reset() [1/2]

void reset ( uint16_t packet_size = MaxPacketSize)
protectedinherited

◆ rx_callback()

void rx_callback ( uint32_t num_bytes_read)
protectedinherited

◆ write() [1/3]

void write ( MessageType msg)
inherited

Send a MIDI USB message.

May block.

Parameters
msgThe 4-byte MIDI USB message to send.

◆ write() [2/3]

void write ( const MessageType * msgs,
uint32_t num_msgs )
inherited

Send multiple MIDI USB messages.

May block.

Parameters
msgsAn array of 4-byte MIDI USB messages to send.
num_msgsThe number of messages in the array.

◆ write() [3/3]

void write ( const MessageType(&) msgs[N])
inlineinherited

Send multiple MIDI USB messages. May block.

Definition at line 32 of file BulkTX.hpp.

◆ write_nonblock()

uint32_t write_nonblock ( const MessageType * msgs,
uint32_t num_msgs )
inherited

Send multiple MIDI USB messages without blocking.

Parameters
msgsAn array of 4-byte MIDI USB messages to send.
num_msgsThe number of messages in the array.
Returns
The number of messages that were actually sent.

◆ send_now()

void send_now ( )
inherited

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.

◆ is_done()

bool is_done ( ) const
inherited

Check if all transfers have completed.

◆ reset() [2/2]

void reset ( uint16_t packet_size = MaxPacketSize)
protectedinherited

◆ index_of()

uint32_t index_of ( wbuffer_t * p) const
inlineprivateinherited

Definition at line 96 of file BulkTX.hpp.

◆ other_buf()

wbuffer_t * other_buf ( wbuffer_t * p)
inlineprivateinherited

Definition at line 97 of file BulkTX.hpp.

◆ write_impl()

uint32_t write_impl ( const MessageType * msgs,
uint32_t num_msgs )
privateinherited

◆ tx_callback()

void tx_callback ( )
protectedinherited

Member Data Documentation

◆ usb_connected

interrupt_atomic<bool> usb_connected {false}
protected

Definition at line 102 of file PluggableUSBMIDI.hpp.

◆ timeout_duration

microseconds timeout_duration {1'000}
protected

Definition at line 103 of file PluggableUSBMIDI.hpp.

◆ error_timeout_duration

microseconds error_timeout_duration {40'000}
protected

Definition at line 104 of file PluggableUSBMIDI.hpp.

◆ timeout

mbed::Timeout timeout
protected

Definition at line 105 of file PluggableUSBMIDI.hpp.

◆ write_errors

uint32_t write_errors {0}
protected

Definition at line 106 of file PluggableUSBMIDI.hpp.

◆ bulk_in_ep

usb_ep_t bulk_in_ep
protected

Definition at line 108 of file PluggableUSBMIDI.hpp.

◆ bulk_out_ep

usb_ep_t bulk_out_ep
protected

Definition at line 109 of file PluggableUSBMIDI.hpp.

◆ config_descriptor

uint8_t config_descriptor[0x65]
protected

Definition at line 110 of file PluggableUSBMIDI.hpp.

◆ MaxPacketSize

constexpr uint16_t MaxPacketSize
staticconstexprprivateinherited

Definition at line 24 of file BulkRX.hpp.

◆ SizeReserved

constexpr uint16_t SizeReserved
staticconstexprprivateinherited

Definition at line 25 of file BulkRX.hpp.

◆ NumRxPackets

constexpr uint16_t NumRxPackets
staticconstexprprivateinherited

Definition at line 26 of file BulkRX.hpp.

◆ mo_seq

constexpr std::memory_order mo_seq
staticconstexprprivateinherited

Definition at line 37 of file BulkRX.hpp.

◆ mo_rel

constexpr std::memory_order mo_rel
staticconstexprprivateinherited

Definition at line 38 of file BulkRX.hpp.

◆ mo_acq

constexpr std::memory_order mo_acq
staticconstexprprivateinherited

Definition at line 39 of file BulkRX.hpp.

◆ mo_rlx

constexpr std::memory_order mo_rlx
staticconstexprprivateinherited

Definition at line 40 of file BulkRX.hpp.

◆ mo_acq_rel

constexpr std::memory_order mo_acq_rel
staticconstexprprivateinherited

Definition at line 41 of file BulkRX.hpp.

◆ reading

struct BulkRX::Reading reading
privateinherited

◆ writing

struct BulkTX::Writing writing
privateinherited

The documentation for this class was generated from the following file: