mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 20:22:51 +01:00
40 lines
890 B
Rust
40 lines
890 B
Rust
|
//! 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(c: init::Context) -> (init::LateResources, init::Monotonics) {
|
||
|
hprintln!("init").unwrap();
|
||
|
driver(&bar::spawn);
|
||
|
foo::spawn(123).unwrap();
|
||
|
(init::LateResources {}, init::Monotonics())
|
||
|
}
|
||
|
|
||
|
#[task()]
|
||
|
fn foo(c: foo::Context, data: u32) {
|
||
|
hprintln!("foo {}", data).unwrap();
|
||
|
bar::spawn().unwrap();
|
||
|
}
|
||
|
|
||
|
#[task()]
|
||
|
fn bar(_c: 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();
|
||
|
}
|