[][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 a short example 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.

This example is not tested
let mut dac = MCP4725::create(i2c);

A command can then be created and initialized with the device address and some data, and sent the DAC.

This example is not tested
let mut dac_cmd = Command::default().address(0b111).data(14);
dac.send(dac_cmd);

New data can be sent using the existing command by just changing the data and re-sending.

This example is not tested
dac_cmd = dac_cmd.data(348);
dac.send(dac_cmd);

More information

Structs

Command

A Command to send to the MCP4725, using default() a default instance of this Command can be created. 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.

FastCommand

A FastCommand to send to the MCP4725, using default() a default instance of the FastCommand can be created. Fast commands are special stripped down commands that can be used to send data to an MCP4725 in only 2 bytes instead of 3. It can only be used to set the DAC register, not to write the EEPROM that stores the default values. As with the normal Command the address(), power_mode() and data() builder methods can be used to set parameters. FastCommands can be sent using the send_fast method on the MCP4725 driver. A FastCommand can (and should) be re-used. data() can be used to re-set the data while keeping other parameters the same.

MCP4725

MCP4725 DAC driver. Wraps an I2C port and uses it to communicate to send commands to an MCP4725

Enums

CommandType

The type of the command to send for a Command

PowerMode

Two bit flags indicating the power mode for the MCP4725