GPIO Utils provides convenient access to GPIOs on a Linux system. The library builds on top of the sysfs interface to GPIOs exposed by the kernel and provides essential functionality required for most embedded systems.
To install the latest released version of gpio utils, ensure that you have installed Rust and then run:
sh
cargo install gpio-utils
GPIO Utils provides two main pieces that one may integrate into their final system:
gpio
command. This provides the core functionality for GPIO Utils and
is useful in its own right.gpio
init script/systemd service. This can be integrated into a target
system and will ensure that configured GPIOs get exported on system startup
(The GPIO command searches for /etc/gpio.toml
and /etc/gpio.d/*.toml
configs)The GPIO Utils library is built on top of the Rust sysfs-gpio library which may be used independent of this project.
GPIO Utils uses the TOML. There is some flexibility in the configuration, but the following examples shows the basics of how you can configure your GPIOs.
```toml #
#
#
num
: Required. The GPIO number.names
: Required. One or more names for the GPIOdirection
: Default: "in"
. Must be either "in" or "out"active_low
: Default: false
. If set to true, the polarity of the pin willexport
: Default: true
. If true, this GPIO will be automaticallygpio export-all
is run (e.g. by an init script).user
: User that should own the exported GPIOgroup
: Group that should own the exported GPIOmode
: Mode for exported directory[[pins]] num = 73 # required names = ["resetbutton"] # required (may have multiple) direction = "in" # default: in activelow = false # default: false (really means invert logic) export = true # default: true user = "root" # default: (OS Default - root) group = "gpio" # default: (OS Default - root) mode = 0o664 # default: (OS Default - 0o644)
[[pins]] num = 37 names = ["statusled", "A27", "greenled"] direction = "out"
```
Unlike several other existing solutions to this problem, this project is implemented in Rust (a modern systems programming language operating at the same level as C but with a type system providing greater productivity and reliability) and seeks to operate with a minimum of overhead.
Contributions are very welcome. See CONTRIBUTING.md for additional information on how to report bugs, submit changes, test changes, get support, etc.
Licensed under either of
at your option.
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.
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.