Skip to content

Commit 4fd349d

Browse files
committed
Use interleaved buffer for data
1 parent c3c042a commit 4fd349d

File tree

2 files changed

+17
-22
lines changed

2 files changed

+17
-22
lines changed

src/blocking/i2s.rs

+13-16
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,32 @@ pub trait Read<W> {
55
/// Error type
66
type Error;
77

8-
/// Reads enough bytes from the slave to fill `left_words` and `right_words`.
9-
fn try_read<'w>(
10-
&mut self,
11-
left_words: &'w mut [W],
12-
right_words: &'w mut [W],
13-
) -> Result<(), Self::Error>;
8+
/// Reads enough bytes from the slave to fill `data`.
9+
///
10+
/// The data is filled up with interleaved data as appropriate.
11+
fn try_read<'w>(&mut self, data: &'w mut [W]) -> Result<(), Self::Error>;
1412
}
1513

1614
/// Blocking write
1715
pub trait Write<W> {
1816
/// Error type
1917
type Error;
2018

21-
/// Sends `left_words` and `right_words` to the slave.
22-
fn try_write<'w>(
23-
&mut self,
24-
left_words: &'w [W],
25-
right_words: &'w [W],
26-
) -> Result<(), Self::Error>;
19+
/// Sends `data` to the slave.
20+
///
21+
/// The data should be filled with interleaved data as appropriate.
22+
fn try_write<'w>(&mut self, data: &'w [W]) -> Result<(), Self::Error>;
2723
}
2824

2925
/// Blocking write (iterator version)
3026
pub trait WriteIter<W> {
3127
/// Error type
3228
type Error;
3329

34-
/// Sends `left_words` and `right_words` to the slave.
35-
fn try_write<LW, RW>(&mut self, left_words: LW, right_words: RW) -> Result<(), Self::Error>
30+
/// Sends `data` to the slave.
31+
///
32+
/// The data should be filled with interleaved data as appropriate.
33+
fn try_write<I>(&mut self, data: I) -> Result<(), Self::Error>
3634
where
37-
LW: IntoIterator<Item = W>,
38-
RW: IntoIterator<Item = W>;
35+
I: IntoIterator<Item = W>;
3936
}

src/i2s.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ pub trait FullDuplex<Word> {
77
/// Error type
88
type Error;
99

10-
/// Reads the left word and right word available.
11-
///
12-
/// The order is in the result is `(left_word, right_word)`
13-
fn try_read(&mut self) -> nb::Result<(Word, Word), Self::Error>;
10+
/// Reads the word from the slave.
11+
fn try_read(&mut self) -> nb::Result<Word, Self::Error>;
1412

15-
/// Sends a left word and a right word to the slave.
16-
fn try_send(&mut self, left_word: Word, right_word: Word) -> nb::Result<(), Self::Error>;
13+
/// Sends a word to the slave.
14+
fn try_send(&mut self, word: Word) -> nb::Result<(), Self::Error>;
1715
}

0 commit comments

Comments
 (0)