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)]
|
2018-05-14 21:22:50 +02:00
|
|
|
#![no_main]
|
2017-07-24 05:11:07 +02:00
|
|
|
#![no_std]
|
|
|
|
|
|
|
|
extern crate cortex_m_rtfm as rtfm;
|
2018-05-07 17:46:26 +02:00
|
|
|
extern crate panic_itm;
|
2017-07-24 05:11:07 +02:00
|
|
|
extern crate stm32f103xx;
|
|
|
|
|
2018-05-01 14:01:51 +02:00
|
|
|
use rtfm::{app, Resource};
|
2017-07-24 05:11:07 +02:00
|
|
|
|
|
|
|
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: {
|
2018-05-01 14:01:51 +02:00
|
|
|
exti0: {
|
|
|
|
interrupt: EXTI0,
|
2017-07-27 18:40:15 +02:00
|
|
|
resources: [ON],
|
2017-07-24 05:11:07 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2018-05-01 14:01:51 +02:00
|
|
|
fn init(_ctxt: init::Context) -> init::LateResources {
|
|
|
|
init::LateResources {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn idle(mut ctxt: idle::Context) -> ! {
|
2018-05-14 21:22:50 +02:00
|
|
|
let p = &mut ctxt.priority;
|
2018-05-01 14:01:51 +02:00
|
|
|
let on = ctxt.resources.ON;
|
2017-07-24 05:11:07 +02:00
|
|
|
|
2018-05-14 21:22:50 +02:00
|
|
|
let state = rtfm::atomic(p, |p| {
|
2017-07-24 05:11:07 +02:00
|
|
|
// ERROR borrow can't escape this *global* critical section
|
2018-05-14 21:22:50 +02:00
|
|
|
on.borrow(p) //~ error cannot infer an appropriate lifetime
|
2017-07-24 05:11:07 +02:00
|
|
|
});
|
|
|
|
|
2018-05-14 21:22:50 +02:00
|
|
|
let state = on.claim(p, |state, _p| {
|
2017-07-24 05:11:07 +02:00
|
|
|
// ERROR borrow can't escape this critical section
|
|
|
|
state //~ error cannot infer an appropriate lifetime
|
|
|
|
});
|
|
|
|
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
|
2018-05-01 14:01:51 +02:00
|
|
|
fn exti0(_ctxt: exti0::Context) {}
|