Skip to content

Commit 726c78d

Browse files
committed
Add blocking I2S traits
1 parent 181d44b commit 726c78d

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

src/blocking/i2s.rs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//! Blocking I2S API
2+
3+
/// Blocking read
4+
pub trait Read<W> {
5+
/// Error type
6+
type Error;
7+
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>;
14+
}
15+
16+
/// Blocking write
17+
pub trait Write<W> {
18+
/// Error type
19+
type Error;
20+
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>;
27+
}
28+
29+
/// Blocking write (iterator version)
30+
pub trait WriteIter<W> {
31+
/// Error type
32+
type Error;
33+
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>
36+
where
37+
LW: IntoIterator<Item = W>,
38+
RW: IntoIterator<Item = W>;
39+
}

src/blocking/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
pub mod delay;
88
pub mod i2c;
9+
pub mod i2s;
910
pub mod rng;
1011
pub mod serial;
1112
pub mod spi;

src/prelude.rs

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ pub use crate::blocking::i2c::{
1010
Read as _embedded_hal_blocking_i2c_Read, Write as _embedded_hal_blocking_i2c_Write,
1111
WriteRead as _embedded_hal_blocking_i2c_WriteRead,
1212
};
13+
pub use crate::blocking::i2s::{
14+
Read as _embedded_hal_blocking_i2s_Read, Write as _embedded_hal_blocking_i2s_Write,
15+
};
1316
pub use crate::blocking::rng::Read as _embedded_hal_blocking_rng_Read;
1417
pub use crate::blocking::serial::Write as _embedded_hal_blocking_serial_Write;
1518
pub use crate::blocking::spi::{

0 commit comments

Comments
 (0)