Fix USB MIDI enumeration: switch from ARDUINO_USB_MODE=1 to 0 (matches working Adafruit TinyUSB example), add explicit TinyUSBDevice.begin(0) and detach/attach re-enumeration, remove conflicting tusb_config.h

This commit is contained in:
2026-06-23 23:10:20 +00:00
parent d957e276bd
commit a3e86d0ddf
4 changed files with 21 additions and 24 deletions
+3 -2
View File
@@ -7,12 +7,13 @@ board = esp32-s3-devkitc-1
framework = arduino framework = arduino
lib_deps = lib_deps =
adafruit/Adafruit TinyUSB Library@^2.0.0 adafruit/Adafruit TinyUSB Library@^3.1.0
fastled/FastLED@^3.9.0 fastled/FastLED@^3.9.0
build_flags = build_flags =
-DARDUINO_USB_MODE=1 -DARDUINO_USB_MODE=0
-DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_CDC_ON_BOOT=1
-DUSE_TINYUSB=1
monitor_speed = 115200 monitor_speed = 115200
+7
View File
@@ -82,6 +82,12 @@ void handle_serial_command(const String& cmd) {
mux.set_led_color(1, 255, 255, 255); mux.set_led_color(1, 255, 255, 255);
mux.show(); mux.show();
Serial.println("[CMD] Pixel 1 WHITE (max brightness)"); Serial.println("[CMD] Pixel 1 WHITE (max brightness)");
} else if (cmd == "usb") {
Serial.printf("[CMD] USB mounted: %s\n", TinyUSBDevice.mounted() ? "YES" : "NO");
Serial.printf("[CMD] USB VID:PID = 0x%04X:0x%04X\n", TinyUSBDevice.vid(), TinyUSBDevice.pid());
Serial.printf("[CMD] USB manufacturer: %s\n", TinyUSBDevice.manufacturerDescriptor());
Serial.printf("[CMD] USB product: %s\n", TinyUSBDevice.productDescriptor());
Serial.printf("[CMD] USB serial: %s\n", TinyUSBDevice.serialDescriptor());
} else if (cmd == "gpiotest") { } else if (cmd == "gpiotest") {
Serial.println("[CMD] === Raw GPIO Test ==="); Serial.println("[CMD] === Raw GPIO Test ===");
uint8_t pins[] = {9, 10, 11, 12}; uint8_t pins[] = {9, 10, 11, 12};
@@ -122,6 +128,7 @@ void handle_serial_command(const String& cmd) {
Serial.println(" read - raw button read"); Serial.println(" read - raw button read");
Serial.println(" red/green/blue - solid colour"); Serial.println(" red/green/blue - solid colour");
Serial.println(" pixel0/pixel1 - single pixel test"); Serial.println(" pixel0/pixel1 - single pixel test");
Serial.println(" usb - USB connection status and descriptor info");
Serial.println(" gpiotest - raw GPIO pin diagnostic"); Serial.println(" gpiotest - raw GPIO pin diagnostic");
Serial.println(" rawled - bit-bang WS2812 (no library)"); Serial.println(" rawled - bit-bang WS2812 (no library)");
Serial.println(" anim - re-run startup animation from loop"); Serial.println(" anim - re-run startup animation from loop");
+11 -1
View File
@@ -13,15 +13,25 @@ UsbMidiTransport::~UsbMidiTransport() {
bool UsbMidiTransport::begin() { bool UsbMidiTransport::begin() {
Serial.println("[MIDI] Setting up USB MIDI device..."); Serial.println("[MIDI] Setting up USB MIDI device...");
if (!TinyUSBDevice.isInitialized()) {
TinyUSBDevice.begin(0);
}
TinyUSBDevice.setManufacturerDescriptor("Ashley Strahle"); TinyUSBDevice.setManufacturerDescriptor("Ashley Strahle");
TinyUSBDevice.setProductDescriptor("Loopy Foot Controller"); TinyUSBDevice.setProductDescriptor("Loopy Foot Controller");
TinyUSBDevice.setSerialDescriptor("LFMIDI001"); TinyUSBDevice.setSerialDescriptor("LFMIDI001");
if (!usb_midi.begin(32)) { if (!usb_midi.begin()) {
Serial.println("[MIDI] ERROR: USB MIDI init failed"); Serial.println("[MIDI] ERROR: USB MIDI init failed");
return false; return false;
} }
if (TinyUSBDevice.mounted()) {
TinyUSBDevice.detach();
delay(10);
TinyUSBDevice.attach();
}
initialized = true; initialized = true;
Serial.println("[MIDI] USB MIDI ready - enumerating..."); Serial.println("[MIDI] USB MIDI ready - enumerating...");
return true; return true;
-21
View File
@@ -1,21 +0,0 @@
#ifndef TUSB_CONFIG_H
#define TUSB_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
#define CFG_TUD_MIDI 1
#define CFG_TUD_MIDI_RX_BUFSIZE 64
#define CFG_TUD_MIDI_TX_BUFSIZE 64
#define CFG_TUD_CDC 0
#define CFG_TUD_MSC 0
#define CFG_TUD_HID 0
#define CFG_TUD_NET 0
#ifdef __cplusplus
}
#endif
#endif