aboutsummaryrefslogtreecommitdiff
path: root/embassy-traits/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-03-22 01:15:44 +0100
committerDario Nieuwenhuis <[email protected]>2021-03-29 00:58:58 +0200
commitdf42c384923579c449a13511b0fdb8de3b2a4773 (patch)
tree0c89eb75183e972e81748f9a3e601df30191c14a /embassy-traits/src
parent7b6086d19eca2d51c7cddf9dbbbc47eacf371472 (diff)
nrf/uarte: update to new api
Diffstat (limited to 'embassy-traits/src')
-rw-r--r--embassy-traits/src/uart.rs34
1 files changed, 24 insertions, 10 deletions
diff --git a/embassy-traits/src/uart.rs b/embassy-traits/src/uart.rs
index 441747181..5676e3fca 100644
--- a/embassy-traits/src/uart.rs
+++ b/embassy-traits/src/uart.rs
@@ -1,4 +1,5 @@
1use core::future::Future; 1use core::future::Future;
2use core::pin::Pin;
2 3
3#[derive(Copy, Clone, Debug, Eq, PartialEq)] 4#[derive(Copy, Clone, Debug, Eq, PartialEq)]
4#[cfg_attr(feature = "defmt", derive(defmt::Format))] 5#[cfg_attr(feature = "defmt", derive(defmt::Format))]
@@ -7,18 +8,31 @@ pub enum Error {
7 Other, 8 Other,
8} 9}
9 10
10pub trait Uart { 11pub trait Read {
11 type ReceiveFuture<'a>: Future<Output = Result<(), Error>>; 12 type ReadFuture<'a>: Future<Output = Result<(), Error>>
12 type SendFuture<'a>: Future<Output = Result<(), Error>>; 13 where
13 /// Receive into the buffer until the buffer is full 14 Self: 'a;
14 fn receive<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReceiveFuture<'a>; 15
15 /// Send the specified buffer, and return when the transmission has completed 16 fn read<'a>(self: Pin<&'a mut Self>, buf: &'a mut [u8]) -> Self::ReadFuture<'a>;
16 fn send<'a>(&'a mut self, buf: &'a [u8]) -> Self::SendFuture<'a>;
17} 17}
18 18
19pub trait IdleUart { 19pub trait ReadUntilIdle {
20 type ReceiveFuture<'a>: Future<Output = Result<usize, Error>>; 20 type ReadUntilIdleFuture<'a>: Future<Output = Result<usize, Error>>
21 where
22 Self: 'a;
23
21 /// Receive into the buffer until the buffer is full or the line is idle after some bytes are received 24 /// 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 25 /// Return the number of bytes received
23 fn receive_until_idle<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReceiveFuture<'a>; 26 fn read_until_idle<'a>(
27 self: Pin<&'a mut Self>,
28 buf: &'a mut [u8],
29 ) -> Self::ReadUntilIdleFuture<'a>;
30}
31
32pub trait Write {
33 type WriteFuture<'a>: Future<Output = Result<(), Error>>
34 where
35 Self: 'a;
36
37 fn write<'a>(self: Pin<&'a mut Self>, buf: &'a [u8]) -> Self::WriteFuture<'a>;
24} 38}