rtfm-syntax refactor + heterogeneous multi-core support

This commit is contained in:
Jorge Aparicio 2019-06-13 23:56:59 +02:00
parent fafeeb2727
commit 81275bfa4f
127 changed files with 4072 additions and 5848 deletions

View file

@ -1,64 +0,0 @@
#![no_main]
#![no_std]
extern crate lm3s6965;
extern crate panic_halt;
extern crate rtfm;
use rtfm::app;
#[app(device = lm3s6965)]
const APP: () = {
#[cfg(never)]
static mut O1: u32 = 0; // init
#[cfg(never)]
static mut O2: u32 = 0; // idle
#[cfg(never)]
static mut O3: u32 = 0; // EXTI0
#[cfg(never)]
static O4: u32 = 0; // idle
#[cfg(never)]
static O5: u32 = 0; // EXTI1
#[cfg(never)]
static O6: u32 = 0; // init
#[cfg(never)]
static mut S1: u32 = 0; // idle & EXTI0
#[cfg(never)]
static mut S2: u32 = 0; // EXTI0 & EXTI1
#[cfg(never)]
static S3: u32 = 0;
#[init(resources = [O1, O4, O5, O6, S3])]
fn init(c: init::Context) {
c.resources.O1; //~ ERROR no field `O1`
c.resources.O4; //~ ERROR no field `O4`
c.resources.O5; //~ ERROR no field `O5`
c.resources.O6; //~ ERROR no field `O6`
c.resources.S3; //~ ERROR no field `S3`
}
#[idle(resources = [O2, O4, S1, S3])]
fn idle(c: idle::Context) -> ! {
c.resources.O2; //~ ERROR no field `O2`
c.resources.O4; //~ ERROR no field `O4`
c.resources.S1; //~ ERROR no field `S1`
c.resources.S3; //~ ERROR no field `S3`
loop {}
}
#[interrupt(resources = [O3, S1, S2, S3])]
fn UART0(c: UART0::Context) {
c.resources.O3; //~ ERROR no field `O3`
c.resources.S1; //~ ERROR no field `S1`
c.resources.S2; //~ ERROR no field `S2`
c.resources.S3; //~ ERROR no field `S3`
}
#[interrupt(resources = [S2, O5])]
fn UART1(c: UART1::Context) {
c.resources.S2; //~ ERROR no field `S2`
c.resources.O5; //~ ERROR no field `O5`
}
};

View file

@ -1,57 +0,0 @@
#![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(_: init::Context) {
#[cfg(never)]
static mut FOO: u32 = 0;
FOO; //~ ERROR cannot find value `FOO` in this scope
}
#[idle]
fn idle(_: idle::Context) -> ! {
#[cfg(never)]
static mut FOO: u32 = 0;
FOO; //~ ERROR cannot find value `FOO` in this scope
loop {}
}
#[exception]
fn SVCall(_: SVCall::Context) {
#[cfg(never)]
static mut FOO: u32 = 0;
FOO; //~ ERROR cannot find value `FOO` in this scope
}
#[interrupt]
fn UART0(_: UART0::Context) {
#[cfg(never)]
static mut FOO: u32 = 0;
FOO; //~ ERROR cannot find value `FOO` in this scope
}
#[task]
fn foo(_: foo::Context) {
#[cfg(never)]
static mut FOO: u32 = 0;
FOO; //~ ERROR cannot find value `FOO` in this scope
}
extern "C" {
fn UART1();
}
};

View file

@ -1,24 +0,0 @@
#![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(_: init::Context) {}
#[task(
priority = 1,
priority = 2, //~ ERROR argument appears more than once
)]
fn foo(_: foo::Context) {}
extern "C" {
fn UART0();
}
};

View file

@ -1,24 +0,0 @@
#![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(_: init::Context) {}
#[task(
capacity = 1,
capacity = 2, //~ ERROR argument appears more than once
)]
fn foo(_: foo::Context) {}
extern "C" {
fn UART0();
}
};

View file

@ -1,20 +0,0 @@
#![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(_: init::Context) {}
#[exception]
fn SVCall(_: SVCall::Context) -> ! {
//~^ ERROR this `exception` handler must have type signature `fn(SVCall::Context)`
loop {}
}
};

View file

