#i2c #embedded-hal-i2c #embedded-hal #driver #hal #excamera

i2cdriver

Use Excamera I2CDriver and I2CMini devices from Rust, optionally via embeddded-hal traits

3 unstable releases

0.2.1 Jan 16, 2024
0.2.0 Dec 25, 2023
0.1.0 Nov 5, 2023

#1830 in Embedded development

31 downloads per month

0BSD license

20KB
382 lines

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

Dependencies

~2–2.8MB
~58K SLoC