Skip to content

Commit c3c042a

Browse files
committed
Add full duplex I2S trait
1 parent 726c78d commit c3c042a

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
@@ -691,6 +691,7 @@ pub mod blocking;
691691
pub mod capture;
692692
pub mod digital;
693693
pub mod fmt;
694+
pub mod i2s;
694695
pub mod prelude;
695696
pub mod pwm;
696697
pub mod qei;

src/prelude.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub use crate::capture::Capture as _embedded_hal_Capture;
2222
pub use crate::digital::InputPin as _embedded_hal_digital_InputPin;
2323
pub use crate::digital::OutputPin as _embedded_hal_digital_OutputPin;
2424
pub use crate::digital::ToggleableOutputPin as _embedded_hal_digital_ToggleableOutputPin;
25+
pub use crate::i2s::FullDuplex as _embedded_hal_i2s_FullDuplex;
2526
pub use crate::pwm::Pwm as _embedded_hal_Pwm;
2627
pub use crate::pwm::PwmPin as _embedded_hal_PwmPin;
2728
pub use crate::qei::Qei as _embedded_hal_Qei;

0 commit comments

Comments
 (0)