aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Vahter <[email protected]>2023-10-23 22:40:24 +0300
committerAndres Vahter <[email protected]>2023-10-23 22:40:24 +0300
commit188ee59ba656d5fd47f5a13f978cd064752d3b75 (patch)
treeb544d8f4acfef57f37a94d32f79c1182798046ae
parent591612db7e5f8f8dd5120b12a55c00da38a510a8 (diff)
stm32: fix setting uart databits
-rw-r--r--embassy-stm32/src/usart/mod.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs
index 09d5a59d2..8c4df375a 100644
--- a/embassy-stm32/src/usart/mod.rs
+++ b/embassy-stm32/src/usart/mod.rs
@@ -910,6 +910,11 @@ fn configure(
910 brr + rounding 910 brr + rounding
911 } 911 }
912 912
913 // UART must be disabled during configuration.
914 r.cr1().modify(|w| {
915 w.set_ue(false);
916 });
917
913 #[cfg(not(usart_v1))] 918 #[cfg(not(usart_v1))]
914 let mut over8 = false; 919 let mut over8 = false;
915 let mut found_brr = None; 920 let mut found_brr = None;
@@ -977,10 +982,9 @@ fn configure(
977 // enable receiver 982 // enable receiver
978 w.set_re(enable_rx); 983 w.set_re(enable_rx);
979 // configure word size 984 // configure word size
980 w.set_m0(if config.parity != Parity::ParityNone { 985 w.set_m0(match config.data_bits {
981 vals::M0::BIT9 986 DataBits::DataBits8 => vals::M0::BIT8,
982 } else { 987 DataBits::DataBits9 => vals::M0::BIT9,
983 vals::M0::BIT8
984 }); 988 });
985 // configure parity 989 // configure parity
986 w.set_pce(config.parity != Parity::ParityNone); 990 w.set_pce(config.parity != Parity::ParityNone);