Crate ds3502

Crate ds3502 

Source
Expand description

§I2C Digitial Potentiometer DS3502 driver in Rust

Crates.io License Crates.io Version docs.rs Crates.io MSRV embedded-hal Version

Rust embedded driver for the DS3502 Digital Potentiometer by Analog Devices Inc./Maxim Integrated. Supports block and async APIs.

§Usage

use ds3502::{Ds3502, Wiper, ControlRegisterMode};
let mut digipot = Ds3502::blocking_init(i2c, Default::default())?;

// By default, driver initialized with Control Register in Mode 1 (Don't save to EEPROM)
assert_eq!(digipot.mode(), ControlRegisterMode::WiperOnly);

let wv = Wiper::try_from(88)?;
digipot.write_wiper(wv)?;

// Set wiper value and save to EEPROM
let wv = Wiper::try_from(123)?;
digipot.write_and_save_wiper(wv);

For a complete example that builds and flashes to a Raspberry Pi Pico using the embassy framework, checkout the pico-example directory.

§Installation

Add to your Cargo.toml:

ds3502 = "0.1"

§License

Licensed under either of

at your option.

§Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Modules§

error
Error for DS3502

Structs§

Config
Configuration of the DS3502 for set-up.
Ds3502
Represents a driver for the DS3502.
Wiper
Represents the position of the digital wiper.

Enums§

ControlRegisterMode
Control whether writes to the wiper register (WR) are also written to the initial value register (IVR) on the EEPROM.
Ds3502Error
Error during DS3502 operation
I2cAddr
Represents the I2C address for the DS3502.