1 unstable release
0.1.0 | Mar 4, 2025 |
---|
#648 in Hardware support
122 downloads per month
31KB
703 lines
i2c-tiny-usb
A Rust library for communicating with USB-to-I2C adapters from userspace using libusb
via the
rusb
crate. The library is compatible with a variety of USB adapters supported by the
i2c-tiny-usb
Linux kernel driver.
The library implements traits from the i2c crate so it can be used
as a drop-in replacement for i2c-linux
on non-Linux platforms if no other implementation is
available.
Examples
You can find some example programs using the library in the examples/
directory. Most of them
require some kind of extra hardware to be present on the I2C bus which is described in the top level
comment of each example.
dump-eeprom.rs
: Dumps content from an I2C EEPROMi2cdetect.rs
: Scans for devices on the I2C bussht35.rs
: Reads temperature and humidity from an SHT35 sensor
Hardware Tests
Basic testcases can be simply run with cargo test
but other tests require a pysical setup with an
i2c-tiny-usb
device present and an EEPROM chip connected to the I2C bus. Check the top level
comment of hw_tests.rs
for more details.
Run the hardware tests with:
cargo test --features hw-tests
Dependencies
~1.6–2.4MB
~52K SLoC