main: use a noop mutex with i2c
This commit is contained in:
@@ -100,9 +100,9 @@ async fn main(spawner: Spawner) {
|
||||
{
|
||||
use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice;
|
||||
use esp_hal::{i2c::master::{Config, I2c}, Async};
|
||||
use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, mutex::Mutex};
|
||||
use embassy_sync::{blocking_mutex::raw::NoopRawMutex, mutex::Mutex};
|
||||
|
||||
static I2C_BUS: StaticCell<Mutex<CriticalSectionRawMutex, I2c<'static, Async>>> = StaticCell::new();
|
||||
static I2C_BUS: StaticCell<Mutex<NoopRawMutex, I2c<'static, Async>>> = StaticCell::new();
|
||||
|
||||
info!("Launching i2c sensor tasks");
|
||||
let sda = peripherals.GPIO4;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use alloc::string::String;
|
||||
use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice;
|
||||
use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, channel::DynamicSender};
|
||||
use embassy_sync::{blocking_mutex::raw::NoopRawMutex, channel::DynamicSender};
|
||||
use embassy_time::Timer;
|
||||
use embedded_hal_async::i2c::I2c as _;
|
||||
use esp_hal::{i2c::master::I2c, Async};
|
||||
@@ -12,7 +12,7 @@ use crate::{backoff::Backoff, events::{Measurement, SensorSource, SensorState}};
|
||||
|
||||
// FIXME: We need a way to put the GPS to sleep when the system goes to sleep
|
||||
#[embassy_executor::task]
|
||||
pub async fn gps_task(events: DynamicSender<'static, Measurement>, mut i2c_bus: I2cDevice<'static, CriticalSectionRawMutex, I2c<'static, Async>>) {
|
||||
pub async fn gps_task(events: DynamicSender<'static, Measurement>, mut i2c_bus: I2cDevice<'static, NoopRawMutex, I2c<'static, Async>>) {
|
||||
Backoff::from_secs(5).forever().attempt::<_, (), ()>(async || {
|
||||
events.send(Measurement::SensorHardwareStatus(SensorSource::GPS, SensorState::Offline)).await;
|
||||
Backoff::from_secs(5).forever().attempt(async || {
|
||||
@@ -41,7 +41,6 @@ pub async fn gps_task(events: DynamicSender<'static, Measurement>, mut i2c_bus:
|
||||
let mut parsing = false;
|
||||
let mut has_lock = false;
|
||||
events.send(Measurement::SensorHardwareStatus(SensorSource::GPS, SensorState::Online)).await;
|
||||
events.send(Measurement::SensorHardwareStatus(SensorSource::Location, SensorState::AcquiringFix)).await;
|
||||
info!("GPS is ready!");
|
||||
loop {
|
||||
let mut buf = [0; 1];
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use core::cell::RefCell;
|
||||
|
||||
use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice;
|
||||
use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, channel::DynamicSender};
|
||||
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
|
||||
use embassy_sync::channel::DynamicSender;
|
||||
use embassy_time::{Delay, Timer, Instant};
|
||||
use esp_hal::{i2c::master::I2c, Async};
|
||||
use log::*;
|
||||
@@ -33,7 +34,7 @@ fn gyro_raw_to_rads(raw: i16) -> f32 {
|
||||
static mut MPU_WAS_CALIBRATED: u8 = 0;
|
||||
|
||||
#[embassy_executor::task]
|
||||
pub async fn mpu_task(events: DynamicSender<'static, Measurement>, bus: I2cDevice<'static, CriticalSectionRawMutex, I2c<'static, Async>>) {
|
||||
pub async fn mpu_task(events: DynamicSender<'static, Measurement>, bus: I2cDevice<'static, NoopRawMutex, I2c<'static, Async>>) {
|
||||
let backoff = Backoff::from_millis(5);
|
||||
let busref = RefCell::new(Some(bus));
|
||||
|
||||
@@ -111,7 +112,7 @@ pub async fn mpu_task(events: DynamicSender<'static, Measurement>, bus: I2cDevic
|
||||
}).await.ok();
|
||||
}
|
||||
|
||||
async fn mpu_init(sensor: &mut Mpu6050<I2cDevice<'static, CriticalSectionRawMutex, I2c<'static, Async>>>) -> Result<(), Error<I2cDevice<'static, CriticalSectionRawMutex, I2c<'static, Async>>>> {
|
||||
async fn mpu_init(sensor: &mut Mpu6050<I2cDevice<'static, NoopRawMutex, I2c<'static, Async>>>) -> Result<(), Error<I2cDevice<'static, NoopRawMutex, I2c<'static, Async>>>> {
|
||||
if cfg!(feature="wokwi") {
|
||||
warn!("Initializing simulated MPU");
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user