From e2364aae3eebf3326534bd4818d0312a03817538 Mon Sep 17 00:00:00 2001 From: Henrik Tjäder Date: Tue, 8 Sep 2020 17:51:10 +0000 Subject: Updated examples and rtic-name --- examples/task-local-minimal.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/task-local-minimal.rs (limited to 'examples/task-local-minimal.rs') diff --git a/examples/task-local-minimal.rs b/examples/task-local-minimal.rs new file mode 100644 index 00000000..fd5ac68a --- /dev/null +++ b/examples/task-local-minimal.rs @@ -0,0 +1,33 @@ +//! examples/task-local_minimal.rs +#![deny(unsafe_code)] +#![deny(warnings)] +#![no_main] +#![no_std] + +use cortex_m_semihosting::{debug, hprintln}; +use panic_semihosting as _; + +#[rtic::app(device = lm3s6965)] +mod app { + #[resources] + struct Resources { + // A local (move), late resource + #[task_local] + l: u32, + } + + #[init] + fn init(_: init::Context) -> init::LateResources { + init::LateResources { l: 42 } + } + + // l is task_local + #[idle(resources =[l])] + fn idle(cx: idle::Context) -> ! { + hprintln!("IDLE:l = {}", cx.resources.l).unwrap(); + debug::exit(debug::EXIT_SUCCESS); + loop { + cortex_m::asm::nop(); + } + } +} -- cgit v1.2.3