#dac #microchip #driver #embedded-hal-driver #mcp4725

no-std mcp4725-rs

Platform agnostic Rust driver for the Microchip MCP3425 ADC

2 releases

0.1.1 Dec 26, 2018
0.1.0 Dec 26, 2018

#1013 in Embedded development

MIT/Apache

7KB
62 lines

Rust MC4725 Driver

This is a platform agnostic Rust driver for the MCP4725, based on the embedded-hal traits.

The Device

The Microchip MCP4725 is a low-power, high accuracy, single channel, 12-bit buffered voltage output Digital-to-Analog Convertor (DAC) with non-volatile memory (EEPROM).

Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/22039d.pdf

Status

  • Support generation of DAC output using Fast Mode Write Command
  • Support writing DAC Input register and EEPROM
  • Support RESET command
  • Test on Raspberry Pi

Examples

From examples/linux_raspi.rs:

extern crate linux_embedded_hal as linux_hal;
extern crate mcp4725_rs;

use linux_hal::{Delay, I2cdev};
use mcp4725_rs::MCP4725;

fn main() {
    println!("Hello, MCP4725!");
    println!();
    println!("Generating sawtooth wave signal on DAC output...");

    let dev = I2cdev::new("/dev/i2c-1").unwrap();
    let address = 0x60;

    let mut dac = MCP4725::new(dev, address, Delay).unwrap();
    
    loop {
        for dac_code in 0..4096 {
            dac.set_dac_value(dac_code);
        }
    }
}

Build the example on Raspberry PI

cargo build --examples

License

Licensed under either of

Dependencies

~71KB