Skip to content

blocking DAC trait #240

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
14 changes: 14 additions & 0 deletions src/blocking/dac.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! Blocking DAC trait for single channel digital to analog conversion

/// A single DAC channel. Word is the type used to represent a single sample, this would typically
/// be u8, u16 or u32.
/// Note that not all bits will always be used. A 12 bit DAC for example will probably use u16 here
/// <DISCUSSION> should we prescribe to use the most significant bits here for compat between word
/// sizes?
pub trait DAC<WORD> {
/// Error type returned by DAC methods
type Error;

/// Set the output of the DAC
fn try_set_output(&mut self, value: WORD) -> Result<(), Self::Error>;
}
1 change: 1 addition & 0 deletions src/blocking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! traits. To save boilerplate when that's the case a `Default` marker trait may be provided.
//! Implementing that marker trait will opt in your type into a blanket implementation.

pub mod dac;
pub mod delay;
pub mod i2c;
pub mod rng;
Expand Down