Skip to content

Commit

Permalink
improvements for UART API
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Sep 24, 2024
1 parent 0f31ee6 commit 3c3270f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions va416xx-hal/src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1201,10 +1201,20 @@ impl<Uart: Instance> embedded_hal_nb::serial::Read<u8> for UartBase<Uart> {

impl<Uart: Instance> embedded_hal_nb::serial::Write<u8> for UartBase<Uart> {
fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> {
self.tx.write(word)
self.tx.write(word).map_err(|e| {
if let nb::Error::Other(_) = e {
unreachable!()
}
nb::Error::WouldBlock
})
}

fn flush(&mut self) -> nb::Result<(), Self::Error> {
self.tx.flush()
self.tx.flush().map_err(|e| {
if let nb::Error::Other(_) = e {
unreachable!()
}
nb::Error::WouldBlock
})
}
}

0 comments on commit 3c3270f

Please sign in to comment.