linux-embedded-hal

Implementation of the Embedded Linux team

linux-embedded-hal

Implementation of the embedded-hal traits for Linux devices

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

Documentation

Note that current v0.4.0-alpha.X releases track the unstable ['embedded-hal'] v1.0.0-alpha.Y. For bugfixes or backports please open PRs against the v0.3.x branch.

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.

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.46.0 and up. It might compile with older versions but that may change in any new patch release.

License

Licensed under either of

  • Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or #404)

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.

Issues

Collection of the latest Issues

eldruin

eldruin

help wanted
0

We have merged #71 which did the heavy-lifting for updating this to embedded-hal 1.0.0-alpha.6. However, currently we are missing the extraction of information from the underlying nix/io errors in the embedded_hal::*::Error implementations so that they can be converted to a meaningful embedded_hal::*::ErrorKind. At the moment, converting all errors to Other would render all drivers unable to act on things like i2c::NoAcknowledge. For this one needs to dig a bit into the Linux kernel, and so on, though.

TODO:

  • #75
  • SPI
  • Serial
marcelbuesing

marcelbuesing

enhancement
8

I think it would be great to add implementations for the new embedded-hal CAN traits via socketcan. Would you be open for a PR for this?

Joe23232

Joe23232

0

Is this crate as simple as using rust_gpiozero crate? For example if I want to print out hello world and turn on and off the lights, is the code as simple to type as ``rust_gpiozero`:

image


Another question, is there another crate that is based on embedded-hal (just like linux-embedded-hal) that would work for the Arduino and the syntax for linux-embedded-hal would be similar for the Arduino version?

psiphi75

psiphi75

3

When I use the below configuration and cross compile to ARMv7 I get the following error message on the BeagleBone:

When I use v0.2.2 of linux-embedded-hal or earlier I do not get this error. If I remove extern crate linux_embedded_hal as hal; from the code I do not get the error.

Any ideas?

The code

src/main.rs

.cargo/config

Cargo.toml

To compile I use:

b-zee

b-zee

0

The embedded_hal::serial::Read trait defines its read method with a nb::Result. This suggests Read::read being nonblocking. But, linux_embedded_hal::Serial implements this trait by calling serial_unix::TTYPort::read which internally uses ppoll.

By default, the timeout passed to ppoll is 100ms, which results in read blocking for that amount of time. (Instead of immediately returning nb::Error::WouldBlock.)

dmitrijoseph

dmitrijoseph

6

Currently trying to build with gpio-cdev feature flag like

Gives the error

Version 0.3.0 of linux-embedded-hal was released in December 2019. gpio-cdev support was merged in afterward in March, 2020.

mvirkkunen

mvirkkunen

0

Currently the pins always implement both InputPin and OutputPin even thought the pin might not be in the correct mode, and presumably trying to use it in the wrong mode either doesn't work or causes an error.

This could be done neatly with type states and into_output style methods like many other HALs. This would also make them more convenient to use as the user then doesn't have to manually set the correct mode before constructing the pin.

vmasdani

vmasdani

3

Greetings. I was kind of having a hard time getting the grasp of trying to use the digital GPIO pin. I worked it out in the end anyway, but I think it would be cool to add basic examples as simple as LED blinking, LED breathing, etc. like this:

Versions

Find the latest versions by id

v0.4.0-alpha.2 - Feb 14, 2022

Added

  • Mappings for embedded-hal error kinds

Changed

  • Updated to embedded-hal 1.0.0-alpha.7 release (significant API changes)
  • Updated dependencies to force use of newer nix version
    • spidev to version 0.5.1
    • i2cdev to version 0.5.1
    • gpio-cdev to version 0.5.1
    • sysfs_gpio to version 0.6.1

v0.3.2 - Oct 25, 2021

Fixed

  • Readd Pin type export as an alias to SysfsPin for compatibility with the 0.3.0 version.

v0.3.1 - Sep 27, 2021

Added

  • Added implementation of transactional SPI and I2C traits.
  • CountDown implementation for SysTimer.
  • Default implementation for SysTimer.

Changed

  • Set default features to build both sysfs and cdev pin types.
  • Removed Pin export, use CdevPin or SysfsPin.
  • Updated embedded-hal to version 0.2.6.
  • Updated nb to version 0.1.3.
  • Updated gpio-cdev to version 0.5.
  • Updated i2cdev to version 0.5.
  • Updated spidev to version 0.5.
  • Updated sysfs-gpio to version 0.6.
  • Updated cast to version 0.3.

Fixed

  • Modified OutputPin behavior for active-low pins to match InputPin behavior.

Information - Updated May 01, 2022

Stars: 141
Forks: 22
Issues: 9

rust_embedded_starter

Boilerplate für Embedded Entwicklung mit Rust mit Flash und Debug automatik

rust_embedded_starter

Embedded rust HAL (hardware abstraction layer) for the STM32WL

This is a work in progress, it is unstable, incomplete, and (mostly) untested

Embedded rust HAL (hardware abstraction layer) for the STM32WL

Embedded Rust Template

This template is based on stm32f4xx-hal

Embedded Rust Template

A Rust embedded-hal HAL for all MCUs in the STM32 F7 family

This crate is largely inspired by the awesome work done here:

A Rust embedded-hal HAL for all MCUs in the STM32 F7 family

For use with the AnyLeaf pH and RTD sensors in Rust on embedded systems, and...

For use with the AnyLeaf pH and RTD sensors in Rust on embedded systems, and single-board computers

For use with the AnyLeaf pH and RTD sensors in Rust on embedded systems, and...

An embedded rust no_std driver for the AHT20 temperature and humidity sensor, forked from Anthony...

An embedded rust no_std driver for the AHT20 temperature and humidity sensor, forked from Anthony Romano's docs

An embedded rust no_std driver for the AHT20 temperature and humidity sensor, forked from Anthony...

embedded-rust-H2AL

Hardware abstraction layer - abstraction layer

embedded-rust-H2AL

cargo-pio = Cargo + PlatformIO

Build Rust embedded projects with PlatformIO!

cargo-pio = Cargo + PlatformIO
Facebook Instagram Twitter GitHub Dribbble
Privacy