stm32/usart: Data length is including parity. To get e.g. 8E1 you need to choose 9 data bits

This commit is contained in:
Ralf 2022-05-11 19:57:56 +02:00
parent 6040517774
commit f4677469f9

View File

@ -219,7 +219,11 @@ impl<'d, T: Instance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> {
w.set_ue(true); w.set_ue(true);
w.set_te(true); w.set_te(true);
w.set_re(true); w.set_re(true);
w.set_m0(vals::M0::BIT8); w.set_m0(if config.parity != Parity::ParityNone {
vals::M0::BIT9
} else {
vals::M0::BIT8
});
w.set_pce(config.parity != Parity::ParityNone); w.set_pce(config.parity != Parity::ParityNone);
w.set_ps(match config.parity { w.set_ps(match config.parity {
Parity::ParityOdd => vals::Ps::ODD, Parity::ParityOdd => vals::Ps::ODD,