-
Hello, I'd like to have two MIDI IN ports on ESP32, using UART0 @115200 baud and UART2 @32150 baud simultaneously. I use MIDI_CREATE_CUSTOM_INSTANCE, and UART2 seems to work well, while UART0 gives errors in hairless midi log. Please, is there some working example? |
Beta Was this translation helpful? Give feedback.
Answered by
copych
Feb 6, 2023
Replies: 1 comment
-
This seems to work #ifdef MIDI_VIA_SERIAL
// default settings for Hairless midi is 115200 8-N-1
struct CustomBaudRateSettings : public MIDI_NAMESPACE::DefaultSerialSettings {
static const long BaudRate = 115200;
};
MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings> serialMIDI(Serial);
MIDI_NAMESPACE::MidiInterface<MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>> MIDI((MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>&)serialMIDI);
#endif
#ifdef MIDI_VIA_SERIAL2
// MIDI port on UART2, pins 16 (RX) and 17 (TX) prohibited, as they are used for PSRAM
struct Serial2MIDISettings : public midi::DefaultSettings{
static const long BaudRate = 31250;
static const int8_t RxPin = MIDIRX_PIN;
static const int8_t TxPin = MIDITX_PIN;
};
MIDI_NAMESPACE::SerialMIDI<HardwareSerial> Serial2MIDI2(Serial2);
MIDI_NAMESPACE::MidiInterface<MIDI_NAMESPACE::SerialMIDI<HardwareSerial, Serial2MIDISettings>> MIDI2((MIDI_NAMESPACE::SerialMIDI<HardwareSerial, Serial2MIDISettings>&)Serial2MIDI2);
#endif void setup() {
#ifdef MIDI_VIA_SERIAL
Serial.begin(115200, SERIAL_8N1);
#endif
#ifdef MIDI_VIA_SERIAL2
pinMode( MIDIRX_PIN , INPUT_PULLDOWN);
pinMode( MIDITX_PIN , OUTPUT);
Serial2.begin( 31250, SERIAL_8N1, MIDIRX_PIN, MIDITX_PIN );
#endif
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
copych
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This seems to work