@ -1,19 +0,0 @@
#![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(_: init::Context) {}
#[exception]
fn SVCall(_: SVCall::Context, undef: u32) {
//~^ ERROR this `exception` handler must have type signature `fn(SVCall::Context)`
}
};

View file

@ -1,19 +0,0 @@
#![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(_: init::Context) {}
#[exception]
fn NonMaskableInt(_: NonMaskableInt::Context) {
//~^ ERROR only exceptions with configurable priority can be used as hardware tasks
}
};

View file

@ -1,20 +0,0 @@
#![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(_: init::Context) {}
#[exception]
fn SVCall(_: SVCall::Context) -> u32 {
//~^ ERROR this `exception` handler must have type signature `fn(SVCall::Context)`
0
}
};

View file

@ -1,19 +0,0 @@
#![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(_: init::Context) {}
#[exception]
fn SysTick(_: SysTick::Context) {
//~^ ERROR the `SysTick` exception can't be used because it's used by the runtime
}
};

View file

@ -1,19 +0,0 @@
#![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(_: init::Context) {}
#[idle]
fn idle(_: idle::Context, undef: u32) {
//~^ ERROR `idle` must have type signature `fn(idle::Context) -> !`
}
};

View file

@ -1,19 +0,0 @@
#![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(_: init::Context) {}
#[idle]
fn idle(_: idle::Context) {
//~^ ERROR `idle` must have type signature `fn(idle::Context) -> !`
}
};

View file

@ -1,17 +0,0 @@
#![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(_: init::Context) -> ! {
//~^ ERROR `init` must have type signature `fn(init::Context) [-> init::LateResources]`
loop {}
}
};

View file

@ -1,15 +0,0 @@
#![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(_: init::Context) -> init::LateResources {}
//~^ error: `init` signature must be `fn(init::Context)` if there are no late resources
};

View file

@ -1,16 +0,0 @@
#![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(_: init::Context, undef: u32) {
//~^ ERROR `init` must have type signature `fn(init::Context) [-> init::LateResources]`
}
};

View file

@ -1,17 +0,0 @@
#![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: i32 = ();
#[init]
fn init(_: init::Context) {}
//~^ error: late resources have been specified so `init` must return `init::LateResources`
};

View file

@ -1,29 +0,0 @@
//! This is equivalent to the `late-not-send` cfail test
#![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(c: init::Context) {
*c.resources.X = Some(NotSend { _0: PhantomData })
}
#[interrupt(resources = [X])]
fn UART0(_: UART0::Context) {}
};

View file

@ -1,17 +0,0 @@
#![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(_: init::Context) -> u32 {
//~^ ERROR `init` must have type signature `fn(init::Context) [-> init::LateResources]`
0
}
};

View file

@ -1,17 +0,0 @@
#![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(_: init::Context) {}
#[task]
fn foo(_: foo::Context) {}
};

View file

@ -1,20 +0,0 @@
#![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(_: init::Context) {}
#[interrupt]
fn UART0(_: UART0::Context) -> ! {
//~^ ERROR this `interrupt` handler must have type signature `fn(UART0::Context)`
loop {}
}
};

View file

@ -1,19 +0,0 @@
#![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(_: init::Context) {}
#[interrupt]
fn UART0(_: UART0::Context, undef: u32) {
//~^ ERROR this `interrupt` handler must have type signature `fn(UART0::Context)`
}
};

View file

@ -1,20 +0,0 @@
#![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(_: init::Context) {}
#[interrupt]
fn UART0(_: UART0::Context) -> u32 {
//~^ ERROR this `interrupt` handler must have type signature `fn(UART0::Context)`
0
}
};

View file

@ -1,16 +0,0 @@
#![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(_: init::Context) {}
};

View file

@ -1,32 +0,0 @@
//! `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
#![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(_: init::Context) -> init::LateResources {
init::LateResources {
X: NotSend { _0: PhantomData },
}
}
#[interrupt(resources = [X])]
fn UART0(_: UART0::Context) {}
};

View file

@ -1,29 +0,0 @@
#![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(_: init::Context) {}
#[task]
fn foo(_: foo::Context, _x: NotSend) {}
extern "C" {
fn UART0();
}
};

View file

