rp: Allow zero len writes for buffered uart

Prevents the write methods from getting stuck forever.
This commit is contained in:
Timo Kröger 2023-04-02 14:36:32 +02:00
parent f78aa4f936
commit 7ef6a3cfb2

View File

@ -301,6 +301,10 @@ impl<'d, T: Instance> BufferedUartTx<'d, T> {
fn write<'a>(buf: &'a [u8]) -> impl Future<Output = Result<usize, Error>> + '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<usize, Error> {
if buf.is_empty() {
return Ok(0);
}
loop {
let state = T::state();
let mut tx_writer = unsafe { state.tx_buf.writer() };