Skip to content

Commit

Permalink
Fix implementations of embedded_io::Write for UartPeripheral
Browse files Browse the repository at this point in the history
Fixes #840
  • Loading branch information
jannic committed Feb 4, 2025
1 parent abb61f0 commit fff4f6c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions rp2040-hal/src/uart/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,8 @@ impl<D: UartDevice, P: ValidUartPinout<D>> embedded_io::ReadReady

impl<D: UartDevice, P: ValidUartPinout<D>> embedded_io::Write for UartPeripheral<Enabled, D, P> {
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.write_full_blocking(buf);
Ok(buf.len())
let remaining = nb::block!(super::writer::write_raw(&self.device, buf)).unwrap(); // Infallible
Ok(buf.len() - remaining.len())
}
fn flush(&mut self) -> Result<(), Self::Error> {
nb::block!(super::writer::transmit_flushed(&self.device)).unwrap(); // Infallible
Expand Down
4 changes: 2 additions & 2 deletions rp235x-hal/src/uart/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,8 @@ impl<D: UartDevice, P: ValidUartPinout<D>> embedded_io::ReadReady

impl<D: UartDevice, P: ValidUartPinout<D>> embedded_io::Write for UartPeripheral<Enabled, D, P> {
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.write_full_blocking(buf);
Ok(buf.len())
let remaining = nb::block!(super::writer::write_raw(&self.device, buf)).unwrap(); // Infallible
Ok(buf.len() - remaining.len())
}
fn flush(&mut self) -> Result<(), Self::Error> {
nb::block!(super::writer::transmit_flushed(&self.device)).unwrap(); // Infallible
Expand Down

0 comments on commit fff4f6c

Please sign in to comment.