@ -1,35 +0,0 @@
#![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(_: init::Context) {}
#[task(priority = 1, resources = [X])]
fn foo(_: foo::Context) {}
#[task(priority = 2, resources = [X])]
fn bar(_: bar::Context) {}
extern "C" {
fn UART0();
fn UART1();
}
};

View file

@ -1,22 +0,0 @@
#![no_main]
#![no_std]
extern crate lm3s6965;
extern crate panic_halt;
extern crate rtfm;
use rtfm::app;
#[app(device = lm3s6965)] //~ error evaluation of constant value failed
const APP: () = {
#[init]
fn init(_: init::Context) {}
// OK, this is the maximum priority supported by the device
#[interrupt(priority = 8)]
fn UART0(_: UART0::Context) {}
// this value is too high!
#[interrupt(priority = 9)]
fn UART1(_: UART1::Context) {}
};

View file

@ -1,22 +0,0 @@
#![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(_: init::Context) {}
// OK, this is the minimum priority that tasks can have
#[interrupt(priority = 1)]
fn UART0(_: UART0::Context) {}
// this value is too low!
#[interrupt(priority = 0)] //~ error this literal must be in the range 1...255
fn UART1(_: UART1::Context) {}
};

View file

@ -1,14 +0,0 @@
#![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(_: init::Context) {}
};

View file

@ -1,17 +0,0 @@
#![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(_: init::Context) {}
};

View file

@ -1,22 +0,0 @@
#![no_main]
#![no_std]
extern crate lm3s6965;
extern crate panic_halt;
extern crate rtfm;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[init]
fn init(_: init::Context) {}
#[task]
fn foo(_: foo::Context) -> ! {
//~^ ERROR this `task` handler must have type signature `fn(foo::Context, ..)`
loop {}
}
extern "C" {
fn UART0();
}
};

View file

@ -1,23 +0,0 @@
#![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(_: init::Context) {}
#[task]
fn idle(_: idle::Context) {
//~^ ERROR `task` handlers can NOT be named `idle`, `init` or `resources`
}
extern "C" {
fn UART0();
}
};

View file

@ -1,14 +0,0 @@
#![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(_: init::Context) {}
};

View file

@ -1,18 +0,0 @@
#![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(_: init::Context) {}
#[exception(binds = SVCall)]
unsafe fn foo(_: foo::Context) {}
//~^ ERROR this `exception` handler must have type signature `fn(foo::Context)`
};

View file

@ -1,20 +0,0 @@
#![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(_: init::Context) {}
#[idle]
unsafe fn idle(_: idle::Context) -> ! {
//~^ ERROR `idle` must have type signature `fn(idle::Context) -> !`
loop {}
}
};

View file

@ -1,15 +0,0 @@
#![no_main]
#![no_std]
extern crate lm3s6965;
extern crate panic_halt;
extern crate rtfm;
use rtfm::app;
#[app(device = lm3s6965)]
const APP: () = {
#[init]
unsafe fn init(_: init::Context) {}
//~^ ERROR `init` must have type signature `fn(init::Context) [-> init::LateResources]`
};

View file

@ -1,18 +0,0 @@
#![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(_: init::Context) {}
#[interrupt(binds = UART0)]
unsafe fn foo(_: foo::Context) {}
//~^ ERROR this `interrupt` handler must have type signature `fn(foo::Context)`
};

View file

@ -1,22 +0,0 @@
#![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(_: init::Context) {}
#[task]
unsafe fn foo(_: foo::Context) {}
//~^ ERROR this `task` handler must have type signature `fn(foo::Context, ..)`
extern "C" {
fn UART0();
}
};

View file

@ -1,21 +0,0 @@
#![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(_: init::Context) {}
#[interrupt(binds = UART0)] //~ ERROR free interrupts (`extern { .. }`) can't be used as interrupt handlers
fn foo(_: foo::Context) {}
extern "C" {
fn UART0();
}
};

View file

@ -1,22 +0,0 @@
#![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(_: init::Context) {}
#[interrupt]
fn UART0(_: UART0::Context) {}
//~^ ERROR free interrupts (`extern { .. }`) can't be used as interrupt handlers
extern "C" {
fn UART0();
}
};

View file

