rp: Allow zero len writes for buffered uart
Prevents the write methods from getting stuck forever.
This commit is contained in:
parent
f78aa4f936
commit
7ef6a3cfb2
@ -301,6 +301,10 @@ impl<'d, T: Instance> BufferedUartTx<'d, T> {
|
|||||||
|
|
||||||
fn write<'a>(buf: &'a [u8]) -> impl Future<Output = Result<usize, Error>> + 'a {
|
fn write<'a>(buf: &'a [u8]) -> impl Future<Output = Result<usize, Error>> + 'a {
|
||||||
poll_fn(move |cx| {
|
poll_fn(move |cx| {
|
||||||
|
if buf.is_empty() {
|
||||||
|
return Poll::Ready(Ok(0));
|
||||||
|
}
|
||||||
|
|
||||||
let state = T::state();
|
let state = T::state();
|
||||||
let mut tx_writer = unsafe { state.tx_buf.writer() };
|
let mut tx_writer = unsafe { state.tx_buf.writer() };
|
||||||
let n = tx_writer.push(|data| {
|
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> {
|
pub fn blocking_write(&mut self, buf: &[u8]) -> Result<usize, Error> {
|
||||||
|
if buf.is_empty() {
|
||||||
|
return Ok(0);
|
||||||
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let state = T::state();
|
let state = T::state();
|
||||||
let mut tx_writer = unsafe { state.tx_buf.writer() };
|
let mut tx_writer = unsafe { state.tx_buf.writer() };
|
||||||
|
Loading…
Reference in New Issue
Block a user