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:
- API documentation: https://docs.rs/dac5578/
- GitHub repository: https://github.com/chmanie/dac5578
- Crates.io: https://crates.io/crates/dac5578
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:
| ADDR0 | I²C Address |
|---|---|
| Low | 0x48 |
| High | 0x4A |
| Float | 0x4C |
This is represented using I2cAddress::SinglePin.
§Dual-pin addressing (QFN-24 / RGE package)
Devices with ADDR1 + ADDR0 support up to 8 I²C addresses:
| ADDR1 | ADDR0 | Address |
|---|---|---|
| Low | Low | 0x48 |
| Low | High | 0x49 |
| High | Low | 0x4A |
| High | High | 0x4B |
| Float | Low | 0x4C |
| Float | High | 0x4D |
| Low | Float | 0x4E |
| High | Float | 0x4F |
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
- DAC5578 datasheet: https://www.ti.com/product/DAC5578
- DAC6578 datasheet: https://www.ti.com/product/DAC6578
- DAC7578 datasheet: https://www.ti.com/product/DAC7578
Structs§
- DACx578
- Universal DACx578 driver.
Enums§
- AddrPin
- Logical state of an address selection pin.
- Channel
- DAC output channel selection.
- Command
Type - DAC command type.
- DacResolution
- Supported DAC resolutions.
- I2cAddress
- I2C address configuration for DACx578 devices.
- Reset
Mode - Software reset mode.