Control Surface main
MIDI Control Surface library for Arduino
USBMIDI.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <AH/STL/cstdint>
5#include <Settings/NamespaceSettings.hpp>
6
8
10 return {{
11 uint8_t((u >> 0) & 0xFF),
12 uint8_t((u >> 8) & 0xFF),
13 uint8_t((u >> 16) & 0xFF),
14 uint8_t((u >> 24) & 0xFF),
15 }};
16}
17
18inline uint32_t bytes_to_u32(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3) {
19 return (uint32_t(b0) << 0) | //
20 (uint32_t(b1) << 8) | //
21 (uint32_t(b2) << 16) | //
22 (uint32_t(b3) << 24); //
23}
24
26 return (uint32_t(b.data[0]) << 0) | //
27 (uint32_t(b.data[1]) << 8) | //
28 (uint32_t(b.data[2]) << 16) | //
29 (uint32_t(b.data[3]) << 24); //
30}
31
33
34#ifdef ARDUINO
35
36#if defined(TEENSYDUINO)
37
38#if defined(__AVR__) /* Teensy 2.x */
39#include "USBMIDI_Teensy2.hpp"
43
44#elif defined(__MK20DX128__) /* Teensy 3.0 */ \
45 || defined(__MK20DX256__) /* Teensy 3.1/3.2 */ \
46 || defined(__MK64FX512__) /* Teensy 3.5 */ \
47 || defined(__MK66FX1M0__) /* Teensy 3.6 */
48#include "USBMIDI_Teensy3.hpp"
52
53#elif defined(__IMXRT1062__) || defined(__IMXRT1052__) /* Teensy 4.0 */
54#include "USBMIDI_Teensy4.hpp"
58
59#elif defined(__MKL26Z64__) /* Teensy LC */
60#include "USBMIDI_TeensyLC.hpp"
64
65#else
66#warning "Unknown Teensy board, please open an issue on GitHub" \
67 "https://github.com/tttapa/Arduino-Helpers"
68// Fall back to the MIDIUSB library and hope for the best
69#include "USBMIDI_MIDIUSB.hpp"
73#endif
74
75#elif defined(ARDUINO_ARCH_MBED_RP2040)
76
77#include "USBMIDI_RP2040.hpp"
81
82#elif defined(ARDUINO_ARCH_MBED)
83
88
89#elif defined(ARDUINO_RASPBERRY_PI_PICO) && defined(USE_TINYUSB)
90
95
96#else
97
98#include <AH/Arduino-Wrapper.h>
99#ifdef USBCON
100#include "USBMIDI_MIDIUSB.hpp"
104#else
105#define CS_USB_MIDI_NOT_SUPPORTED
106#endif
107
108#endif
109
110#else
111
112#include "USBMIDI_Mock.hpp"
113
114#endif
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
AH::Array< uint8_t, 4 > u32_to_bytes(uint32_t u)
Definition: USBMIDI.hpp:9
uint32_t bytes_to_u32(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3)
Definition: USBMIDI.hpp:18
Teensy3_USBDeviceMIDIBackend Teensy4_USBDeviceMIDIBackend
Teensy3_USBDeviceMIDIBackend TeensyLC_USBDeviceMIDIBackend
T data[N]
Definition: Array.hpp:37