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"
40
41#elif defined(__MK20DX128__) /* Teensy 3.0 */ \
42 || defined(__MK20DX256__) /* Teensy 3.1/3.2 */ \
43 || defined(__MK64FX512__) /* Teensy 3.5 */ \
44 || defined(__MK66FX1M0__) /* Teensy 3.6 */
45#include "USBMIDI_Teensy3.hpp"
46
47#elif defined(__IMXRT1062__) || defined(__IMXRT1052__) /* Teensy 4.0 */
48#include "USBMIDI_Teensy4.hpp"
49
50#elif defined(__MKL26Z64__) /* Teensy LC */
51#include "USBMIDI_TeensyLC.hpp"
52
53#else
54#warning "Unknown Teensy board, please open an issue on GitHub" \
55 "https://github.com/tttapa/Arduino-Helpers"
56// Fall back to the MIDIUSB library and hope for the best
57#include "USBMIDI_MIDIUSB.hpp"
58#endif
59
60#elif defined(ARDUINO_ARCH_MBED_RP2040)
61
62#include "USBMIDI_RP2040.hpp"
63
64#elif defined(ARDUINO_ARCH_MBED)
65
67
68#elif defined(ARDUINO_RASPBERRY_PI_PICO) && defined(USE_TINYUSB)
69
71
72#else
73
74#include <AH/Arduino-Wrapper.h>
75#ifdef USBCON
76#include "USBMIDI_MIDIUSB.hpp"
77#else
78#define CS_USB_MIDI_NOT_SUPPORTED
79#endif
80
81#endif
82
83#else
84
85#include "USBMIDI_Mock.hpp"
86
87#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
T data[N]
Definition: Array.hpp:37