Module esp32s3_hal::cpu_control
source · Expand description
Control CPU Cores (ESP32-S3)
Overview
This module provides essential functionality for controlling
and managing the APP (second) CPU core on the ESP32-S3
chip. It is used to
start and stop program execution on the APP core.
Example
static mut APP_CORE_STACK: Stack<8192> = Stack::new();
let counter = Mutex::new(RefCell::new(0));
let mut cpu_control = CpuControl::new(system.cpu_control);
let cpu1_fnctn = || {
cpu1_task(&mut timer1, &counter);
};
let _guard = cpu_control
.start_app_core(unsafe { &mut APP_CORE_STACK }, cpu1_fnctn)
.unwrap();
loop {
block!(timer0.wait()).unwrap();
let count = critical_section::with(|cs| *counter.borrow_ref(cs));
println!("Hello World - Core 0! Counter is {}", count);
}
Where cpu1_task()
may be defined as:
fn cpu1_task(
timer: &mut Timer<Timer0<TIMG1>>,
counter: &critical_section::Mutex<RefCell<i32>>,
) -> ! {
println!("Hello World - Core 1!");
loop {
block!(timer.wait()).unwrap();
critical_section::with(|cs| {
let new_val = counter.borrow_ref_mut(cs).wrapping_add(1);
*counter.borrow_ref_mut(cs) = new_val;
});
}
}
Structs
- Will park the APP (second) core when dropped
- Control CPU Cores
- Data type for a properly aligned stack of N bytes