#free-rtos #embedded #demo #library #cargo-build

nightly sys freertos-rust

Create to use FreeRTOS in rust projects. The freertos-cargo-build crate can be used to build and link FreeRTOS from source inside build.rs

3 releases

0.1.2 Apr 29, 2020
0.1.1 Apr 29, 2020
0.1.0 Apr 29, 2020

#286 in Operating systems

Download history 7280/week @ 2024-06-13 7394/week @ 2024-06-20 7329/week @ 2024-06-27 6421/week @ 2024-07-04 5657/week @ 2024-07-11 6496/week @ 2024-07-18 6894/week @ 2024-07-25 6192/week @ 2024-08-01 7765/week @ 2024-08-08 9409/week @ 2024-08-15 7117/week @ 2024-08-22 5799/week @ 2024-08-29 8659/week @ 2024-09-05 7212/week @ 2024-09-12 6058/week @ 2024-09-19 5856/week @ 2024-09-26

29,062 downloads per month
Used in icu_freertos

MIT license

84KB
2K SLoC

Rust 1.5K SLoC // 0.0% comments C 353 SLoC // 0.2% comments

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;
}

Dependencies