From 39c111a59a077da8d8ea310a45aac4bf78242692 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 25 Apr 2017 09:29:29 -0500 Subject: [PATCH] change tasks! syntax to resemble struct initialization --- src/lib.rs | 6 +++++- tests/cfail/tasks-p0.rs | 6 +++++- tests/cfail/tasks-same-handler.rs | 12 ++++++++++-- tests/cfail/tasks-wrong-idle.rs | 6 +++++- tests/cfail/tasks-wrong-init.rs | 6 +++++- tests/cfail/tasks-wrong-priority.rs | 6 +++++- tests/cfail/tasks-wrong-task.rs | 6 +++++- 7 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8a3b330839..04a95a1248 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -699,7 +699,11 @@ pub unsafe trait LessThanOrEqual {} #[macro_export] macro_rules! tasks { ($device:ident, { - $($task:ident: ($Interrupt:ident, $P:ident, $enabled:expr),)* + $($task:ident: Task { + interrupt:$Interrupt:ident, + priority: $P:ident, + enabled: $enabled:expr, + },)* }) => { fn main() { $crate::critical(|cmax| { diff --git a/tests/cfail/tasks-p0.rs b/tests/cfail/tasks-p0.rs index 4db3d3895e..521db54584 100644 --- a/tests/cfail/tasks-p0.rs +++ b/tests/cfail/tasks-p0.rs @@ -11,7 +11,11 @@ use device::interrupt::Exti0; // WRONG: Tasks can't have a priority of 0. // Only idle and init can have a priority of 0. tasks!(device, { - j1: (Exti0, P0), + j1: Task { + interrupt: Exti0, + priority: P0, + enabled: true, + }, }); fn init(_: P0, _: &C16) {} diff --git a/tests/cfail/tasks-same-handler.rs b/tests/cfail/tasks-same-handler.rs index 89e20121bf..457ff55e91 100644 --- a/tests/cfail/tasks-same-handler.rs +++ b/tests/cfail/tasks-same-handler.rs @@ -10,8 +10,16 @@ use device::interrupt::Exti0; // WRONG: Two tasks mapped to the same interrupt handler tasks!(device, { - j1: (Exti0, P1), - j2: (Exti0, P2), + j1: Task { + interrupt: Exti0, + priority: P1, + enabled: true, + }, + j2: Task { + interrupt: Exti0, + priority: P2, + enabled: true, + }, }); fn init(_: P0, _: &C16) {} diff --git a/tests/cfail/tasks-wrong-idle.rs b/tests/cfail/tasks-wrong-idle.rs index 4ee910ee84..9c247a94ad 100644 --- a/tests/cfail/tasks-wrong-idle.rs +++ b/tests/cfail/tasks-wrong-idle.rs @@ -9,7 +9,11 @@ use device::interrupt::Exti0; use rtfm::{C16, P0, P1}; tasks!(device, { - j1: (Exti0, P1), + j1: Task { + interrupt: Exti0, + priority: P1, + enabled: true, + }, }); fn init(_: P0, _: &C16) {} diff --git a/tests/cfail/tasks-wrong-init.rs b/tests/cfail/tasks-wrong-init.rs index 0f6e1c1e1c..ab82234dd7 100644 --- a/tests/cfail/tasks-wrong-init.rs +++ b/tests/cfail/tasks-wrong-init.rs @@ -9,7 +9,11 @@ use rtfm::{C1, P0, P1}; use device::interrupt::Exti0; tasks!(device, { - j1: (Exti0, P1), + j1: Task { + interrupt: Exti0, + priority: P1, + enabled: true, + }, }); // WRONG. `init` must have signature `fn(P0, &C16)` diff --git a/tests/cfail/tasks-wrong-priority.rs b/tests/cfail/tasks-wrong-priority.rs index 75cbc0cc40..827acdde9e 100644 --- a/tests/cfail/tasks-wrong-priority.rs +++ b/tests/cfail/tasks-wrong-priority.rs @@ -9,7 +9,11 @@ use cortex_m_srp::{C16, P0, P1, P2}; use device::interrupt::Exti1; tasks!(device, { - j1: (Exti0, P1), + j1: Task { + interrupt: Exti0, + priority: P1, + enabled: true, + }, }); fn init(_: P0, _: &C16) {} diff --git a/tests/cfail/tasks-wrong-task.rs b/tests/cfail/tasks-wrong-task.rs index 0200da2d18..479c223fcd 100644 --- a/tests/cfail/tasks-wrong-task.rs +++ b/tests/cfail/tasks-wrong-task.rs @@ -9,7 +9,11 @@ use cortex_mrtfm::{C16, P0, P1}; use device::interrupt::Exti1; tasks!(device, { - j1: (Exti0, P1), + j1: Task { + interrupt: Exti0, + priority: P1, + enabled: true, + }, }); fn init(_: P0, _: &C16) {}