Cleanup
This commit is contained in:
parent
d8821cfd41
commit
96d6c7243b
@ -1,4 +1,4 @@
|
|||||||
//! Multicore support
|
//! MultiCore support
|
||||||
//!
|
//!
|
||||||
//! This module handles setup of the 2nd cpu core on the rp2040, which we refer to as core1.
|
//! This module handles setup of the 2nd cpu core on the rp2040, which we refer to as core1.
|
||||||
//! It provides functionality for setting up the stack, and starting core1.
|
//! It provides functionality for setting up the stack, and starting core1.
|
||||||
@ -62,9 +62,9 @@ fn core1_setup(stack_bottom: *mut usize) {
|
|||||||
install_stack_guard(stack_bottom);
|
install_stack_guard(stack_bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Multicore execution management.
|
/// MultiCore execution management.
|
||||||
pub struct Multicore {
|
pub struct MultiCore {
|
||||||
cores: (Core, Core),
|
pub cores: (Core, Core),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Data type for a properly aligned stack of N 32-bit (usize) words
|
/// Data type for a properly aligned stack of N 32-bit (usize) words
|
||||||
@ -81,8 +81,8 @@ impl<const SIZE: usize> Stack<SIZE> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Multicore {
|
impl MultiCore {
|
||||||
/// Create a new |Multicore| instance.
|
/// Create a new |MultiCore| instance.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
cores: (Core { id: CoreId::Core0 }, Core { id: CoreId::Core1 }),
|
cores: (Core { id: CoreId::Core0 }, Core { id: CoreId::Core1 }),
|
||||||
|
@ -6,7 +6,7 @@ use defmt::*;
|
|||||||
use embassy_executor::Executor;
|
use embassy_executor::Executor;
|
||||||
use embassy_executor::_export::StaticCell;
|
use embassy_executor::_export::StaticCell;
|
||||||
use embassy_rp::gpio::{Level, Output};
|
use embassy_rp::gpio::{Level, Output};
|
||||||
use embassy_rp::multicore::{Multicore, Stack};
|
use embassy_rp::multicore::{MultiCore, Stack};
|
||||||
use embassy_rp::peripherals::PIN_25;
|
use embassy_rp::peripherals::PIN_25;
|
||||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||||
use embassy_sync::channel::Channel;
|
use embassy_sync::channel::Channel;
|
||||||
@ -28,9 +28,8 @@ fn main() -> ! {
|
|||||||
let p = embassy_rp::init(Default::default());
|
let p = embassy_rp::init(Default::default());
|
||||||
let led = Output::new(p.PIN_25, Level::Low);
|
let led = Output::new(p.PIN_25, Level::Low);
|
||||||
|
|
||||||
let mut mc = Multicore::new();
|
let mut mc = MultiCore::new();
|
||||||
let (_, core1) = mc.cores();
|
let _ = mc.cores.1.spawn(unsafe { &mut CORE1_STACK.mem }, move || {
|
||||||
let _ = core1.spawn(unsafe { &mut CORE1_STACK.mem }, move || {
|
|
||||||
let executor1 = EXECUTOR1.init(Executor::new());
|
let executor1 = EXECUTOR1.init(Executor::new());
|
||||||
executor1.run(|spawner| unwrap!(spawner.spawn(core1_task(led))));
|
executor1.run(|spawner| unwrap!(spawner.spawn(core1_task(led))));
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user