i2cdriver

Crates.ioi2cdriver
lib.rsi2cdriver
version0.2.1
sourcesrc
created_at2023-11-05 07:15:19.797189
updated_at2024-01-16 20:01:54.941628
descriptionUse Excamera I2CDriver and I2CMini devices from Rust, optionally via embeddded-hal traits.
homepage
repositoryhttps://gitlab.com/tschundler/i2cdriver
max_upload_size
id1025792
size34,657
(tschundler)

documentation

README

Excamera I2CDriver crates.io page docs.rs

This is a support library / driver for using the Excamera I2CDriver or I2CMini devices within Rust/Crablang. It is intended to facilitate the development of embedded-hal-compatible drivers for I2C devices.

This project is not associated with Excamera / James Bowman.

See CONTRIBUTING if you are interested in submitting patches.

Basic Usage

The I2CDriver can be initialized with the name of a serial port.

let mut i2c = I2CDriver::open("/dev/ttyUSB0").unwrap();

let mut d = my_i2c_driver::Driver::new(i2c).unwrap();
d.do_the_thing()

Depending on your OS, the port name may appear differently.

  • Linux: /dev/ttyUSB0 or /dev/ttyS0; see the output of sudo dmesg for the exact device name.
  • MacOS: /dev/ttyACM0; see the output of sudo dmesg for the exact device name.
  • Windows: COM5; see Device Manager for the exact name.

HAL Support

This implements both 0.2.x and 1.x embedded-hal traits. They are both enabled by default, but may be controlled by feature flags, eh0 and eh1.

There is embedded-hal-async support using the async feature. It is not enabled by default as it requires nightly compiler to build.

Testing Using Examples

One convenient way to manually test changes against real hardware is using cargo watch combined with example files.

$ git clone git@gitlab.com:tschundler/i2cdriver.git
cd i2cdriver
cargo watch -- cargo run --example scanbus -- -d /dev/ttyUSB0
Commit count: 27

cargo fmt