minimult_cortex-m

This crate for Rust provides a minimal multitask library Minimult for Cortex-M microcontrollers.

Target

Single-core systems of

Minimult is still in beta because the author had only a few tests only on Cortex-M4 with FPU.

Features

Examples

Usage Outline

```rust

![no_main]

![no_std]

use cortexm::Peripherals; use cortexmrt::entry; use cortexmrt::exception; extern crate panicsemihosting;

// other codes...

use minimultcortexm::*;

[entry]

fn main() -> ! { let mut mem = Minimult::mem::<[u8; 4096]>(); let mut mt = Minimult::new(&mut mem, 2);

// other codes...

let mut q = mt.msgq::<u32>(4);
let (snd, rcv) = q.ch();

mt.register(0/*tid*/, 1, 256, || task0(snd));
mt.register(1/*tid*/, 1, 256, || task1(rcv));

// other codes...

let cmperi = Peripherals::take().unwrap();
let mut syst = cmperi.SYST;
syst.set_clock_source(cortex_m::peripheral::syst::SystClkSource::Core);
syst.set_reload(0xffffff);
syst.clear_current();
syst.enable_counter();
syst.enable_interrupt();

// other codes...

mt.run()

}

[exception]

fn SysTick() { // other codes...

Minimult::kick(0/*tid*/);

}

fn task0(snd: MTMsgSender) { // other codes...

loop {
    Minimult::idle();

    // other codes...

    let some_value = 1;
    snd.send(some_value);
}

}

fn task1(rcv: MTMsgReceiver) { // other codes...

loop {
    let mut some_value = 0;
    rcv.receive(|v| {some_value = *v});

    // other codes...
}

} ```

Other Examples

You can find a specific board's example here. Currently there are very few examples, however.