Expand description

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.

The options for an entrypoint for core1 are

  • a function that never returns - eg fn core1_task() -> ! { loop{} };
  • a lambda (note: This requires a global allocator which requires a nightly compiler. Not recommended for beginners)

Usage

static mut CORE1_STACK: Stack<4096> = Stack::new();
fn core1_task() -> ! {
    loop{}
}
// fn main() -> ! {
    use rp2040_hal::{pac, gpio::Pins, sio::Sio, multicore::{Multicore, Stack}};
    let mut pac = pac::Peripherals::take().unwrap();
    let mut sio = Sio::new(pac.SIO);
    // Other init code above this line
    let mut mc = Multicore::new(&mut pac.PSM, &mut pac.PPB, &mut sio);
    let cores = mc.cores();
    let core1 = &mut cores[1];
    let _test = core1.spawn(core1_task, unsafe { &mut CORE1_STACK.mem });
    // The rest of your application below this line
//}

For inter-processor communications, see crate::sio::SioFifo and crate::sio::Spinlock0

For a detailed example, see examples/multicore_fifo_blink.rs

Structs

A handle for controlling a logical core.

Multicore execution management.

Data type for a properly aligned stack of N 32-bit (usize) words

Enums

Errors for multicore operations.