Expand description
§FreeRTOS for Rust
Rust interface for the FreeRTOS embedded operating system. Requires beta 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. Check the subdirectory shim
. Copy the source file to
your firmware’s sources directory and modify it to include the appropriate headers for
target your system.
For a complete example, 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();
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;
}
Modules§
Structs§
- Helper methods to be performed on the task that is currently executing.
- Time unit used by FreeRTOS, passed to the scheduler as ticks.
- Data protected with a critical region. Lightweight version of a mutex, intended for simple data structures.
- Holds the mutex until we are dropped
- Keep track of whether we need to yield the execution to a different task at the end of the interrupt.
- Holds the mutex until we are dropped
- Mutual exclusion access to a contained value. Can be recursive - the current owner of a lock can re-lock it.
- A queue with a finite size. The items are owned by the queue and are copied.
- A counting or binary semaphore
- Holds the lock to the semaphore until we are dropped
- Handle for a FreeRTOS task
- Helper for spawning a new task. Instantiate with
Task::new()
. - Delay the current task by the given duration, minus the time that was spent processing the last wakeup loop.
- Periodic delay timer.
- Task’s execution priority. Low priority numbers denote low priority tasks.
- A FreeRTOS software timer.
- Helper builder for a new software timer.
Enums§
- Basic error type for the library.
- Notification to be sent to a task.
Traits§
Functions§
- Perform checks whether the C FreeRTOS shim and Rust agree on the sizes of used types.