2017-12-09 15:12:42 +01:00
|
|
|
#![deny(unsafe_code)]
|
2017-07-18 22:14:39 +02:00
|
|
|
#![deny(warnings)]
|
|
|
|
#![feature(proc_macro)]
|
2017-07-24 03:51:58 +02:00
|
|
|
#![no_std]
|
2017-07-18 22:14:39 +02:00
|
|
|
|
|
|
|
extern crate cortex_m_rtfm as rtfm;
|
2018-05-01 14:01:51 +02:00
|
|
|
extern crate panic_abort;
|
2017-07-18 22:14:39 +02:00
|
|
|
extern crate stm32f103xx;
|
|
|
|
|
2018-05-01 14:01:51 +02:00
|
|
|
use rtfm::{app, Resource};
|
2017-07-18 22:14:39 +02:00
|
|
|
|
|
|
|
app! {
|
|
|
|
device: stm32f103xx,
|
|
|
|
|
|
|
|
resources: {
|
2017-07-24 03:51:58 +02:00
|
|
|
static STATE: bool = false;
|
2017-07-18 22:14:39 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
tasks: {
|
2018-05-01 14:01:51 +02:00
|
|
|
exti0: {
|
|
|
|
interrupt: EXTI0,
|
|
|
|
// priority: 1,
|
2017-07-18 22:14:39 +02:00
|
|
|
resources: [STATE],
|
|
|
|
},
|
|
|
|
|
2018-05-01 14:01:51 +02:00
|
|
|
exti1: {
|
|
|
|
interrupt: EXTI1,
|
2017-07-18 22:14:39 +02:00
|
|
|
priority: 2,
|
|
|
|
resources: [STATE],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2018-05-01 14:01:51 +02:00
|
|
|
fn init(_ctxt: init::Context) -> init::LateResources {
|
|
|
|
init::LateResources {}
|
|
|
|
}
|
2017-07-18 22:14:39 +02:00
|
|
|
|
2018-05-01 14:01:51 +02:00
|
|
|
fn idle(_ctxt: idle::Context) -> ! {
|
2017-07-18 22:14:39 +02:00
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
|
2018-05-01 14:01:51 +02:00
|
|
|
fn exti0(ctxt: exti0::Context) {
|
2017-07-18 22:14:39 +02:00
|
|
|
// ERROR token should not outlive the critical section
|
2018-05-01 14:01:51 +02:00
|
|
|
let t = &mut ctxt.threshold;
|
|
|
|
let t = ctxt.resources.STATE.claim(t, |_state, t| t);
|
2017-07-18 22:14:39 +02:00
|
|
|
//~^ error cannot infer an appropriate lifetime
|
|
|
|
}
|
|
|
|
|
2018-05-01 14:01:51 +02:00
|
|
|
fn exti1(_ctxt: exti1::Context) {}
|