Skip to content

Commit d07a9a3

Browse files
committed
Add full duplex I2S trait
1 parent df0b3ec commit d07a9a3

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/i2s.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//! I2S - Inter-IC Sound Interface
2+
3+
use nb;
4+
5+
/// Full duplex
6+
pub trait FullDuplex<Word> {
7+
/// Error type
8+
type Error;
9+
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>;
14+
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>;
17+
}

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ pub mod blocking;
692692
pub mod capture;
693693
pub mod digital;
694694
pub mod fmt;
695+
pub mod i2s;
695696
pub mod prelude;
696697
pub mod pwm;
697698
pub mod qei;

src/prelude.rs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub use crate::digital::InputPin as _embedded_hal_digital_InputPin;
2727
pub use crate::digital::OutputPin as _embedded_hal_digital_OutputPin;
2828
pub use crate::digital::StatefulOutputPin as _embedded_hal_digital_StatefulOutputPin;
2929
pub use crate::digital::ToggleableOutputPin as _embedded_hal_digital_ToggleableOutputPin;
30+
pub use crate::i2s::FullDuplex as _embedded_hal_i2s_FullDuplex;
3031
pub use crate::pwm::Pwm as _embedded_hal_Pwm;
3132
pub use crate::pwm::PwmPin as _embedded_hal_PwmPin;
3233
pub use crate::qei::Qei as _embedded_hal_Qei;

0 commit comments

Comments
 (0)