diff --git a/embassy-rp/src/uart/buffered.rs b/embassy-rp/src/uart/buffered.rs index 9aa0b571..c620ed08 100644 --- a/embassy-rp/src/uart/buffered.rs +++ b/embassy-rp/src/uart/buffered.rs @@ -301,6 +301,10 @@ impl<'d, T: Instance> BufferedUartTx<'d, T> { fn write<'a>(buf: &'a [u8]) -> impl Future> + 'a { poll_fn(move |cx| { + if buf.is_empty() { + return Poll::Ready(Ok(0)); + } + let state = T::state(); let mut tx_writer = unsafe { state.tx_buf.writer() }; let n = tx_writer.push(|data| { @@ -335,6 +339,10 @@ impl<'d, T: Instance> BufferedUartTx<'d, T> { } pub fn blocking_write(&mut self, buf: &[u8]) -> Result { + if buf.is_empty() { + return Ok(0); + } + loop { let state = T::state(); let mut tx_writer = unsafe { state.tx_buf.writer() };