mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-29 06:54:33 +01:00
update compile-pass tests
This commit is contained in:
parent
1b4b006bab
commit
d2fb62f729
10 changed files with 107 additions and 212 deletions
|
@ -1,4 +1,6 @@
|
|||
//! Check that `binds` works as advertised
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
|
@ -6,18 +8,20 @@ extern crate lm3s6965;
|
|||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
#[rtfm::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() {}
|
||||
fn init(_: init::Context) {}
|
||||
|
||||
#[exception(binds = SVCall)]
|
||||
fn foo() {}
|
||||
fn foo(c: foo::Context) {
|
||||
foo_trampoline(c)
|
||||
}
|
||||
|
||||
#[interrupt(binds = UART0)]
|
||||
fn bar() {}
|
||||
fn bar(c: bar::Context) {
|
||||
bar_trampoline(c)
|
||||
}
|
||||
};
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
|
|
@ -6,24 +6,22 @@
|
|||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_semihosting;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
#[rtfm::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[cfg(never)]
|
||||
static mut FOO: u32 = 0;
|
||||
|
||||
#[init]
|
||||
fn init() {
|
||||
fn init(_: init::Context) {
|
||||
#[cfg(never)]
|
||||
static mut BAR: u32 = 0;
|
||||
}
|
||||
|
||||
#[idle]
|
||||
fn idle() -> ! {
|
||||
fn idle(_: idle::Context) -> ! {
|
||||
#[cfg(never)]
|
||||
static mut BAR: u32 = 0;
|
||||
|
||||
|
@ -31,20 +29,20 @@ const APP: () = {
|
|||
}
|
||||
|
||||
#[task(resources = [FOO], schedule = [quux], spawn = [quux])]
|
||||
fn foo() {
|
||||
fn foo(_: foo::Context) {
|
||||
#[cfg(never)]
|
||||
static mut BAR: u32 = 0;
|
||||
}
|
||||
|
||||
#[task(priority = 3, resources = [FOO], schedule = [quux], spawn = [quux])]
|
||||
fn bar() {
|
||||
fn bar(_: bar::Context) {
|
||||
#[cfg(never)]
|
||||
static mut BAR: u32 = 0;
|
||||
}
|
||||
|
||||
#[cfg(never)]
|
||||
#[task]
|
||||
fn quux() {}
|
||||
fn quux(_: quux::Context) {}
|
||||
|
||||
extern "C" {
|
||||
fn UART0();
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
|
@ -7,20 +9,18 @@ extern crate rtfm;
|
|||
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
pub struct NotSend {
|
||||
_0: PhantomData<*const ()>,
|
||||
}
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
#[rtfm::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
static mut X: NotSend = ();
|
||||
static mut Y: Option<NotSend> = None;
|
||||
|
||||
#[init(resources = [Y])]
|
||||
fn init() -> init::LateResources {
|
||||
*resources.Y = Some(NotSend { _0: PhantomData });
|
||||
fn init(c: init::Context) -> init::LateResources {
|
||||
*c.resources.Y = Some(NotSend { _0: PhantomData });
|
||||
|
||||
init::LateResources {
|
||||
X: NotSend { _0: PhantomData },
|
||||
|
@ -28,7 +28,7 @@ const APP: () = {
|
|||
}
|
||||
|
||||
#[idle(resources = [X, Y])]
|
||||
fn idle() -> ! {
|
||||
fn idle(_: idle::Context) -> ! {
|
||||
loop {}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
//! Runtime initialized resources
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
|
@ -6,15 +8,13 @@ extern crate lm3s6965;
|
|||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
#[rtfm::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
static mut X: u32 = ();
|
||||
static Y: u32 = ();
|
||||
|
||||
#[init]
|
||||
fn init() -> init::LateResources {
|
||||
fn init(_: init::Context) -> init::LateResources {
|
||||
init::LateResources { X: 0, Y: 1 }
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
//! Core and device peripherals
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
|
@ -6,13 +8,11 @@ extern crate lm3s6965;
|
|||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
#[rtfm::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() {
|
||||
let _: rtfm::Peripherals = core;
|
||||
let _: lm3s6965::Peripherals = device;
|
||||
fn init(c: init::Context) {
|
||||
let _: rtfm::Peripherals = c.core;
|
||||
let _: lm3s6965::Peripherals = c.device;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
//! Check code generation of resources
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
|
@ -7,9 +9,9 @@ extern crate lm3s6965;
|
|||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::{app, Exclusive};
|
||||
use rtfm::Exclusive;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
#[rtfm::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
static mut O1: u32 = 0; // init
|
||||
static mut O2: u32 = 0; // idle
|
||||
|
@ -23,57 +25,57 @@ const APP: () = {
|
|||
static S3: u32 = 0;
|
||||
|
||||
#[init(resources = [O1, O4, O5, O6, S3])]
|
||||
fn init() {
|
||||
fn init(c: init::Context) {
|
||||
// owned by `init` == `&'static mut`
|
||||
let _: &'static mut u32 = resources.O1;
|
||||
let _: &'static mut u32 = c.resources.O1;
|
||||
|
||||
// owned by `init` == `&'static` if read-only
|
||||
let _: &'static u32 = resources.O6;
|
||||
let _: &'static u32 = c.resources.O6;
|
||||
|
||||
// `init` has exclusive access to all resources
|
||||
let _: &mut u32 = resources.O4;
|
||||
let _: &mut u32 = resources.O5;
|
||||
let _: &mut u32 = resources.S3;
|
||||
let _: &mut u32 = c.resources.O4;
|
||||
let _: &mut u32 = c.resources.O5;
|
||||
let _: &mut u32 = c.resources.S3;
|
||||
}
|
||||
|
||||
#[idle(resources = [O2, O4, S1, S3])]
|
||||
fn idle() -> ! {
|
||||
fn idle(mut c: idle::Context) -> ! {
|
||||
// owned by `idle` == `&'static mut`
|
||||
let _: &'static mut u32 = resources.O2;
|
||||
let _: &'static mut u32 = c.resources.O2;
|
||||
|
||||
// owned by `idle` == `&'static` if read-only
|
||||
let _: &'static u32 = resources.O4;
|
||||
let _: &'static u32 = c.resources.O4;
|
||||
|
||||
// shared with `idle` == `Mutex`
|
||||
resources.S1.lock(|_| {});
|
||||
c.resources.S1.lock(|_| {});
|
||||
|
||||
// `&` if read-only
|
||||
let _: &u32 = resources.S3;
|
||||
let _: &u32 = c.resources.S3;
|
||||
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[interrupt(resources = [O3, S1, S2, S3])]
|
||||
fn UART0() {
|
||||
fn UART0(c: UART0::Context) {
|
||||
// owned by interrupt == `&mut`
|
||||
let _: &mut u32 = resources.O3;
|
||||
let _: &mut u32 = c.resources.O3;
|
||||
|
||||
// no `Mutex` proxy when access from highest priority task
|
||||
let _: Exclusive<u32> = resources.S1;
|
||||
let _: Exclusive<u32> = c.resources.S1;
|
||||
|
||||
// no `Mutex` proxy when co-owned by cooperative (same priority) tasks
|
||||
let _: Exclusive<u32> = resources.S2;
|
||||
let _: Exclusive<u32> = c.resources.S2;
|
||||
|
||||
// `&` if read-only
|
||||
let _: &u32 = resources.S3;
|
||||
let _: &u32 = c.resources.S3;
|
||||
}
|
||||
|
||||
#[interrupt(resources = [S2, O5])]
|
||||
fn UART1() {
|
||||
fn UART1(c: UART1::Context) {
|
||||
// owned by interrupt == `&` if read-only
|
||||
let _: &u32 = resources.O5;
|
||||
let _: &u32 = c.resources.O5;
|
||||
|
||||
// no `Mutex` proxy when co-owned by cooperative (same priority) tasks
|
||||
let _: Exclusive<u32> = resources.S2;
|
||||
let _: Exclusive<u32> = c.resources.S2;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
|
@ -5,52 +7,52 @@ extern crate lm3s6965;
|
|||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::{app, Instant};
|
||||
use rtfm::Instant;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
#[rtfm::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init(schedule = [foo, bar, baz])]
|
||||
fn init() {
|
||||
let _: Result<(), ()> = schedule.foo(start + 10.cycles());
|
||||
let _: Result<(), u32> = schedule.bar(start + 20.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = schedule.baz(start + 30.cycles(), 0, 1);
|
||||
fn init(c: init::Context) {
|
||||
let _: Result<(), ()> = c.schedule.foo(c.start + 10.cycles());
|
||||
let _: Result<(), u32> = c.schedule.bar(c.start + 20.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 30.cycles(), 0, 1);
|
||||
}
|
||||
|
||||
#[idle(schedule = [foo, bar, baz])]
|
||||
fn idle() -> ! {
|
||||
let _: Result<(), ()> = schedule.foo(Instant::now() + 40.cycles());
|
||||
let _: Result<(), u32> = schedule.bar(Instant::now() + 50.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = schedule.baz(Instant::now() + 60.cycles(), 0, 1);
|
||||
fn idle(c: idle::Context) -> ! {
|
||||
let _: Result<(), ()> = c.schedule.foo(Instant::now() + 40.cycles());
|
||||
let _: Result<(), u32> = c.schedule.bar(Instant::now() + 50.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = c.schedule.baz(Instant::now() + 60.cycles(), 0, 1);
|
||||
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[exception(schedule = [foo, bar, baz])]
|
||||
fn SVCall() {
|
||||
let _: Result<(), ()> = schedule.foo(start + 70.cycles());
|
||||
let _: Result<(), u32> = schedule.bar(start + 80.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = schedule.baz(start + 90.cycles(), 0, 1);
|
||||
fn SVCall(c: SVCall::Context) {
|
||||
let _: Result<(), ()> = c.schedule.foo(c.start + 70.cycles());
|
||||
let _: Result<(), u32> = c.schedule.bar(c.start + 80.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 90.cycles(), 0, 1);
|
||||
}
|
||||
|
||||
#[interrupt(schedule = [foo, bar, baz])]
|
||||
fn UART0() {
|
||||
let _: Result<(), ()> = schedule.foo(start + 100.cycles());
|
||||
let _: Result<(), u32> = schedule.bar(start + 110.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = schedule.baz(start + 120.cycles(), 0, 1);
|
||||
fn UART0(c: UART0::Context) {
|
||||
let _: Result<(), ()> = c.schedule.foo(c.start + 100.cycles());
|
||||
let _: Result<(), u32> = c.schedule.bar(c.start + 110.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 120.cycles(), 0, 1);
|
||||
}
|
||||
|
||||
#[task(schedule = [foo, bar, baz])]
|
||||
fn foo() {
|
||||
let _: Result<(), ()> = schedule.foo(scheduled + 130.cycles());
|
||||
let _: Result<(), u32> = schedule.bar(scheduled + 140.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = schedule.baz(scheduled + 150.cycles(), 0, 1);
|
||||
fn foo(c: foo::Context) {
|
||||
let _: Result<(), ()> = c.schedule.foo(c.scheduled + 130.cycles());
|
||||
let _: Result<(), u32> = c.schedule.bar(c.scheduled + 140.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = c.schedule.baz(c.scheduled + 150.cycles(), 0, 1);
|
||||
}
|
||||
|
||||
#[task]
|
||||
fn bar(_x: u32) {}
|
||||
fn bar(_: bar::Context, _x: u32) {}
|
||||
|
||||
#[task]
|
||||
fn baz(_x: u32, _y: u32) {}
|
||||
fn baz(_: baz::Context, _x: u32, _y: u32) {}
|
||||
|
||||
extern "C" {
|
||||
fn UART1();
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate owned_singleton;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::{app, Exclusive};
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[Singleton]
|
||||
static mut O1: u32 = 0;
|
||||
#[Singleton]
|
||||
static mut O2: u32 = 0;
|
||||
#[Singleton]
|
||||
static mut O3: u32 = 0;
|
||||
#[Singleton]
|
||||
static O4: u32 = 0;
|
||||
#[Singleton]
|
||||
static O5: u32 = 0;
|
||||
#[Singleton]
|
||||
static O6: u32 = 0;
|
||||
|
||||
#[Singleton]
|
||||
static mut S1: u32 = 0;
|
||||
#[Singleton]
|
||||
static S2: u32 = 0;
|
||||
|
||||
#[init(resources = [O1, O2, O3, O4, O5, O6, S1, S2])]
|
||||
fn init() {
|
||||
let _: O1 = resources.O1;
|
||||
let _: &mut O2 = resources.O2;
|
||||
let _: &mut O3 = resources.O3;
|
||||
let _: O4 = resources.O4;
|
||||
let _: &mut O5 = resources.O5;
|
||||
let _: &mut O6 = resources.O6;
|
||||
|
||||
let _: &mut S1 = resources.S1;
|
||||
let _: &mut S2 = resources.S2;
|
||||
}
|
||||
|
||||
#[idle(resources = [O2, O5])]
|
||||
fn idle() -> ! {
|
||||
let _: O2 = resources.O2;
|
||||
let _: O5 = resources.O5;
|
||||
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[interrupt(resources = [O3, O6, S1, S2])]
|
||||
fn UART0() {
|
||||
let _: &mut O3 = resources.O3;
|
||||
let _: &O6 = resources.O6;
|
||||
|
||||
let _: Exclusive<S1> = resources.S1;
|
||||
let _: &S2 = resources.S2;
|
||||
}
|
||||
|
||||
#[interrupt(resources = [S1, S2])]
|
||||
fn UART1() {
|
||||
let _: Exclusive<S1> = resources.S1;
|
||||
let _: &S2 = resources.S2;
|
||||
}
|
||||
};
|
|
@ -1,4 +1,6 @@
|
|||
//! Check code generation of `spawn`
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
|
@ -6,52 +8,50 @@ extern crate lm3s6965;
|
|||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
#[rtfm::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init(spawn = [foo, bar, baz])]
|
||||
fn init() {
|
||||
let _: Result<(), ()> = spawn.foo();
|
||||
let _: Result<(), u32> = spawn.bar(0);
|
||||
let _: Result<(), (u32, u32)> = spawn.baz(0, 1);
|
||||
fn init(c: init::Context) {
|
||||
let _: Result<(), ()> = c.spawn.foo();
|
||||
let _: Result<(), u32> = c.spawn.bar(0);
|
||||
let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);
|
||||
}
|
||||
|
||||
#[idle(spawn = [foo, bar, baz])]
|
||||
fn idle() -> ! {
|
||||
let _: Result<(), ()> = spawn.foo();
|
||||
let _: Result<(), u32> = spawn.bar(0);
|
||||
let _: Result<(), (u32, u32)> = spawn.baz(0, 1);
|
||||
fn idle(c: idle::Context) -> ! {
|
||||
let _: Result<(), ()> = c.spawn.foo();
|
||||
let _: Result<(), u32> = c.spawn.bar(0);
|
||||
let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);
|
||||
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[exception(spawn = [foo, bar, baz])]
|
||||
fn SVCall() {
|
||||
let _: Result<(), ()> = spawn.foo();
|
||||
let _: Result<(), u32> = spawn.bar(0);
|
||||
let _: Result<(), (u32, u32)> = spawn.baz(0, 1);
|
||||
fn SVCall(c: SVCall::Context) {
|
||||
let _: Result<(), ()> = c.spawn.foo();
|
||||
let _: Result<(), u32> = c.spawn.bar(0);
|
||||
let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);
|
||||
}
|
||||
|
||||
#[interrupt(spawn = [foo, bar, baz])]
|
||||
fn UART0() {
|
||||
let _: Result<(), ()> = spawn.foo();
|
||||
let _: Result<(), u32> = spawn.bar(0);
|
||||
let _: Result<(), (u32, u32)> = spawn.baz(0, 1);
|
||||
fn UART0(c: UART0::Context) {
|
||||
let _: Result<(), ()> = c.spawn.foo();
|
||||
let _: Result<(), u32> = c.spawn.bar(0);
|
||||
let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);
|
||||
}
|
||||
|
||||
#[task(spawn = [foo, bar, baz])]
|
||||
fn foo() {
|
||||
let _: Result<(), ()> = spawn.foo();
|
||||
let _: Result<(), u32> = spawn.bar(0);
|
||||
let _: Result<(), (u32, u32)> = spawn.baz(0, 1);
|
||||
fn foo(c: foo::Context) {
|
||||
let _: Result<(), ()> = c.spawn.foo();
|
||||
let _: Result<(), u32> = c.spawn.bar(0);
|
||||
let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);
|
||||
}
|
||||
|
||||
#[task]
|
||||
fn bar(_x: u32) {}
|
||||
fn bar(_: bar::Context, _x: u32) {}
|
||||
|
||||
#[task]
|
||||
fn baz(_x: u32, _y: u32) {}
|
||||
fn baz(_: baz::Context, _x: u32, _y: u32) {}
|
||||
|
||||
extern "C" {
|
||||
fn UART1();
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
//! Check code generation of `unsafe` `init` / `idle` / `exception` / `interrupt` / `task`
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate lm3s6965;
|
||||
extern crate panic_halt;
|
||||
extern crate rtfm;
|
||||
|
||||
use rtfm::app;
|
||||
|
||||
unsafe fn foo() {}
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
unsafe fn init() {
|
||||
foo();
|
||||
}
|
||||
|
||||
#[idle]
|
||||
unsafe fn idle() -> ! {
|
||||
foo();
|
||||
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[exception]
|
||||
unsafe fn SVCall() {
|
||||
foo();
|
||||
}
|
||||
|
||||
#[interrupt]
|
||||
unsafe fn UART0() {
|
||||
foo();
|
||||
}
|
||||
|
||||
#[task]
|
||||
unsafe fn bar() {
|
||||
foo();
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
fn UART1();
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue