13 releases

Uses old Rust 2015

0.6.0 Aug 9, 2023
0.5.1 Nov 22, 2021
0.5.0 Sep 22, 2021
0.4.4 Dec 2, 2019
0.2.0 Oct 7, 2015

#1940 in Embedded development

Download history 5125/week @ 2023-12-16 1639/week @ 2023-12-23 3003/week @ 2023-12-30 4404/week @ 2024-01-06 4849/week @ 2024-01-13 4986/week @ 2024-01-20 4950/week @ 2024-01-27 4274/week @ 2024-02-03 5186/week @ 2024-02-10 5094/week @ 2024-02-17 6042/week @ 2024-02-24 6235/week @ 2024-03-02 6286/week @ 2024-03-09 4950/week @ 2024-03-16 5666/week @ 2024-03-23 4388/week @ 2024-03-30

22,174 downloads per month
Used in fewer than 57 crates

MIT/Apache

47KB
820 lines

Rust I2cdev

Build Status Version License Minimum Supported Rust Version

Documentation

The Rust i2cdev crate seeks to provide full access to the Linux i2cdev driver interface in Rust without the need to wrap any C code or directly make low-level system calls. The documentation for the i2cdev interace can be found at https://www.kernel.org/doc/Documentation/i2c/dev-interface and in the lm-sensors projects.

Device driver developers should consider building on top of the embedded-hal traits rather than directly coupling to this library. An implementation of those generic traits for Linux can be found in linux-embedded-hal which, at present, uses this crate as the backend for I2C.

Example/API

The source includes an example of using the library to talk to a Wii Nunchuck (which has an i2c interface). Go View the Example.

The Documentation contains a quick overview of how to get started with an i2c device.

In addition to the Read/Write traits, the following methods are available via the I2CDevice trait.

Features

The following features are implemented and planned for the library:

  • Implement the Read trait
  • Implement the Write trait
  • Implement SMBus Methods
  • Add Tests/Example for SMBus Methods
  • Add sensor library for handy sensors (and examples)
  • Add higher-level APIs/Macros for simplifying access to devices with large register sets
  • Add Support for Non-SMBus ioctl methods
  • Add examples for non-smbus ioctl methods
  • Unit Testing

Cross Compiling

Most likely, the machine you are running on is not your development machine (although it could be). In those cases, you will need to cross-compile. See https://github.com/cross-rs/cross for pointers.

Minimum Supported Rust Version (MSRV)

This crate is guaranteed to compile on stable Rust 1.60.0 and up. It might compile with older versions but that may change in any new patch release.

License

Licensed under either of

at your option.

Contribution

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.

Code of Conduct

Contribution to this crate is organized under the terms of the Rust Code of Conduct, the maintainer of this crate, the Embedded Linux Team, promises to intervene to uphold that code of conduct.

Dependencies

~1.5MB
~37K SLoC