From 569a761122f15a92671b299603a5dc7fe6e5324b Mon Sep 17 00:00:00 2001 From: Per Lindgren Date: Sat, 7 Jan 2023 14:27:57 +0100 Subject: examples/multiloc fixed --- examples/message.no_rs | 52 ++++++++++++++++++++++++++++++++++++++++++ examples/message.rs | 52 ------------------------------------------ examples/message_passing.no_rs | 37 ++++++++++++++++++++++++++++++ examples/message_passing.rs | 37 ------------------------------ examples/multilock.rs | 6 ++--- 5 files changed, 92 insertions(+), 92 deletions(-) create mode 100644 examples/message.no_rs delete mode 100644 examples/message.rs create mode 100644 examples/message_passing.no_rs delete mode 100644 examples/message_passing.rs (limited to 'examples') diff --git a/examples/message.no_rs b/examples/message.no_rs new file mode 100644 index 0000000..76c5675 --- /dev/null +++ b/examples/message.no_rs @@ -0,0 +1,52 @@ +//! examples/message.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}; + + #[shared] + struct Shared {} + + #[local] + struct Local {} + + #[init] + fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { + foo::spawn(/* no message */).unwrap(); + + (Shared {}, Local {}, init::Monotonics()) + } + + #[task(local = [count: u32 = 0])] + fn foo(cx: foo::Context) { + hprintln!("foo").unwrap(); + + bar::spawn(*cx.local.count).unwrap(); + *cx.local.count += 1; + } + + #[task] + fn bar(_: bar::Context, x: u32) { + hprintln!("bar({})", x).unwrap(); + + baz::spawn(x + 1, x + 2).unwrap(); + } + + #[task] + fn baz(_: baz::Context, x: u32, y: u32) { + hprintln!("baz({}, {})", x, y).unwrap(); + + if x + y > 4 { + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + } + + foo::spawn().unwrap(); + } +} diff --git a/examples/message.rs b/examples/message.rs deleted file mode 100644 index 76c5675..0000000 --- a/examples/message.rs +++ /dev/null @@ -1,52 +0,0 @@ -//! examples/message.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}; - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[init] - fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { - foo::spawn(/* no message */).unwrap(); - - (Shared {}, Local {}, init::Monotonics()) - } - - #[task(local = [count: u32 = 0])] - fn foo(cx: foo::Context) { - hprintln!("foo").unwrap(); - - bar::spawn(*cx.local.count).unwrap(); - *cx.local.count += 1; - } - - #[task] - fn bar(_: bar::Context, x: u32) { - hprintln!("bar({})", x).unwrap(); - - baz::spawn(x + 1, x + 2).unwrap(); - } - - #[task] - fn baz(_: baz::Context, x: u32, y: u32) { - hprintln!("baz({}, {})", x, y).unwrap(); - - if x + y > 4 { - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - } - - foo::spawn().unwrap(); - } -} diff --git a/examples/message_passing.no_rs b/examples/message_passing.no_rs new file mode 100644 index 0000000..ffa9537 --- /dev/null +++ b/examples/message_passing.no_rs @@ -0,0 +1,37 @@ +//! examples/message_passing.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}; + + #[shared] + struct Shared {} + + #[local] + struct Local {} + + #[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(capacity = 3)] + fn foo(_c: foo::Context, x: i32, y: u32) { + hprintln!("foo {}, {}", x, y).unwrap(); + if x == 2 { + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + } + } +} diff --git a/examples/message_passing.rs b/examples/message_passing.rs deleted file mode 100644 index ffa9537..0000000 --- a/examples/message_passing.rs +++ /dev/null @@ -1,37 +0,0 @@ -//! examples/message_passing.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}; - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[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(capacity = 3)] - fn foo(_c: foo::Context, x: i32, y: u32) { - hprintln!("foo {}, {}", x, y).unwrap(); - if x == 2 { - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - } - } -} diff --git a/examples/multilock.rs b/examples/multilock.rs index d99bae6..7bea2d3 100644 --- a/examples/multilock.rs +++ b/examples/multilock.rs @@ -4,6 +4,7 @@ #![deny(warnings)] #![no_main] #![no_std] +#![feature(type_alias_impl_trait)] use panic_semihosting as _; @@ -22,7 +23,7 @@ mod app { struct Local {} #[init] - fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { + fn init(_: init::Context) -> (Shared, Local) { locks::spawn().unwrap(); ( @@ -32,13 +33,12 @@ mod app { shared3: 0, }, Local {}, - init::Monotonics(), ) } // when omitted priority is assumed to be `1` #[task(shared = [shared1, shared2, shared3])] - fn locks(c: locks::Context) { + async fn locks(c: locks::Context) { let s1 = c.shared.shared1; let s2 = c.shared.shared2; let s3 = c.shared.shared3; -- cgit v1.2.3