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

59
macros/src/tests/multi.rs Normal file
View file

@ -0,0 +1,59 @@
use quote::quote;
use rtfm_syntax::Settings;
#[test]
fn analyze() {
let (app, analysis) = rtfm_syntax::parse2(
quote!(device = pac, cores = 2),
quote!(
const APP: () = {
#[task(core = 0, priority = 1)]
fn a(_: a::Context) {}
#[task(core = 0, priority = 2)]
fn b(_: b::Context) {}
#[task(core = 1, priority = 1)]
fn c(_: c::Context) {}
#[task(core = 1, priority = 2)]
fn d(_: d::Context) {}
// first interrupt is assigned to the highest priority dispatcher
extern "C" {
#[core = 0]
fn B();
#[core = 0]
fn A();
#[core = 1]
fn A();
#[core = 1]
fn C();
}
};
),
Settings {
parse_cores: true,
parse_extern_interrupt: true,
..Settings::default()
},
)
.unwrap();
let analysis = crate::analyze::app(analysis, &app);
// first core
let interrupts0 = &analysis.interrupts[&0];
assert_eq!(interrupts0.len(), 2);
assert_eq!(interrupts0[&2].to_string(), "B");
assert_eq!(interrupts0[&1].to_string(), "A");
// second core
let interrupts1 = &analysis.interrupts[&1];
assert_eq!(interrupts1.len(), 2);
assert_eq!(interrupts1[&2].to_string(), "A");
assert_eq!(interrupts1[&1].to_string(), "C");
}

View file

@ -0,0 +1,35 @@
use quote::quote;
use rtfm_syntax::Settings;
#[test]
fn analyze() {
let (app, analysis) = rtfm_syntax::parse2(
quote!(device = pac),
quote!(
const APP: () = {
#[task(priority = 1)]
fn a(_: a::Context) {}
#[task(priority = 2)]
fn b(_: b::Context) {}
// first interrupt is assigned to the highest priority dispatcher
extern "C" {
fn B();
fn A();
}
};
),
Settings {
parse_extern_interrupt: true,
..Settings::default()
},
)
.unwrap();
let analysis = crate::analyze::app(analysis, &app);
let interrupts = &analysis.interrupts[&0];
assert_eq!(interrupts.len(), 2);
assert_eq!(interrupts[&2].to_string(), "B");
assert_eq!(interrupts[&1].to_string(), "A");
}