Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
USBMIDI.hpp
Go to the documentation of this file.
1#pragma once
2
3#ifndef CS_USB_MIDI_NOT_SUPPORTED
4
6#include <AH/STL/cstdint>
7#include <Settings/NamespaceSettings.hpp>
8
9#ifdef ARDUINO_ARCH_ESP32
10#include <esp_arduino_version.h>
11#include <sdkconfig.h>
12#endif
13
15
17 return {{
18 uint8_t((u >> 0) & 0xFF),
19 uint8_t((u >> 8) & 0xFF),
20 uint8_t((u >> 16) & 0xFF),
21 uint8_t((u >> 24) & 0xFF),
22 }};
23}
24
25inline uint32_t bytes_to_u32(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3) {
26 return (uint32_t(b0) << 0) | //
27 (uint32_t(b1) << 8) | //
28 (uint32_t(b2) << 16) | //
29 (uint32_t(b3) << 24); //
30}
31
33 return (uint32_t(b.data[0]) << 0) | //
34 (uint32_t(b.data[1]) << 8) | //
35 (uint32_t(b.data[2]) << 16) | //
36 (uint32_t(b.data[3]) << 24); //
37}
38
40
41#ifdef ARDUINO
42
43#if defined(TEENSYDUINO)
44
45#if defined(__AVR__) /* Teensy 2.x */
46#include "USBMIDI_Teensy2.hpp"
50
51#elif defined(__MK20DX128__) /* Teensy 3.0 */ \
52 || defined(__MK20DX256__) /* Teensy 3.1/3.2 */ \
53 || defined(__MK64FX512__) /* Teensy 3.5 */ \
54 || defined(__MK66FX1M0__) /* Teensy 3.6 */
55#include "USBMIDI_Teensy3.hpp"
59
60#elif defined(__IMXRT1062__) || defined(__IMXRT1052__) /* Teensy 4.0 */
61#include "USBMIDI_Teensy4.hpp"
65
66#elif defined(__MKL26Z64__) /* Teensy LC */
67#include "USBMIDI_TeensyLC.hpp"
71
72#else
73#warning "Unknown Teensy board, please open an issue on GitHub" \
74 "https://github.com/tttapa/Arduino-Helpers"
75// Fall back to the MIDIUSB library and hope for the best
76#include "USBMIDI_MIDIUSB.hpp"
80#endif
81
82#elif defined(ARDUINO_ARCH_ESP32) && (ESP_ARDUINO_VERSION_MAJOR >= 3) && \
83 (CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3)
84
85#ifndef ARDUINO_USB_MODE
86#error "ESP32-S2/S3 expects ARDUINO_USB_MODE to be set"
87#endif
88#if ARDUINO_USB_MODE != 1
89#include "USBMIDI_ESP32.hpp"
93#else
94#define CS_USB_MIDI_NOT_SUPPORTED 1
95#pragma message( \
96 "ESP32-S2/S3: USB MIDI not enabled. Set the Tools > USB Type setting to \"USB-OTG\" to enable it.")
97#endif
98
99#elif defined(ARDUINO_ARCH_MBED)
100
105
106#elif defined(ARDUINO_ARCH_RP2040) && defined(USE_TINYUSB)
107
112
113#else
114
115#include <AH/Arduino-Wrapper.h>
116#ifdef USBCON
117#include "USBMIDI_MIDIUSB.hpp"
121#else
122#define CS_USB_MIDI_NOT_SUPPORTED 1
123#endif
124
125#endif
126
127#else
128
129#include "USBMIDI_Mock.hpp"
130
131#endif
132
133#endif // CS_USB_MIDI_NOT_SUPPORTED
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
AH::Array< uint8_t, 4 > u32_to_bytes(uint32_t u)
Definition USBMIDI.hpp:16
uint32_t bytes_to_u32(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3)
Definition USBMIDI.hpp:25
Teensy3_USBDeviceMIDIBackend Teensy4_USBDeviceMIDIBackend
Teensy3_USBDeviceMIDIBackend TeensyLC_USBDeviceMIDIBackend
A class that reads and filters an analog input.