aboutsummaryrefslogtreecommitdiff
path: root/examples/task.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/task.rs')
-rw-r--r--examples/task.rs40
1 files changed, 23 insertions, 17 deletions
diff --git a/examples/task.rs b/examples/task.rs
index 4f168bb8..80a9c431 100644
--- a/examples/task.rs
+++ b/examples/task.rs
@@ -5,47 +5,53 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::{debug, hprintln};
-use rtfm::app;
+use panic_semihosting as _;
-#[app(device = lm3s6965)]
-const APP: () = {
+#[rtic::app(device = lm3s6965)]
+mod app {
#[init(spawn = [foo])]
- fn init() {
- spawn.foo().unwrap();
+ fn init(c: init::Context) -> init::LateResources {
+ c.spawn.foo().unwrap();
+
+ init::LateResources {}
}
#[task(spawn = [bar, baz])]
- fn foo() {
- hprintln!("foo").unwrap();
+ fn foo(c: foo::Context) {
+ hprintln!("foo - start").unwrap();
// spawns `bar` onto the task scheduler
// `foo` and `bar` have the same priority so `bar` will not run until
// after `foo` terminates
- spawn.bar().unwrap();
+ c.spawn.bar().unwrap();
+
+ hprintln!("foo - middle").unwrap();
// spawns `baz` onto the task scheduler
// `baz` has higher priority than `foo` so it immediately preempts `foo`
- spawn.baz().unwrap();
+ c.spawn.baz().unwrap();
+
+ hprintln!("foo - end").unwrap();
}
#[task]
- fn bar() {
+ fn bar(_: bar::Context) {
hprintln!("bar").unwrap();
debug::exit(debug::EXIT_SUCCESS);
}
#[task(priority = 2)]
- fn baz() {
+ fn baz(_: baz::Context) {
hprintln!("baz").unwrap();
}
- // Interrupt handlers used to dispatch software tasks
+ // 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 UART0();
- fn UART1();
+ fn SSI0();
+ fn QEI0();
}
-};
+}