feat(stm32): Add embedded-io traits for UartRx and UartTx

This commit is contained in:
Rasmus Melchior Jacobsen 2023-01-06 14:24:29 +01:00
parent 5aa59e9737
commit 4c4b47f78a

View file

@ -948,6 +948,45 @@ mod eio {
self.blocking_flush()
}
}
impl<T, RxDma> Io for UartRx<'_, T, RxDma>
where
T: BasicInstance,
{
type Error = Error;
}
impl<T, RxDma> Read for UartRx<'_, T, RxDma>
where
T: BasicInstance,
RxDma: super::RxDma<T>,
{
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
self.read_until_idle(buf).await
}
}
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(