mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-18 13:55:23 +01:00
parent
653338e799
commit
c631049efc
154 changed files with 7538 additions and 3276 deletions
|
|
@ -1,47 +0,0 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![feature(const_fn)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::{app, Resource, Threshold};
|
||||
|
||||
app! {
|
||||
device: stm32f103xx,
|
||||
|
||||
resources: {
|
||||
static ON: bool = false;
|
||||
},
|
||||
|
||||
idle: {
|
||||
resources: [ON],
|
||||
},
|
||||
|
||||
tasks: {
|
||||
EXTI0: {
|
||||
path: exti0,
|
||||
priority: 1,
|
||||
resources: [ON],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fn init(_p: init::Peripherals, _r: init::Resources) {}
|
||||
|
||||
fn idle(t: &mut Threshold, r: idle::Resources) -> ! {
|
||||
let state = rtfm::atomic(t, |t| {
|
||||
// ERROR borrow can't escape this *global* critical section
|
||||
r.ON.borrow(t) //~ error cannot infer an appropriate lifetime
|
||||
});
|
||||
|
||||
let state = r.ON.claim(t, |state, _t| {
|
||||
// ERROR borrow can't escape this critical section
|
||||
state //~ error cannot infer an appropriate lifetime
|
||||
});
|
||||
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn exti0(_t: &mut Threshold, _r: EXTI0::Resources) {}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
app! {
|
||||
//~^ error proc macro panicked
|
||||
device: stm32f103xx,
|
||||
|
||||
tasks: {
|
||||
SYS_TICK: {
|
||||
priority: 1,
|
||||
},
|
||||
|
||||
SYS_TICK: {
|
||||
priority: 2,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fn init(_p: init::Peripherals) {}
|
||||
|
||||
fn idle() -> ! {}
|
||||
20
tests/cfail/exception-divergent.rs
Normal file
20
tests/cfail/exception-divergent.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() {}
|
||||
|
||||
#[exception]
|
||||
fn SVCall() -> ! {
|
||||
//~^ ERROR `exception` handlers must have type signature `[unsafe] fn()`
|
||||
loop {}
|
||||
}
|
||||
};
|
||||
19
tests/cfail/exception-input.rs
Normal file
19
tests/cfail/exception-input.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() {}
|
||||
|
||||
#[exception]
|
||||
fn SVCall(undef: u32) {
|
||||
//~^ ERROR `exception` handlers must have type signature `[unsafe] fn()`
|
||||
}
|
||||
};
|
||||
19
tests/cfail/exception-invalid.rs
Normal file
19
tests/cfail/exception-invalid.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() {}
|
||||
|
||||
#[exception]
|
||||
fn NonMaskableInt() {
|
||||
//~^ ERROR only exceptions with configurable priority can be used as hardware tasks
|
||||
}
|
||||
};
|
||||
20
tests/cfail/exception-output.rs
Normal file
20
tests/cfail/exception-output.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() {}
|
||||
|
||||
#[exception]
|
||||
fn SVCall() -> u32 {
|
||||
//~^ ERROR `exception` handlers must have type signature `[unsafe] fn()`
|
||||
0
|
||||
}
|
||||
};
|
||||
19
tests/cfail/exception-sys-tick.rs
Normal file
19
tests/cfail/exception-sys-tick.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() {}
|
||||
|
||||
#[exception]
|
||||
fn SysTick() {
|
||||
//~^ ERROR the `SysTick` exception can't be used because it's used by the runtime
|
||||
}
|
||||
};
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
app! { //~ error proc macro panicked
|
||||
device: stm32f103xx,
|
||||
|
||||
tasks: {
|
||||
// ERROR exceptions can't be enabled / disabled here
|
||||
SYS_TICK: {
|
||||
enabled: true,
|
||||
priority: 1,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fn init(_p: init::Peripherals) {}
|
||||
|
||||
fn idle() -> ! {
|
||||
loop {}
|
||||
}
|
||||
19
tests/cfail/idle-input.rs
Normal file
19
tests/cfail/idle-input.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() {}
|
||||
|
||||
#[idle]
|
||||
fn idle(undef: u32) {
|
||||
//~^ ERROR `idle` must have type signature `[unsafe] fn() -> !`
|
||||
}
|
||||
};
|
||||
19
tests/cfail/idle-not-divergent.rs
Normal file
19
tests/cfail/idle-not-divergent.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() {}
|
||||
|
||||
#[idle]
|
||||
fn idle() {
|
||||
//~^ ERROR `idle` must have type signature `[unsafe] fn() -> !`
|
||||
}
|
||||
};
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
app! { //~ error mismatched types
|
||||
device: stm32f103xx,
|
||||
}
|
||||
|
||||
fn init(_p: init::Peripherals) {}
|
||||
|
||||
// ERROR `idle` must be a diverging function
|
||||
fn idle() {}
|
||||
17
tests/cfail/init-divergent.rs
Normal file
17
tests/cfail/init-divergent.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() -> ! {
|
||||
//~^ ERROR `init` must have type signature `[unsafe] fn()`
|
||||
loop {}
|
||||
}
|
||||
};
|
||||
16
tests/cfail/init-input.rs
Normal file
16
tests/cfail/init-input.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init(undef: u32) {
|
||||
//~^ ERROR `init` must have type signature `[unsafe] fn()`
|
||||
}
|
||||
};
|
||||
30
tests/cfail/init-not-send.rs
Normal file
30
tests/cfail/init-not-send.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
//! This is equivalent to the `late-not-send` cfail test
|
||||
|
||||
#![feature(extern_crate_item_prelude)] // ???
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
pub struct NotSend {
|
||||
_0: PhantomData<*const ()>,
|
||||
}
|
||||
|
||||
#[app(device = lm3s6965)] //~ ERROR `*const ()` cannot be sent between threads safely
|
||||
const APP: () = {
|
||||
static mut X: Option<NotSend> = None;
|
||||
|
||||
#[init(resources = [X])]
|
||||
fn init() {
|
||||
*resources.X = Some(NotSend { _0: PhantomData })
|
||||
}
|
||||
|
||||
#[interrupt(resources = [X])]
|
||||
fn UART0() {}
|
||||
};
|
||||
17
tests/cfail/init-output.rs
Normal file
17
tests/cfail/init-output.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() -> u32 {
|
||||
//~^ ERROR `init` must have type signature `[unsafe] fn()`
|
||||
0
|
||||
}
|
||||
};
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#![deny(warnings)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
app! { //~ proc macro panicked
|
||||
device: stm32f103xx,
|
||||
|
||||
resources: {
|
||||
static BUFFER: [u8; 16] = [0; 16];
|
||||
},
|
||||
|
||||
init: {
|
||||
resources: [BUFFER],
|
||||
},
|
||||
|
||||
idle: {
|
||||
resources: [BUFFER],
|
||||
//~^ error: this resource is owned by `init` and can't be shared
|
||||
},
|
||||
}
|
||||
|
||||
fn init(_p: init::Peripherals, _r: init::Resources) {}
|
||||
|
||||
fn idle(_r: init::Resources) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
#![deny(warnings)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
app! { //~ proc macro panicked
|
||||
device: stm32f103xx,
|
||||
|
||||
resources: {
|
||||
static BUFFER: [u8; 16] = [0; 16];
|
||||
},
|
||||
|
||||
init: {
|
||||
resources: [BUFFER],
|
||||
},
|
||||
|
||||
tasks: {
|
||||
SYS_TICK: {
|
||||
path: sys_tick,
|
||||
resources: [BUFFER],
|
||||
//~^ error: this resource is owned by `init` and can't be shared
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fn init(_p: init::Peripherals) {}
|
||||
|
||||
fn idle() -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn sys_tick() {}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
app! { //~ error mismatched types
|
||||
device: stm32f103xx,
|
||||
}
|
||||
|
||||
// ERROR `init` must have signature `fn (init::Peripherals)`
|
||||
fn init() {}
|
||||
|
||||
fn idle() -> ! {
|
||||
loop {}
|
||||
}
|
||||
17
tests/cfail/insufficient-free-interrupts.rs
Normal file
17
tests/cfail/insufficient-free-interrupts.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)] //~ ERROR 1 free interrupt (`extern { .. }`) is required
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() {}
|
||||
|
||||
#[task]
|
||||
fn foo() {}
|
||||
};
|
||||
20
tests/cfail/interrupt-divergent.rs
Normal file
20
tests/cfail/interrupt-divergent.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() {}
|
||||
|
||||
#[interrupt]
|
||||
fn UART0() -> ! {
|
||||
//~^ ERROR `interrupt` handlers must have type signature `[unsafe] fn()`
|
||||
loop {}
|
||||
}
|
||||
};
|
||||
19
tests/cfail/interrupt-input.rs
Normal file
19
tests/cfail/interrupt-input.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() {}
|
||||
|
||||
#[interrupt]
|
||||
fn UART0(undef: u32) {
|
||||
//~^ ERROR `interrupt` handlers must have type signature `[unsafe] fn()`
|
||||
}
|
||||
};
|
||||
20
tests/cfail/interrupt-output.rs
Normal file
20
tests/cfail/interrupt-output.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() {}
|
||||
|
||||
#[interrupt]
|
||||
fn UART0() -> u32 {
|
||||
//~^ ERROR `interrupt` handlers must have type signature `[unsafe] fn()`
|
||||
0
|
||||
}
|
||||
};
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
app! { //~ error no variant named `EXTI33` found for type
|
||||
device: stm32f103xx,
|
||||
|
||||
tasks: {
|
||||
EXTI33: {
|
||||
path: exti33,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fn init(_p: init::Peripherals) {}
|
||||
|
||||
fn idle() -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn exti33() {}
|
||||
16
tests/cfail/late-assigned-to-init.rs
Normal file
16
tests/cfail/late-assigned-to-init.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
static mut X: u32 = ();
|
||||
|
||||
#[init(resources = [X])] //~ ERROR late resources can NOT be assigned to `init`
|
||||
fn init() {}
|
||||
};
|
||||
31
tests/cfail/late-not-send.rs
Normal file
31
tests/cfail/late-not-send.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
//! `init` has a static priority of `0`. Initializing resources from it is equivalent to sending a
|
||||
//! message to the task that will own the resource
|
||||
|
||||
#![feature(extern_crate_item_prelude)] // ???
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
struct NotSend {
|
||||
_0: PhantomData<*const ()>,
|
||||
}
|
||||
|
||||
#[app(device = lm3s6965)] //~ ERROR `*const ()` cannot be sent between threads safely
|
||||
const APP: () = {
|
||||
static mut X: NotSend = ();
|
||||
|
||||
#[init]
|
||||
fn init() {
|
||||
X = NotSend { _0: PhantomData };
|
||||
}
|
||||
|
||||
#[interrupt(resources = [X])]
|
||||
fn UART0() {}
|
||||
};
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::{app, Threshold};
|
||||
|
||||
app! {
|
||||
device: stm32f103xx,
|
||||
|
||||
resources: {
|
||||
static A: u8 = 0;
|
||||
static LATE: u8;
|
||||
},
|
||||
|
||||
tasks: {
|
||||
EXTI0: {
|
||||
path: exti0,
|
||||
priority: 1,
|
||||
resources: [A, LATE],
|
||||
},
|
||||
|
||||
EXTI1: {
|
||||
path: exti1,
|
||||
priority: 2,
|
||||
resources: [A, LATE],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fn init(_p: init::Peripherals, r: init::Resources) -> init::LateResources {
|
||||
// Try to use a resource that's not yet initialized:
|
||||
r.LATE;
|
||||
//~^ error: no field `LATE`
|
||||
|
||||
init::LateResources {
|
||||
LATE: 0,
|
||||
}
|
||||
}
|
||||
|
||||
fn idle() -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn exti0(_t: &mut Threshold, _r: EXTI0::Resources) {}
|
||||
|
||||
fn exti1(_t: &mut Threshold, _r: EXTI1::Resources) {}
|
||||
16
tests/cfail/late-uninit.rs
Normal file
16
tests/cfail/late-uninit.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
static mut X: u32 = (); //~ ERROR late resources MUST be initialized at the end of `init`
|
||||
|
||||
#[init]
|
||||
fn init() {}
|
||||
};
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![feature(const_fn)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::{app, Resource, Threshold};
|
||||
|
||||
app! {
|
||||
device: stm32f103xx,
|
||||
|
||||
resources: {
|
||||
static ON: bool = false;
|
||||
static MAX: u8 = 0;
|
||||
},
|
||||
|
||||
tasks: {
|
||||
EXTI0: {
|
||||
path: exti0,
|
||||
priority: 1,
|
||||
resources: [MAX, ON],
|
||||
},
|
||||
|
||||
EXTI1: {
|
||||
path: exti1,
|
||||
priority: 2,
|
||||
resources: [ON],
|
||||
},
|
||||
|
||||
EXTI2: {
|
||||
path: exti2,
|
||||
priority: 16,
|
||||
resources: [MAX],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fn init(_p: init::Peripherals, _r: init::Resources) {}
|
||||
|
||||
fn idle() -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn exti0(mut t: &mut Threshold, mut r: EXTI0::Resources) {
|
||||
// ERROR need to lock to access the resource because priority < ceiling
|
||||
if *r.ON {
|
||||
//~^ error type `EXTI0::ON` cannot be dereferenced
|
||||
}
|
||||
|
||||
// OK need to lock to access the resource
|
||||
if r.ON.claim(&mut t, |on, _| *on) {}
|
||||
|
||||
// OK can claim a resource with maximum ceiling
|
||||
r.MAX.claim_mut(&mut t, |max, _| *max += 1);
|
||||
}
|
||||
|
||||
fn exti1(mut t: &mut Threshold, r: EXTI1::Resources) {
|
||||
// OK to directly access the resource because priority == ceiling
|
||||
if *r.ON {}
|
||||
|
||||
// though the resource can still be claimed -- the claim is a no-op
|
||||
if r.ON.claim(&mut t, |on, _| *on) {}
|
||||
}
|
||||
|
||||
fn exti2(_t: &mut Threshold, _r: EXTI2::Resources) {}
|
||||
30
tests/cfail/needs-send.rs
Normal file
30
tests/cfail/needs-send.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#![feature(extern_crate_item_prelude)] // ???
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
pub struct NotSend {
|
||||
_0: PhantomData<*const ()>,
|
||||
}
|
||||
|
||||
unsafe impl Sync for NotSend {}
|
||||
|
||||
#[app(device = lm3s6965)] //~ ERROR cannot be sent between threads safely
|
||||
const APP: () = {
|
||||
#[init(spawn = [foo])]
|
||||
fn init() {}
|
||||
|
||||
#[task]
|
||||
fn foo(_x: NotSend) {}
|
||||
|
||||
extern "C" {
|
||||
fn UART0();
|
||||
}
|
||||
};
|
||||
36
tests/cfail/needs-sync.rs
Normal file
36
tests/cfail/needs-sync.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#![feature(extern_crate_item_prelude)] // ???
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
pub struct NotSync {
|
||||
_0: PhantomData<*const ()>,
|
||||
}
|
||||
|
||||
unsafe impl Send for NotSync {}
|
||||
|
||||
#[app(device = lm3s6965)] //~ ERROR cannot be shared between threads safely
|
||||
const APP: () = {
|
||||
static X: NotSync = NotSync { _0: PhantomData };
|
||||
|
||||
#[init(spawn = [foo])]
|
||||
fn init() {}
|
||||
|
||||
#[task(priority = 1, resources = [X])]
|
||||
fn foo() {}
|
||||
|
||||
#[task(priority = 2, resources = [X])]
|
||||
fn bar() {}
|
||||
|
||||
extern "C" {
|
||||
fn UART0();
|
||||
fn UART1();
|
||||
}
|
||||
};
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
app! { //~ error proc macro panicked
|
||||
device: stm32f103xx,
|
||||
|
||||
tasks: {
|
||||
EXTI0: {
|
||||
enabled: true,
|
||||
priority: 1,
|
||||
// ERROR peripheral appears twice in this list
|
||||
resources: [GPIOA, GPIOA],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fn init(_p: init::Peripherals) {}
|
||||
|
||||
fn idle() -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
app! { //~ error referenced constant has errors
|
||||
//~^ error could not evaluate constant
|
||||
//~| error constant evaluation error
|
||||
device: stm32f103xx,
|
||||
|
||||
tasks: {
|
||||
SYS_TICK: {
|
||||
path: sys_tick,
|
||||
// ERROR priority must be in the range [1, 16]
|
||||
priority: 17,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fn init(_p: init::Peripherals) {}
|
||||
|
||||
fn idle() -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn sys_tick() {}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
app! { //~ error referenced constant has errors
|
||||
//~^ error could not evaluate constant
|
||||
//~| error constant evaluation error
|
||||
device: stm32f103xx,
|
||||
|
||||
tasks: {
|
||||
SYS_TICK: {
|
||||
path: sys_tick,
|
||||
// ERROR priority must be in the range [1, 16]
|
||||
priority: 0,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fn init(_p: init::Peripherals) {}
|
||||
|
||||
fn idle() -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn sys_tick() {}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
app! { //~ error proc macro panicked
|
||||
device: stm32f103xx,
|
||||
|
||||
resources: {
|
||||
// resource `MAX` listed twice
|
||||
MAX: u8 = 0;
|
||||
MAX: u16 = 0;
|
||||
},
|
||||
|
||||
tasks: {
|
||||
EXTI0: {
|
||||
enabled: true,
|
||||
priority: 1,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fn init(_p: init::Peripherals) {}
|
||||
|
||||
fn idle() -> ! {
|
||||
loop {}
|
||||
}
|
||||
14
tests/cfail/resource-not-declared.rs
Normal file
14
tests/cfail/resource-not-declared.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init(resources = [X])] //~ ERROR this resource has NOT been declared
|
||||
fn init() {}
|
||||
};
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![feature(const_fn)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::{app, Threshold};
|
||||
|
||||
app! {
|
||||
device: stm32f103xx,
|
||||
|
||||
resources: {
|
||||
static SHARED: bool = false;
|
||||
},
|
||||
|
||||
tasks: {
|
||||
EXTI0: {
|
||||
path: exti0,
|
||||
priority: 1,
|
||||
resources: [SHARED],
|
||||
},
|
||||
|
||||
EXTI1: {
|
||||
path: exti1,
|
||||
priority: 2,
|
||||
resources: [SHARED],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fn init(_p: init::Peripherals, _r: init::Resources) {}
|
||||
|
||||
fn idle() -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn is_send<T>(_: &T) where T: Send {}
|
||||
fn is_sync<T>(_: &T) where T: Sync {}
|
||||
|
||||
fn exti0(_t: &mut Threshold, r: EXTI0::Resources) {
|
||||
// ERROR resource proxies can't be shared between tasks
|
||||
is_sync(&r.SHARED);
|
||||
//~^ error `*const ()` cannot be shared between threads safely
|
||||
|
||||
// ERROR resource proxies are not `Send`able across tasks
|
||||
is_send(&r.SHARED);
|
||||
//~^ error `*const ()` cannot be sent between threads safely
|
||||
}
|
||||
|
||||
fn exti1(_t: &mut Threshold, _r: EXTI1::Resources) {
|
||||
}
|
||||
17
tests/cfail/resource-pub.rs
Normal file
17
tests/cfail/resource-pub.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
pub static mut X: u32 = 0;
|
||||
//~^ ERROR resources must have inherited / private visibility
|
||||
|
||||
#[init]
|
||||
fn init() {}
|
||||
};
|
||||
24
tests/cfail/task-divergent.rs
Normal file
24
tests/cfail/task-divergent.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() {}
|
||||
|
||||
#[task]
|
||||
fn foo() -> ! {
|
||||
//~^ ERROR `task` handlers must have type signature `[unsafe] fn(..)`
|
||||
loop {}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
fn UART0();
|
||||
}
|
||||
};
|
||||
23
tests/cfail/task-idle.rs
Normal file
23
tests/cfail/task-idle.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() {}
|
||||
|
||||
#[task]
|
||||
fn idle() {
|
||||
//~^ ERROR `task` handlers can NOT be named `idle`, `init` or `resources`
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
fn UART0();
|
||||
}
|
||||
};
|
||||
14
tests/cfail/task-not-declared.rs
Normal file
14
tests/cfail/task-not-declared.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init(spawn = [X])] //~ ERROR this task has NOT been declared
|
||||
fn init() {}
|
||||
};
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![feature(const_fn)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::{app, Resource, Threshold};
|
||||
|
||||
app! {
|
||||
device: stm32f103xx,
|
||||
|
||||
resources: {
|
||||
static STATE: bool = false;
|
||||
},
|
||||
|
||||
tasks: {
|
||||
EXTI0: {
|
||||
path: exti0,
|
||||
priority: 1,
|
||||
resources: [STATE],
|
||||
},
|
||||
|
||||
EXTI1: {
|
||||
path: exti1,
|
||||
priority: 2,
|
||||
resources: [STATE],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fn init(_p: init::Peripherals, _r: init::Resources) {}
|
||||
|
||||
fn idle() -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn exti0(mut t: &mut Threshold, r: EXTI0::Resources) {
|
||||
// ERROR token should not outlive the critical section
|
||||
let t = r.STATE.claim(&mut t, |_state, t| t);
|
||||
//~^ error cannot infer an appropriate lifetime
|
||||
}
|
||||
|
||||
fn exti1(_t: &mut Threshold, _r: EXTI1::Resources) {}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![feature(const_fn)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::{app, Threshold};
|
||||
|
||||
app! { //~ error `*const ()` cannot be sent between threads safely
|
||||
device: stm32f103xx,
|
||||
|
||||
resources: {
|
||||
static TOKEN: Option<Threshold> = None;
|
||||
},
|
||||
|
||||
idle: {
|
||||
resources: [TOKEN],
|
||||
},
|
||||
|
||||
tasks: {
|
||||
EXTI0: {
|
||||
path: exti0,
|
||||
resources: [TOKEN],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn init(_p: init::Peripherals, _r: init::Resources) {}
|
||||
|
||||
fn idle(_t: &mut Threshold, _r: idle::Resources) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn exti0(_t: &mut Threshold, _r: EXTI0::Resources) {}
|
||||
21
tests/cfail/used-free-interrupt.rs
Normal file
21
tests/cfail/used-free-interrupt.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() {}
|
||||
|
||||
#[interrupt]
|
||||
fn UART0() {} //~ ERROR free interrupts (`extern { .. }`) can't be used as interrupt handlers
|
||||
|
||||
extern "C" {
|
||||
fn UART0();
|
||||
}
|
||||
};
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m_rtfm as rtfm;
|
||||
extern crate stm32f103xx;
|
||||
|
||||
use rtfm::{app, Resource, Threshold};
|
||||
|
||||
app! {
|
||||
device: stm32f103xx,
|
||||
|
||||
resources: {
|
||||
static A: u8 = 0;
|
||||
static B: u8 = 0;
|
||||
},
|
||||
|
||||
tasks: {
|
||||
EXTI0: {
|
||||
path: exti0,
|
||||
priority: 1,
|
||||
resources: [A, B],
|
||||
},
|
||||
|
||||
EXTI1: {
|
||||
path: exti1,
|
||||
priority: 2,
|
||||
resources: [A, B],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fn init(_p: init::Peripherals, _r: init::Resources) {}
|
||||
|
||||
fn idle() -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn exti0(mut ot: &mut Threshold, r: EXTI0::Resources) {
|
||||
r.A.claim(&mut ot, |_a, mut _it| {
|
||||
//~^ error cannot borrow `ot` as mutable more than once at a time
|
||||
// ERROR must use inner token `it` instead of the outer one (`ot`)
|
||||
r.B.claim(&mut ot, |_b, _| {})
|
||||
});
|
||||
}
|
||||
|
||||
fn exti1(_t: &mut Threshold, _r: EXTI1::Resources) {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue