Skip to content
Snippets Groups Projects
Commit 66e94a27 authored by zdmx's avatar zdmx :crab:
Browse files

Add executor on second core

parent a3a5f103
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ use embassy_time::{Duration, Timer}; ...@@ -3,7 +3,7 @@ use embassy_time::{Duration, Timer};
use esp_println::println; use esp_println::println;
use hal::{ use hal::{
clock::{ClockControl, Clocks}, clock::{ClockControl, Clocks},
cpu_control::CpuControl, cpu_control::{CpuControl, AppCoreGuard},
embassy, embassy,
gdma::Gdma, gdma::Gdma,
i2c::I2C, i2c::I2C,
...@@ -11,7 +11,7 @@ use hal::{ ...@@ -11,7 +11,7 @@ use hal::{
peripherals::{Peripherals, I2C0}, peripherals::{Peripherals, I2C0},
prelude::*, prelude::*,
systimer::SystemTimer, systimer::SystemTimer,
timer::TimerGroup, Rng, Rtc, Spi, Uart, IO, uart::{self, TxRxPins}, gpio::{Gpio6, Unknown, Gpio4, Gpio7, Gpio5}, Rmt, timer::TimerGroup, Rng, Rtc, Spi, Uart, IO, uart::{self, TxRxPins}, Rmt,
}; };
use static_cell::StaticCell; use static_cell::StaticCell;
...@@ -30,7 +30,9 @@ const READ_BUF_SIZE: usize = 64; ...@@ -30,7 +30,9 @@ const READ_BUF_SIZE: usize = 64;
static RNG: StaticCell<Rng> = StaticCell::new(); static RNG: StaticCell<Rng> = StaticCell::new();
static EXECUTOR: StaticCell<Executor> = StaticCell::new(); static EXECUTOR: StaticCell<Executor> = StaticCell::new();
//static APP_CORE_EXECUTOR: StaticCell<Executor> = StaticCell::new(); static APP_CORE_EXECUTOR: StaticCell<Executor> = StaticCell::new();
static APP_CORE_GUARD: StaticCell<AppCoreGuard> = StaticCell::new();
static APP_CORE_FN: StaticCell<fn()> = StaticCell::new();
static CLOCKS: StaticCell<Clocks> = StaticCell::new(); static CLOCKS: StaticCell<Clocks> = StaticCell::new();
pub fn start_runtime() -> ! { pub fn start_runtime() -> ! {
...@@ -40,18 +42,22 @@ pub fn start_runtime() -> ! { ...@@ -40,18 +42,22 @@ pub fn start_runtime() -> ! {
}); });
} }
#[embassy_executor::task] fn start_app_core () {
async fn start_app_core(mut cpu_control: CpuControl) -> ! { let executor = APP_CORE_EXECUTOR.init(Executor::new());
let mut app_core_function = || {
/*let executor = APP_CORE_EXECUTOR.init(Executor::new());
executor.run(|spawner| { executor.run(|spawner| {
spawner.spawn(display_refresh()).ok(); spawner.spawn(init_second_core()).ok();
})*/ });
}; }
let _guard = cpu_control.start_app_core(&mut app_core_function).unwrap();
#[embassy_executor::task]
async fn init_second_core() {
loop { loop {
Timer::after(Duration::from_secs(100)).await; println!("second core running");
Timer::after(Duration::from_millis(1000)).await;
} }
} }
#[embassy_executor::task] #[embassy_executor::task]
...@@ -83,7 +89,9 @@ async fn init_runtime() { ...@@ -83,7 +89,9 @@ async fn init_runtime() {
embassy::init(&clocks, SystemTimer::new(peripherals.SYSTIMER)); embassy::init(&clocks, SystemTimer::new(peripherals.SYSTIMER));
let _cpu_control = CpuControl::new(system.cpu_control); let app_core_fn = APP_CORE_FN.init(start_app_core);
let mut cpu_control = CpuControl::new(system.cpu_control);
let _ = APP_CORE_GUARD.init(cpu_control.start_app_core(app_core_fn).unwrap());
// Async requires the GPIO interrupt to wake futures // Async requires the GPIO interrupt to wake futures
hal::interrupt::enable( hal::interrupt::enable(
...@@ -195,7 +203,7 @@ async fn init_runtime() { ...@@ -195,7 +203,7 @@ async fn init_runtime() {
// Init Flow3r components // Init Flow3r components
let mut badgelink = BadgeLink::new(i2c_busmanager.acquire_i2c()); let badgelink = BadgeLink::new(i2c_busmanager.acquire_i2c());
let imu = ImuHandler::new(i2c_busmanager.acquire_i2c()); let imu = ImuHandler::new(i2c_busmanager.acquire_i2c());
let inputs = InputHandler; let inputs = InputHandler;
let captouch = CaptouchHandler; let captouch = CaptouchHandler;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment