Module drone_cortexm::thr[][src]

The Threads module.

NOTE This module documentation should be viewed as a continuation of the drone_core documentation.

Vector Table

use drone_cortexm::{map::thr::*, thr};

thr::nvic! {
    // See the `drone_core` documentation of `thr::pool!` macro for details.
    thread => pub Thr {};

    // See the `drone_core` documentation of `thr::pool!` macro for details.
    local => pub ThrLocal {};

    // See the `drone_core` documentation of `thr::pool!` macro for details.
    index => pub Thrs;

    /// The vector table type.
    vtable => pub Vtable;

    /// Threads initialization token.
    init => pub ThrsInit;

    // Threads configuration.
    threads => {
        // Threads for exceptions.
        exceptions => {
            // Define a regular thread for the NMI exception. This creates a thread token
            // structure `Nmi`, a field `nmi` in the `Thrs` structure, and an element in the
            // array of `Thr`.
            /// Non maskable interrupt.
            pub nmi;
            /// All classes of fault.
            pub hard_fault;
            // Define a naked handler for the SV_CALL exception. This inserts the function
            // `sv_call_handler` directly to the vector table.
            /// System service call.
            pub naked(sv_call_handler) sv_call;
            /// System tick timer.
            pub sys_tick;
        };
        // Threads for interrupts.
        interrupts => {
            // Define a regular thread for the interrupt #5 with name `rcc`.
            /// RCC global interrupt.
            5: pub rcc;
            // Define an outer thread for the interrupt #18 with name `adc1`. This creates a
            // thread token structure `Adc1`, a field `adc1` in the `Thrs` structure, and an
            // element in the array of `Thr`. But unlike a regular thread, this outer thread
            // uses a custom handler `adc1_handler`.
            /// ADC1 global interrupt.
            18: pub outer(adc1_handler) adc1;
        };
    };
}

// The reset handler should always be provided externally.
unsafe extern "C" fn reset() -> ! {
    loop {}
}

// Define external handlers for the exceptions defined using `fn` or
// `extern` keyword.
unsafe extern "C" fn sv_call_handler() {}
unsafe fn adc1_handler(_thr: &Thr) {}

// Define and export the actual vector table with all handlers attached.
#[no_mangle]
pub static VTABLE: Vtable = Vtable::new(reset);

The list of all available non-interrupt exceptions:

Re-exports

pub use drone_core::thr::*;

Modules

prelude

The Threads prelude.

Macros

nvic

Defines a thread pool driven by NVIC (Nested Vector Interrupt Controller).

Structs

NvicIabr

Interrupt Active-Bit Register.

NvicIcer

Interrupt Clear-Enable Register.

NvicIcpr

Interrupt Clear-Pending Register.

NvicIser

Interrupt Set-Enable Register.

NvicIspr

Interrupt Set-Pending Register.

StreamRootWait

An iterator that blocks on values from a stream until they become available.

ThrInitExtended

A set of register tokens returned by init_extended.

Traits

FutureRootExt

An extension trait for Future that provides root_wait method.

IntToken

An interrupt token.

NvicBlock

NVIC registers block.

StreamRootExt

An extension trait for Stream that provides root_wait method.

ThrNvic

NVIC methods for interrupt tokens.

ThrSv

A trait to assign a supervisor to threads.

ThrsInitToken

Threads initialization token.

Functions

init

Initializes the thread system and returns a set of thread tokens.

init_extended

Initializes the thread system and returns a set of thread tokens.