diff options
Diffstat (limited to 'examples')
43 files changed, 516 insertions, 337 deletions
diff --git a/examples/big-struct-opt.rs b/examples/big-struct-opt.rs index 2d0cc83d..bbc2535a 100644 --- a/examples/big-struct-opt.rs +++ b/examples/big-struct-opt.rs @@ -24,6 +24,7 @@ impl BigStruct { mod app { use super::BigStruct; use core::mem::MaybeUninit; + use cortex_m_semihosting::debug; #[shared] struct Shared { @@ -41,6 +42,8 @@ mod app { &mut *cx.local.bs.as_mut_ptr() }; + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + ( Shared { // assign the reference so we can use the resource diff --git a/examples/binds.rs b/examples/binds.rs index 0b30af65..56565cbe 100644 --- a/examples/binds.rs +++ b/examples/binds.rs @@ -34,7 +34,7 @@ mod app { rtic::pend(Interrupt::UART0); - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator loop { cortex_m::asm::nop(); diff --git a/examples/cancel-reschedule.rs b/examples/cancel-reschedule.rs new file mode 100644 index 00000000..c5ef2e73 --- /dev/null +++ b/examples/cancel-reschedule.rs @@ -0,0 +1,74 @@ +//! examples/cancel-reschedule.rs + +#![deny(unsafe_code)] +#![deny(warnings)] +#![no_main] +#![no_std] + +use panic_semihosting as _; + +#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] +mod app { + use cortex_m_semihosting::{debug, hprintln}; + use rtic::time::duration::*; + use systick_monotonic::Systick; + + #[monotonic(binds = SysTick, default = true)] + type MyMono = Systick<100>; // 100 Hz / 10 ms granularity + + #[shared] + struct Shared {} + + #[local] + struct Local {} + + #[init] + fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { + let systick = cx.core.SYST; + + // Initialize the monotonic + let mono = Systick::new(systick, 12_000_000); + + hprintln!("init").ok(); + + // Schedule `foo` to run 1 second in the future + foo::spawn_after(1.seconds()).unwrap(); + + ( + Shared {}, + Local {}, + init::Monotonics(mono), // Give the monotonic to RTIC + ) + } + + #[task] + fn foo(_: foo::Context) { + hprintln!("foo").ok(); + + // Schedule `bar` to run 2 seconds in the future (1 second after foo runs) + let spawn_handle = baz::spawn_after(2.seconds()).unwrap(); + bar::spawn_after(1.seconds(), spawn_handle, false).unwrap(); // Change to true + } + + #[task] + fn bar(_: bar::Context, baz_handle: baz::SpawnHandle, do_reschedule: bool) { + hprintln!("bar").ok(); + + if do_reschedule { + // Reschedule baz 2 seconds from now, instead of the original 1 second + // from now. + baz_handle.reschedule_after(2.seconds()).unwrap(); + // Or baz_handle.reschedule_at(/* time */) + } else { + // Or cancel it + baz_handle.cancel().unwrap(); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + } + } + + #[task] + fn baz(_: baz::Context) { + hprintln!("baz").ok(); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + } +} diff --git a/examples/capacity.rs b/examples/capacity.rs index ea1613f7..a6172698 100644 --- a/examples/capacity.rs +++ b/examples/capacity.rs @@ -44,6 +44,6 @@ mod app { fn bar(_: bar::Context) { hprintln!("bar").unwrap(); - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator } } diff --git a/examples/cfg-whole-task.rs b/examples/cfg-whole-task.rs index 3fbdb2d1..213fe13f 100644 --- a/examples/cfg-whole-task.rs +++ b/examples/cfg-whole-task.rs @@ -43,7 +43,7 @@ mod app { #[idle] fn idle(_: idle::Context) -> ! { - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator loop { cortex_m::asm::nop(); diff --git a/examples/common.rs b/examples/common.rs new file mode 100644 index 00000000..770a0ae5 --- /dev/null +++ b/examples/common.rs @@ -0,0 +1,101 @@ +//! examples/common.rs + +#![deny(unsafe_code)] +#![deny(warnings)] +#![no_main] +#![no_std] + +use panic_semihosting as _; + +#[rtic::app(device = lm3s6965, dispatchers = [SSI0, QEI0])] +mod app { + use cortex_m_semihosting::{debug, hprintln}; + use rtic::time::duration::*; + use systick_monotonic::Systick; // Implements the `Monotonic` trait // Time helpers, such as `N.seconds()` + + // A monotonic timer to enable scheduling in RTIC + #[monotonic(binds = SysTick, default = true)] + type MyMono = Systick<100>; // 100 Hz / 10 ms granularity + + // Resources shared between tasks + #[shared] + struct Shared { + s1: u32, + s2: i32, + } + + // Local resources to specific tasks (cannot be shared) + #[local] + struct Local { + l1: u8, + l2: i8, + } + + #[init] + fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { + let systick = cx.core.SYST; + let mono = Systick::new(systick, 12_000_000); + + // Spawn the task `foo` directly after `init` finishes + foo::spawn().unwrap(); + + // Spawn the task `bar` 1 second after `init` finishes, this is enabled + // by the `#[monotonic(..)]` above + bar::spawn_after(1.seconds()).unwrap(); + + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + + ( + // Initialization of shared resources + Shared { s1: 0, s2: 1 }, + // Initialization of task local resources + Local { l1: 2, l2: 3 }, + // Move the monotonic timer to the RTIC run-time, this enables + // scheduling + init::Monotonics(mono), + ) + } + + // Background task, runs whenever no other tasks are running + #[idle] + fn idle(_: idle::Context) -> ! { + loop { + continue; + } + } + + // Software task, not bound to a hardware interrupt. + // This task takes the task local resource `l1` + // The resources `s1` and `s2` are shared between all other tasks. + #[task(shared = [s1, s2], local = [l1])] + fn foo(_: foo::Context) { + // This task is only spawned once in `init`, hence this task will run + // only once + + hprintln!("foo").ok(); + } + + // Software task, also not bound to a hardware interrupt + // This task takes the task local resource `l2` + // The resources `s1` and `s2` are shared between all other tasks. + #[task(shared = [s1, s2], local = [l2])] + fn bar(_: bar::Context) { + hprintln!("bar").ok(); + + // Run `bar` once per second + bar::spawn_after(1.seconds()).unwrap(); + } + + // Hardware task, bound to a hardware interrupt + // The resources `s1` and `s2` are shared between all other tasks. + #[task(binds = UART0, priority = 3, shared = [s1, s2])] + fn uart0_interrupt(_: uart0_interrupt::Context) { + // This task is bound to the interrupt `UART0` and will run + // whenever the interrupt fires + + // Note that RTIC does NOT clear the interrupt flag, this is up to the + // user + + hprintln!("UART0 interrupt!").ok(); + } +} diff --git a/examples/declared_locals.rs b/examples/declared_locals.rs new file mode 100644 index 00000000..52d354bc --- /dev/null +++ b/examples/declared_locals.rs @@ -0,0 +1,46 @@ +//! examples/declared_locals.rs + +#![deny(unsafe_code)] +#![deny(warnings)] +#![no_main] +#![no_std] + +use panic_semihosting as _; + +#[rtic::app(device = lm3s6965, dispatchers = [UART0])] +mod app { + use cortex_m_semihosting::debug; + + #[shared] + struct Shared {} + + #[local] + struct Local {} + + #[init(local = [a: u32 = 0])] + fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { + // Locals in `#[init]` have 'static lifetime + let _a: &'static mut u32 = cx.local.a; + + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + + (Shared {}, Local {}, init::Monotonics()) + } + + #[idle(local = [a: u32 = 0])] + fn idle(cx: idle::Context) -> ! { + // Locals in `#[idle]` have 'static lifetime + let _a: &'static mut u32 = cx.local.a; + + loop {} + } + + #[task(local = [a: u32 = 0])] + fn foo(cx: foo::Context) { + // Locals in `#[task]`s have a local lifetime + let _a: &mut u32 = cx.local.a; + + // error: explicit lifetime required in the type of `cx` + // let _a: &'static mut u32 = cx.local.a; + } +} diff --git a/examples/destructure.rs b/examples/destructure.rs index 984c9b8a..6019c225 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(); } } diff --git a/examples/double_schedule.rs b/examples/double_schedule.rs deleted file mode 100644 index 6f24297e..00000000 --- a/examples/double_schedule.rs +++ /dev/null @@ -1,46 +0,0 @@ -//! examples/double_schedule.rs - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] -mod app { - use dwt_systick_monotonic::DwtSystick; - use rtic::time::duration::Seconds; - - #[monotonic(binds = SysTick, default = true)] - type MyMono = DwtSystick<8_000_000>; // 8 MHz - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[init] - fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { - task1::spawn().ok(); - - let mut dcb = cx.core.DCB; - let dwt = cx.core.DWT; - let systick = cx.core.SYST; - - let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000); - - (Shared {}, Local {}, init::Monotonics(mono)) - } - - #[task] - fn task1(_cx: task1::Context) { - task2::spawn_after(Seconds(1_u32)).ok(); - } - - #[task] - fn task2(_cx: task2::Context) { - task1::spawn_after(Seconds(1_u32)).ok(); - } -} diff --git a/examples/extern_binds.rs b/examples/extern_binds.rs index ce4bc17e..4dc6633c 100644 --- a/examples/extern_binds.rs +++ b/examples/extern_binds.rs @@ -40,7 +40,7 @@ mod app { rtic::pend(Interrupt::UART0); - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator loop { cortex_m::asm::nop(); diff --git a/examples/extern_spawn.rs b/examples/extern_spawn.rs index d035fe7f..7f9b5a5f 100644 --- a/examples/extern_spawn.rs +++ b/examples/extern_spawn.rs @@ -12,7 +12,7 @@ use panic_semihosting as _; fn foo(_c: app::foo::Context, x: i32, y: u32) { hprintln!("foo {}, {}", x, y).unwrap(); if x == 2 { - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator } app::foo::spawn(2, 3).unwrap(); } diff --git a/examples/generics.rs b/examples/generics.rs index b2c59a08..72b861ba 100644 --- a/examples/generics.rs +++ b/examples/generics.rs @@ -39,7 +39,7 @@ mod app { rtic::pend(Interrupt::UART1); - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator } #[task(binds = UART1, priority = 2, shared = [shared], local = [state: u32 = 0])] diff --git a/examples/hardware.rs b/examples/hardware.rs index 5dff8222..60632247 100644 --- a/examples/hardware.rs +++ b/examples/hardware.rs @@ -37,7 +37,7 @@ mod app { rtic::pend(Interrupt::UART0); - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator loop { cortex_m::asm::nop(); diff --git a/examples/idle.rs b/examples/idle.rs index 34c861b9..55d6b153 100644 --- a/examples/idle.rs +++ b/examples/idle.rs @@ -31,7 +31,7 @@ mod app { hprintln!("idle").unwrap(); - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator loop { cortex_m::asm::nop(); diff --git a/examples/init.rs b/examples/init.rs index 97e3c513..b8a5bc5b 100644 --- a/examples/init.rs +++ b/examples/init.rs @@ -34,7 +34,7 @@ mod app { hprintln!("init").unwrap(); - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator (Shared {}, Local {}, init::Monotonics()) } diff --git a/examples/locals.rs b/examples/locals.rs new file mode 100644 index 00000000..eeb7fb75 --- /dev/null +++ b/examples/locals.rs @@ -0,0 +1,86 @@ +//! examples/locals.rs + +#![deny(unsafe_code)] +#![deny(warnings)] +#![no_main] +#![no_std] + +use panic_semihosting as _; + +#[rtic::app(device = lm3s6965, dispatchers = [UART0, UART1])] +mod app { + use cortex_m_semihosting::{debug, hprintln}; + + #[shared] + struct Shared {} + + #[local] + struct Local { + local_to_foo: i64, + local_to_bar: i64, + local_to_idle: i64, + } + + // `#[init]` cannot access locals from the `#[local]` struct as they are initialized here. + #[init] + fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { + foo::spawn().unwrap(); + bar::spawn().unwrap(); + + ( + Shared {}, + // initial values for the `#[local]` resources + Local { + local_to_foo: 0, + local_to_bar: 0, + local_to_idle: 0, + }, + init::Monotonics(), + ) + } + + // `local_to_idle` can only be accessed from this context + #[idle(local = [local_to_idle])] + fn idle(cx: idle::Context) -> ! { + let local_to_idle = cx.local.local_to_idle; + *local_to_idle += 1; + + hprintln!("idle: local_to_idle = {}", local_to_idle).unwrap(); + + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + + // error: no `local_to_foo` field in `idle::LocalResources` + // _cx.local.local_to_foo += 1; + + // error: no `local_to_bar` field in `idle::LocalResources` + // _cx.local.local_to_bar += 1; + + loop { + cortex_m::asm::nop(); + } + } + + // `local_to_foo` can only be accessed from this context + #[task(local = [local_to_foo])] + fn foo(cx: foo::Context) { + let local_to_foo = cx.local.local_to_foo; + *local_to_foo += 1; + + // error: no `local_to_bar` field in `foo::LocalResources` + // cx.local.local_to_bar += 1; + + hprintln!("foo: local_to_foo = {}", local_to_foo).unwrap(); + } + + // `shared` can only be accessed from this context + #[task(local = [local_to_bar])] + fn bar(cx: bar::Context) { + let local_to_bar = cx.local.local_to_bar; + *local_to_bar += 1; + + // error: no `local_to_foo` field in `bar::LocalResources` + // cx.local.local_to_foo += 1; + + hprintln!("bar: local_to_bar = {}", local_to_bar).unwrap(); + } +} diff --git a/examples/lock-free.rs b/examples/lock-free.rs index db74c7d8..ea6ff1bf 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 } } diff --git a/examples/lock.rs b/examples/lock.rs index aeadd295..f1a16968 100644 --- a/examples/lock.rs +++ b/examples/lock.rs @@ -7,10 +7,9 @@ use panic_semihosting as _; -#[rtic::app(device = lm3s6965)] +#[rtic::app(device = lm3s6965, dispatchers = [GPIOA, GPIOB, GPIOC])] mod app { use cortex_m_semihosting::{debug, hprintln}; - use lm3s6965::Interrupt; #[shared] struct Shared { @@ -22,14 +21,14 @@ mod app { #[init] fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { - rtic::pend(Interrupt::GPIOA); + foo::spawn().unwrap(); (Shared { shared: 0 }, Local {}, init::Monotonics()) } // when omitted priority is assumed to be `1` - #[task(binds = GPIOA, shared = [shared])] - fn gpioa(mut c: gpioa::Context) { + #[task(shared = [shared])] + fn foo(mut c: foo::Context) { hprintln!("A").unwrap(); // the lower priority task requires a critical section to access the data @@ -37,24 +36,24 @@ mod app { // data can only be modified within this critical section (closure) *shared += 1; - // GPIOB will *not* run right now due to the critical section - rtic::pend(Interrupt::GPIOB); + // bar will *not* run right now due to the critical section + bar::spawn().unwrap(); hprintln!("B - shared = {}", *shared).unwrap(); - // GPIOC does not contend for `shared` so it's allowed to run now - rtic::pend(Interrupt::GPIOC); + // baz does not contend for `shared` so it's allowed to run now + baz::spawn().unwrap(); }); - // critical section is over: GPIOB can now start + // critical section is over: bar can now start hprintln!("E").unwrap(); - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator } - #[task(binds = GPIOB, priority = 2, shared = [shared])] - fn gpiob(mut c: gpiob::Context) { + #[task(priority = 2, shared = [shared])] + fn bar(mut c: bar::Context) { // the higher priority task does still need a critical section let shared = c.shared.shared.lock(|shared| { *shared += 1; @@ -65,8 +64,8 @@ mod app { hprintln!("D - shared = {}", shared).unwrap(); } - #[task(binds = GPIOC, priority = 3)] - fn gpioc(_: gpioc::Context) { + #[task(priority = 3)] + fn baz(_: baz::Context) { hprintln!("C").unwrap(); } } diff --git a/examples/message.rs b/examples/message.rs index 7318d4b7..76c5675a 100644 --- a/examples/message.rs +++ b/examples/message.rs @@ -44,7 +44,7 @@ mod app { hprintln!("baz({}, {})", x, y).unwrap(); if x + y > 4 { - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator } foo::spawn().unwrap(); diff --git a/examples/spawn2.rs b/examples/message_passing.rs index ed285b70..ffa95371 100644 --- a/examples/spawn2.rs +++ b/examples/message_passing.rs @@ -1,4 +1,4 @@ -//! examples/spawn2.rs +//! examples/message_passing.rs #![deny(unsafe_code)] #![deny(warnings)] @@ -19,23 +19,19 @@ mod app { #[init] fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { + foo::spawn(1, 1).unwrap(); foo::spawn(1, 2).unwrap(); + foo::spawn(2, 3).unwrap(); + assert!(foo::spawn(1, 4).is_err()); // The capacity of `foo` is reached (Shared {}, Local {}, init::Monotonics()) } - #[task] + #[task(capacity = 3)] fn foo(_c: foo::Context, x: i32, y: u32) { hprintln!("foo {}, {}", x, y).unwrap(); if x == 2 { - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator } - foo2::spawn(2).unwrap(); - } - - #[task] - fn foo2(_c: foo2::Context, x: i32) { - hprintln!("foo2 {}", x).unwrap(); - foo::spawn(x, 0).unwrap(); } } diff --git a/examples/multilock.rs b/examples/multilock.rs index 7d8d7d24..d99bae69 100644 --- a/examples/multilock.rs +++ b/examples/multilock.rs @@ -1,6 +1,4 @@ //! examples/mutlilock.rs -//! -//! The multi-lock feature example. #![deny(unsafe_code)] #![deny(warnings)] @@ -9,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 { @@ -26,7 +23,7 @@ mod app { #[init] fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { - rtic::pend(Interrupt::GPIOA); + locks::spawn().unwrap(); ( Shared { @@ -40,47 +37,20 @@ mod app { } // when omitted priority is assumed to be `1` - #[task(binds = GPIOA, shared = [shared1, shared2, shared3])] + #[task(shared = [shared1, shared2, shared3])] fn locks(c: locks::Context) { - let mut s1 = c.shared.shared1; - let mut s2 = c.shared.shared2; - let mut s3 = c.shared.shared3; - - hprintln!("Multiple single locks").unwrap(); - s1.lock(|s1| { - s2.lock(|s2| { - s3.lock(|s3| { - *s1 += 1; - *s2 += 1; - *s3 += 1; - - hprintln!( - "Multiple single locks, s1: {}, s2: {}, s3: {}", - *s1, - *s2, - *s3 - ) - .unwrap(); - }) - }) - }); - - hprintln!("Multilock!").unwrap(); + let s1 = c.shared.shared1; + let s2 = c.shared.shared2; + let s3 = c.shared.shared3; (s1, s2, s3).lock(|s1, s2, s3| { *s1 += 1; *s2 += 1; *s3 += 1; - hprintln!( - "Multiple single locks, s1: {}, s2: {}, s3: {}", - *s1, - *s2, - *s3 - ) - .unwrap(); + hprintln!("Multiple locks, s1: {}, s2: {}, s3: {}", *s1, *s2, *s3).unwrap(); }); - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator } } diff --git a/examples/not-sync.rs b/examples/not-sync.rs index 1510e504..aa79ad56 100644 --- a/examples/not-sync.rs +++ b/examples/not-sync.rs @@ -30,7 +30,7 @@ mod app { #[init] fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator ( Shared { diff --git a/examples/only-shared-access.rs b/examples/only-shared-access.rs index e3f1dbd3..8b0a77ef 100644 --- a/examples/only-shared-access.rs +++ b/examples/only-shared-access.rs @@ -1,4 +1,4 @@ -//! examples/static.rs +//! examples/only-shared-access.rs #![deny(unsafe_code)] #![deny(warnings)] @@ -7,10 +7,9 @@ use panic_semihosting as _; -#[rtic::app(device = lm3s6965)] +#[rtic::app(device = lm3s6965, dispatchers = [UART0, UART1])] mod app { use cortex_m_semihosting::{debug, hprintln}; - use lm3s6965::Interrupt; #[shared] struct Shared { @@ -22,22 +21,22 @@ 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 { key: 0xdeadbeef }, Local {}, init::Monotonics()) } - #[task(binds = UART0, shared = [&key])] - fn uart0(cx: uart0::Context) { + #[task(shared = [&key])] + fn foo(cx: foo::Context) { let key: &u32 = cx.shared.key; - hprintln!("UART0(key = {:#x})", key).unwrap(); + hprintln!("foo(key = {:#x})", key).unwrap(); - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator } - #[task(binds = UART1, priority = 2, shared = [&key])] - fn uart1(cx: uart1::Context) { - hprintln!("UART1(key = {:#x})", cx.shared.key).unwrap(); + #[task(priority = 2, shared = [&key])] + fn bar(cx: bar::Context) { + hprintln!("bar(key = {:#x})", cx.shared.key).unwrap(); } } diff --git a/examples/periodic.rs b/examples/periodic.rs index b1868839..74c240c2 100644 --- a/examples/periodic.rs +++ b/examples/periodic.rs @@ -10,11 +10,12 @@ use panic_semihosting as _; // NOTE: does NOT work on QEMU! #[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { - use dwt_systick_monotonic::DwtSystick; - use rtic::time::duration::Seconds; + use cortex_m_semihosting::{debug, hprintln}; + use rtic::time::duration::*; + use systick_monotonic::Systick; #[monotonic(binds = SysTick, default = true)] - type MyMono = DwtSystick<8_000_000>; // 8 MHz + type MyMono = Systick<100>; // 100 Hz / 10 ms granularity #[shared] struct Shared {} @@ -24,20 +25,25 @@ mod app { #[init] fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { - let mut dcb = cx.core.DCB; - let dwt = cx.core.DWT; let systick = cx.core.SYST; - let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000); + let mono = Systick::new(systick, 12_000_000); - foo::spawn_after(Seconds(1_u32)).unwrap(); + foo::spawn_after(1.seconds()).unwrap(); (Shared {}, Local {}, init::Monotonics(mono)) } - #[task] - fn foo(_cx: foo::Context) { - // Periodic - foo::spawn_after(Seconds(1_u32)).unwrap(); + #[task(local = [cnt: u32 = 0])] + fn foo(cx: foo::Context) { + hprintln!("foo").ok(); + *cx.local.cnt += 1; + + if *cx.local.cnt == 4 { + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + } + + // Periodic ever 1 seconds + foo::spawn_after(1.seconds()).unwrap(); } } diff --git a/examples/peripherals-taken.rs b/examples/peripherals-taken.rs index cb90319e..d542c0e6 100644 --- a/examples/peripherals-taken.rs +++ b/examples/peripherals-taken.rs @@ -18,7 +18,7 @@ mod app { #[init] fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { assert!(cortex_m::Peripherals::take().is_none()); - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator (Shared {}, Local {}, init::Monotonics()) } diff --git a/examples/pool.rs b/examples/pool.rs index 010ee44e..d59bd916 100644 --- a/examples/pool.rs +++ b/examples/pool.rs @@ -61,7 +61,7 @@ mod app { // explicitly return the block to the pool drop(x); - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator } #[task(priority = 2)] diff --git a/examples/preempt.rs b/examples/preempt.rs index 8d9f9ead..d0c8cc7d 100644 --- a/examples/preempt.rs +++ b/examples/preempt.rs @@ -6,10 +6,9 @@ use panic_semihosting as _; use rtic::app; -#[app(device = lm3s6965)] +#[app(device = lm3s6965, dispatchers = [SSI0, QEI0])] mod app { use cortex_m_semihosting::{debug, hprintln}; - use lm3s6965::Interrupt; #[shared] struct Shared {} @@ -19,28 +18,28 @@ mod app { #[init] fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { - rtic::pend(Interrupt::GPIOA); + foo::spawn().unwrap(); (Shared {}, Local {}, init::Monotonics()) } - #[task(binds = GPIOA, priority = 1)] - fn gpioa(_: gpioa::Context) { - hprintln!("GPIOA - start").unwrap(); - rtic::pend(Interrupt::GPIOC); - hprintln!("GPIOA - end").unwrap(); - debug::exit(debug::EXIT_SUCCESS); + #[task(priority = 1)] + fn foo(_: foo::Context) { + hprintln!("foo - start").unwrap(); + baz::spawn().unwrap(); + hprintln!("foo - end").unwrap(); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator } - #[task(binds = GPIOB, priority = 2)] - fn gpiob(_: gpiob::Context) { - hprintln!(" GPIOB").unwrap(); + #[task(priority = 2)] + fn bar(_: bar::Context) { + hprintln!(" bar").unwrap(); } - #[task(binds = GPIOC, priority = 2)] - fn gpioc(_: gpioc::Context) { - hprintln!(" GPIOC - start").unwrap(); - rtic::pend(Interrupt::GPIOB); - hprintln!(" GPIOC - end").unwrap(); + #[task(priority = 2)] + fn baz(_: baz::Context) { + hprintln!(" baz - start").unwrap(); + bar::spawn().unwrap(); + hprintln!(" baz - end").unwrap(); } } diff --git a/examples/ramfunc.rs b/examples/ramfunc.rs index ecff8530..54acd7e8 100644 --- a/examples/ramfunc.rs +++ b/examples/ramfunc.rs @@ -36,7 +36,7 @@ mod app { fn foo(_: foo::Context) { hprintln!("foo").unwrap(); - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator } // run this task from RAM diff --git a/examples/resource-user-struct.rs b/examples/resource-user-struct.rs index 1ebaa59e..ae1918d0 100644 --- a/examples/resource-user-struct.rs +++ b/examples/resource-user-struct.rs @@ -39,7 +39,7 @@ mod app { // `shared` cannot be accessed from this context #[idle] fn idle(_cx: idle::Context) -> ! { - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator // error: no `shared` field in `idle::Context` // _cx.shared.shared += 1; diff --git a/examples/resource.rs b/examples/resource.rs deleted file mode 100644 index dca0b370..00000000 --- a/examples/resource.rs +++ /dev/null @@ -1,81 +0,0 @@ -//! examples/resource.rs - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965)] -mod app { - use cortex_m_semihosting::{debug, hprintln}; - use lm3s6965::Interrupt; - - #[shared] - struct Shared {} - - #[local] - struct Local { - local_to_uart0: i64, - local_to_uart1: i64, - } - - #[init] - fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { - rtic::pend(Interrupt::UART0); - rtic::pend(Interrupt::UART1); - - ( - Shared {}, - // initial values for the `#[local]` resources - Local { - local_to_uart0: 0, - local_to_uart1: 0, - }, - init::Monotonics(), - ) - } - - // `#[local]` resources cannot be accessed from this context - #[idle] - fn idle(_cx: idle::Context) -> ! { - debug::exit(debug::EXIT_SUCCESS); - - // error: no `local` field in `idle::Context` - // _cx.local.local_to_uart0 += 1; - - // error: no `local` field in `idle::Context` - // _cx.local.local_to_uart1 += 1; - - loop { - cortex_m::asm::nop(); - } - } - - // `local_to_uart0` can only be accessed from this context - // defaults to priority 1 - #[task(binds = UART0, local = [local_to_uart0])] - fn uart0(cx: uart0::Context) { - *cx.local.local_to_uart0 += 1; - let local_to_uart0 = cx.local.local_to_uart0; - - // error: no `local_to_uart1` field in `uart0::LocalResources` - // cx.local.local_to_uart1 += 1; - - hprintln!("UART0: local_to_uart0 = {}", local_to_uart0).unwrap(); - } - - // `shared` can only be accessed from this context - // explicitly set to priority 2 - #[task(binds = UART1, local = [local_to_uart1], priority = 2)] - fn uart1(cx: uart1::Context) { - *cx.local.local_to_uart1 += 1; - let local_to_uart1 = cx.local.local_to_uart1; - - // error: no `local_to_uart0` field in `uart1::LocalResources` - // cx.local.local_to_uart0 += 1; - - hprintln!("UART1: local_to_uart1 = {}", local_to_uart1).unwrap(); - } -} diff --git a/examples/schedule.rs b/examples/schedule.rs index f62f24a7..669c67c9 100644 --- a/examples/schedule.rs +++ b/examples/schedule.rs @@ -7,17 +7,14 @@ use panic_semihosting as _; -// NOTE: does NOT work on QEMU! #[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { - use cortex_m_semihosting::hprintln; - use dwt_systick_monotonic::DwtSystick; - use rtic::time::duration::Seconds; - - const MONO_HZ: u32 = 8_000_000; // 8 MHz + use cortex_m_semihosting::{debug, hprintln}; + use rtic::time::duration::*; + use systick_monotonic::Systick; #[monotonic(binds = SysTick, default = true)] - type MyMono = DwtSystick<MONO_HZ>; + type MyMono = Systick<100>; // 100 Hz / 10 ms granularity #[shared] struct Shared {} @@ -27,30 +24,42 @@ mod app { #[init] fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { - let mut dcb = cx.core.DCB; - let dwt = cx.core.DWT; let systick = cx.core.SYST; - let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000); + // Initialize the monotonic + let mono = Systick::new(systick, 12_000_000); hprintln!("init").ok(); // Schedule `foo` to run 1 second in the future - foo::spawn_after(Seconds(1_u32)).ok(); - - // Schedule `bar` to run 2 seconds in the future - bar::spawn_after(Seconds(2_u32)).ok(); + foo::spawn_after(1.seconds()).unwrap(); - (Shared {}, Local {}, init::Monotonics(mono)) + ( + Shared {}, + Local {}, + init::Monotonics(mono), // Give the monotonic to RTIC + ) } #[task] fn foo(_: foo::Context) { hprintln!("foo").ok(); + + // Schedule `bar` to run 2 seconds in the future (1 second after foo runs) + bar::spawn_after(1.seconds()).unwrap(); } #[task] fn bar(_: bar::Context) { hprintln!("bar").ok(); + + // Schedule `baz` to run 1 seconds from now, but with a specific time instant. + baz::spawn_at(monotonics::now() + 1.seconds()).unwrap(); + } + + #[task] + fn baz(_: baz::Context) { + hprintln!("baz").ok(); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator } } diff --git a/examples/shared.rs b/examples/shared.rs index 9585c388..d87dca52 100644 --- a/examples/shared.rs +++ b/examples/shared.rs @@ -36,7 +36,7 @@ mod app { if let Some(byte) = c.shared.c.lock(|c| c.dequeue()) { hprintln!("received message: {}", byte).unwrap(); - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator } else { rtic::pend(Interrupt::UART0); } diff --git a/examples/smallest.rs b/examples/smallest.rs index 31750e25..b121fcff 100644 --- a/examples/smallest.rs +++ b/examples/smallest.rs @@ -8,6 +8,8 @@ use rtic::app; #[app(device = lm3s6965)] mod app { + use cortex_m_semihosting::debug; + #[shared] struct Shared {} @@ -16,6 +18,7 @@ mod app { #[init] fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator (Shared {}, Local {}, init::Monotonics()) } } diff --git a/examples/spawn.rs b/examples/spawn.rs index 435cdf56..2db1ab8a 100644 --- a/examples/spawn.rs +++ b/examples/spawn.rs @@ -19,17 +19,16 @@ mod app { #[init] fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { - foo::spawn(1, 2).unwrap(); + hprintln!("init").unwrap(); + foo::spawn().unwrap(); (Shared {}, Local {}, init::Monotonics()) } - #[task()] - fn foo(_c: foo::Context, x: i32, y: u32) { - hprintln!("foo {}, {}", x, y).unwrap(); - if x == 2 { - debug::exit(debug::EXIT_SUCCESS); - } - foo::spawn(2, 3).unwrap(); + #[task] + fn foo(_: foo::Context) { + hprintln!("foo").unwrap(); + + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator } } diff --git a/examples/static.rs b/examples/static.rs index 0ea5d2df..c9aa6046 100644 --- a/examples/static.rs +++ b/examples/static.rs @@ -7,45 +7,53 @@ use panic_semihosting as _; -#[rtic::app(device = lm3s6965)] +#[rtic::app(device = lm3s6965, dispatchers = [UART0])] mod app { - use cortex_m_semihosting::{debug, hprintln}; use heapless::spsc::{Consumer, Producer, Queue}; - use lm3s6965::Interrupt; #[shared] - struct Shared { + struct Shared {} + + #[local] + struct Local { p: Producer<'static, u32, 5>, c: Consumer<'static, u32, 5>, } - #[local] - struct Local {} - #[init(local = [q: Queue<u32, 5> = Queue::new()])] fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { + // q has 'static life-time so after the split and return of `init` + // it will continue to exist and be allocated let (p, c) = cx.local.q.split(); - (Shared { p, c }, Local {}, init::Monotonics()) + foo::spawn().unwrap(); + + (Shared {}, Local { p, c }, init::Monotonics()) } - #[idle(shared = [c])] - fn idle(mut c: idle::Context) -> ! { + #[idle(local = [c])] + fn idle(c: idle::Context) -> ! { loop { - if let Some(byte) = c.shared.c.lock(|c| c.dequeue()) { - hprintln!("received message: {}", byte).unwrap(); - - debug::exit(debug::EXIT_SUCCESS); - } else { - rtic::pend(Interrupt::UART0); + // Lock-free access to the same underlying queue! + if let Some(data) = c.local.c.dequeue() { + hprintln!("received message: {}", data).unwrap(); + + // Run foo until data + if data == 3 { + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + } else { + foo::spawn().unwrap(); + } } } } - #[task(binds = UART0, shared = [p], local = [kalle: u32 = 0])] - fn uart0(mut c: uart0::Context) { - *c.local.kalle += 1; - c.shared.p.lock(|p| p.enqueue(42).unwrap()); + #[task(local = [p, state: u32 = 0])] + fn foo(c: foo::Context) { + *c.local.state += 1; + + // Lock-free access to the same underlying queue! + c.local.p.enqueue(*c.local.state).unwrap(); } } diff --git a/examples/t-binds.rs b/examples/t-binds.rs index 2c405ea0..12479c0a 100644 --- a/examples/t-binds.rs +++ b/examples/t-binds.rs @@ -9,6 +9,8 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::debug; + #[shared] struct Shared {} @@ -17,6 +19,8 @@ mod app { #[init] fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + (Shared {}, Local {}, init::Monotonics()) } diff --git a/examples/t-cfg-resources.rs b/examples/t-cfg-resources.rs index 3b06f0e0..99c97ba5 100644 --- a/examples/t-cfg-resources.rs +++ b/examples/t-cfg-resources.rs @@ -7,6 +7,8 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::debug; + #[shared] struct Shared { // A conditionally compiled resource behind feature_x @@ -19,6 +21,8 @@ mod app { #[init] fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + ( Shared { #[cfg(feature = "feature_x")] diff --git a/examples/t-htask-main.rs b/examples/t-htask-main.rs index 39404322..37189faf 100644 --- a/examples/t-htask-main.rs +++ b/examples/t-htask-main.rs @@ -24,6 +24,6 @@ mod app { #[task(binds = UART0)] fn taskmain(_: taskmain::Context) { - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator } } diff --git a/examples/t-idle-main.rs b/examples/t-idle-main.rs index c649a973..1adc9bf0 100644 --- a/examples/t-idle-main.rs +++ b/examples/t-idle-main.rs @@ -22,7 +22,7 @@ mod app { #[idle] fn taskmain(_: taskmain::Context) -> ! { - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator loop { cortex_m::asm::nop(); } diff --git a/examples/t-late-not-send.rs b/examples/t-late-not-send.rs index 7408a1eb..06aedaa2 100644 --- a/examples/t-late-not-send.rs +++ b/examples/t-late-not-send.rs @@ -15,6 +15,7 @@ pub struct NotSend { mod app { use super::NotSend; use core::marker::PhantomData; + use cortex_m_semihosting::debug; #[shared] struct Shared { @@ -39,6 +40,7 @@ mod app { #[idle(shared = [x, y])] fn idle(_: idle::Context) -> ! { + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator loop { cortex_m::asm::nop(); } diff --git a/examples/t-schedule.rs b/examples/t-schedule.rs index 6708c689..5530ec6a 100644 --- a/examples/t-schedule.rs +++ b/examples/t-schedule.rs @@ -9,11 +9,12 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { - use dwt_systick_monotonic::DwtSystick; + use cortex_m_semihosting::debug; use rtic::time::duration::Seconds; + use systick_monotonic::Systick; #[monotonic(binds = SysTick, default = true)] - type MyMono = DwtSystick<8_000_000>; // 8 MHz + type MyMono = Systick<100>; // 100 Hz / 10 ms granularity #[shared] struct Shared {} @@ -23,12 +24,17 @@ mod app { #[init] fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { - let mut dcb = cx.core.DCB; - let dwt = cx.core.DWT; let systick = cx.core.SYST; - let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000); + let mono = Systick::new(systick, 12_000_000); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + + (Shared {}, Local {}, init::Monotonics(mono)) + } + + #[idle] + fn idle(_: idle::Context) -> ! { // Task without message passing // Not default @@ -120,11 +126,6 @@ mod app { let handle: Result<baz::SpawnHandle, (u32, u32)> = baz::spawn_after(Seconds(1_u32), 0, 1); let _: Result<(u32, u32), ()> = handle.unwrap().cancel(); - (Shared {}, Local {}, init::Monotonics(mono)) - } - - #[idle] - fn idle(_: idle::Context) -> ! { loop { cortex_m::asm::nop(); } diff --git a/examples/t-spawn.rs b/examples/t-spawn.rs index 0f98592e..2bd771d7 100644 --- a/examples/t-spawn.rs +++ b/examples/t-spawn.rs @@ -9,6 +9,8 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { + use cortex_m_semihosting::debug; + #[shared] struct Shared {} @@ -21,6 +23,8 @@ mod app { let _: Result<(), u32> = bar::spawn(0); let _: Result<(), (u32, u32)> = baz::spawn(0, 1); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + (Shared {}, Local {}, init::Monotonics()) } diff --git a/examples/task.rs b/examples/task.rs index bec7b1ab..2c53aa23 100644 --- a/examples/task.rs +++ b/examples/task.rs @@ -46,7 +46,7 @@ mod app { fn bar(_: bar::Context) { hprintln!("bar").unwrap(); - debug::exit(debug::EXIT_SUCCESS); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator } #[task(priority = 2)] |