dual core setup

This commit is contained in:
Priec
2026-01-18 11:20:20 +01:00
parent 5c12591524
commit 273bf2f946
5 changed files with 62 additions and 27 deletions

View File

@@ -7,17 +7,16 @@ use embedded_hal_bus::i2c::RefCellDevice;
use esp_hal::i2c::master::I2c;
use esp_hal::Async;
/// The underlying I2C peripheral type for esp-hal 1.0.0-rc.0
/// The underlying I2C peripheral type
pub type I2cInner = I2c<'static, Async>;
/// We use RefCell to share the bus on a single core.
/// It's zero-overhead and safe because Embassy tasks don't preempt each other.
/// RefCell to share the bus on a single core.
pub type SharedI2c = RefCell<I2cInner>;
/// A handle to a shared I2C device.
pub type I2cDevice = RefCellDevice<'static, I2cInner>;
/// Create a new I2C device handle from the shared bus.
/// New I2C device handle from the shared bus.
pub fn new_device(bus: &'static SharedI2c) -> I2cDevice {
RefCellDevice::new(bus)
}