Skip to content

Commit fcda9f2

Browse files
committed
Add full duplex I2S trait
1 parent 3d47e30 commit fcda9f2

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
@@ -412,6 +412,7 @@ pub mod blocking;
412412
pub mod capture;
413413
pub mod digital;
414414
pub mod fmt;
415+
pub mod i2s;
415416
pub mod prelude;
416417
pub mod pwm;
417418
pub mod qei;

src/prelude.rs

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

0 commit comments

Comments
 (0)