mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-10-30 22:01:02 +00:00
Merge #1140
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:
commit
aea5a0fd96
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user