Skip to content

Commit d9d08fa

Browse files
committed
Remove futures::spi::FullDuplex
1 parent 3a30a33 commit d9d08fa

File tree

1 file changed

+0
-100
lines changed

1 file changed

+0
-100
lines changed

src/futures/spi.rs

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,6 @@
22
33
use core::future::Future;
44

5-
/// Full duplex (master mode)
6-
///
7-
/// # Notes
8-
///
9-
/// - It's the task of the user of this interface to manage the slave select lines
10-
///
11-
/// - Due to how full duplex SPI works each `read` call must be preceded by a `write` call.
12-
///
13-
/// - `read` calls only return the data received with the last `write` call.
14-
/// Previously received data is discarded
15-
///
16-
/// - Data is only guaranteed to be clocked out when the `read` call succeeds.
17-
/// The slave select line shouldn't be released before that.
18-
///
19-
/// - Some SPIs can work with 8-bit *and* 16-bit words. You can overload this trait with different
20-
/// `Word` types to allow operation in both modes.
21-
pub trait FullDuplex<Word> {
22-
/// An enumeration of SPI errors
23-
type Error;
24-
25-
/// The future associated with the `read` method.
26-
type ReadFuture<'a>: Future<Output=Result<Word, Self::Error>> + 'a
27-
where
28-
Self: 'a;
29-
30-
/// The future associated with the `write` method.
31-
type WriteFuture<'a>: Future<Output=Result<(), Self::Error>> + 'a
32-
where
33-
Self: 'a;
34-
35-
/// Reads the word stored in the shift register
36-
///
37-
/// **NOTE** A word must be sent to the slave before attempting to call this
38-
/// method.
39-
fn read<'a>(&'a mut self) -> Self::ReadFuture<'a>;
40-
41-
/// Writes a word to the slave
42-
fn write<'a>(&'a mut self, word: Word) -> Self::WriteFuture<'a>;
43-
}
44-
455
/// Async transfer
466
pub trait Transfer<Word: 'static> {
477
/// Error type
@@ -70,66 +30,6 @@ pub trait Write<W> {
7030
fn write<'a>(&'a mut self, words: &'a [W]) -> Self::WriteFuture<'a>;
7131
}
7232

73-
/// Async transfer
74-
pub mod transfer {
75-
use core::future::Future;
76-
77-
/// Default implementation of `futures::spi::Transfer<W>` for implementers of
78-
/// `futures::spi::FullDuplex<W>`
79-
pub trait Default<Word>: super::FullDuplex<Word> {}
80-
81-
impl<Word, S> super::Transfer<Word> for S
82-
where
83-
S: Default<Word>,
84-
Word: Clone + 'static,
85-
{
86-
type Error = S::Error;
87-
88-
type TransferFuture<'a> where Self: 'a = impl Future<Output = Result<&'a [Word], S::Error>> + 'a;
89-
90-
fn transfer<'w>(&'w mut self, words: &'w mut [Word]) -> Self::TransferFuture<'w> {
91-
async move {
92-
for word in words.iter_mut() {
93-
self.write(word.clone()).await?;
94-
*word = self.read().await?;
95-
}
96-
97-
Ok(words as &'w [Word])
98-
}
99-
}
100-
}
101-
}
102-
103-
/// Blocking write
104-
pub mod write {
105-
use core::future::Future;
106-
107-
/// Default implementation of `futures::spi::Write<W>` for implementers
108-
/// of `futures::spi::FullDuplex<W>`
109-
pub trait Default<W>: super::FullDuplex<W> {}
110-
111-
impl<W, S> super::Write<W> for S
112-
where
113-
S: Default<W>,
114-
W: Clone + 'static,
115-
{
116-
type Error = S::Error;
117-
118-
type WriteFuture<'a> where Self: 'a = impl Future<Output = Result<(), S::Error>> + 'a;
119-
120-
fn write<'a>(&'a mut self, words: &'a [W]) -> Self::WriteFuture<'a> {
121-
async move {
122-
for word in words {
123-
self.write(word.clone()).await?;
124-
self.read().await?;
125-
}
126-
127-
Ok(())
128-
}
129-
}
130-
}
131-
}
132-
13333
// /// Operation for transactional SPI trait
13434
// ///
13535
// /// This allows composition of SPI operations into a single bus transaction

0 commit comments

Comments
 (0)