working everything properly well
This commit is contained in:
23
mqtt_display/src/bus/mod.rs
Normal file
23
mqtt_display/src/bus/mod.rs
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user