| Crates.io | i2c-multiplexer |
| lib.rs | i2c-multiplexer |
| version | 0.2.0 |
| created_at | 2023-02-24 05:54:21.65692+00 |
| updated_at | 2024-12-01 19:53:02.603012+00 |
| description | An I2C Multiplexer library that supports the PCA9546 and TCA9546A chips |
| homepage | |
| repository | https://github.com/FloppyDisck/i2c-multiplexer |
| max_upload_size | |
| id | 793353 |
| size | 31,673 |
An I2C Multiplexer library that supports the PCA9546 and TCA9546A chips
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)?;
}
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);
}
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])?;
}
bus flaguse 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);
}