Skip to content

Commit 3c50894

Browse files
Implement Send for FullDuplex
1 parent 4edb37d commit 3c50894

File tree

1 file changed

+5
-25
lines changed

1 file changed

+5
-25
lines changed

Diff for: src/spi.rs

+5-25
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,13 @@ 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> Send<W> for FullDuplex<W> {
51+
fn send(&mut self, word: W) -> nb::Result<(), Self::Error> {
52+
self.send(word)
6153
}
6254

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-
}
55+
fn completed(&mut self) -> nb::Result<(), Self::Error> {
56+
self.read().map(|_| ())
7757
}
7858
}
7959

0 commit comments

Comments
 (0)