i2c-multiplexer

Crates.ioi2c-multiplexer
lib.rsi2c-multiplexer
version
sourcesrc
created_at2023-02-24 05:54:21.65692
updated_at2024-12-01 19:53:02.603012
descriptionAn I2C Multiplexer library that supports the PCA9546 and TCA9546A chips
homepage
repositoryhttps://github.com/FloppyDisck/i2c-multiplexer
max_upload_size
id793353
Cargo.toml error:TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Guy S Garcia (FloppyDisck)

documentation

README

I2C-Multiplexer   Build Status Latest Version

An I2C Multiplexer library that supports the PCA9546 and TCA9546A chips


Usage

The sensor is initialized

use i2c_multiplexer::prelude::*;

fn main() -> Result<()> {
    // Disable all ports and only enable port 0
    Multiplexer::new(i2c).with_ports_disabled()?.set_port(0, true)?;
}

Changing Address

use i2c_multiplexer::prelude::*;

fn main() -> Result<()> {
    // Manually set the address
    Multiplexer::new(i2c).with_address(0x72);
    
    // Or set it according to the selected hardware pins
    // This uses A0 which means the address is 0x71
    Multiplexer::new(i2c).with_address_pins(true, false, false);
}

Setting multiple ports

use i2c_multiplexer::prelude::*;

fn main() -> Result<()> {
    // Manually set the ports 0,2 to enabled and 1,3 to disabled
    Multiplexer::new(i2c).with_ports([true, false, true, false])?;
}

Initializing as bus using the bus flag

use i2c_multiplexer::prelude::*;

fn main() -> Result<()> {
    let i2c = SomeI2CInit;
    
    // Initialize multiplexer
    let multiplexer = MultiplexerBus::new();

    // Setup the i2c port
    let port = 0;
    let mut multiplexed_i2c = multiplexer.new_port(i2c, port);
}
Commit count: 17

cargo fmt