blob: df4106b95b26a5e93f95c07b22690e73453471bd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
//! examples/callback.rs
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use panic_semihosting as _;
#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
mod app {
use super::*;
#[init()]
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
hprintln!("init").unwrap();
driver(&bar::spawn);
foo::spawn(123).unwrap();
(init::LateResources {}, init::Monotonics())
}
#[task()]
fn foo(_: foo::Context, data: u32) {
hprintln!("foo {}", data).unwrap();
bar::spawn().unwrap();
}
#[task()]
fn bar(_: bar::Context) {
hprintln!("bar").unwrap();
debug::exit(debug::EXIT_SUCCESS);
}
}
// some external code (e.g. driver)
fn driver<E>(_callback: &dyn Fn() -> Result<(), E>) {
hprintln!("driver").unwrap();
}
|