All Projects → rust-embedded → Rust Sysfs Gpio

rust-embedded / Rust Sysfs Gpio

Licence: other
A Rust Interface to the Linux sysfs GPIO interface (https://www.kernel.org/doc/Documentation/gpio/sysfs.txt)

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Rust Sysfs Gpio

Drivers
TinyGo drivers for sensors and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.
Stars: ✭ 250 (-21.87%)
Mutual labels:  gpio, embedded
Homegenie
HomeGenie, the open source, programmable, home automation server for smart connected devices and applications
Stars: ✭ 313 (-2.19%)
Mutual labels:  gpio, embedded
w1-gpio-cl
Command line configured kernel mode 1-wire bus master driver. w1-gpio standard Linux module enhancement/substitution.
Stars: ✭ 17 (-94.69%)
Mutual labels:  embedded, gpio
Gpio Utils
Userspace Utilities for managing GPIOs in Linux
Stars: ✭ 82 (-74.37%)
Mutual labels:  gpio, embedded
gpio-cdev
Rust interface to the Linux GPIO Character Device API (/dev/gpiochip...)
Stars: ✭ 153 (-52.19%)
Mutual labels:  embedded, gpio
Jimtcl
Official repository of Jim Tcl, an open-source, small footprint implementation of Tcl
Stars: ✭ 272 (-15%)
Mutual labels:  embedded
Blynk Library
Blynk library for embedded hardware. Works with Arduino, ESP8266, Raspberry Pi, Intel Edison/Galileo, LinkIt ONE, Particle Core/Photon, Energia, ARM mbed, etc.
Stars: ✭ 3,305 (+932.81%)
Mutual labels:  embedded
Rusty Clock
An alarm clock with environment stats in pure bare metal embedded rust
Stars: ✭ 269 (-15.94%)
Mutual labels:  embedded
Drone Core
The core crate for Drone, an Embedded Operating System.
Stars: ✭ 263 (-17.81%)
Mutual labels:  embedded
Trezor Mcu
🔒 Don't use this repo, use the new monorepo instead:
Stars: ✭ 315 (-1.56%)
Mutual labels:  embedded
Libuhttpd
A very flexible, lightweight and fully asynchronous HTTP server library based on libev and http-parser for Embedded Linux.
Stars: ✭ 302 (-5.62%)
Mutual labels:  embedded
Nanoprintf
A tiny embeddable printf replacement written in C99.
Stars: ✭ 287 (-10.31%)
Mutual labels:  embedded
Stlink
Open source STM32 MCU programming toolset
Stars: ✭ 3,158 (+886.88%)
Mutual labels:  embedded
Fastmot
High-performance multiple object tracking based on YOLO, Deep SORT, and optical flow
Stars: ✭ 284 (-11.25%)
Mutual labels:  embedded
Lwext4
ext2/ext3/ext4 filesystem library for microcontrollers
Stars: ✭ 270 (-15.62%)
Mutual labels:  embedded
Octoprint Enclosure
OctoPrint Enclosure Plugin
Stars: ✭ 267 (-16.56%)
Mutual labels:  gpio
Selectmenu
Simple, easily and diversity menu solution
Stars: ✭ 284 (-11.25%)
Mutual labels:  embedded
Jetty.project
Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more
Stars: ✭ 3,260 (+918.75%)
Mutual labels:  embedded
Polodb
PoloDB is an embedded JSON-based database.
Stars: ✭ 282 (-11.87%)
Mutual labels:  embedded
Simba
Simba Embedded Programming Platform.
Stars: ✭ 281 (-12.19%)
Mutual labels:  embedded

sysfs_gpio

Build Status Version License

The sysfs_gpio crate provides access to the Linux sysfs GPIO interface (https://www.kernel.org/doc/Documentation/gpio/sysfs.txt). It seeks to provide an API that is safe, convenient, and efficient and supports exporting, unexporting, reading, writing and waiting for interrupts on pins.

Many devices such as the Raspberry Pi or Beaglebone Black provide userspace access to a number of GPIO peripherals. The standard kernel API for providing access to these GPIOs is via sysfs.

You might want to also check out the gpio-utils Project for a convenient way to associate names with pins and export them as part of system boot. That project uses this library.

Install/Use

To use sysfs_gpio, first add this to your Cargo.toml:

[dependencies]
sysfs_gpio = "0.5"

Then, add this to your crate root:

extern crate sysfs_gpio;

Example/API

Blinking an LED:

extern crate sysfs_gpio;

use sysfs_gpio::{Direction, Pin};
use std::thread::sleep;
use std::time::Duration;

fn main() {
    let my_led = Pin::new(127); // number depends on chip, etc.
    my_led.with_exported(|| {
        my_led.set_direction(Direction::Out).unwrap();
        loop {
            my_led.set_value(0).unwrap();
            sleep(Duration::from_millis(200));
            my_led.set_value(1).unwrap();
            sleep(Duration::from_millis(200));
        }
    }).unwrap();
}

More Examples:

Features

The following features are planned for the library:

  • [x] Support for exporting a GPIO
  • [x] Support for unexporting a GPIO
  • [x] Support for setting the direction of a GPIO (in/out)
  • [x] Support for reading the value of a GPIO input
  • [x] Support for writing the value of a GPIO output
  • [ ] Support for configuring whether a pin is active low/high
  • [x] Support for configuring interrupts on GPIO
  • [x] Support for polling on GPIO with configured interrupt
  • [x] Support for asynchronous polling using mio or tokio (requires enabling the mio-evented or use_tokio crate features, respectively)

Minimum Supported Rust Version (MSRV)

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

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. The rust-cross guide provides excellent, detailed instructions for cross-compiling.

Running the Example

Cross-compiling can be done by specifying an appropriate target. You can then move that to your device by whatever means and run it.

$ cargo build --target=arm-unknown-linux-gnueabihf --example blinky
$ scp target/arm-unknown-linux-gnueabihf/debug/examples/blinky ...

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].