Crate dacx578

Crate dacx578 

Source
Expand description

Texas Instruments DAC5578 / DAC6578 / DAC7578 Driver for Rust Embedded HAL

This crate provides a unified driver for the TI DACx578 family:

  • DAC5578 (8-bit resolution)
  • DAC6578 (10-bit resolution)
  • DAC7578 (12-bit resolution)

The driver is built on top of the Rust embedded-hal and provides a resolution-aware, no_std compatible API to control any DACx578 device over I²C.


§Origin of this crate

This driver is based on the original open-source DAC5578 driver:

The original project provided a clean and minimal driver for the DAC5578. This crate extends that work by generalizing the implementation to support the full DACx578 family, introducing resolution-aware encoding and extended I²C addressing support while preserving the original command structure and API philosophy.


§Initialization

To initialize the driver, create an instance of DACx578 by providing:

  • an I²C interface implementing embedded_hal::i2c::I2c,
  • the I²C address configuration derived from the ADDR pins,
  • the device resolution (8, 10, or 12 bits depending on the DAC model).

§Example (single address pin)

use dacx578::{DACx578, I2cAddress, AddrPin, DacResolution};
use embedded_hal_mock::eh1::i2c::Mock;

let i2c = Mock::new(&[]);

let mut dac = DACx578::new(
    i2c,
    I2cAddress::SinglePin { addr0: AddrPin::Low },
    DacResolution::Bits12,
);

§Writing to a Channel

To set the DAC output value of channel A:

use dacx578::{DACx578, I2cAddress, AddrPin, DacResolution, Channel};
use embedded_hal_mock::eh1::i2c::{Mock, Transaction};

let i2c = Mock::new(&[
    Transaction::write(0x48, vec![0x30, 0xFF, 0x00]),
]);

let mut dac = DACx578::new(
    i2c,
    I2cAddress::SinglePin { addr0: AddrPin::Low },
    DacResolution::Bits12,
);

// Write a value and update the output
dac.write_and_update(Channel::A, 0x0FF0).unwrap();

The provided value is automatically clamped and aligned according to the selected resolution (8, 10, or 12 bits).


§I²C Addressing

The DACx578 family exists in multiple package variants with different I²C addressing schemes.

§Single-pin addressing (TSSOP-16 (PW) Package)

Some devices expose only ADDR0:

ADDR0I²C Address
Low0x48
High0x4A
Float0x4C

This is represented using I2cAddress::SinglePin.

§Dual-pin addressing (QFN-24 / RGE package)

Devices with ADDR1 + ADDR0 support up to 8 I²C addresses:

ADDR1ADDR0Address
LowLow0x48
LowHigh0x49
HighLow0x4A
HighHigh0x4B
FloatLow0x4C
FloatHigh0x4D
LowFloat0x4E
HighFloat0x4F

The combination (Float, Float) is not supported by the hardware and will panic if used.


§Device Support Status

  • The driver has been tested on real hardware with the DAC6578.
  • Support for DAC5578 and DAC7578 is based on:
    • the shared command set,
    • identical data register formats,
    • and the original DAC5578 driver.

The DAC7578 is functionally almost identical to the DAC6578, differing mainly in resolution.


§More information

Structs§

DACx578
Universal DACx578 driver.

Enums§

AddrPin
Logical state of an address selection pin.
Channel
DAC output channel selection.
CommandType
DAC command type.
DacResolution
Supported DAC resolutions.
I2cAddress
I2C address configuration for DACx578 devices.
ResetMode
Software reset mode.