rtic/heterogeneous/examples/x-init-2.rs

40 lines
803 B
Rust
Raw Permalink Normal View History

//! [compile-pass] Cross initialization of late resources
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
use panic_halt as _;
2019-06-18 10:31:31 +02:00
#[rtfm::app(cores = 2, device = heterogeneous)]
const APP: () = {
2019-07-10 22:42:44 +02:00
struct Resources {
// owned by core #1 but initialized by core #0
2019-07-10 22:42:44 +02:00
x: u32,
// owned by core #0 but initialized by core #1
2019-07-10 22:42:44 +02:00
y: u32,
}
2019-07-10 22:42:44 +02:00
#[init(core = 0, late = [x])]
fn a(_: a::Context) -> a::LateResources {
2019-07-10 22:42:44 +02:00
a::LateResources { x: 0 }
}
2019-07-10 22:42:44 +02:00
#[idle(core = 0, resources = [y])]
fn b(_: b::Context) -> ! {
loop {}
}
#[init(core = 1)]
fn c(_: c::Context) -> c::LateResources {
2019-07-10 22:42:44 +02:00
c::LateResources { y: 0 }
}
2019-07-10 22:42:44 +02:00
#[idle(core = 1, resources = [x])]
fn d(_: d::Context) -> ! {
loop {}
}
};