From f6d92b76111d8619c92b13aa28e765abe356465c Mon Sep 17 00:00:00 2001 From: Badr Bouslikhin Date: Fri, 30 Aug 2024 18:52:23 +0200 Subject: [PATCH] fix(stm32): disable transmitter during half-duplex read --- embassy-stm32/src/usart/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index 89d92dda2..af34b548e 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs @@ -526,9 +526,12 @@ fn blocking_flush(info: &Info) -> Result<(), Error> { let r = info.regs; while !sr(r).read().tc() {} - // Enable Receiver after transmission complete for Half-Duplex mode + // Disable Transmitter and enable receiver after transmission complete for Half-Duplex mode if r.cr3().read().hdsel() { - r.cr1().modify(|reg| reg.set_re(true)); + r.cr1().modify(|reg| { + reg.set_te(false); + reg.set_re(true); + }); } Ok(())