From 93dd21042ceadea114b01c40a250d33402672569 Mon Sep 17 00:00:00 2001 From: flippette Date: Thu, 31 Oct 2024 22:14:11 +0200 Subject: [PATCH] Implement `embedded_io::Write` for `Uart<'d, T: Instance, Blocking>` (#3483) * Implement `embedded_io::{Read,Write}` for `Uart<'d, T: Instance, Blocking>` * Unimplement `embedded_io::Read` for `Uart<'d, T: Instance, Blocking>` * Revert "Unimplement `embedded_io::Read` for `Uart<'d, T: Instance, Blocking>`" * Unimplement `embedded_io::Read` for `Uart<'d, T: Instance, Blocking>` (take 2) --- embassy-rp/src/uart/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/embassy-rp/src/uart/mod.rs b/embassy-rp/src/uart/mod.rs index c94e5e185..ad98a46c7 100644 --- a/embassy-rp/src/uart/mod.rs +++ b/embassy-rp/src/uart/mod.rs @@ -1264,6 +1264,20 @@ impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::Write for Uart<'d, T, M> } } +impl<'d, T: Instance> embedded_io::ErrorType for Uart<'d, T, Blocking> { + type Error = Error; +} + +impl<'d, T: Instance> embedded_io::Write for Uart<'d, T, Blocking> { + fn write(&mut self, buf: &[u8]) -> Result { + self.blocking_write(buf).map(|_| buf.len()) + } + + fn flush(&mut self) -> Result<(), Self::Error> { + self.blocking_flush() + } +} + trait SealedMode {} trait SealedInstance {