rtic/examples/preempt.rs

41 lines
975 B
Rust
Raw Normal View History

2019-08-21 10:17:27 +02:00
//! examples/preempt.rs
#![no_main]
#![no_std]
use panic_semihosting as _;
2020-06-11 19:18:29 +02:00
use rtic::app;
2019-08-21 10:17:27 +02:00
#[app(device = lm3s6965)]
2020-05-19 20:00:13 +02:00
mod app {
2020-10-15 18:50:17 +02:00
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
2019-08-21 10:17:27 +02:00
#[init]
2021-02-20 19:22:45 +01:00
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
2020-06-11 19:18:29 +02:00
rtic::pend(Interrupt::GPIOA);
2020-10-01 19:38:49 +02:00
2021-02-20 19:22:45 +01:00
(init::LateResources {}, init::Monotonics())
2019-08-21 10:17:27 +02:00
}
2019-08-21 10:53:13 +02:00
#[task(binds = GPIOA, priority = 1)]
fn gpioa(_: gpioa::Context) {
hprintln!("GPIOA - start").unwrap();
2020-06-11 19:18:29 +02:00
rtic::pend(Interrupt::GPIOC);
2019-08-21 10:53:13 +02:00
hprintln!("GPIOA - end").unwrap();
2019-08-21 10:17:27 +02:00
debug::exit(debug::EXIT_SUCCESS);
}
2019-08-21 10:53:13 +02:00
#[task(binds = GPIOB, priority = 2)]
fn gpiob(_: gpiob::Context) {
hprintln!(" GPIOB").unwrap();
2019-08-21 10:17:27 +02:00
}
2019-08-21 10:53:13 +02:00
#[task(binds = GPIOC, priority = 2)]
fn gpioc(_: gpioc::Context) {
hprintln!(" GPIOC - start").unwrap();
2020-06-11 19:18:29 +02:00
rtic::pend(Interrupt::GPIOB);
2019-08-21 10:53:13 +02:00
hprintln!(" GPIOC - end").unwrap();
2019-08-21 10:17:27 +02:00
}
2020-04-22 12:58:14 +02:00
}