DACx0501

crates.io crates.io Documentation

An embedded-hal DAC Driver

What is DACx0501

This crate is an embedded-hal driver library implementation for the Texas Instruments 80501, 70501 and 60501 DACs. It relies on the embedded-hal 1.0.0-alpha.8 traits being implemented in the board hal.

What is supported

The driver supports setting the output level, configuring the gain, internal reference, internal reference divider, output power state and reading the alarm status. There is also an option to set the output level without bounds checking.

What still needs to be implemented

The driver does not currently support reading the DEVID, reading or writing to the SYNC register or setting the TRIGGER register.

Example setting a sine table on one dac and setting a constant value on another

```rust let mut dacone = Dac80501::new(spione); let mut dactwo = Dac60501::new(spitwo);

// The dac one output will now be pulled to ground and have no output dacone.setpower_state(dacx0501::PowerState::Off).unwrap();

dactwo .setreferencedivider(dacx0501::RefDivState::Half) .unwrap(); dactwo.setoutputgain(dacx0501::GainState::TwoX).unwrap();

for val in sintable::SINETABLE.iter().cycle() { let mut daconeval = 4095; dactwo setoutputlevel(*val).unwrap(); dacone.setoutputlevel(daconeval).unwrap(); } ```

Issues and pull requests are welcome