diff options
author | 2020-09-08 17:51:10 +0000 | |
---|---|---|
committer | 2020-10-15 15:56:20 +0000 | |
commit | e2364aae3eebf3326534bd4818d0312a03817538 (patch) | |
tree | 36b0accc25bae25257d67b4d23ebdbe1f72d2b8b /examples/task-local-minimal.rs | |
parent | b29a0c134811cdde9ace237493f9dbed58c7d671 (diff) | |
download | rtic-e2364aae3eebf3326534bd4818d0312a03817538.tar.gz rtic-e2364aae3eebf3326534bd4818d0312a03817538.tar.zst rtic-e2364aae3eebf3326534bd4818d0312a03817538.zip |
Updated examples and rtic-name
Diffstat (limited to 'examples/task-local-minimal.rs')
-rw-r--r-- | examples/task-local-minimal.rs | 33 |
1 files changed, 33 insertions, 0 deletions
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(); + } + } +} |