aboutsummaryrefslogtreecommitdiff
path: root/examples/baseline.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/baseline.rs')
-rw-r--r--examples/baseline.rs39
1 files changed, 22 insertions, 17 deletions
diff --git a/examples/baseline.rs b/examples/baseline.rs
index fdf36838..3ab40dbb 100644
--- a/examples/baseline.rs
+++ b/examples/baseline.rs
@@ -5,47 +5,52 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
-use rtfm::app;
+use panic_semihosting as _;
// NOTE: does NOT properly work on QEMU
-#[app(device = lm3s6965)]
-const APP: () = {
+#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
+mod app {
#[init(spawn = [foo])]
- fn init() {
- hprintln!("init(baseline = {:?})", start).unwrap();
+ fn init(cx: init::Context) -> init::LateResources {
+ // omitted: initialization of `CYCCNT`
+
+ hprintln!("init(baseline = {:?})", cx.start).unwrap();
// `foo` inherits the baseline of `init`: `Instant(0)`
- spawn.foo().unwrap();
+ cx.spawn.foo().unwrap();
+
+ init::LateResources {}
}
#[task(schedule = [foo])]
- fn foo() {
+ fn foo(cx: foo::Context) {
static mut ONCE: bool = true;
- hprintln!("foo(baseline = {:?})", scheduled).unwrap();
+ hprintln!("foo(baseline = {:?})", cx.scheduled).unwrap();
if *ONCE {
*ONCE = false;
- rtfm::pend(Interrupt::UART0);
+ rtic::pend(Interrupt::UART0);
} else {
debug::exit(debug::EXIT_SUCCESS);
}
}
- #[interrupt(spawn = [foo])]
- fn UART0() {
- hprintln!("UART0(baseline = {:?})", start).unwrap();
+ #[task(binds = UART0, spawn = [foo])]
+ fn uart0(cx: uart0::Context) {
+ hprintln!("UART0(baseline = {:?})", cx.start).unwrap();
// `foo` inherits the baseline of `UART0`: its `start` time
- spawn.foo().unwrap();
+ cx.spawn.foo().unwrap();
}
+ // RTIC requires that unused interrupts are declared in an extern block when
+ // using software tasks; these free interrupts will be used to dispatch the
+ // software tasks.
extern "C" {
- fn UART1();
+ fn SSI0();
}
-};
+}