1140: feat(stm32): Let uart implement embedded-io Write trait r=Dirbaio a=rmja



Co-authored-by: Rasmus Melchior Jacobsen <rmja@laesoe.org>
This commit is contained in:
bors[bot] 2023-01-14 19:45:28 +00:00 committed by GitHub
commit aea5a0fd96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -910,6 +910,58 @@ mod eh1 {
}
}
#[cfg(all(feature = "unstable-traits", feature = "nightly"))]
mod eio {
use embedded_io::asynch::Write;
use embedded_io::Io;
use super::*;
impl<T, TxDma, RxDma> Io for Uart<'_, T, TxDma, RxDma>
where
T: BasicInstance,
{
type Error = Error;
}
impl<T, TxDma, RxDma> Write for Uart<'_, T, TxDma, RxDma>
where
T: BasicInstance,
TxDma: super::TxDma<T>,
{
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.write(buf).await?;
Ok(buf.len())
}
async fn flush(&mut self) -> Result<(), Self::Error> {
self.blocking_flush()
}
}
impl<T, TxDma> Io for UartTx<'_, T, TxDma>
where
T: BasicInstance,
{
type Error = Error;
}
impl<T, TxDma> Write for UartTx<'_, T, TxDma>
where
T: BasicInstance,
TxDma: super::TxDma<T>,
{
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.write(buf).await?;
Ok(buf.len())
}
async fn flush(&mut self) -> Result<(), Self::Error> {
self.blocking_flush()
}
}
}
#[cfg(all(
feature = "unstable-traits",
feature = "nightly",