diff --git a/src/blocking/dac.rs b/src/blocking/dac.rs new file mode 100644 index 000000000..6e99cb947 --- /dev/null +++ b/src/blocking/dac.rs @@ -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 +/// should we prescribe to use the most significant bits here for compat between word +/// sizes? +pub trait DAC { + /// 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>; +} diff --git a/src/blocking/mod.rs b/src/blocking/mod.rs index 3a050f6d2..3255216c9 100644 --- a/src/blocking/mod.rs +++ b/src/blocking/mod.rs @@ -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;