Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
BulkTX< Derived, MessageTypeT, MaxPacketSizeV > Struct Template Reference

#include <MIDI_Interfaces/USBMIDI/LowLevel/BulkTX.hpp>

Detailed Description

template<class Derived, class MessageTypeT, uint16_t MaxPacketSizeV>
struct BulkTX< Derived, MessageTypeT, MaxPacketSizeV >

Sends Bulk packets (IN for device mode, OUT for host mode)

Definition at line 12 of file BulkTX.hpp.

+ Inheritance diagram for BulkTX< Derived, MessageTypeT, MaxPacketSizeV >:
+ Collaboration diagram for BulkTX< Derived, MessageTypeT, MaxPacketSizeV >:

Classes

struct  Writing
 State for writing outgoing USB-MIDI data. More...
 

Public Types

using MessageType = MessageTypeT
 

Public Member Functions

void write (MessageType msg)
 Send a MIDI USB message.
 
void write (const MessageType *msgs, uint32_t num_msgs)
 Send multiple MIDI USB messages.
 
template<size_t N>
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.
 
uint32_t getWriteError () const
 Get the number messages that failed to send.
 
uint32_t clearWriteError ()
 Get and clear the number messages that failed to send.
 

Protected Member Functions

void reset (uint16_t packet_size=MaxPacketSize)
 
bool wait_connect ()
 
void start_timeout ()=delete
 Start a timeout (e.g.
 
void cancel_timeout ()=delete
 Cancel the timeout started by timeout_callback().
 
void tx_start (const void *data, uint32_t size)=delete
 Start a USB transfer (from the main program).
 
void tx_start_timeout (const void *data, uint32_t size)=delete
 Start a USB transfer (from the timeout callback).
 
void tx_start_isr (const void *data, uint32_t size)=delete
 Start a USB transfer (from the USB interrupt handler).
 
void timeout_callback ()
 
void tx_callback ()
 

Private Types

using wbuffer_t = typename Writing::Buffer
 

Private Member Functions

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)
 

Private Attributes

struct BulkTX::Writing writing
 
bool disconnected = false
 

Static Private Attributes

static constexpr uint16_t MaxPacketSize = MaxPacketSizeV
 
static constexpr uint16_t SizeReserved = MaxPacketSize + 1
 
static constexpr std::memory_order mo_seq = std::memory_order_seq_cst
 
static constexpr std::memory_order mo_rel = std::memory_order_release
 
static constexpr std::memory_order mo_acq = std::memory_order_acquire
 
static constexpr std::memory_order mo_rlx = std::memory_order_relaxed
 
static constexpr std::memory_order mo_acq_rel = std::memory_order_acq_rel
 

Member Typedef Documentation

◆ MessageType

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
using MessageType = MessageTypeT

Definition at line 14 of file BulkTX.hpp.

◆ wbuffer_t

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
using wbuffer_t = typename Writing::Buffer
private

Definition at line 101 of file BulkTX.hpp.

Member Function Documentation

◆ write() [1/3]

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
void write ( MessageType msg)

Send a MIDI USB message.

May block.

Parameters
msgThe 4-byte MIDI USB message to send.

◆ write() [2/3]

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
void write ( const MessageType * msgs,
uint32_t num_msgs )

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]

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
template<size_t N>
void write ( const MessageType(&) msgs[N])
inline

Send multiple MIDI USB messages. May block.

Definition at line 32 of file BulkTX.hpp.

◆ write_nonblock()

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
uint32_t write_nonblock ( const MessageType * msgs,
uint32_t num_msgs )

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()

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
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.

◆ is_done()

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
bool is_done ( ) const

Check if all transfers have completed.

◆ getWriteError()

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
uint32_t getWriteError ( ) const
inline

Get the number messages that failed to send.

Definition at line 54 of file BulkTX.hpp.

◆ clearWriteError()

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
uint32_t clearWriteError ( )
inline

Get and clear the number messages that failed to send.

Definition at line 56 of file BulkTX.hpp.

◆ reset()

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
void reset ( uint16_t packet_size = MaxPacketSize)
protected

◆ wait_connect()

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
bool wait_connect ( )
protected

◆ start_timeout()

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
void start_timeout ( )
protecteddelete

Start a timeout (e.g.

using a timer interrupt) that later calls timeout_callback().

◆ cancel_timeout()

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
void cancel_timeout ( )
protecteddelete

Cancel the timeout started by timeout_callback().

◆ tx_start()

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
void tx_start ( const void * data,
uint32_t size )
protecteddelete

Start a USB transfer (from the main program).

◆ tx_start_timeout()

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
void tx_start_timeout ( const void * data,
uint32_t size )
protecteddelete

Start a USB transfer (from the timeout callback).

◆ tx_start_isr()

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
void tx_start_isr ( const void * data,
uint32_t size )
protecteddelete

Start a USB transfer (from the USB interrupt handler).

◆ index_of()

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
uint32_t index_of ( wbuffer_t * p) const
inlineprivate

Definition at line 104 of file BulkTX.hpp.

◆ other_buf()

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
wbuffer_t * other_buf ( wbuffer_t * p)
inlineprivate

Definition at line 105 of file BulkTX.hpp.

◆ write_impl()

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
uint32_t write_impl ( const MessageType * msgs,
uint32_t num_msgs )
private

◆ timeout_callback()

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
void timeout_callback ( )
protected

◆ tx_callback()

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
void tx_callback ( )
protected

Member Data Documentation

◆ MaxPacketSize

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
constexpr uint16_t MaxPacketSize = MaxPacketSizeV
staticconstexprprivate

Definition at line 63 of file BulkTX.hpp.

◆ SizeReserved

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
constexpr uint16_t SizeReserved = MaxPacketSize + 1
staticconstexprprivate

Definition at line 64 of file BulkTX.hpp.

◆ mo_seq

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
constexpr std::memory_order mo_seq = std::memory_order_seq_cst
staticconstexprprivate

Definition at line 82 of file BulkTX.hpp.

◆ mo_rel

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
constexpr std::memory_order mo_rel = std::memory_order_release
staticconstexprprivate

Definition at line 83 of file BulkTX.hpp.

◆ mo_acq

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
constexpr std::memory_order mo_acq = std::memory_order_acquire
staticconstexprprivate

Definition at line 84 of file BulkTX.hpp.

◆ mo_rlx

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
constexpr std::memory_order mo_rlx = std::memory_order_relaxed
staticconstexprprivate

Definition at line 85 of file BulkTX.hpp.

◆ mo_acq_rel

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
constexpr std::memory_order mo_acq_rel = std::memory_order_acq_rel
staticconstexprprivate

Definition at line 86 of file BulkTX.hpp.

◆ writing

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
struct BulkTX::Writing writing
private

◆ disconnected

template<class Derived , class MessageTypeT , uint16_t MaxPacketSizeV>
bool disconnected = false
private

Definition at line 102 of file BulkTX.hpp.


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