Skip to content

Teensy specific Serial data format - #196

Open
jacobanana wants to merge 6 commits into
FortySevenEffects:masterfrom
MixedMode-fX:settings-teensy-serial-format
Open

Teensy specific Serial data format#196
jacobanana wants to merge 6 commits into
FortySevenEffects:masterfrom
MixedMode-fX:settings-teensy-serial-format

Conversation

@jacobanana

Copy link
Copy Markdown

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
Copy Markdown
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.

2 participants