Crates.io | dacx0501 |
lib.rs | dacx0501 |
version | 0.2.2 |
source | src |
created_at | 2022-07-04 05:29:02.607209 |
updated_at | 2022-08-05 06:22:25.072723 |
description | An embedded-hal driver implementation for the x0501 family of DACs |
homepage | https://github.com/jrmoulton/dacx0501 |
repository | https://github.com/jrmoulton/dacx0501 |
max_upload_size | |
id | 618766 |
size | 16,262 |
An embedded-hal DAC Driver
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.
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.
The driver does not currently support reading the DEVID, reading or writing to the SYNC register or setting the TRIGGER register.
let mut dac_one = Dac80501::new(spi_one);
let mut dac_two = Dac60501::new(spi_two);
// The dac one output will now be pulled to ground and have no output
dac_one.set_power_state(dacx0501::PowerState::Off).unwrap();
dac_two
.set_reference_divider(dacx0501::RefDivState::Half)
.unwrap();
dac_two.set_output_gain(dacx0501::GainState::TwoX).unwrap();
for val in sin_table::SINE_TABLE.iter().cycle() {
let mut dac_one_val = 4095;
dac_two set_output_level(*val).unwrap();
dac_one.set_output_level(dac_one_val).unwrap();
}
Issues and pull requests are welcome