rust-embedded / embedded-hal

A Hardware Abstraction Layer (HAL) for embedded systems
Apache License 2.0
1.95k stars 197 forks source link

e-h-bus: Adding `AtomicDevice` for I2C and SPI bus sharing in multiple interrupt contexts #579

Closed ryan-summers closed 5 months ago

ryan-summers commented 6 months ago

This PR adds a primitive for sharing an I2C or SPI bus across multiple threads where the synchronization scheme is managed externally (i.e. RTIC sync resources).

The user is returned an Error::Busy if they ever attempt to pre-empt usage of the bus.

CC @Dirbaio as we were talking about this in the Matrix channel yesterday.

Dirbaio commented 5 months ago

you didn't check "allow maintainers to push", i've pushed some fixes to https://github.com/rust-embedded/embedded-hal/pull/593

ryan-summers commented 5 months ago

Thanks for taking this over and pushing it through! :)

I didn't see the maintainer allow button, my bad.