Skip to content

Commit 70d59dc

Browse files
authored
Merge pull request #369 from prjh/SERIAL_8E1
Uart: support even parity SERIAL_8E1
2 parents 6c9e42a + 58ac771 commit 70d59dc

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

cores/nRF5/Uart.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void Uart::begin(unsigned long baudrate)
6464
begin(baudrate, (uint8_t)SERIAL_8N1);
6565
}
6666

67-
void Uart::begin(unsigned long baudrate, uint16_t /*config*/)
67+
void Uart::begin(unsigned long baudrate, uint16_t config)
6868
{
6969
// skip if already begun
7070
if ( _begun ) return;
@@ -75,9 +75,17 @@ void Uart::begin(unsigned long baudrate, uint16_t /*config*/)
7575
if (uc_hwFlow == 1) {
7676
nrfUart->PSELCTS = uc_pinCTS;
7777
nrfUart->PSELRTS = uc_pinRTS;
78-
nrfUart->CONFIG = (UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos) | UART_CONFIG_HWFC_Enabled;
78+
if (config==SERIAL_8E1) {
79+
nrfUart->CONFIG = (UART_CONFIG_PARITY_Included << UART_CONFIG_PARITY_Pos) | UART_CONFIG_HWFC_Enabled;
80+
} else {
81+
nrfUart->CONFIG = (UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos) | UART_CONFIG_HWFC_Enabled;
82+
}
7983
} else {
80-
nrfUart->CONFIG = (UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos) | UART_CONFIG_HWFC_Disabled;
84+
if (config==SERIAL_8E1) {
85+
nrfUart->CONFIG = (UART_CONFIG_PARITY_Included << UART_CONFIG_PARITY_Pos) | UART_CONFIG_HWFC_Disabled;
86+
} else {
87+
nrfUart->CONFIG = (UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos) | UART_CONFIG_HWFC_Disabled;
88+
}
8189
}
8290

8391
uint32_t nrfBaudRate;

0 commit comments

Comments
 (0)