Skip to content

Commit a9739a3

Browse files
committed
Add example
1 parent f049a3c commit a9739a3

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#![no_main]
2+
#![no_std]
3+
4+
use core::marker::PhantomData;
5+
use {defmt_rtt as _, panic_probe as _};
6+
pub mod pac {
7+
pub use embassy_stm32::pac::Interrupt as interrupt;
8+
pub use embassy_stm32::pac::*;
9+
}
10+
11+
#[rtic::app(device = pac, dispatchers = [SPI1])]
12+
mod app {
13+
use crate::NotSendNotSync;
14+
15+
#[shared]
16+
struct Shared {}
17+
18+
// Local resources go here
19+
#[local]
20+
struct Local {}
21+
22+
#[init]
23+
fn init(_cx: init::Context) -> (Shared, Local) {
24+
task1::spawn().ok();
25+
//task2::spawn(Default::default()).ok(); <--- This is rejected
26+
(Shared {}, Local {})
27+
}
28+
29+
// Optional idle, can be removed if not needed.
30+
#[idle]
31+
fn idle(_: idle::Context) -> ! {
32+
defmt::info!("idle");
33+
34+
loop {
35+
continue;
36+
}
37+
}
38+
39+
// TODO: Add tasks
40+
#[task(priority = 1)]
41+
async fn task1(cx: task1::Context) {
42+
defmt::info!("Hello from task1!");
43+
cx.local_spawner.task2(Default::default());
44+
}
45+
46+
#[task(priority = 1, is_local_task = true)]
47+
async fn task2(_cx: task2::Context, _nsns: super::NotSendNotSync) {
48+
defmt::info!("Hello from task1!");
49+
}
50+
}
51+
52+
#[derive(Default)]
53+
struct NotSendNotSync(PhantomData<*mut u8>);

0 commit comments

Comments
 (0)