diff options
author | 2020-06-12 22:39:20 +0200 | |
---|---|---|
committer | 2020-06-12 22:39:20 +0200 | |
commit | 3c208003f564c7f256435d1b3845bd1269a8f506 (patch) | |
tree | 16dd6503e4b63eb293d449ee5afdbb5ae49dd8ed /examples/lock2.rs | |
parent | cfd5f4785e9c2ae88e666d1fb94a3488904a87f5 (diff) | |
download | rtic-3c208003f564c7f256435d1b3845bd1269a8f506.tar.gz rtic-3c208003f564c7f256435d1b3845bd1269a8f506.tar.zst rtic-3c208003f564c7f256435d1b3845bd1269a8f506.zip |
wip1
Diffstat (limited to 'examples/lock2.rs')
-rw-r--r-- | examples/lock2.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/examples/lock2.rs b/examples/lock2.rs new file mode 100644 index 00000000..ab41cf8a --- /dev/null +++ b/examples/lock2.rs @@ -0,0 +1,40 @@ +//! examples/lock2.rs + +#![deny(unsafe_code)] +#![deny(warnings)] +#![no_main] +#![no_std] + +use cortex_m_semihosting::debug; +use lm3s6965::Interrupt; + +#[rtic::app(device = lm3s6965)] +const APP: () = { + struct Resources { + #[init(0)] + shared: u32, + #[init(0)] + shared2: u32, + } + + #[init] + fn init(_: init::Context) { + rtic::pend(Interrupt::GPIOA); + } + + // when omitted priority is assumed to be `1` + #[task(binds = GPIOA, resources = [shared, shared2])] + fn gpioa(mut c: gpioa::Context) { + c.resources.shared.lock(|shared| { + *shared += 1; + rtic::pend(Interrupt::GPIOB); + }); + + debug::exit(debug::EXIT_SUCCESS); + } + + #[task(binds = GPIOB, priority = 2, resources = [shared, shared2])] + fn gpiob(c: gpiob::Context) { + *c.resources.shared += 1; + } +}; |