Expand description
§FreeRTOS
freertos-next is a Rust wrapper for the FreeRTOS API.
- It bundles the official FreeRTOS-Kernel sources (currently
V11.2.0). If you need a customized setup, you can prepare your own kernel source files and callb.freertos("path/to/your/kernel");in yourbuild.rs. - It implements several traits to ensure smooth integration with embedded projects:
The crate is published as freertos-next on crates.io because the more obvious names (freertos, freertos-rust) are already taken.
§📦 Usage
freertos-next works together with freertos-build.
- Add the dependencies to your application:
cargo add freertos-next
cargo add --build freertos-build- Add the following snippet to your application’s
build.rs:
use freertos_build::prelude::*;
fn main() {
let mut b = freertos_build::Builder::new();
b.cpu_clock(72.MHz());
b.heap_size(10 * 1024);
b.minimal_stack_size(80);
b.interrupt_priority_bits(4, 5, 15);
b.compile().unwrap();
}- For more Optional configuration, see freertos-build
A complete example using freertos-next with stm32f1-hal is available here: stm32f1-FreeRTOS-example
§📘 C Compiler
freertos-build uses the cc crate to compile the FreeRTOS kernel.
The C compiler can be configured via the CC environment variable, or it will fall back to the defaults provided by cc.
For ARM targets, the expected compiler is arm-none-eabi-gcc, which can be obtained from the ARM GNU toolchain.
§Install
# Ubuntu
sudo apt-get install -y gcc-arm-none-eabi
# Windows (Scoop)
scoop install gcc-arm-none-eabiSee also the main repository.
Re-exports§
pub use os_trait;
Modules§
Macros§
- os_
type_ alias - Use this macro to alias the OS-specific types for greater convenience, or manually alias only the ones you need.
Structs§
- Critical
Region - Current
Task - Helper methods to be performed on the task that is currently executing.
- Duration
Impl - Time unit used by FreeRTOS, passed to the scheduler as ticks.
- Event
Group - An event group
- Exclusive
Data - Data protected with a critical region. Lightweight version of a mutex, intended for simple data structures.
- Exclusive
Data Guard - Holds the mutex until we are dropped
- Exclusive
Data Guard Isr - Free
Rtos Allocator - Use with:
- Free
Rtos RawMutex mutex-traitsimplementation- Free
Rtos System State - Free
Rtos Task Status - Free
Rtos Task Status Ffi - Free
Rtos Time Units Shimmed - Free
Rtos Utils - Interrupt
Context - Keep track of whether we need to yield the execution to a different task at the end of the interrupt.
- Mutex
Guard - Holds the mutex until we are dropped
- Mutex
Impl - Mutual exclusion access to a contained value. Can be recursive - the current owner of a lock can re-lock it.
- Mutex
Normal - Mutex
Recursive - Queue
- A queue with a finite size.
- Semaphore
- A counting or binary semaphore
- Semaphore
Guard - Holds the lock to the semaphore until we are dropped
- Send
Error - Suspend
Scheduler - Data protected with a critical region, implemented by suspending the FreeRTOS scheduler.
- Suspend
Scheduler Guard - Task
- Handle for a FreeRTOS task
- Task
Builder - Helper for spawning a new task. Instantiate with
Task::new(). - Task
Delay Periodic - Periodic delay timer.
- Task
Priority - Task’s execution priority. Low priority numbers denote low priority tasks.
- Timer
- A FreeRTOS software timer.
- Timer
Builder - Helper builder for a new software timer.
Enums§
- Free
Rtos Error - Basic error type for the library.
- Free
Rtos Scheduler State - Free
Rtos Task State - Task
Notification - Notification to be sent to a task.
Traits§
Functions§
- assert_
callback - freertos_
rs_ âšcreate_ binary_ semaphore - freertos_
rs_ âšcreate_ counting_ semaphore - freertos_
rs_ âšcreate_ mutex - freertos_
rs_ âšcreate_ recursive_ mutex - freertos_
rs_ âšdelete_ semaphore - freertos_
rs_ âšdelete_ task - freertos_
rs_ âšenter_ critical - freertos_
rs_ âšenter_ critical_ from_ isr - freertos_
rs_ âševent_ group_ clear_ bits - freertos_
rs_ âševent_ group_ create - freertos_
rs_ âševent_ group_ delete - freertos_
rs_ âševent_ group_ get_ bits - freertos_
rs_ âševent_ group_ set_ bits - freertos_
rs_ âševent_ group_ sync - freertos_
rs_ âševent_ group_ wait_ bits - freertos_
rs_ âšexit_ critical - freertos_
rs_ âšexit_ critical_ from_ isr - freertos_
rs_ âšget_ current_ task - freertos_
rs_ âšget_ free_ heap_ size - freertos_
rs_ âšget_ minimum_ free_ heap_ size - freertos_
rs_ âšget_ number_ of_ tasks - freertos_
rs_ âšget_ portTICK_ PERIOD_ MS - freertos_
rs_ âšget_ stack_ high_ water_ mark - freertos_
rs_ âšget_ system_ state - freertos_
rs_ âšgive_ recursive_ semaphore - freertos_
rs_ âšgive_ semaphore - freertos_
rs_ âšgive_ semaphore_ isr - freertos_
rs_ âšinvoke_ configASSERT - freertos_
rs_ âšis_ in_ isr - freertos_
rs_ âšisr_ yield - freertos_
rs_ âšmax_ wait - freertos_
rs_ âšpvPort Malloc - freertos_
rs_ âšqueue_ create - freertos_
rs_ âšqueue_ delete - freertos_
rs_ âšqueue_ messages_ waiting - freertos_
rs_ âšqueue_ receive - freertos_
rs_ âšqueue_ send - freertos_
rs_ âšqueue_ send_ isr - freertos_
rs_ âšreset_ minimum_ free_ heap_ size - freertos_
rs_ âšsizeof - freertos_
rs_ âšspawn_ task - freertos_
rs_ âšsuspend_ task - freertos_
rs_ âštake_ recursive_ semaphore - freertos_
rs_ âštake_ semaphore - freertos_
rs_ âštake_ semaphore_ isr - freertos_
rs_ âštask_ get_ name - freertos_
rs_ âštask_ notify - freertos_
rs_ âštask_ notify_ isr - freertos_
rs_ âštask_ notify_ take - freertos_
rs_ âštask_ notify_ wait - freertos_
rs_ âštask_ yield - freertos_
rs_ âštimer_ change_ period - freertos_
rs_ âštimer_ create - freertos_
rs_ âštimer_ delete - freertos_
rs_ âštimer_ get_ id - freertos_
rs_ âštimer_ start - freertos_
rs_ âštimer_ start_ from_ isr - freertos_
rs_ âštimer_ stop - freertos_
rs_ âšuxTask GetTask Number - freertos_
rs_ âšvPort Free - freertos_
rs_ âšvTask Delay - freertos_
rs_ âšvTask Delay Until - freertos_
rs_ âšvTask SetTask Number - freertos_
rs_ âšvTask Start Scheduler - freertos_
rs_ âšvTask Suspend All - freertos_
rs_ âšxTask GetTick Count - freertos_
rs_ âšxTask GetTick Count FromISR - freertos_
rs_ âšxTask Resume All - freertos_
rt_ âšxTask GetScheduler State - is_
in_ isr - shim_
sanity_ check - Perform checks whether the C FreeRTOS shim and Rust agree on the sizes of used types.
- str_
from_ âšc_ string - Safety
Type Aliases§
- Duration
- Free
Rtos Base Type - Free
Rtos Base Type MutPtr - Free
Rtos Char - Free
Rtos Char Ptr - Free
Rtos Event Bits Type - Free
Rtos Event Group Handle - Free
Rtos MutVoid Ptr - Free
Rtos Queue Handle - Free
Rtos Semaphore Handle - Free
Rtos Stack Type - Free
Rtos Task Function - Free
Rtos Task Handle - Free
Rtos Tick Type - Free
Rtos Timer Callback - Free
Rtos Timer Handle - Free
RtosU Base Type - Free
Rtos Unsigned Long - Free
Rtos Unsigned Short - Free
Rtos Void Ptr - Mutex
- Recursive
Mutex