Control Surface
main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
src
MIDI_Interfaces
USBMIDI
USBMIDI_Adafruit_TinyUSB.hpp
Go to the documentation of this file.
1
#include <
AH/Containers/Array.hpp
>
2
#include <Settings/NamespaceSettings.hpp>
3
4
#include <Adafruit_TinyUSB.h>
5
6
BEGIN_CS_NAMESPACE
7
8
struct
Adafruit_TinyUSB_USBDeviceMIDIBackend
{
9
using
MIDIUSBPacket_t
=
AH::Array<uint8_t, 4>
;
10
void
begin
() {
11
// Manual begin() is required on core without built-in support e.g. mbed rp2040
12
if
(!TinyUSBDevice.isInitialized())
13
TinyUSBDevice.begin(0);
14
backend
.begin();
15
// If already enumerated, additional class driver begin() e.g msc, hid, midi won't take effect until re-enumeration
16
if
(TinyUSBDevice.mounted()) {
17
TinyUSBDevice.detach();
18
delay(10);
19
TinyUSBDevice.attach();
20
}
21
}
22
MIDIUSBPacket_t
read
() {
23
#ifdef TINYUSB_NEED_POLLING_TASK
24
TinyUSBDevice.task();
25
#endif
26
MIDIUSBPacket_t
packet {};
27
if
(TinyUSBDevice.mounted())
28
backend
.readPacket(packet.data);
29
return
packet;
30
}
31
void
write
(
MIDIUSBPacket_t
packet) {
32
if
(TinyUSBDevice.mounted())
33
backend
.writePacket(packet.
data
);
34
}
35
void
sendNow
() {
36
if
(TinyUSBDevice.mounted())
37
backend
.flush();
38
}
39
bool
preferImmediateSend
() {
return
false
; }
40
41
Adafruit_USBD_MIDI
backend
;
42
};
43
44
END_CS_NAMESPACE
Array.hpp
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:14
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:11
AH::SPIShiftRegisterOut
A class for serial-in/parallel-out shift registers, like the 74HC595 that are connected to the SPI bu...
Definition
SPIShiftRegisterOut.hpp:28
AH::Array< uint8_t, 4 >
AH::Array::data
T data[N]
Definition
Array.hpp:33
Adafruit_TinyUSB_USBDeviceMIDIBackend
Definition
USBMIDI_Adafruit_TinyUSB.hpp:8
Adafruit_TinyUSB_USBDeviceMIDIBackend::sendNow
void sendNow()
Definition
USBMIDI_Adafruit_TinyUSB.hpp:35
Adafruit_TinyUSB_USBDeviceMIDIBackend::read
MIDIUSBPacket_t read()
Definition
USBMIDI_Adafruit_TinyUSB.hpp:22
Adafruit_TinyUSB_USBDeviceMIDIBackend::preferImmediateSend
bool preferImmediateSend()
Definition
USBMIDI_Adafruit_TinyUSB.hpp:39
Adafruit_TinyUSB_USBDeviceMIDIBackend::backend
Adafruit_USBD_MIDI backend
Definition
USBMIDI_Adafruit_TinyUSB.hpp:41
Adafruit_TinyUSB_USBDeviceMIDIBackend::begin
void begin()
Definition
USBMIDI_Adafruit_TinyUSB.hpp:10
Adafruit_TinyUSB_USBDeviceMIDIBackend::write
void write(MIDIUSBPacket_t packet)
Definition
USBMIDI_Adafruit_TinyUSB.hpp:31
Generated by
1.10.0