diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ca79a8ec..8f720d894 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Added +- I2S traits + ## [v1.0.0-alpha.8] - 2022-04-15 *** This is (also) an alpha release with breaking changes (sorry) *** diff --git a/src/i2s.rs b/src/i2s.rs new file mode 100644 index 000000000..3932d202c --- /dev/null +++ b/src/i2s.rs @@ -0,0 +1,35 @@ +//! I2S API + +/// Blocking I2S traits +pub mod blocking { + + /// Blocking I2S trait + pub trait I2s { + /// Error type + type Error: core::fmt::Debug; + + /// Reads enough bytes to fill `left_words` and `right_words`. + fn read<'w>( + &mut self, + left_words: &'w mut [W], + right_words: &'w mut [W], + ) -> Result<(), Self::Error>; + + /// Sends `left_words` and `right_words`. + fn write<'w>( + &mut self, + left_words: &'w [W], + right_words: &'w [W], + ) -> Result<(), Self::Error>; + + /// Sends `left_words` and `right_words`. + fn write_iter( + &mut self, + left_words: LW, + right_words: RW, + ) -> Result<(), Self::Error> + where + LW: IntoIterator, + RW: IntoIterator; + } +} diff --git a/src/lib.rs b/src/lib.rs index 30099bf0b..4b9162659 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -359,6 +359,7 @@ pub mod can; pub mod delay; pub mod digital; pub mod i2c; +pub mod i2s; pub mod serial; pub mod spi;