3 releases
0.1.2 | Apr 29, 2020 |
---|---|
0.1.1 | Apr 29, 2020 |
0.1.0 | Apr 29, 2020 |
#286 in Operating systems
29,062 downloads per month
Used in icu_freertos
84KB
2K
SLoC
FreeRTOS Rust
Wrapper library to use FreeRTOS API in Rust.
To build an embedded application with FreeRTOS please refer to freertos-rust home.
Usage
The crate is published on crates.io
[dependencies]
freertos-rust = "*"
lib.rs
:
FreeRTOS for Rust
Rust interface for the FreeRTOS embedded operating system. Requires nightly Rust. It is assumed that dynamic memory allocation is provided on the target system.
This library interfaces with FreeRTOS using a C shim library which provides function wrappers for FreeRTOS macros. The compiled Rust application should be linked to the base C/C++ firmware binary.
Examples are provided inside freertos-rust-examples
For more examples, check the enclosed GCC ARM/Rust/QEMU based unit tests. The project
qemu_runner
cross-compiles this library, compiles the main firmware using GCC ARM and links
in the appropriate entry points for unit tests. GNU ARM Eclipse QEMU
is used to run the test binaries.
Be sure to check the FreeRTOS documentation.
Samples
Spawning a new task
Task::new().name("hello").stack_size(128).start(|| {
loop {
println!("Hello world!");
CurrentTask::delay(Duration::infinite());
}
}).unwrap();
FreeRtosUtils::start_scheduler();
Queue
let q = Queue::new(10).unwrap();
q.send(10, Duration::ms(5)).unwrap();
q.receive(Duration::infinite()).unwrap();
Mutex
let m = Mutex::new(0).unwrap();
{
let mut v = m.lock(Duration::infinite()).unwrap();
*v += 1;
}