mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-18 13:55:23 +01:00
add homogeneous multi-core support
This commit is contained in:
parent
81275bfa4f
commit
9897728709
33 changed files with 385 additions and 53 deletions
7
heterogeneous/examples/smallest.rs
Normal file
7
heterogeneous/examples/smallest.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use panic_halt as _;
|
||||
|
||||
#[rtfm::app(cores = 2, device = heterogeneous)]
|
||||
const APP: () = {};
|
||||
39
heterogeneous/examples/x-init-2.rs
Normal file
39
heterogeneous/examples/x-init-2.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
//! [compile-pass] Cross initialization of late resources
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use panic_halt as _;
|
||||
|
||||
#[rtfm::app(cores = 2, device = heterogeneous)]
|
||||
const APP: () = {
|
||||
extern "C" {
|
||||
// owned by core #1 but initialized by core #0
|
||||
static mut X: u32;
|
||||
|
||||
// owned by core #0 but initialized by core #1
|
||||
static mut Y: u32;
|
||||
}
|
||||
|
||||
#[init(core = 0, late = [X])]
|
||||
fn a(_: a::Context) -> a::LateResources {
|
||||
a::LateResources { X: 0 }
|
||||
}
|
||||
|
||||
#[idle(core = 0, resources = [Y])]
|
||||
fn b(_: b::Context) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[init(core = 1)]
|
||||
fn c(_: c::Context) -> c::LateResources {
|
||||
c::LateResources { Y: 0 }
|
||||
}
|
||||
|
||||
#[idle(core = 1, resources = [X])]
|
||||
fn d(_: d::Context) -> ! {
|
||||
loop {}
|
||||
}
|
||||
};
|
||||
26
heterogeneous/examples/x-init.rs
Normal file
26
heterogeneous/examples/x-init.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
//! [compile-pass] Split initialization of late resources
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use panic_halt as _;
|
||||
|
||||
#[rtfm::app(cores = 2, device = heterogeneous)]
|
||||
const APP: () = {
|
||||
extern "C" {
|
||||
static mut X: u32;
|
||||
static mut Y: u32;
|
||||
}
|
||||
|
||||
#[init(core = 0, late = [X])]
|
||||
fn a(_: a::Context) -> a::LateResources {
|
||||
a::LateResources { X: 0 }
|
||||
}
|
||||
|
||||
#[init(core = 1)]
|
||||
fn b(_: b::Context) -> b::LateResources {
|
||||
b::LateResources { Y: 0 }
|
||||
}
|
||||
};
|
||||
36
heterogeneous/examples/x-schedule.rs
Normal file
36
heterogeneous/examples/x-schedule.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use panic_halt as _;
|
||||
|
||||
#[rtfm::app(cores = 2, device = heterogeneous, monotonic = heterogeneous::MT)]
|
||||
const APP: () = {
|
||||
#[init(core = 0, spawn = [ping])]
|
||||
fn init(c: init::Context) {
|
||||
c.spawn.ping().ok();
|
||||
}
|
||||
|
||||
#[task(core = 0, schedule = [ping])]
|
||||
fn pong(c: pong::Context) {
|
||||
c.schedule.ping(c.scheduled + 1_000_000).ok();
|
||||
}
|
||||
|
||||
#[task(core = 1, schedule = [pong])]
|
||||
fn ping(c: ping::Context) {
|
||||
c.schedule.pong(c.scheduled + 1_000_000).ok();
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
#[core = 0]
|
||||
fn I0();
|
||||
|
||||
#[core = 0]
|
||||
fn I1();
|
||||
|
||||
#[core = 1]
|
||||
fn I0();
|
||||
|
||||
#[core = 1]
|
||||
fn I1();
|
||||
}
|
||||
};
|
||||
20
heterogeneous/examples/x-spawn.rs
Normal file
20
heterogeneous/examples/x-spawn.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use panic_halt as _;
|
||||
|
||||
#[rtfm::app(cores = 2, device = heterogeneous)]
|
||||
const APP: () = {
|
||||
#[init(core = 0, spawn = [foo])]
|
||||
fn init(c: init::Context) {
|
||||
c.spawn.foo().ok();
|
||||
}
|
||||
|
||||
#[task(core = 1)]
|
||||
fn foo(_: foo::Context) {}
|
||||
|
||||
extern "C" {
|
||||
#[core = 1]
|
||||
fn I0();
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue