2017-12-09 15:12:42 +01:00
|
|
|
#![deny(unsafe_code)]
|
2017-07-24 05:11:07 +02:00
|
|
|
#![deny(warnings)]
|
|
|
|
#![feature(const_fn)]
|
|
|
|
#![feature(proc_macro)]
|
|
|
|
#![no_std]
|
|
|
|
|
|
|
|
extern crate cortex_m_rtfm as rtfm;
|
|
|
|
extern crate stm32f103xx;
|
|
|
|
|
|
|
|
use rtfm::{app, Resource, Threshold};
|
|
|
|
|
|
|
|
app! {
|
|
|
|
device: stm32f103xx,
|
|
|
|
|
|
|
|
resources: {
|
2017-07-27 18:40:15 +02:00
|
|
|
static ON: bool = false;
|
2017-07-24 05:11:07 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
idle: {
|
2017-07-27 18:40:15 +02:00
|
|
|
resources: [ON],
|
2017-07-24 05:11:07 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
tasks: {
|
|
|
|
EXTI0: {
|
2017-07-27 18:40:15 +02:00
|
|
|
path: exti0,
|
2017-07-24 05:11:07 +02:00
|
|
|
priority: 1,
|
2017-07-27 18:40:15 +02:00
|
|
|
resources: [ON],
|
2017-07-24 05:11:07 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
fn init(_p: init::Peripherals, _r: init::Resources) {}
|
|
|
|
|
|
|
|
fn idle(t: &mut Threshold, r: idle::Resources) -> ! {
|
2017-07-27 18:40:15 +02:00
|
|
|
let state = rtfm::atomic(t, |t| {
|
2017-07-24 05:11:07 +02:00
|
|
|
// ERROR borrow can't escape this *global* critical section
|
2017-07-27 18:40:15 +02:00
|
|
|
r.ON.borrow(t) //~ error cannot infer an appropriate lifetime
|
2017-07-24 05:11:07 +02:00
|
|
|
});
|
|
|
|
|
2017-07-27 18:40:15 +02:00
|
|
|
let state = r.ON.claim(t, |state, _t| {
|
2017-07-24 05:11:07 +02:00
|
|
|
// ERROR borrow can't escape this critical section
|
|
|
|
state //~ error cannot infer an appropriate lifetime
|
|
|
|
});
|
|
|
|
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn exti0(_t: &mut Threshold, _r: EXTI0::Resources) {}
|