Skip to content

added dac #247

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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Added
- 10-bit addressing mode for I2C traits.
- Added `blocking::dac::SingleChannelDac` trait for digitial-to-analog-converters.
- `try_set_state` method for `OutputPin` using an input `PinState` value.

### Changed
Expand Down
10 changes: 10 additions & 0 deletions src/blocking/dac.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//! Digital-to-analog conversion traits

/// Trait representing a single-channel digital-to-analog converter (DAC).
pub trait SingleChannelDac<Word> {
/// Error type returned by DAC methods
type Error;

/// Output a constant signal, given a bit word.
fn try_set_value(&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
1 change: 1 addition & 0 deletions src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

pub use crate::adc::Channel as _embedded_hal_adc_Channel;
pub use crate::adc::OneShot as _embedded_hal_adc_OneShot;
pub use crate::blocking::dac::SingleChannelDac as _embedded_hal_blocking_dac_SingleChannelDac;
pub use crate::blocking::delay::DelayMs as _embedded_hal_blocking_delay_DelayMs;
pub use crate::blocking::delay::DelayUs as _embedded_hal_blocking_delay_DelayUs;
pub use crate::blocking::i2c::{
Expand Down