#hardware-abstraction-layer #abstraction-layer #embedded-hal #spi-bus #i2c-bus #hal #devices

no-std embedded-hal-bus

Bus/Device connection mechanisms for embedded-hal, a Hardware Abstraction Layer (HAL) for embedded systems

9 releases

0.2.0 Apr 23, 2024
0.1.0 Jan 9, 2024
0.1.0-rc.3 Dec 14, 2023
0.1.0-rc.2 Nov 29, 2023
0.1.0-alpha.1 Sep 28, 2022

#1843 in Embedded development

Download history 3833/week @ 2024-08-03 4136/week @ 2024-08-10 5125/week @ 2024-08-17 10405/week @ 2024-08-24 11754/week @ 2024-08-31 9175/week @ 2024-09-07 9225/week @ 2024-09-14 9317/week @ 2024-09-21 5296/week @ 2024-09-28 4418/week @ 2024-10-05 5675/week @ 2024-10-12 5647/week @ 2024-10-19 4331/week @ 2024-10-26 4521/week @ 2024-11-02 4165/week @ 2024-11-09 3806/week @ 2024-11-16

17,540 downloads per month
Used in 36 crates (34 directly)

MIT/Apache

110KB
1.5K SLoC

crates.io crates.io Documentation Minimum Supported Rust Version

embedded-hal-bus

Bus sharing utilities for embedded-hal, a Hardware Abstraction Layer (HAL) for embedded systems.

embedded-hal provides traits for SPI and I2C buses and devices. This crate provides hardware-independent adapters for sharing a single bus between multiple devices, compatible with the traits.

This project is developed and maintained by the HAL team.

SPI

To support bus sharing, embedded-hal provides the SpiBus and SpiDevice traits. SpiBus represents an entire bus, while SpiDevice represents a device on that bus. For further details on these traits, please consult the embedded-hal documentation.

embedded-hal trait implementations for microcontrollers should implement the SpiBus trait. However, device drivers should use the SpiDevice traits, not the SpiBus traits if at all possible in order to allow for sharing of the bus they are connected to.

This crate provides mechanisms to connect a SpiBus and a SpiDevice.

I2C

In the case of I2C, the same I2c embedded-hal trait represents either an entire bus, or a device on a bus. This crate provides mechanisms to obtain multiple I2c instances out of a single I2c instance, sharing the bus.

Optional Cargo features

  • std: enable shared bus implementations using std::sync::Mutex, and implement std::error::Error for DeviceError.
  • async: enable embedded-hal-async support.
  • defmt-03: Derive defmt::Format from defmt 0.3 for enums and structs.

Minimum Supported Rust Version (MSRV)

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

See here for details on how the MSRV may be upgraded.

Enabling the async Cargo features requires Rust 1.75 or higher.

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.

Dependencies

~1MB
~22K SLoC