tasks: motion: move the entire motion prediction engine into the second core, dedicating core 1 to hardware
This commit is contained in:
@@ -20,7 +20,7 @@ use esp_hal::{
|
||||
|
||||
use log::*;
|
||||
use renderbug_embassy::{graphics::display::DisplayControls, logging::RenderbugLogger, tasks::{oled::{OledUI, OledUiSurfacePool, oled_ui}, safetyui::{SafetyUi, safety_ui_main}, ui::UiSurfacePool}};
|
||||
use renderbug_embassy::events::BusGarage;
|
||||
use renderbug_embassy::events::{BusGarage, Measurement};
|
||||
use static_cell::StaticCell;
|
||||
use esp_backtrace as _;
|
||||
use esp_rtos::embassy::{Executor, InterruptExecutor};
|
||||
@@ -31,6 +31,8 @@ use renderbug_embassy::tasks::{
|
||||
ui::{Ui, ui_main}
|
||||
};
|
||||
|
||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||
use embassy_sync::channel::Channel;
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
@@ -68,7 +70,8 @@ async fn main(spawner: Spawner) {
|
||||
ui_wdt.set_timeout(esp_hal::timer::timg::MwdtStage::Stage0, esp_hal::time::Duration::from_secs(10));
|
||||
ui_wdt.enable();
|
||||
|
||||
let garage = BUS_GARAGE.init_with(|| { Default::default() });
|
||||
static MOTION_BUS: StaticCell<Channel<CriticalSectionRawMutex,Measurement,5> > = StaticCell::new();
|
||||
let motion_bus = MOTION_BUS.init_with(|| { Channel::new() });
|
||||
|
||||
info!("Setting up rendering pipeline");
|
||||
let mut surfaces = UiSurfacePool::default();
|
||||
@@ -107,9 +110,9 @@ async fn main(spawner: Spawner) {
|
||||
let i2c = I2c::new(peripherals.I2C1, Config::default()).unwrap().with_scl(scl).with_sda(sda).into_async();
|
||||
let i2c_bus = I2C_BUS.init(Mutex::new(i2c));
|
||||
#[cfg(feature="mpu")]
|
||||
spawner.must_spawn(renderbug_embassy::tasks::mpu::mpu_task(garage.motion.dyn_sender(), I2cDevice::new(i2c_bus)));
|
||||
spawner.must_spawn(renderbug_embassy::tasks::mpu::mpu_task(motion_bus.dyn_sender(), I2cDevice::new(i2c_bus)));
|
||||
#[cfg(feature="gps")]
|
||||
spawner.must_spawn(renderbug_embassy::tasks::gps::gps_task(garage.motion.dyn_sender(), I2cDevice::new(i2c_bus)));
|
||||
spawner.must_spawn(renderbug_embassy::tasks::gps::gps_task(motion_bus.dyn_sender(), I2cDevice::new(i2c_bus)));
|
||||
}
|
||||
|
||||
#[cfg(feature="oled")]
|
||||
@@ -141,9 +144,6 @@ async fn main(spawner: Spawner) {
|
||||
}
|
||||
}
|
||||
|
||||
info!("Launching motion engine");
|
||||
spawner.must_spawn(motion_task(garage.motion.dyn_receiver(), garage.notify.dyn_publisher().unwrap(), garage.predict.dyn_sender()));
|
||||
|
||||
#[cfg(feature="radio")]
|
||||
let wifi_init = {
|
||||
info!("Configuring wifi");
|
||||
@@ -156,6 +156,11 @@ async fn main(spawner: Spawner) {
|
||||
esp_rtos::start_second_core(peripherals.CPU_CTRL, swi.software_interrupt0, swi.software_interrupt1, unsafe { &mut *addr_of_mut!(CORE2_STACK) }, || {
|
||||
let exec = CORE2_EXEC.init_with(|| { Executor::new() });
|
||||
exec.run(|spawner| {
|
||||
let garage = BUS_GARAGE.init_with(|| { Default::default() });
|
||||
|
||||
info!("Launching motion engine");
|
||||
spawner.must_spawn(motion_task(motion_bus.dyn_receiver(), garage.predict.dyn_sender()));
|
||||
|
||||
info!("Launching Safety UI");
|
||||
spawner.must_spawn(safety_ui_main(garage.notify.dyn_subscriber().unwrap(), safety_ui));
|
||||
info!("Launching UI");
|
||||
|
||||
Reference in New Issue
Block a user