From 45ef9444579c8d7af72fc2d42093f26ef6f6ac3c Mon Sep 17 00:00:00 2001 From: huntc Date: Fri, 10 Dec 2021 15:11:41 +1100 Subject: [PATCH] Stm flush required implementing also, along with std alloc split --- embassy-stm32/src/usart/mod.rs | 14 ++++++++++++++ embassy/src/io/util/split.rs | 3 +++ 2 files changed, 17 insertions(+) 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) {