Skip to content
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

Teensy specific Serial data format #196

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

jacobanana
Copy link

It is possible to specify inverted pins on UART ports when using Teensy. This is documented here: https://www.pjrc.com/teensy/td_uart.html under the Serial1.begin(baud, format) section.

For MIDI, the relevant formats are :

Format Name Data Bits Parity RX Polarity TX Polarity
SERIAL_8N1 8 None Normal Normal
SERIAL_8N1_RXINV 8 None Inverted Normal
SERIAL_8N1_TXINV 8 None Normal Inverted
SERIAL_8N1_RXINV_TXINV 8 None Inverted Inverted

This allows more flexibility with input and output circuits that may be inverting.

In order to configure the polarity, it is important to inherit the custom settings struct from DefaultSerialSettings instead of DefaultSettings

struct TXInvMidiSettings : public midi::DefaultSerialSettings
{
    static const uint16_t SerialFormat = SERIAL_8N1_TXINV; // Invert TX
};

MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial1, midi1, TXInvMidiSettings);

@jacobanana jacobanana changed the title Settings teensy serial format Teensy specific Serial data format Jan 18, 2021
@franky47
Copy link
Member

There might be special cases to handle for SofttwareSerial, which does not have this extra configuration input (see failing tests).

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

Successfully merging this pull request may close these issues.

None yet

2 participants