Type Definition shared_bus::BusManagerAtomicCheck [−][src]
type BusManagerAtomicCheck<T> = BusManager<AtomicCheckMutex<T>>;
A bus manager for safely sharing the bus when using concurrency frameworks (such as RTIC).
This manager relies on RTIC or some other concurrency framework to manage resource contention automatically. As a redundancy, this manager uses an atomic boolean to check whether or not a resource is currently in use. This is purely used as a fail-safe against misuse.
Warning
If devices on the same shared bus are not treated as a singular resource, it is possible that pre-emption may occur. In this case, the manger will panic to prevent the race condition.
Usage
In order to use this manager with a concurrency framework such as RTIC, all devices on the shared bus must be stored in the same logic resource. The concurrency framework will require a resource lock if pre-emption is possible.
In order to use this with RTIC (as an example), all devices on the shared bus must be stored in a singular resource:
struct Device<T> { _bus: T }; struct OtherDevice<T> { _bus: T }; type I2C = (); type Proxy = shared_bus::I2cProxy<'static, shared_bus::AtomicCheckMutex<I2C>>; struct SharedBusResources { device: Device<Proxy>, other_device: OtherDevice<Proxy>, } struct Resources { shared_bus_resources: SharedBusResources, }
Usually, for sharing / between tasks, a manager with 'static
lifetime is needed which can be
created using the shared_bus::new_atomic_check!()
macro.
This type is only available with the cortex-m
feature.