[−][src]Crate shared_bus_rtic
Introduction
This crate provides convenience definitions for working with
shared-bus
.
This repository aids in using shared-bus
, which is a tool to share a single peripheral bus
such as I2C or SPI, with multiple drivers.
Generally, shared-bus
creates a BusManager
which hands out BusProxy
structures to drivers.
Notice
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::BusProxy; struct SharedBusResources<T> { device: Device<BusProxy<T>>, other_device: OtherDevice<BusProxy<T>>, } // ... // Replace this type with the type of your bus (e.g. hal::i2c::I2c<...>). type BusType = (); struct Resources { shared_bus_resources: SharedBusResources<BusType>, } #[init] 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 }, } }
Re-exports
pub use shared_bus; |
Macros
new | Provides a method of generating a |
Type Definitions
BusProxy | A convenience type definition for a |