Add Uart trait, implement it for nrf.

This commit is contained in:
Dario Nieuwenhuis
2021-01-02 19:59:37 +01:00
parent 1d53985abe
commit 0ab88ea279
4 changed files with 73 additions and 49 deletions

View File

@ -12,4 +12,5 @@ pub mod interrupt;
pub mod io;
pub mod rand;
pub mod time;
pub mod uart;
pub mod util;

15
embassy/src/uart.rs Normal file
View File

@ -0,0 +1,15 @@
use core::future::Future;
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[non_exhaustive]
pub enum Error {
Other,
}
pub trait Uart {
type ReceiveFuture<'a>: Future<Output = Result<(), Error>>;
type SendFuture<'a>: Future<Output = Result<(), Error>>;
fn receive<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReceiveFuture<'a>;
fn send<'a>(&'a mut self, buf: &'a [u8]) -> Self::SendFuture<'a>;
}