From 3c9d5b61bbf2126c198c9a0c243fafb06118ede2 Mon Sep 17 00:00:00 2001 From: xoviat Date: Tue, 23 Mar 2021 21:04:18 -0500 Subject: [PATCH] traits: add idle trait --- embassy-traits/src/uart.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/embassy-traits/src/uart.rs b/embassy-traits/src/uart.rs index b40b9e9b..44174718 100644 --- a/embassy-traits/src/uart.rs +++ b/embassy-traits/src/uart.rs @@ -10,6 +10,15 @@ pub enum Error { pub trait Uart { type ReceiveFuture<'a>: Future>; type SendFuture<'a>: Future>; + /// Receive into the buffer until the buffer is full fn receive<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReceiveFuture<'a>; + /// Send the specified buffer, and return when the transmission has completed fn send<'a>(&'a mut self, buf: &'a [u8]) -> Self::SendFuture<'a>; } + +pub trait IdleUart { + type ReceiveFuture<'a>: Future>; + /// Receive into the buffer until the buffer is full or the line is idle after some bytes are received + /// Return the number of bytes received + fn receive_until_idle<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReceiveFuture<'a>; +}