diff options
Diffstat (limited to 'examples/not-sync.rs')
-rw-r--r-- | examples/not-sync.rs | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/examples/not-sync.rs b/examples/not-sync.rs index aa79ad56..eb5c9f8f 100644 --- a/examples/not-sync.rs +++ b/examples/not-sync.rs @@ -4,12 +4,14 @@ #![deny(warnings)] #![no_main] #![no_std] +#![feature(type_alias_impl_trait)] use core::marker::PhantomData; use panic_semihosting as _; pub struct NotSync { _0: PhantomData<*const ()>, + data: u32, } unsafe impl Send for NotSync {} @@ -18,7 +20,7 @@ unsafe impl Send for NotSync {} mod app { use super::NotSync; use core::marker::PhantomData; - use cortex_m_semihosting::debug; + use cortex_m_semihosting::{debug, hprintln}; #[shared] struct Shared { @@ -29,25 +31,37 @@ mod app { struct Local {} #[init] - fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + fn init(_: init::Context) -> (Shared, Local) { + hprintln!("init").unwrap(); + foo::spawn().unwrap(); + bar::spawn().unwrap(); ( Shared { - shared: NotSync { _0: PhantomData }, + shared: NotSync { + _0: PhantomData, + data: 13, + }, }, Local {}, - init::Monotonics(), ) } + #[idle] + fn idle(_: idle::Context) -> ! { + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + loop {} + } + #[task(shared = [&shared])] - fn foo(c: foo::Context) { - let _: &NotSync = c.shared.shared; + async fn foo(c: foo::Context) { + let shared: &NotSync = c.shared.shared; + hprintln!("foo a {}", shared.data).unwrap(); } #[task(shared = [&shared])] - fn bar(c: bar::Context) { - let _: &NotSync = c.shared.shared; + async fn bar(c: bar::Context) { + let shared: &NotSync = c.shared.shared; + hprintln!("foo a {}", shared.data).unwrap(); } } |