#free-rtos #demo #embedded #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

#270 in Operating systems

Download history 3484/week @ 2023-12-14 3183/week @ 2023-12-21 2145/week @ 2023-12-28 2974/week @ 2024-01-04 2591/week @ 2024-01-11 2881/week @ 2024-01-18 3095/week @ 2024-01-25 3127/week @ 2024-02-01 3707/week @ 2024-02-08 2995/week @ 2024-02-15 4739/week @ 2024-02-22 3835/week @ 2024-02-29 5145/week @ 2024-03-07 6101/week @ 2024-03-14 6342/week @ 2024-03-21 4750/week @ 2024-03-28

23,577 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