mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 06:42:32 +00:00
Add usage in to docs
This commit is contained in:
parent
eb1d2e1295
commit
aea28c8aa0
@ -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.
|
||||
//! It provides functionality for setting up the stack, and starting core1.
|
||||
@ -7,6 +7,28 @@
|
||||
//!
|
||||
//! Enable the `critical-section-impl` feature in embassy-rp when sharing data across cores using
|
||||
//! the `embassy-sync` primitives and `CriticalSectionRawMutex`.
|
||||
//!
|
||||
//! # Usage
|
||||
//! ```no_run
|
||||
//! static mut CORE1_STACK: Stack<4096> = Stack::new();
|
||||
//! static EXECUTOR0: StaticCell<Executor> = StaticCell::new();
|
||||
//! static EXECUTOR1: StaticCell<Executor> = StaticCell::new();
|
||||
//!
|
||||
//! #[cortex_m_rt::entry]
|
||||
//! fn main() -> ! {
|
||||
//! let p = embassy_rp::init(Default::default());
|
||||
//!
|
||||
//! let mut mc = MultiCore::new();
|
||||
//! let _ = mc.cores.1.spawn(unsafe { &mut CORE1_STACK.mem }, move || {
|
||||
//! let executor1 = EXECUTOR1.init(Executor::new());
|
||||
//! executor1.run(|spawner| unwrap!(spawner.spawn(core1_task())));
|
||||
//! });
|
||||
//!
|
||||
//! let executor0 = EXECUTOR0.init(Executor::new());
|
||||
//! executor0.run(|spawner| unwrap!(spawner.spawn(core0_task())));
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
|
||||
use core::mem::ManuallyDrop;
|
||||
use core::sync::atomic::{compiler_fence, Ordering};
|
||||
@ -28,14 +50,6 @@ pub enum Error {
|
||||
Unresponsive,
|
||||
}
|
||||
|
||||
/// Core ID
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
pub enum CoreId {
|
||||
Core0,
|
||||
Core1,
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn install_stack_guard(stack_bottom: *mut usize) {
|
||||
let core = unsafe { cortex_m::Peripherals::steal() };
|
||||
|
Loading…
Reference in New Issue
Block a user