mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-30 15:34:33 +01:00
change tasks! syntax to resemble struct initialization
This commit is contained in:
parent
62356da0be
commit
39c111a59a
7 changed files with 40 additions and 8 deletions
|
@ -699,7 +699,11 @@ pub unsafe trait LessThanOrEqual<RHS> {}
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! tasks {
|
macro_rules! tasks {
|
||||||
($device:ident, {
|
($device:ident, {
|
||||||
$($task:ident: ($Interrupt:ident, $P:ident, $enabled:expr),)*
|
$($task:ident: Task {
|
||||||
|
interrupt:$Interrupt:ident,
|
||||||
|
priority: $P:ident,
|
||||||
|
enabled: $enabled:expr,
|
||||||
|
},)*
|
||||||
}) => {
|
}) => {
|
||||||
fn main() {
|
fn main() {
|
||||||
$crate::critical(|cmax| {
|
$crate::critical(|cmax| {
|
||||||
|
|
|
@ -11,7 +11,11 @@ use device::interrupt::Exti0;
|
||||||
// WRONG: Tasks can't have a priority of 0.
|
// WRONG: Tasks can't have a priority of 0.
|
||||||
// Only idle and init can have a priority of 0.
|
// Only idle and init can have a priority of 0.
|
||||||
tasks!(device, {
|
tasks!(device, {
|
||||||
j1: (Exti0, P0),
|
j1: Task {
|
||||||
|
interrupt: Exti0,
|
||||||
|
priority: P0,
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
fn init(_: P0, _: &C16) {}
|
fn init(_: P0, _: &C16) {}
|
||||||
|
|
|
@ -10,8 +10,16 @@ use device::interrupt::Exti0;
|
||||||
|
|
||||||
// WRONG: Two tasks mapped to the same interrupt handler
|
// WRONG: Two tasks mapped to the same interrupt handler
|
||||||
tasks!(device, {
|
tasks!(device, {
|
||||||
j1: (Exti0, P1),
|
j1: Task {
|
||||||
j2: (Exti0, P2),
|
interrupt: Exti0,
|
||||||
|
priority: P1,
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
j2: Task {
|
||||||
|
interrupt: Exti0,
|
||||||
|
priority: P2,
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
fn init(_: P0, _: &C16) {}
|
fn init(_: P0, _: &C16) {}
|
||||||
|
|
|
@ -9,7 +9,11 @@ use device::interrupt::Exti0;
|
||||||
use rtfm::{C16, P0, P1};
|
use rtfm::{C16, P0, P1};
|
||||||
|
|
||||||
tasks!(device, {
|
tasks!(device, {
|
||||||
j1: (Exti0, P1),
|
j1: Task {
|
||||||
|
interrupt: Exti0,
|
||||||
|
priority: P1,
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
fn init(_: P0, _: &C16) {}
|
fn init(_: P0, _: &C16) {}
|
||||||
|
|
|
@ -9,7 +9,11 @@ use rtfm::{C1, P0, P1};
|
||||||
use device::interrupt::Exti0;
|
use device::interrupt::Exti0;
|
||||||
|
|
||||||
tasks!(device, {
|
tasks!(device, {
|
||||||
j1: (Exti0, P1),
|
j1: Task {
|
||||||
|
interrupt: Exti0,
|
||||||
|
priority: P1,
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// WRONG. `init` must have signature `fn(P0, &C16)`
|
// WRONG. `init` must have signature `fn(P0, &C16)`
|
||||||
|
|
|
@ -9,7 +9,11 @@ use cortex_m_srp::{C16, P0, P1, P2};
|
||||||
use device::interrupt::Exti1;
|
use device::interrupt::Exti1;
|
||||||
|
|
||||||
tasks!(device, {
|
tasks!(device, {
|
||||||
j1: (Exti0, P1),
|
j1: Task {
|
||||||
|
interrupt: Exti0,
|
||||||
|
priority: P1,
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
fn init(_: P0, _: &C16) {}
|
fn init(_: P0, _: &C16) {}
|
||||||
|
|
|
@ -9,7 +9,11 @@ use cortex_mrtfm::{C16, P0, P1};
|
||||||
use device::interrupt::Exti1;
|
use device::interrupt::Exti1;
|
||||||
|
|
||||||
tasks!(device, {
|
tasks!(device, {
|
||||||
j1: (Exti0, P1),
|
j1: Task {
|
||||||
|
interrupt: Exti0,
|
||||||
|
priority: P1,
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
fn init(_: P0, _: &C16) {}
|
fn init(_: P0, _: &C16) {}
|
||||||
|
|
Loading…
Reference in a new issue