soft_uart: fix handling of num_data_bits < 8

Change-Id: Ife13b1f2d9063ba7253d01523ca9ecb15e9eaf07
Related: OS#4396
This commit is contained in:
Vadim Yanitskiy 2023-11-19 15:37:10 +07:00
parent bf95f82291
commit 2d2ce49e52
2 changed files with 7 additions and 4 deletions

View File

@ -136,6 +136,9 @@ static inline void osmo_uart_rx_bit(struct osmo_soft_uart *suart, const ubit_t b
suart->rx.flow_state = SUART_FLOW_ST_PARITY;
else
suart->rx.flow_state = SUART_FLOW_ST_STOP;
/* align the register if needed */
if (suart->cfg.num_data_bits < 8)
suart->rx.shift_reg >>= (8 - suart->cfg.num_data_bits);
}
break;
case SUART_FLOW_ST_PARITY:

View File

@ -128,16 +128,16 @@ suart_tx_cb(len=0/4):
test_tx_rx_exec_one(n_bits_total=44): 11111111111 11111111111 11111111111 11111111111
======== test_tx_rx(): testing 6-N-1
suart_tx_cb(len=4/4): de ad be ef
suart_rx_cb(flags=00): 78 b4 f8 bc
suart_rx_cb(flags=00): 1e 2d 3e 2f
test_tx_rx_exec_one(n_bits_total=32): 00111101 01011011 00111111 01111011
suart_tx_cb(len=4/4): 00 aa 55 ff
suart_rx_cb(flags=00): 00 a8 54 fc
suart_rx_cb(flags=00): 00 2a 15 3f
test_tx_rx_exec_one(n_bits_total=32): 00000001 00101011 01010101 01111111
suart_tx_cb(len=4/4): 01 02 04 08
suart_rx_cb(flags=00): 04 08 10 20
suart_rx_cb(flags=00): 01 02 04 08
test_tx_rx_exec_one(n_bits_total=32): 01000001 00100001 00010001 00001001
suart_tx_cb(len=4/4): 10 20 40 80
suart_rx_cb(flags=00): 40 80 00 00
suart_rx_cb(flags=00): 10 20 00 00
test_tx_rx_exec_one(n_bits_total=32): 00000101 00000011 00000001 00000001
suart_tx_cb(len=0/4):
test_tx_rx_exec_one(n_bits_total=32): 11111111 11111111 11111111 11111111