aboutsummaryrefslogtreecommitdiff
path: root/mc/examples/x-init-2.rs
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2019-06-13 23:56:59 +0200
committerGravatar Jorge Aparicio <jorge@japaric.io> 2019-06-13 23:56:59 +0200
commit81275bfa4f41e2066770087f3a33cad4227eab41 (patch)
treec779a68e7cecf4c2613c7593376f980cea5dbc05 /mc/examples/x-init-2.rs
parentfafeeb27270ef24fc3852711c6032f65aa7dbcc0 (diff)
downloadrtic-81275bfa4f41e2066770087f3a33cad4227eab41.tar.gz
rtic-81275bfa4f41e2066770087f3a33cad4227eab41.tar.zst
rtic-81275bfa4f41e2066770087f3a33cad4227eab41.zip
rtfm-syntax refactor + heterogeneous multi-core support
Diffstat (limited to 'mc/examples/x-init-2.rs')
-rw-r--r--mc/examples/x-init-2.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/mc/examples/x-init-2.rs b/mc/examples/x-init-2.rs
new file mode 100644
index 00000000..ff48b110
--- /dev/null
+++ b/mc/examples/x-init-2.rs
@@ -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 = mc)]
+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 {}
+ }
+};