Expand description
MCP4725 Driver
Provides a unit tested driver to access the MCP4725 digital to analog converter ICs.
Focuses on:
- Providing reliable data.
- A safter interface to an i2c DAC.
- No infinite loops.
ⓘ
use dac_lib_mcp4725::MCP4725;
/*--SNIP--*/
fn main() -> ! {
/*--SNIP--*/
//Device Specific I2C pins(ch32v203kxt6)
let scl = p.PB6;
let sda = p.PB7;
let i2c_config = hal::Config::default();
let i2c = I2c::new_blocking(p.I2C1, scl, sda, Hertz::hz(100_000), Default::default());
let mut dac_0 = MCP4725::new(&mut i2c, DEFAULT_ADDR);
//Set the output to full VCC.
let ret = dac_0.write_dac(0x0FFF);
if !res.is_ok() {
//TOSS ERROR MSG
}
}Structs§
Enums§
- Command
- Command bitmasks, see datasheet page 18/19 for details
- FPower
Modes - FPowerModes are for when writing using Fast mode. It affects bits 4 and 5
- Power
Modes - PowerModes are for when writing using normal mode. It affects bits 1 and 2
Constants§
- DEFAULT_
ADDR - The default address, depends on factory programming and the configuration via the address pin.
- JUMPER_
ADDR - The address for jumpered units
- MAX_
ATTEMPTS