@ -1,57 +0,0 @@
use std::{fs, path::PathBuf, process::Command};
use compiletest_rs::{common::Mode, Config};
use tempdir::TempDir;
#[test]
fn cfail() {
let mut config = Config::default();
config.mode = Mode::CompileFail;
config.src_base = PathBuf::from("tests/cfail");
config.link_deps();
// remove duplicate and trailing `-L` flags
let mut s = String::new();
if let Some(flags) = config.target_rustcflags.as_mut() {
let mut iter = flags.split_whitespace().peekable();
while let Some(flag) = iter.next() {
if flag == "-L" && (iter.peek() == Some(&"-L") || iter.peek() == None) {
iter.next();
continue;
}
s += flag;
s += " ";
}
// path to proc-macro crate
s += "-L target/debug/deps ";
// avoid "error: language item required, but not found: `eh_personality`"
s += "-C panic=abort ";
}
let td = TempDir::new("rtfm").unwrap();
for f in fs::read_dir("tests/cpass").unwrap() {
let f = f.unwrap().path();
let name = f.file_stem().unwrap().to_str().unwrap();
assert!(Command::new("rustc")
.args(s.split_whitespace())
.arg(f.display().to_string())
.arg("-o")
.arg(td.path().join(name).display().to_string())
.arg("-C")
.arg("linker=true")
.status()
.unwrap()
.success());
}
config.target_rustcflags = Some(s);
config.clean_rmeta();
compiletest_rs::run_tests(&config);
}

View file

@ -1,31 +0,0 @@
//! Check that `binds` works as advertised
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
extern crate lm3s6965;
extern crate panic_halt;
extern crate rtfm;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[init]
fn init(_: init::Context) {}
#[exception(binds = SVCall)]
fn foo(c: foo::Context) {
foo_trampoline(c)
}
#[interrupt(binds = UART0)]
fn bar(c: bar::Context) {
bar_trampoline(c)
}
};
#[allow(dead_code)]
fn foo_trampoline(_: foo::Context) {}
#[allow(dead_code)]
fn bar_trampoline(_: bar::Context) {}

View file

@ -1,51 +0,0 @@
//! Compile-pass test that checks that `#[cfg]` attributes are respected
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
extern crate lm3s6965;
extern crate panic_halt;
extern crate rtfm;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[cfg(never)]
static mut FOO: u32 = 0;
#[init]
fn init(_: init::Context) {
#[cfg(never)]
static mut BAR: u32 = 0;
}
#[idle]
fn idle(_: idle::Context) -> ! {
#[cfg(never)]
static mut BAR: u32 = 0;
loop {}
}
#[task(resources = [FOO], schedule = [quux], spawn = [quux])]
fn foo(_: foo::Context) {
#[cfg(never)]
static mut BAR: u32 = 0;
}
#[task(priority = 3, resources = [FOO], schedule = [quux], spawn = [quux])]
fn bar(_: bar::Context) {
#[cfg(never)]
static mut BAR: u32 = 0;
}
#[cfg(never)]
#[task]
fn quux(_: quux::Context) {}
extern "C" {
fn UART0();
fn UART1();
}
};

View file

@ -1,34 +0,0 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
extern crate lm3s6965;
extern crate panic_halt;
extern crate rtfm;
use core::marker::PhantomData;
pub struct NotSend {
_0: PhantomData<*const ()>,
}
#[rtfm::app(device = lm3s6965)]
const APP: () = {
static mut X: NotSend = ();
static mut Y: Option<NotSend> = None;
#[init(resources = [Y])]
fn init(c: init::Context) -> init::LateResources {
*c.resources.Y = Some(NotSend { _0: PhantomData });
init::LateResources {
X: NotSend { _0: PhantomData },
}
}
#[idle(resources = [X, Y])]
fn idle(_: idle::Context) -> ! {
loop {}
}
};

View file

@ -1,20 +0,0 @@
//! Runtime initialized resources
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
extern crate lm3s6965;
extern crate panic_halt;
extern crate rtfm;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
static mut X: u32 = ();
static Y: u32 = ();
#[init]
fn init(_: init::Context) -> init::LateResources {
init::LateResources { X: 0, Y: 1 }
}
};

View file

