working everything properly well

This commit is contained in:
Priec
2026-01-10 16:55:02 +01:00
parent fe4e48fbcc
commit 1cb6f3a3ee
13 changed files with 872 additions and 105 deletions

View File

@@ -0,0 +1,23 @@
// src/bus/mod.rs
use core::cell::RefCell;
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
use embassy_sync::mutex::Mutex;
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
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.
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.
pub fn new_device(bus: &'static SharedI2c) -> I2cDevice {
RefCellDevice::new(bus)
}