Rust TCA954xA and PCA954xA I2C Switch Driver
This is a platform agnostic Rust driver for the for TCA9548A and PCA9548A I2C
switches/multiplexers using the embedded-hal
traits.
This driver allows you to:
- Enable one or multiple I2C channels. See:
select_channels()
. - Communicate with the slaves connected to the enabled channels transparently.
- Split the device into slave (virtual) I2C devices (one per channel). See:
split()
.
The devices
The TCA954xA and PCA954x devices have two to eight bidirectional translating switches that can be controlled through the I2C bus. The SCL/SDA upstream pair fans out to eight downstream pairs, or channels. Any individual SCn/SDn channel or combination of channels can be selected, determined by the contents of the programmable control register. These downstream channels can be used to resolve I2C slave address conflicts. For example, if eight identical digital temperature sensors are needed in the application, one sensor can be connected at each channel: 0-N.
The TCA9545/3A and PCA9545/3A devices have an assosciated interrupt pin INT
for each channel
which can be polled to check which channels have pending interrupts.
(Tip: Can also be used as general inputs)
Datasheets
Usage
To use this driver, import this crate and an embedded_hal
implementation,
then instantiate the device.
Please find additional examples using hardware in this repository: driver-examples
use ;
use I2cdev;
use ;
/// Some driver defined in a different crate.
/// Defined here for completeness.
Support
For questions, issues, feature requests, and other changes, please file an issue in the github project.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
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.