@ -1,18 +0,0 @@
//! Core and device peripherals
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
extern crate lm3s6965;
extern crate panic_halt;
extern crate rtfm;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[init]
fn init(c: init::Context) {
let _: rtfm::Peripherals = c.core;
let _: lm3s6965::Peripherals = c.device;
}
};

View file

@ -1,81 +0,0 @@
//! Check code generation of resources
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
extern crate lm3s6965;
extern crate panic_halt;
extern crate rtfm;
use rtfm::Exclusive;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
static mut O1: u32 = 0; // init
static mut O2: u32 = 0; // idle
static mut O3: u32 = 0; // EXTI0
static O4: u32 = 0; // idle
static O5: u32 = 0; // EXTI1
static O6: u32 = 0; // init
static mut S1: u32 = 0; // idle & EXTI0
static mut S2: u32 = 0; // EXTI0 & EXTI1
static S3: u32 = 0;
#[init(resources = [O1, O4, O5, O6, S3])]
fn init(c: init::Context) {
// owned by `init` == `&'static mut`
let _: &'static mut u32 = c.resources.O1;
// owned by `init` == `&'static` if read-only
let _: &'static u32 = c.resources.O6;
// `init` has exclusive access to all resources
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(mut c: idle::Context) -> ! {
// owned by `idle` == `&'static mut`
let _: &'static mut u32 = c.resources.O2;
// owned by `idle` == `&'static` if read-only
let _: &'static u32 = c.resources.O4;
// shared with `idle` == `Mutex`
c.resources.S1.lock(|_| {});
// `&` if read-only
let _: &u32 = c.resources.S3;
loop {}
}
#[interrupt(resources = [O3, S1, S2, S3])]
fn UART0(c: UART0::Context) {
// owned by interrupt == `&mut`
let _: &mut u32 = c.resources.O3;
// no `Mutex` proxy when access from highest priority task
let _: Exclusive<u32> = c.resources.S1;
// no `Mutex` proxy when co-owned by cooperative (same priority) tasks
let _: Exclusive<u32> = c.resources.S2;
// `&` if read-only
let _: &u32 = c.resources.S3;
}
#[interrupt(resources = [S2, O5])]
fn UART1(c: UART1::Context) {
// owned by interrupt == `&` if read-only
let _: &u32 = c.resources.O5;
// no `Mutex` proxy when co-owned by cooperative (same priority) tasks
let _: Exclusive<u32> = c.resources.S2;
}
};

View file

@ -1,60 +0,0 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
extern crate lm3s6965;
extern crate panic_halt;
extern crate rtfm;
use rtfm::Instant;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[init(schedule = [foo, bar, baz])]
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(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(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(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(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(_: bar::Context, _x: u32) {}
#[task]
fn baz(_: baz::Context, _x: u32, _y: u32) {}
extern "C" {
fn UART1();
}
};

View file

@ -1,59 +0,0 @@
//! Check code generation of `spawn`
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
extern crate lm3s6965;
extern crate panic_halt;
extern crate rtfm;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[init(spawn = [foo, bar, baz])]
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(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(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(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(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(_: bar::Context, _x: u32) {}
#[task]
fn baz(_: baz::Context, _x: u32, _y: u32) {}
extern "C" {
fn UART1();
}
};

16
tests/multi.rs Normal file
View file

@ -0,0 +1,16 @@
use std::path::PathBuf;
use compiletest_rs::{common::Mode, Config};
#[test]
fn ui() {
let mut config = Config::default();
config.mode = Mode::Ui;
config.src_base = PathBuf::from("ui/multi");
config.target_rustcflags = Some("--edition=2018 -Z unstable-options --extern rtfm".to_owned());
config.link_deps();
config.clean_rmeta();
compiletest_rs::run_tests(&config);
}

17
tests/single.rs Normal file
View file

@ -0,0 +1,17 @@
use std::path::PathBuf;
use compiletest_rs::{common::Mode, Config};
#[test]
fn ui() {
let mut config = Config::default();
config.mode = Mode::Ui;
config.src_base = PathBuf::from("ui/single");
config.target_rustcflags =
Some("--edition=2018 -L target/debug/deps -Z unstable-options --extern rtfm --extern lm3s6965".to_owned());
config.link_deps();
config.clean_rmeta();
compiletest_rs::run_tests(&config);
}