Home
Softono
linux-embedded-hal

linux-embedded-hal

Open source Apache-2.0 Rust
311
Stars
57
Forks
23
Issues
20
Watchers
4 months
Last Commit

About linux-embedded-hal

linux-embedded-hal is a Rust crate that implements the embedded-hal traits for Linux devices, enabling development and testing of embedded Rust applications directly on Linux systems. It provides support for GPIO access through either the modern character device interface (gpiocdev feature) or the legacy sysfs interface (gpiosysfs feature), I2C communication (i2c feature), and SPI communication (spi feature). The GPIO character device support wraps a LineHandle from gpio-cdev offering CdevPin, while SysfsPin remains available for older systems. Features can be selectively enabled through Cargo.toml configuration. The crate is maintained by the Embedded Linux team, supports a minimum Rust version of 1.84, and is dual-licensed under Apache 2.0 and MIT terms.

Platforms

Web Self-hosted Linux

Languages

Rust

Links

crates.io crates.io Documentation Minimum Supported Rust Version

linux-embedded-hal

Implementation of the embedded-hal traits for Linux devices

This project is developed and maintained by the Embedded Linux team.

Documentation

GPIO character device

Since Linux kernel v4.4 the use of sysfs GPIO was deprecated and replaced by the character device GPIO. See gpio-cdev documentation for details.

This crate includes feature flag gpio_cdev that exposes CdevPin as wrapper around LineHandle from gpio-cdev. To enable it update your Cargo.toml. Please note that in order to prevent LineHandle fd from closing you should assign to a variable, see cdev issue for more details.

linux-embedded-hal = { version = "0.4", features = ["gpio_cdev"] }

SysfsPin can be still used with feature flag gpio_sysfs.

With default-features = false you can enable the features gpio_cdev, gpio_sysfs, i2c, and spi as needed.

Minimum Supported Rust Version (MSRV)

This crate is guaranteed to compile on stable Rust 1.84.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 HAL team, promises to intervene to uphold that code of conduct.