use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, mutex::Mutex};
use esp_hal::{Async, i2c::master::I2c};
pub struct SharedI2cBus(Mutex<CriticalSectionRawMutex, I2c<'static, Async>>);
unsafe impl Send for SharedI2cBus {}
unsafe impl Sync for SharedI2cBus {}
impl SharedI2cBus {
pub const fn new(i2c: I2c<'static, Async>) -> Self {
Self(Mutex::new(i2c))
}
pub fn lock(
&self,
) -> impl core::future::Future<
Output = embassy_sync::mutex::MutexGuard<'_, CriticalSectionRawMutex, I2c<'static, Async>>,
> {
self.0.lock()
}
}