Skip to content

[Proposal] I2S traits - take 2 #385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) ***
Expand Down
35 changes: 35 additions & 0 deletions src/i2s.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//! I2S API

/// Blocking I2S traits
pub mod blocking {

/// Blocking I2S trait
pub trait I2s<W> {
/// 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<LW, RW>(
&mut self,
left_words: LW,
right_words: RW,
) -> Result<(), Self::Error>
where
LW: IntoIterator<Item = W>,
RW: IntoIterator<Item = W>;
}
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down