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

SerialX.begin - support 7 bit modes. #391

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions cores/arduino/Serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,38 @@ void UART::begin(unsigned long baudrate, uint16_t config) {
uart_cfg.parity = UART_PARITY_ODD;
uart_cfg.stop_bits = UART_STOP_BITS_2;
break;
// add 7 bit support
case SERIAL_7N1:
uart_cfg.data_bits = UART_DATA_BITS_7;
uart_cfg.parity = UART_PARITY_OFF;
uart_cfg.stop_bits = UART_STOP_BITS_1;
break;
case SERIAL_7N2:
uart_cfg.data_bits = UART_DATA_BITS_7;
uart_cfg.parity = UART_PARITY_OFF;
uart_cfg.stop_bits = UART_STOP_BITS_2;
break;
case SERIAL_7E1:
uart_cfg.data_bits = UART_DATA_BITS_7;
uart_cfg.parity = UART_PARITY_EVEN;
uart_cfg.stop_bits = UART_STOP_BITS_1;
break;
case SERIAL_7E2:
uart_cfg.data_bits = UART_DATA_BITS_7;
uart_cfg.parity = UART_PARITY_EVEN;
uart_cfg.stop_bits = UART_STOP_BITS_2;
break;
case SERIAL_7O1:
uart_cfg.data_bits = UART_DATA_BITS_7;
uart_cfg.parity = UART_PARITY_ODD;
uart_cfg.stop_bits = UART_STOP_BITS_1;
break;
case SERIAL_7O2:
uart_cfg.data_bits = UART_DATA_BITS_7;
uart_cfg.parity = UART_PARITY_ODD;
uart_cfg.stop_bits = UART_STOP_BITS_2;
break;

}

uart_cfg.p_callback = UART::WrapperCallback;
Expand Down
Loading