[][src]Crate shared_bus_rtic


This crate provides a means of sharing an I2C or SPI bus between multiple drivers.


Note that all of the drivers that use the same underlying bus must be stored within a single resource (e.g. as one larger struct) within the RTIC resources. This ensures that RTIC will prevent one driver from interrupting another while they are using the same underlying bus.

This crate also provides convenience types for working with shared-bus RTIC resources.

Usage Example

use shared_bus_rtic::SharedBus;

struct SharedBusResources<T> {
    device: Device<SharedBus<T>>,
    other_device: OtherDevice<SharedBus<T>>,

// ...

// Replace this type with the type of your bus (e.g. hal::i2c::I2c<...>).
type BusType = ();

struct Resources {
    shared_bus_resources: SharedBusResources<BusType>,

fn init(c: init::Context) -> init::LateResources {
    // TODO: Define your custom bus here.
    let bus: BusType = ();

    // Construct the bus manager.
    let manager = shared_bus_rtic::new!(bus, BusType);

    // Construct all of your devices that use the shared bus.
    let device = Device::new(manager.acquire());
    let other_device = OtherDevice::new(manager.acquire());

    init::LateResources {
        shared_bus_resources: SharedBusResources { device, other_device },



Provides a method of generating a shared bus.



Type Definitions


A convenience type to use for declaring the underlying bus type.