Macro cortex_m_rtfm::tasks [] [src]

macro_rules! tasks {
    ($device:ident, {
        $($task:ident: Task {
            priority: $P:ident,
            enabled: $enabled:expr,
    }) => { ... };

A macro to declare tasks

NOTE This macro will expand to a main function.

Each $task is bound to an $Interrupt handler and has a priority $P. The minimum priority of a task is P1. $enabled indicates whether the task will be enabled before idle runs.

The $Interrupt handlers are defined in the $device crate.

Apart from defining the listed $tasks, the init and idle functions must be defined as well. init has signature fn(P0, &TMax), and idle has signature fn(P0) -> !.



extern crate cortex_m_rt;
extern crate cortex_m_rtfm as rtfm;
// device crate generated using `svd2rust`
extern crate stm32f30x;

use rtfm::{P0, P1, P2, T0, T1, T2, TMax};
use stm32f30x::interrupt::{Exti0, Tim7};

tasks!(stm32f30x, {
    periodic: Task {
        interrupt: Tim7,
        priority: P1,
        enabled: true,
    button: Task {
        interrupt: Exti0,
        priority: P2,
        enabled: true,

fn init(priority: P0, threshold: &TMax) {
    // ..

fn idle(priority: P0, threshold: T0) -> ! {
    // Sleep
    loop {

// NOTE signature must match the tasks! declaration
fn periodic(task: Tim7, priority: P1, threshold: T1) {
    // ..

fn button(task: Exti0, priority: P2, threshold: T2) {
    // ..