Skip to content

MIDI_CREATE_DEFAULT_INSTANCE should default to Serial1 on all ARM-based boards #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tfry-git opened this issue Dec 8, 2017 · 1 comment

Comments

@tfry-git
Copy link

tfry-git commented Dec 8, 2017

MIDI_CREATE_DEFAULT_INSTANCE() binds to "Serial" by default, which is known to break on certain boards. There already is special casing to handle Leonardo, Due, and (as far as I understand) some Teensy variants.

On popular STM32(duino) variants, Serial is similarly wired to the USB port, instead of external connectors (apparently including all STM32F103 boards, according to http://wiki.stm32duino.com/index.php?title=API#Serial_.26_USB_Serial), and should thus default to using "Serial1", too. Given that the STM32 chips (all 32-bit arm chips?) all come with a multitude of Serial ports, that seems like a natural choice, too.

Thus, instead of trying to come up with a complete list of board names, I believe it will make most sense to cover the whole family, by checking for defined(arm). I.e.:

diff --git a/src/midi_Defs.h b/src/midi_Defs.h
index 9adec03..126f4d2 100644
--- a/src/midi_Defs.h
+++ b/src/midi_Defs.h
@@ -214,7 +214,7 @@ struct RPN
 #define MIDI_CREATE_INSTANCE(Type, SerialPort, Name)                            \
     midi::MidiInterface<Type> Name((Type&)SerialPort);
 
-#if defined(ARDUINO_SAM_DUE) || defined(USBCON) || defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__)
+#if defined(ARDUINO_SAM_DUE) || defined(USBCON) || defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__) || defined(__arm__)
     // Leonardo, Due and other USB boards use Serial1 by default.
     #define MIDI_CREATE_DEFAULT_INSTANCE()                                      \
         MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);
@franky47
Copy link
Member

I've tried to compile a list of boards, their defs and which serial ports are available in #65.
I'll add this one to the list, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants