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
4#include <AH/STL/cstdint>
5#include <Settings/NamespaceSettings.hpp>
6
7#ifdef ARDUINO_ARCH_ESP32
8#include <esp_arduino_version.h>
9#include <sdkconfig.h>
10#endif
11
13
15 return {{
16 uint8_t((u >> 0) & 0xFF),
17 uint8_t((u >> 8) & 0xFF),
18 uint8_t((u >> 16) & 0xFF),
19 uint8_t((u >> 24) & 0xFF),
20 }};
21}
22
23inline uint32_t bytes_to_u32(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3) {
24 return (uint32_t(b0) << 0) | //
25 (uint32_t(b1) << 8) | //
26 (uint32_t(b2) << 16) | //
27 (uint32_t(b3) << 24); //
28}
29
31 return (uint32_t(b.data[0]) << 0) | //
32 (uint32_t(b.data[1]) << 8) | //
33 (uint32_t(b.data[2]) << 16) | //
34 (uint32_t(b.data[3]) << 24); //
35}
36
38
39#ifdef ARDUINO
40
41#if defined(TEENSYDUINO)
42
43#if defined(__AVR__) /* Teensy 2.x */
44#include "USBMIDI_Teensy2.hpp"
48
49#elif defined(__MK20DX128__) /* Teensy 3.0 */ \
50 || defined(__MK20DX256__) /* Teensy 3.1/3.2 */ \
51 || defined(__MK64FX512__) /* Teensy 3.5 */ \
52 || defined(__MK66FX1M0__) /* Teensy 3.6 */
53#include "USBMIDI_Teensy3.hpp"
57
58#elif defined(__IMXRT1062__) || defined(__IMXRT1052__) /* Teensy 4.0 */
59#include "USBMIDI_Teensy4.hpp"
63
64#elif defined(__MKL26Z64__) /* Teensy LC */
65#include "USBMIDI_TeensyLC.hpp"
69
70#else
71#warning "Unknown Teensy board, please open an issue on GitHub" \
72 "https://github.com/tttapa/Arduino-Helpers"
73// Fall back to the MIDIUSB library and hope for the best
74#include "USBMIDI_MIDIUSB.hpp"
78#endif
79
80#elif defined(ARDUINO_ARCH_ESP32) && (ESP_ARDUINO_VERSION_MAJOR >= 3) && \
81 CONFIG_IDF_TARGET_ESP32S3
82
83#ifndef ARDUINO_USB_MODE
84#error "ESP32S3 expects ARDUINO_USB_MODE to be set"
85#endif
86#if ARDUINO_USB_MODE != 1
87#include "USBMIDI_ESP32.hpp"
91#else
92#define CS_USB_MIDI_NOT_SUPPORTED
93#pragma message( \
94 "ESP32S3: USB MIDI not enabled. Set the Tools > USB Type setting to \"USB-OTG\" to enable it.")
95#endif
96
97#elif defined(ARDUINO_ARCH_MBED)
98
103
104#elif defined(ARDUINO_ARCH_RP2040) && defined(USE_TINYUSB)
105
110
111#else
112
113#include <AH/Arduino-Wrapper.h>
114#ifdef USBCON
115#include "USBMIDI_MIDIUSB.hpp"
119#else
120#define CS_USB_MIDI_NOT_SUPPORTED
121#endif
122
123#endif
124
125#else
126
127#include "USBMIDI_Mock.hpp"
128
129#endif
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
AH::Array< uint8_t, 4 > u32_to_bytes(uint32_t u)
Definition USBMIDI.hpp:14
uint32_t bytes_to_u32(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3)
Definition USBMIDI.hpp:23
Teensy3_USBDeviceMIDIBackend Teensy4_USBDeviceMIDIBackend
Teensy3_USBDeviceMIDIBackend TeensyLC_USBDeviceMIDIBackend
An array wrapper for easy copying, comparing, and iterating.
Definition Array.hpp:32
T data[N]
Definition Array.hpp:33