Skip to main content

Module ipc

Module ipc 

Source
Available on crate feature unstable only.
Expand description

§Inter-Processor Call (IPC)

§Overview

Ipc posts a function to a CPU, then raises that CPU’s IPC interrupt. The interrupt handler runs the posted function at Priority::min.

The same interrupt also carries a context switch. A CPU asks the other CPU to switch tasks through this interrupt. The context-switch handler of the RTOS that owns scheduling runs after the posted function, and chooses the context that the interrupt returns to. A posted function and a context switch do not wait for each other. A posted function alone does not make a CPU switch tasks.

§Configuration

Each CPU takes the call in its machine software interrupt. The path needs no peripheral interrupt. crate::init installs the handler on the PRO CPU. The start of the APP CPU installs the handler on that CPU.

§Usage

Ipc::new creates a handle from the IPC peripheral singleton, and Ipc::call_function posts a function to a CPU.

The posted function runs in an interrupt handler. The handler saves the registers that the calling convention lets the callee clobber, except the floating-point registers. The posted function must not use those registers, and must be callable with the cache disabled.

§Examples

§Run a Function on the PRO CPU

use esp_hal::{interrupt::ipc::Ipc, system::Cpu};

fn on_cpu() {
    // Runs on the selected CPU at minimum interrupt priority.
}

let ipc = Ipc::new(peripherals.IPC);
ipc.call_function(Cpu::ProCpu, on_cpu);

Structs§

Ipc
Handle that posts a function to a CPU through the IPC interrupt.