rtic/examples/lock2.rs

42 lines
889 B
Rust
Raw Permalink Normal View History

2020-06-12 22:39:20 +02:00
//! examples/lock2.rs
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
use cortex_m_semihosting::debug;
use lm3s6965::Interrupt;
2020-06-13 00:19:01 +02:00
use panic_semihosting as _;
2020-06-12 22:39:20 +02:00
#[rtic::app(device = lm3s6965)]
const APP: () = {
struct Resources {
#[init(0)]
shared: u32,
#[init(0)]
shared2: u32,
}
#[init]
fn init(_: init::Context) {
rtic::pend(Interrupt::GPIOA);
}
// when omitted priority is assumed to be `1`
#[task(binds = GPIOA, resources = [shared, shared2])]
2020-06-13 02:02:42 +02:00
fn gpioa(c: gpioa::Context) {
2020-06-12 22:39:20 +02:00
c.resources.shared.lock(|shared| {
*shared += 1;
rtic::pend(Interrupt::GPIOB);
});
debug::exit(debug::EXIT_SUCCESS);
}
#[task(binds = GPIOB, priority = 2, resources = [shared, shared2])]
fn gpiob(c: gpiob::Context) {
*c.resources.shared += 1;
}
};