aboutsummaryrefslogtreecommitdiff
path: root/examples/destructure.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-09-25 17:09:54 +0000
committerGitHub <noreply@github.com>2021-09-25 17:09:54 +0000
commitf0c319982524988fa67cac3c59a4a4a863c409c9 (patch)
treede4cbe4b43d399d4dcf2021c33225ccd00627434 /examples/destructure.rs
parentc8621d78b9b1c0c67dff31404ade873a9d7b426e (diff)
parentb71df58f2fb4ed85d4c8cf806d5837ce63c73f31 (diff)
Merge #528
528: The great 0.6 docs update r=AfoHT a=korken89 Closes #530 Closes #527 Closes #487 Closes #461 Closes #448 Closes #440 Closes #422 Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
Diffstat (limited to 'examples/destructure.rs')
-rw-r--r--examples/destructure.rs30
1 files changed, 17 insertions, 13 deletions
diff --git a/examples/destructure.rs b/examples/destructure.rs
index 984c9b8..6019c22 100644
--- a/examples/destructure.rs
+++ b/examples/destructure.rs
@@ -7,14 +7,12 @@
use panic_semihosting as _;
-#[rtic::app(device = lm3s6965)]
+#[rtic::app(device = lm3s6965, dispatchers = [UART0])]
mod app {
- use cortex_m_semihosting::hprintln;
- use lm3s6965::Interrupt;
+ use cortex_m_semihosting::{debug, hprintln};
#[shared]
struct Shared {
- // Some resources to work with
a: u32,
b: u32,
c: u32,
@@ -25,27 +23,33 @@ mod app {
#[init]
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
- rtic::pend(Interrupt::UART0);
- rtic::pend(Interrupt::UART1);
+ foo::spawn().unwrap();
+ bar::spawn().unwrap();
(Shared { a: 0, b: 0, c: 0 }, Local {}, init::Monotonics())
}
+ #[idle]
+ fn idle(_: idle::Context) -> ! {
+ debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ loop {}
+ }
+
// Direct destructure
- #[task(binds = UART0, shared = [&a, &b, &c])]
- fn uart0(cx: uart0::Context) {
+ #[task(shared = [&a, &b, &c])]
+ fn foo(cx: foo::Context) {
let a = cx.shared.a;
let b = cx.shared.b;
let c = cx.shared.c;
- hprintln!("UART0: a = {}, b = {}, c = {}", a, b, c).unwrap();
+ hprintln!("foo: a = {}, b = {}, c = {}", a, b, c).unwrap();
}
// De-structure-ing syntax
- #[task(binds = UART1, shared = [&a, &b, &c])]
- fn uart1(cx: uart1::Context) {
- let uart1::SharedResources { a, b, c } = cx.shared;
+ #[task(shared = [&a, &b, &c])]
+ fn bar(cx: bar::Context) {
+ let bar::SharedResources { a, b, c } = cx.shared;
- hprintln!("UART0: a = {}, b = {}, c = {}", a, b, c).unwrap();
+ hprintln!("bar: a = {}, b = {}, c = {}", a, b, c).unwrap();
}
}