diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-09-25 17:09:54 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-25 17:09:54 +0000 |
| commit | f0c319982524988fa67cac3c59a4a4a863c409c9 (patch) | |
| tree | de4cbe4b43d399d4dcf2021c33225ccd00627434 /examples/lock-free.rs | |
| parent | c8621d78b9b1c0c67dff31404ade873a9d7b426e (diff) | |
| parent | b71df58f2fb4ed85d4c8cf806d5837ce63c73f31 (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/lock-free.rs')
| -rw-r--r-- | examples/lock-free.rs | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/examples/lock-free.rs b/examples/lock-free.rs index db74c7d..ea6ff1b 100644 --- a/examples/lock-free.rs +++ b/examples/lock-free.rs @@ -7,10 +7,9 @@ use panic_semihosting as _; -#[rtic::app(device = lm3s6965)] +#[rtic::app(device = lm3s6965, dispatchers = [GPIOA])] mod app { use cortex_m_semihosting::{debug, hprintln}; - use lm3s6965::Interrupt; #[shared] struct Shared { @@ -23,38 +22,28 @@ mod app { #[init] fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { - rtic::pend(Interrupt::GPIOA); + foo::spawn().unwrap(); (Shared { counter: 0 }, Local {}, init::Monotonics()) } - #[task(binds = GPIOA, shared = [counter])] // <- same priority - fn gpioa(c: gpioa::Context) { - hprintln!("GPIOA/start").unwrap(); - rtic::pend(Interrupt::GPIOB); + #[task(shared = [counter])] // <- same priority + fn foo(c: foo::Context) { + bar::spawn().unwrap(); *c.shared.counter += 1; // <- no lock API required let counter = *c.shared.counter; - hprintln!(" GPIOA/counter = {}", counter).unwrap(); - - if counter == 5 { - debug::exit(debug::EXIT_SUCCESS); - } - hprintln!("GPIOA/end").unwrap(); + hprintln!(" foo = {}", counter).unwrap(); } - #[task(binds = GPIOB, shared = [counter])] // <- same priority - fn gpiob(c: gpiob::Context) { - hprintln!("GPIOB/start").unwrap(); - rtic::pend(Interrupt::GPIOA); + #[task(shared = [counter])] // <- same priority + fn bar(c: bar::Context) { + foo::spawn().unwrap(); *c.shared.counter += 1; // <- no lock API required let counter = *c.shared.counter; - hprintln!(" GPIOB/counter = {}", counter).unwrap(); + hprintln!(" bar = {}", counter).unwrap(); - if counter == 5 { - debug::exit(debug::EXIT_SUCCESS); - } - hprintln!("GPIOB/end").unwrap(); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator } } |
