Skip to content

Commit a501daf

Browse files
Implement Send for FullDuplex
1 parent 4edb37d commit a501daf

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

src/spi.rs

+6-25
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,14 @@ pub trait Send<Word> {
4747

4848
/// Write (master mode)
4949
#[cfg(feature = "unproven")]
50-
pub mod full_duplex {
51-
/// Default implementation of `spi::FullDuplex<W>` for implementers of
52-
/// `spi::Send<W>`
53-
///
54-
/// Also needs a `send` method to return the byte read during the last send
55-
pub trait Default<W>: ::spi::Send<W> {
56-
/// Reads the word stored in the shift register
57-
///
58-
/// **NOTE** A word must be sent to the slave before attempting to call this
59-
/// method.
60-
fn read(&mut self) -> nb::Result<W, Self::Error>;
50+
impl<W, E> Send<W> for FullDuplex<W, Error = E> {
51+
type Error = E;
52+
fn send(&mut self, word: W) -> nb::Result<(), Self::Error> {
53+
self.send(word)
6154
}
6255

63-
impl<W, S> ::spi::FullDuplex<W> for S
64-
where
65-
S: Default<W>,
66-
W: Clone,
67-
{
68-
type Error = S::Error;
69-
70-
fn read(&mut self) -> nb::Result<W, Self::Error> {
71-
self.read()
72-
}
73-
74-
fn send(&mut self, word: W) -> nb::Result<(), Self::Error> {
75-
self.send(word)
76-
}
56+
fn completed(&mut self) -> nb::Result<(), Self::Error> {
57+
self.read().map(|_| ())
7758
}
7859
}
7960

0 commit comments

Comments
 (0)