{"id":20446286,"url":"https://github.com/rust-embedded/rust-sysfs-gpio","last_synced_at":"2025-05-14T10:09:00.696Z","repository":{"id":28613753,"uuid":"32132286","full_name":"rust-embedded/rust-sysfs-gpio","owner":"rust-embedded","description":"A Rust Interface to the Linux sysfs GPIO interface (https://www.kernel.org/doc/Documentation/gpio/sysfs.txt)","archived":false,"fork":false,"pushed_at":"2025-03-06T08:36:03.000Z","size":8145,"stargazers_count":388,"open_issues_count":9,"forks_count":44,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-04-07T17:01:39.833Z","etag":null,"topics":["embedded","gpio","linux","rust","sysfs","sysfs-gpio"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rust-embedded.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-03-13T05:50:08.000Z","updated_at":"2025-04-04T04:39:13.000Z","dependencies_parsed_at":"2024-06-18T19:50:38.462Z","dependency_job_id":"2cb2a265-04ea-41c4-8aff-0a7132b96ba2","html_url":"https://github.com/rust-embedded/rust-sysfs-gpio","commit_stats":{"total_commits":168,"total_committers":23,"mean_commits":7.304347826086956,"dds":"0.45833333333333337","last_synced_commit":"709bd24c19035f2253da516da1ce282a664f9f38"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-embedded%2Frust-sysfs-gpio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-embedded%2Frust-sysfs-gpio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-embedded%2Frust-sysfs-gpio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-embedded%2Frust-sysfs-gpio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rust-embedded","download_url":"https://codeload.github.com/rust-embedded/rust-sysfs-gpio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248950654,"owners_count":21188312,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["embedded","gpio","linux","rust","sysfs","sysfs-gpio"],"created_at":"2024-11-15T10:18:54.310Z","updated_at":"2025-04-14T19:46:03.896Z","avatar_url":"https://github.com/rust-embedded.png","language":"Rust","readme":"sysfs_gpio\n==========\n\n[![Build Status](https://github.com/rust-embedded/rust-sysfs-gpio/workflows/CI/badge.svg)](https://github.com/rust-embedded/rust-sysfs-gpio/actions)\n[![Version](https://img.shields.io/crates/v/sysfs-gpio.svg)](https://crates.io/crates/sysfs-gpio)\n![Minimum Supported Rust Version](https://img.shields.io/badge/rustc-1.70+-blue.svg)\n[![License](https://img.shields.io/crates/l/sysfs-gpio.svg)](https://github.com/rust-embedded/rust-sysfs-gpio/blob/master/README.md#license)\n\n- [API Documentation](https://docs.rs/sysfs_gpio)\n\nThe `sysfs_gpio` crate provides access to the Linux sysfs GPIO interface\n(https://www.kernel.org/doc/Documentation/gpio/sysfs.txt). It seeks to provide\nan API that is safe, convenient, and efficient and supports exporting,\nunexporting, reading, writing and waiting for interrupts on pins.\n\nMany devices such as the Raspberry Pi or Beaglebone Black provide\nuserspace access to a number of GPIO peripherals.  The standard kernel\nAPI for providing access to these GPIOs is via sysfs.\n\nYou might want to also check out the\n[gpio-utils Project](https://github.com/rust-embedded/gpio-utils) for a\nconvenient way to associate names with pins and export them as part of system\nboot.  That project uses this library.\n\n## Install/Use\n\nTo use `sysfs_gpio`, first add this to your `Cargo.toml`:\n\n```toml\n[dependencies]\nsysfs_gpio = \"0.6\"\n```\n\nThen, add this to your crate root:\n\n```rust\nuse sysfs_gpio;\n```\n\n## Example/API\n\nBlinking an LED:\n\n```rust\nuse sysfs_gpio::{Direction, Pin};\nuse std::thread::sleep;\nuse std::time::Duration;\n\nfn main() {\n    let my_led = Pin::new(127); // number depends on chip, etc.\n    my_led.with_exported(|| {\n        my_led.set_direction(Direction::Out).unwrap();\n        loop {\n            my_led.set_value(0).unwrap();\n            sleep(Duration::from_millis(200));\n            my_led.set_value(1).unwrap();\n            sleep(Duration::from_millis(200));\n        }\n    }).unwrap();\n}\n```\n\nMore Examples:\n\n- [Blink an LED](examples/blinky.rs)\n- [Poll a GPIO Input](examples/poll.rs)\n- [Receive interrupt on GPIO Change](examples/interrupt.rs)\n- [Poll several pins asynchronously with Tokio](examples/tokio.rs)\n- [gpio-utils Project (uses most features)](https://github.com/rust-embedded/gpio-utils)\n\n## Features\n\nThe following features are planned for the library:\n\n- [x] Support for exporting a GPIO\n- [x] Support for unexporting a GPIO\n- [x] Support for setting the direction of a GPIO (in/out)\n- [x] Support for reading the value of a GPIO input\n- [x] Support for writing the value of a GPIO output\n- [ ] Support for configuring whether a pin is active low/high\n- [x] Support for configuring interrupts on GPIO\n- [x] Support for polling on GPIO with configured interrupt\n- [x] Support for asynchronous polling using `mio` or `tokio` (requires\n      enabling the `mio-evented` or `async-tokio` crate features, respectively)\n\n## Minimum Supported Rust Version (MSRV)\n\nThis crate is guaranteed to compile on stable Rust 1.70.0 and up.  It *might*\ncompile with older versions but that may change in any new patch release.\n\n## Cross Compiling\n\nMost likely, the machine you are running on is not your development\nmachine (although it could be).  In those cases, you will need to\ncross-compile.  The [rust-cross guide](https://github.com/japaric/rust-cross)\nprovides excellent, detailed instructions for cross-compiling.\n\n## Running the Example\n\nCross-compiling can be done by specifying an appropriate target.  You\ncan then move that to your device by whatever means and run it.\n\n```\n$ cargo build --target=arm-unknown-linux-gnueabihf --example blinky\n$ scp target/arm-unknown-linux-gnueabihf/debug/examples/blinky ...\n```\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or\n  http://www.apache.org/licenses/LICENSE-2.0)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n\n## Code of Conduct\n\nContribution to this crate is organized under the terms of the [Rust Code of\nConduct][CoC], the maintainer of this crate, the [Embedded Linux Team][team], promises\nto intervene to uphold that code of conduct.\n\n[CoC]: CODE_OF_CONDUCT.md\n[team]: https://github.com/rust-embedded/wg#the-embedded-linux-team\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-embedded%2Frust-sysfs-gpio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frust-embedded%2Frust-sysfs-gpio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-embedded%2Frust-sysfs-gpio/lists"}