CORTEXM_THREADS
A simple library for context-switching on ARM Cortex-M ( 0, 0+, 3, 4, 4F ) micro-processors
Supports pre-emptive, priority based switching
This project is meant for learning and should be used only at the user's risk. For practical and mature rust alternatives, see Awesome Embedded Rust
Current State
Processor support:
- Cortex-M0
- Cortex-M0+
- Cortex-M3
- Cortex-M4
- Cortex-M4F
Features:
- Preemptive, priority-based switching
- Efficient sleep
- Accept stack memory area as a vec (arrayvec?, smallvec?) instead of &[]
- Non-privileged mode
- Mutex implementation aware of thread scheduling
Examples
The example_crates
folder contains crates showing how to
use cortexm-threads for different boards.
Available examples:
- stm32f3 - 2 threads with one thread running an LED roulette, and the other periodically printing magnetometer readings. Currently compiles for target thumbv7m-none-eabi instead of thumbv7em-none-eabihf. See Roadmap#1
- microbit - 2 threads printing messages with co-operative context switching
- qemu-m4 - (set up to run
on qemu) 2 threads printing messages via semi-hosting.
Run
cargo run
fromexample_crates/qemu-m4
directory to see it running. You must have qemu-system-arm on the system PATH.
Sample:
extern crate panic_semihosting;
use SystClkSource;
use ;
use ;
use ;
!
License
See LICENSE.md