From 64ebb9b7fee1fec62eacc1064a7458a6e6b07048 Mon Sep 17 00:00:00 2001 From: Patrick Oppenlander Date: Mon, 6 Feb 2023 09:44:13 +1100 Subject: [PATCH] stm32/usart: implement stop_bits configuration --- embassy-stm32/src/usart/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index 20f4eedeb..b18b646ba 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs @@ -770,7 +770,14 @@ fn configure(r: Regs, config: &Config, pclk_freq: Hertz, multiplier: u32, enable unsafe { r.brr().write_value(regs::Brr(div)); - r.cr2().write(|_w| {}); + r.cr2().write(|w| { + w.set_stop(match config.stop_bits { + StopBits::STOP0P5 => vals::Stop::STOP0P5, + StopBits::STOP1 => vals::Stop::STOP1, + StopBits::STOP1P5 => vals::Stop::STOP1P5, + StopBits::STOP2 => vals::Stop::STOP2, + }); + }); r.cr1().write(|w| { // enable uart w.set_ue(true);