mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 20:22:51 +01:00
67 lines
1.4 KiB
Rust
67 lines
1.4 KiB
Rust
//! `examples/not-sync.rs`
|
|
|
|
// #![deny(unsafe_code)]
|
|
#![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 {}
|
|
|
|
#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
|
|
mod app {
|
|
use super::NotSync;
|
|
use core::marker::PhantomData;
|
|
use cortex_m_semihosting::{debug, hprintln};
|
|
|
|
#[shared]
|
|
struct Shared {
|
|
shared: NotSync,
|
|
}
|
|
|
|
#[local]
|
|
struct Local {}
|
|
|
|
#[init]
|
|
fn init(_: init::Context) -> (Shared, Local) {
|
|
hprintln!("init");
|
|
|
|
foo::spawn().unwrap();
|
|
bar::spawn().unwrap();
|
|
(
|
|
Shared {
|
|
shared: NotSync {
|
|
_0: PhantomData,
|
|
data: 13,
|
|
},
|
|
},
|
|
Local {},
|
|
)
|
|
}
|
|
|
|
#[idle]
|
|
fn idle(_: idle::Context) -> ! {
|
|
debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
|
|
loop {}
|
|
}
|
|
|
|
#[task(shared = [&shared])]
|
|
async fn foo(c: foo::Context) {
|
|
let shared: &NotSync = c.shared.shared;
|
|
hprintln!("foo a {}", shared.data);
|
|
}
|
|
|
|
#[task(shared = [&shared])]
|
|
async fn bar(c: bar::Context) {
|
|
let shared: &NotSync = c.shared.shared;
|
|
hprintln!("foo a {}", shared.data);
|
|
}
|
|
}
|