diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index a835093c5..a87b7c020 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs @@ -449,6 +449,20 @@ mod buffered { } poll } + + fn poll_flush( + mut self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll> { + self.inner.with(|state| { + if !state.tx.is_empty() { + state.tx_waker.register(cx.waker()); + return Poll::Pending; + } + + Poll::Ready(Ok(())) + }) + } } } diff --git a/embassy/src/io/util/split.rs b/embassy/src/io/util/split.rs index 0cebb5cbd..cc029aa53 100644 --- a/embassy/src/io/util/split.rs +++ b/embassy/src/io/util/split.rs @@ -32,6 +32,9 @@ impl AsyncWrite for WriteHalf { fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll> { Pin::new(unsafe { &mut *self.handle.get() }).poll_write(cx, buf) } + fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + Pin::new(unsafe { &mut *self.handle.get() }).poll_flush(cx) + } } pub fn split(t: T) -> (ReadHalf, WriteHalf) {