Crate shared_bus[−][src]
shared-bus
shared-bus is a crate to allow sharing bus peripherals safely between multiple devices.
To do so, shared-bus needs a mutex. Because each platform has its own
mutex type, shared-bus uses an abstraction: BusMutex. This type
needs to be implemented for your platforms mutex type to allow using this
crate.
- If
stdis available, activate thestdfeature to enable the implementation ofBusMutexforstd::sync::Mutex. - If you platform is based on
cortex-m, you can activate thecortexmfeature to enable the implementation ofBusMutexfor [cortex_m::interrupt::Mutex] - If neither is the case, take a look at the documentation of
BusMutexfor hints on how to implement it yourself.
Typical usage of this crate might look like this:
extern crate shared_bus; // Create your bus peripheral as usual: // let i2c = I2c::i2c1(dp.I2C1, (scl, sda), 90.khz(), clocks, &mut rcc.apb1); let manager = shared_bus::BusManager::<std::sync::Mutex<_>, _>::new(i2c); // You can now acquire bus handles: let mut handle = manager.acquire(); // handle implements `i2c::{Read, Write, WriteRead}`, depending on the // implementations of the underlying peripheral let mut mydevice = MyDevice::new(manager.acquire());
Re-exports
pub use mutex::BusMutex; |
pub use proxy::BusManager; |
pub use proxy::BusProxy; |
Modules
| mutex | |
| proxy |
Type Definitions
| CortexMBusManager |
Type alias for a bus manager using [ |
| StdBusManager |
Type alias for a bus manager using |