diff options
| author | xoviat <[email protected]> | 2021-03-23 21:04:18 -0500 |
|---|---|---|
| committer | xoviat <[email protected]> | 2021-03-23 21:04:18 -0500 |
| commit | 3c9d5b61bbf2126c198c9a0c243fafb06118ede2 (patch) | |
| tree | b361928f74f4acd2a9668ffab0f27ea74684d793 | |
| parent | 639059ba33e2440027924155df5c8a2efb7f4f6d (diff) | |
traits: add idle trait
| -rw-r--r-- | embassy-traits/src/uart.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/embassy-traits/src/uart.rs b/embassy-traits/src/uart.rs index b40b9e9bd..441747181 100644 --- a/embassy-traits/src/uart.rs +++ b/embassy-traits/src/uart.rs | |||
| @@ -10,6 +10,15 @@ pub enum Error { | |||
| 10 | pub trait Uart { | 10 | pub trait Uart { |
| 11 | type ReceiveFuture<'a>: Future<Output = Result<(), Error>>; | 11 | type ReceiveFuture<'a>: Future<Output = Result<(), Error>>; |
| 12 | type SendFuture<'a>: Future<Output = Result<(), Error>>; | 12 | type SendFuture<'a>: Future<Output = Result<(), Error>>; |
| 13 | /// Receive into the buffer until the buffer is full | ||
| 13 | fn receive<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReceiveFuture<'a>; | 14 | fn receive<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReceiveFuture<'a>; |
| 15 | /// Send the specified buffer, and return when the transmission has completed | ||
| 14 | fn send<'a>(&'a mut self, buf: &'a [u8]) -> Self::SendFuture<'a>; | 16 | fn send<'a>(&'a mut self, buf: &'a [u8]) -> Self::SendFuture<'a>; |
| 15 | } | 17 | } |
| 18 | |||
| 19 | pub trait IdleUart { | ||
| 20 | type ReceiveFuture<'a>: Future<Output = Result<usize, Error>>; | ||
| 21 | /// Receive into the buffer until the buffer is full or the line is idle after some bytes are received | ||
| 22 | /// Return the number of bytes received | ||
| 23 | fn receive_until_idle<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReceiveFuture<'a>; | ||
| 24 | } | ||
