Skip to content

Latest commit

 

History

History
61 lines (41 loc) · 2.05 KB

README.md

File metadata and controls

61 lines (41 loc) · 2.05 KB

FreeRTOS-rust

This project is based on code from freertos.rs and own additions to simplify the usage of FreeRTOS in embedded applications written in Rust.

But in contrast to freertos.rs this crate differs in these points:

  • The application main() entry point is written in Rust.
  • The FreeRTOS scheduler can be started from Rust.
  • The FreeRTOS heap MemMang/heap/heap_x.cis used as global memory allocator for Rust
  • No need for a Clang skeleton project

Usage

Add dependencies to your apps Cargo.toml

[dependencies]
freertos_rust = "*"

[build-dependencies]
freertos-cargo-build = "*"

To build FreeRTOS you need to specify a path to the FreeRTOS Source directory and your FreeRTOSConfig.h. The freertos-cargo-build build dependency takes care of compiling FreeRTOS using the cc crate. You have to specify location of the FreeRTOS kernel code and your project specific FreeRTOSConfig.h.

Add this snippet to your apps build.rs:

use std::env;

fn main() {
    let mut b = freertos_cargo_build::Builder::new();

    // Path to copy of the FreeRTOS kernel "C" code
    b.freertos("FreeRTOS/Source");

    // The `FreeRTOSConfig.h` is usually inside your main crate to match you application and target needs.
    b.freertos_config("src"); 

    // Additional "C" code may optionally compiled beside FreeRTOS using:
    // b.get_cc().file("optionalAdditionCode.c");

    // Compiles the FreeRTOS "C" Code
    b.compile().unwrap_or_else(|e| { panic!(e.to_string()) });
}

The correct port is automatically detected.

Structure