feasible second core sensor impl

This commit is contained in:
Andy Killorin 2025-01-18 13:27:48 -05:00
commit 088e0225ca
Signed by: ank
GPG key ID: 23F9463ECB67FE8C

View file

@ -12,15 +12,17 @@ use log::info;
use mpu6050::Mpu6050;
use nalgebra::Vector3;
use crate::CHANNEL;
pub struct SensorHardware {
bus_tof: I2c<'static, I2C1, Async>,
bus_gyro: I2c<'static, I2C0, Async>,
tof2enable: Output<'static>,
pub bus_tof: I2c<'static, I2C1, Async>,
pub bus_gyro: I2c<'static, I2C0, Async>,
pub tof2enable: Output<'static>,
}
pub fn sensor_manager(mut hardware: SensorHardware) -> ! {
let executor = Executor::new();
let executor: &'static mut Executor = unsafe{transmute(&executor)};
let mut executor = Executor::new();
let executor: &'static mut Executor = unsafe{transmute(&mut executor)};
executor.run(move |spawner| {
spawner.spawn(init_sensors(hardware)).unwrap();
});
@ -35,7 +37,8 @@ enum PollState {
Gyro,
}
struct SensorData {
#[derive(Clone, Debug)]
pub struct SensorData {
/// distance, mm
tof1: Option<u16>,
/// distance, mm
@ -95,8 +98,6 @@ async fn init_sensors(mut hardware: SensorHardware) {
}
POLL_STATE.store(PollState::None as u8, Ordering::SeqCst);
CHANNEL.send(data.clone()).await;
}
}