Crates.io | mcp4728 |
lib.rs | mcp4728 |
version | 0.1.0 |
source | src |
created_at | 2022-10-22 05:31:45.377725 |
updated_at | 2022-10-22 05:31:45.377725 |
description | Platform agnostic rust driver for the MCP4728 4-channel, 12-bit I2C DAC. |
homepage | |
repository | https://github.com/davidstalnaker/mcp4728 |
max_upload_size | |
id | 694138 |
size | 59,674 |
This is a platform agnostic rust driver for the MCP4728 DAC using the embedded-hal traits.
This driver allows you to:
There is one feature that this driver does not support - reading and writing the I2C address of the device. Three bits of the driver can be set (from 0x60 to 0x67) but this is done by toggling another pin in precise timing with the I2C message, which is not possible to do using the embedded-hal traits.
The MCP4728 is a 4-channel, 12-bit digital-to-analog converter with nonvolatile memory (EEPROM) for its output settings. The device will load its previous setting from EEPROM on startup without receiving any commands. Each channel has separate voltage reference, gain, and power down settings. Channels can be written individually or together.
use linux_embedded_hal::I2cdev;
use mcp4728::{MCP4728};
let i2c = I2cdev::new("/dev/i2c-1").unwrap();
let mut dac = MCP4728::new(i2c, 0x60);
dac.fast_write(483, 279, 297, 590).unwrap();
Most commands write to the output register but do not necessarily update the analog output. There are several ways to do so:
OutputEnableMode
is Update
, the output will be updated after the last byte is received for
each channel (not all commands can set this bit)Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.