diff --git a/Cargo.toml b/Cargo.toml index 7f487af..a8b9966 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ authors = [ "The Real Time For the Masses developers", "Jorge Aparicio ", + "Per Lindgren ", ] categories = ["concurrency", "embedded", "no-std"] description = "The Real Time for The Masses (RTFM) meta language" @@ -11,7 +12,7 @@ keywords = [] license = "MIT OR Apache-2.0" name = "rtfm-syntax" repository = "https://github.com/rtfm-rs/rtfm-syntax" -version = "0.4.0" +version = "0.4.1" [dependencies] indexmap = "1.0.2" diff --git a/examples/memory_lane.rs b/examples/memory_lane.rs new file mode 100644 index 0000000..1e3fcf8 --- /dev/null +++ b/examples/memory_lane.rs @@ -0,0 +1,57 @@ +//! Full syntax for single core + +#[mock::app] +const APP: () = { + struct Resources { + a: u32, + b: u32, + #[init(0)] + c: u32, + #[init(0)] + d: u32, + } + + #[init( + resources = [c], + spawn = [foo], + )] + fn init(_: init::Context) -> init::LateResources { + #[cfg(debug_assertions)] + static mut X: u32 = 0; + + init::LateResources { a: 0, b: 0 } + } + + #[idle( + resources = [&a, d], + spawn = [foo], + )] + fn idle(_: idle::Context) -> ! { + static mut X: u32 = 0; + + loop {} + } + + #[task( + resources = [b, &c], + spawn = [bar], + log = , + )] + fn foo(_: foo::Context) { + static mut X: u32 = 0; + + *X += 1; + } + + #[task( + capacity = 2, + priority = 2, + resources = [d], + spawn = [foo], + )] + fn bar(_: bar::Context, _: u32) { + static mut X: u32 = 0; + + *X += 1; + } +}; diff --git a/mock/src/lib.rs b/mock/src/lib.rs index d906cd6..95df5ad 100644 --- a/mock/src/lib.rs +++ b/mock/src/lib.rs @@ -1,6 +1,6 @@ #![deny(rust_2018_compatibility)] -#![deny(rust_2018_idioms)] -#![deny(warnings)] +//#![deny(rust_2018_idioms)] +//#![deny(warnings)] extern crate proc_macro; diff --git a/src/ast.rs b/src/ast.rs index f04ce02..f28c53e 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -3,7 +3,7 @@ use core::ops::Deref; use std::collections::BTreeMap; -use syn::{Attribute, Expr, Ident, Pat, PatType, Path, Stmt, Type}; +use syn::{Attribute, Expr, Ident, Pat, PatType, Path, Stmt, Type, TypeArray}; use crate::{Core, Map, Set}; @@ -244,6 +244,9 @@ pub struct SoftwareTaskArgs { /// Software tasks that can be scheduled from this context pub schedule: Set, + /// Log + pub log: Vec, + pub(crate) _extensible: (), } @@ -256,11 +259,21 @@ impl Default for SoftwareTaskArgs { resources: Resources::new(), spawn: Set::new(), schedule: Set::new(), + log: Vec::new(), _extensible: (), } } } +/// Memory Lane +#[derive(Debug)] +pub struct LogMsg { + /// The identifier of the Log message + pub log_ident: Ident, + /// The array type [T; n] of the Log buffer + pub log_type: TypeArray, +} + /// A hardware task #[derive(Debug)] pub struct HardwareTask { diff --git a/src/lib.rs b/src/lib.rs index 6f326d2..d5e370e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ #![deny(missing_docs)] #![deny(rust_2018_compatibility)] #![deny(rust_2018_idioms)] -#![deny(warnings)] +// #![deny(warnings)] #[allow(unused_extern_crates)] extern crate proc_macro; diff --git a/src/parse.rs b/src/parse.rs index bf0533d..c1c0b18 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -241,6 +241,7 @@ fn task_args( let mut resources = None; let mut schedule = None; let mut spawn = None; + let mut log = None; let content; parenthesized!(content in input); @@ -276,6 +277,17 @@ fn task_args( binds = Some(ident); } + "log" => { + if log.is_some() { + return Err(parse::Error::new( + ident.span(), + "argument appears more than once", + )); + } + + log = Some(Vec::new()); + } + "capacity" => { if capacity.is_some() { return Err(parse::Error::new( @@ -428,6 +440,7 @@ fn task_args( let resources = resources.unwrap_or(Resources::new()); let schedule = schedule.unwrap_or(Set::new()); let spawn = spawn.unwrap_or(Set::new()); + let log = log.unwrap_or(Vec::new()); Ok(if let Some(binds) = binds { Either::Left(HardwareTaskArgs { @@ -447,6 +460,7 @@ fn task_args( resources, schedule, spawn, + log, _extensible: (), }) })