mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-26 05:29:38 +01:00
41 lines
980 B
Rust
41 lines
980 B
Rust
//! examples/schedule.rs
|
|
|
|
#![deny(unsafe_code)]
|
|
#![deny(warnings)]
|
|
#![no_main]
|
|
#![no_std]
|
|
|
|
use cortex_m_semihosting::hprintln;
|
|
use panic_halt as _;
|
|
use rtfm::cyccnt::{Instant, U32Ext as _};
|
|
|
|
// NOTE: does NOT work on QEMU!
|
|
#[rtfm::app(device = lm3s6965, monotonic = rtfm::cyccnt::CYCCNT)]
|
|
const APP: () = {
|
|
#[init(schedule = [foo, bar])]
|
|
fn init(cx: init::Context) {
|
|
let now = Instant::now();
|
|
|
|
hprintln!("init @ {:?}", now).unwrap();
|
|
|
|
// Schedule `foo` to run 8e6 cycles (clock cycles) in the future
|
|
cx.schedule.foo(now + 8_000_000.cycles()).unwrap();
|
|
|
|
// Schedule `bar` to run 4e6 cycles in the future
|
|
cx.schedule.bar(now + 4_000_000.cycles()).unwrap();
|
|
}
|
|
|
|
#[task]
|
|
fn foo(_: foo::Context) {
|
|
hprintln!("foo @ {:?}", Instant::now()).unwrap();
|
|
}
|
|
|
|
#[task]
|
|
fn bar(_: bar::Context) {
|
|
hprintln!("bar @ {:?}", Instant::now()).unwrap();
|
|
}
|
|
|
|
extern "C" {
|
|
fn UART0();
|
|
}
|
|
};
|