2019-06-13 23:56:59 +02:00
|
|
|
//! [compile-pass] Check code generation of resources
|
2018-11-03 17:02:41 +01:00
|
|
|
|
2019-04-21 20:13:15 +02:00
|
|
|
#![deny(unsafe_code)]
|
|
|
|
#![deny(warnings)]
|
2018-11-03 17:02:41 +01:00
|
|
|
#![no_main]
|
|
|
|
#![no_std]
|
|
|
|
|
2019-06-13 23:56:59 +02:00
|
|
|
use panic_halt as _;
|
2018-11-03 17:02:41 +01:00
|
|
|
|
2020-06-11 19:18:29 +02:00
|
|
|
#[rtic::app(device = lm3s6965)]
|
2020-05-19 20:00:13 +02:00
|
|
|
mod app {
|
2020-06-04 17:24:21 +02:00
|
|
|
#[resources]
|
2019-07-10 22:42:44 +02:00
|
|
|
struct Resources {
|
|
|
|
#[init(0)]
|
|
|
|
o1: u32, // init
|
|
|
|
#[init(0)]
|
|
|
|
o2: u32, // idle
|
|
|
|
#[init(0)]
|
|
|
|
o3: u32, // EXTI0
|
|
|
|
#[init(0)]
|
|
|
|
o4: u32, // idle
|
|
|
|
#[init(0)]
|
|
|
|
o5: u32, // EXTI1
|
|
|
|
#[init(0)]
|
|
|
|
o6: u32, // init
|
|
|
|
#[init(0)]
|
|
|
|
s1: u32, // idle & uart0
|
|
|
|
#[init(0)]
|
|
|
|
s2: u32, // uart0 & uart1
|
|
|
|
#[init(0)]
|
|
|
|
s3: u32, // idle & uart0
|
|
|
|
}
|
|
|
|
|
2020-10-22 21:36:32 +02:00
|
|
|
#[init]
|
2021-02-20 19:22:45 +01:00
|
|
|
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
|
|
|
(init::LateResources {}, init::Monotonics())
|
2018-11-03 17:02:41 +01:00
|
|
|
}
|
|
|
|
|
2019-07-10 22:42:44 +02:00
|
|
|
#[idle(resources = [o2, &o4, s1, &s3])]
|
2019-04-21 20:13:15 +02:00
|
|
|
fn idle(mut c: idle::Context) -> ! {
|
2018-11-03 17:02:41 +01:00
|
|
|
// owned by `idle` == `&'static mut`
|
2020-10-22 21:36:32 +02:00
|
|
|
let _: resources::o2 = c.resources.o2;
|
2018-11-03 17:02:41 +01:00
|
|
|
|
|
|
|
// owned by `idle` == `&'static` if read-only
|
2020-10-22 21:36:32 +02:00
|
|
|
let _: &u32 = c.resources.o4;
|
2018-11-03 17:02:41 +01:00
|
|
|
|
|
|
|
// shared with `idle` == `Mutex`
|
2019-07-10 22:42:44 +02:00
|
|
|
c.resources.s1.lock(|_| {});
|
2018-11-03 17:02:41 +01:00
|
|
|
|
|
|
|
// `&` if read-only
|
2019-07-10 22:42:44 +02:00
|
|
|
let _: &u32 = c.resources.s3;
|
2018-11-03 17:02:41 +01:00
|
|
|
|
2020-09-14 09:35:10 +02:00
|
|
|
loop {
|
|
|
|
cortex_m::asm::nop();
|
|
|
|
}
|
2018-11-03 17:02:41 +01:00
|
|
|
}
|
|
|
|
|
2019-07-10 22:42:44 +02:00
|
|
|
#[task(binds = UART0, resources = [o3, s1, s2, &s3])]
|
2019-06-20 06:19:59 +02:00
|
|
|
fn uart0(c: uart0::Context) {
|
2018-11-03 17:02:41 +01:00
|
|
|
// owned by interrupt == `&mut`
|
2020-10-22 21:36:32 +02:00
|
|
|
let _: resources::o3 = c.resources.o3;
|
2018-11-03 17:02:41 +01:00
|
|
|
|
2018-11-04 19:46:49 +01:00
|
|
|
// no `Mutex` proxy when access from highest priority task
|
2020-10-22 21:36:32 +02:00
|
|
|
let _: resources::s1 = c.resources.s1;
|
2018-11-03 17:02:41 +01:00
|
|
|
|
2018-11-04 19:46:49 +01:00
|
|
|
// no `Mutex` proxy when co-owned by cooperative (same priority) tasks
|
2020-10-22 21:36:32 +02:00
|
|
|
let _: resources::s2 = c.resources.s2;
|
2018-11-03 17:02:41 +01:00
|
|
|
|
|
|
|
// `&` if read-only
|
2019-07-10 22:42:44 +02:00
|
|
|
let _: &u32 = c.resources.s3;
|
2018-11-03 17:02:41 +01:00
|
|
|
}
|
|
|
|
|
2019-07-10 22:42:44 +02:00
|
|
|
#[task(binds = UART1, resources = [s2, &o5])]
|
2019-06-20 06:19:59 +02:00
|
|
|
fn uart1(c: uart1::Context) {
|
2018-11-03 17:02:41 +01:00
|
|
|
// owned by interrupt == `&` if read-only
|
2019-07-10 22:42:44 +02:00
|
|
|
let _: &u32 = c.resources.o5;
|
2018-11-03 17:02:41 +01:00
|
|
|
|
2018-11-04 19:46:49 +01:00
|
|
|
// no `Mutex` proxy when co-owned by cooperative (same priority) tasks
|
2020-10-22 21:36:32 +02:00
|
|
|
let _: resources::s2 = c.resources.s2;
|
2018-11-03 17:02:41 +01:00
|
|
|
}
|
2020-04-22 12:58:14 +02:00
|
|
|
}
|