[][src]Crate mcp4725

Microchip MCP4725 DAC Driver for Rust Embedded HAL This is a driver crate for embedded Rust. It's built on top of the Rust embedded HAL It supports sending commands to a MCP4725 DAC over I2C. To get started you can look at the examples on how to use this driver on an inexpensive blue pill STM32F103 board.

The driver can be initialized by calling create and passing it an I2C interface. The three least significant bits of the device address (A2, A1 and A0) also need to be specified. A2 and A1 are set in the device. A0 can be set by pulling the corresponding connection on the device high or low.

let mut dac = MCP4725::new(i2c, 0b010);

To set the dac output and powermode the dac register can be set;

dac.set_dac(PowerDown::Normal, 0x0fff);

The MCP4725 has a built in eeprom that is used to initialize the dac register on power up. The values in the eeprom can be set with the set_dac_and_eeprom method;

dac.set_dac_and_eeprom(PowerDown::Resistor100kOhm, 0x0fff);

More information

Structs

Command

A Command to send to the MCP4725. Using the address(), command_type(), power_mode() and data() builder methods the parameters for this command can be set. Commands can be sent using the send method on the MCP4725 driver. A command can (and should) be re-used. data() can be used to re-set the data while keeping other parameters the same.

DacStatus

The status of the MCP4725 as read by the read command. Contains the DAC register values and the values stored in EEPROM

MCP4725

MCP4725 DAC driver. Wraps an I2C port to send commands to an MCP4725

Enums

CommandType

The type of the command to send for a Command

PowerDown

Two bit flags indicating the power down mode for the MCP4725