diff options
Diffstat (limited to 'rtic/examples/spawn_arguments.rs')
-rw-r--r-- | rtic/examples/spawn_arguments.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/rtic/examples/spawn_arguments.rs b/rtic/examples/spawn_arguments.rs new file mode 100644 index 00000000..01f1a654 --- /dev/null +++ b/rtic/examples/spawn_arguments.rs @@ -0,0 +1,34 @@ +//! examples/message_passing.rs + +#![deny(unsafe_code)] +#![deny(warnings)] +#![no_main] +#![no_std] +#![feature(type_alias_impl_trait)] + +use panic_semihosting as _; + +#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] +mod app { + use cortex_m_semihosting::{debug, hprintln}; + + #[shared] + struct Shared {} + + #[local] + struct Local {} + + #[init] + fn init(_: init::Context) -> (Shared, Local) { + foo::spawn(1, 1).unwrap(); + assert!(foo::spawn(1, 4).is_err()); // The capacity of `foo` is reached + + (Shared {}, Local {}) + } + + #[task] + async fn foo(_c: foo::Context, x: i32, y: u32) { + hprintln!("foo {}, {}", x, y); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + } +} |