This commit is contained in:
Emil Fresk 2020-12-12 23:31:05 +01:00
parent 8e8ec9b7b8
commit 1c8de78f6f
4 changed files with 15 additions and 22 deletions

View file

@ -15,8 +15,7 @@ mod app {
type MyMono2 = hal::Mono2; type MyMono2 = hal::Mono2;
#[init] #[init]
fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) { fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) {}
}
#[task] #[task]
fn task1(_: task1::Context) {} fn task1(_: task1::Context) {}
@ -24,4 +23,3 @@ mod app {
#[task] #[task]
fn task2(_: task2::Context) {} fn task2(_: task2::Context) {}
} }

View file

@ -104,11 +104,15 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
)); ));
} }
let monotonic_imports: Vec<_> = app.monotonics.iter().map(|(_, monotonic)| { let monotonic_imports: Vec<_> = app
.monotonics
.iter()
.map(|(_, monotonic)| {
let name = &monotonic.ident; let name = &monotonic.ident;
let ty = &monotonic.ty; let ty = &monotonic.ty;
quote!(pub type #name = #ty;) quote!(pub type #name = #ty;)
}).collect(); })
.collect();
quote!( quote!(
/// Implementation details /// Implementation details

View file

@ -29,16 +29,6 @@ pub fn codegen(
let mut user_tasks = vec![]; let mut user_tasks = vec![];
for (name, task) in &app.hardware_tasks { for (name, task) in &app.hardware_tasks {
// let (let_instant, instant) = if let Some(ref m) = extra.monotonic {
// (
// Some(quote!(let instant = <#m as rtic::Monotonic>::now();)),
// Some(quote!(, instant)),
// )
// } else {
// (None, None)
// };
let (let_instant, instant) = (quote!(), quote!());
let locals_new = if task.locals.is_empty() { let locals_new = if task.locals.is_empty() {
quote!() quote!()
} else { } else {
@ -56,12 +46,10 @@ pub fn codegen(
unsafe fn #symbol() { unsafe fn #symbol() {
const PRIORITY: u8 = #priority; const PRIORITY: u8 = #priority;
#let_instant
rtic::export::run(PRIORITY, || { rtic::export::run(PRIORITY, || {
#app_path::#name( #app_path::#name(
#locals_new #locals_new
#name::Context::new(&rtic::export::Priority::new(PRIORITY) #instant) #name::Context::new(&rtic::export::Priority::new(PRIORITY))
) )
}); });
} }

View file

@ -78,7 +78,10 @@ pub fn inputs_ident(task: &Ident) -> Ident {
/// Generates an identifier for the `INSTANTS` buffer (`schedule` API) /// Generates an identifier for the `INSTANTS` buffer (`schedule` API)
pub fn monotonic_instants_ident(task: &Ident, monotonic: &Ident) -> Ident { pub fn monotonic_instants_ident(task: &Ident, monotonic: &Ident) -> Ident {
Ident::new(&format!("{}_{}_INSTANTS", task, monotonic), Span::call_site()) Ident::new(
&format!("{}_{}_INSTANTS", task, monotonic),
Span::call_site(),
)
} }
pub fn interrupt_ident() -> Ident { pub fn interrupt_ident() -> Ident {