Crate freertos_next

Crate freertos_next 

Source
Expand description

§FreeRTOS

CI Crates.io Docs.rs License Downloads

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 call b.freertos("path/to/your/kernel"); in your build.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.

  1. Add the dependencies to your application:
cargo add freertos-next
cargo add --build freertos-build
  1. 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();
}
  1. 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-eabi

See also the main repository.

Re-exports§

pub use os_trait;

Modules§

patterns
prelude

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§

CriticalRegion
CurrentTask
Helper methods to be performed on the task that is currently executing.
DurationImpl
Time unit used by FreeRTOS, passed to the scheduler as ticks.
EventGroup
An event group
ExclusiveData
Data protected with a critical region. Lightweight version of a mutex, intended for simple data structures.
ExclusiveDataGuard
Holds the mutex until we are dropped
ExclusiveDataGuardIsr
FreeRtosAllocator
Use with:
FreeRtosRawMutex
mutex-traits implementation
FreeRtosSystemState
FreeRtosTaskStatus
FreeRtosTaskStatusFfi
FreeRtosTimeUnitsShimmed
FreeRtosUtils
InterruptContext
Keep track of whether we need to yield the execution to a different task at the end of the interrupt.
MutexGuard
Holds the mutex until we are dropped
MutexImpl
Mutual exclusion access to a contained value. Can be recursive - the current owner of a lock can re-lock it.
MutexNormal
MutexRecursive
Queue
A queue with a finite size.
Semaphore
A counting or binary semaphore
SemaphoreGuard
Holds the lock to the semaphore until we are dropped
SendError
SuspendScheduler
Data protected with a critical region, implemented by suspending the FreeRTOS scheduler.
SuspendSchedulerGuard
Task
Handle for a FreeRTOS task
TaskBuilder
Helper for spawning a new task. Instantiate with Task::new().
TaskDelayPeriodic
Periodic delay timer.
TaskPriority
Task’s execution priority. Low priority numbers denote low priority tasks.
Timer
A FreeRTOS software timer.
TimerBuilder
Helper builder for a new software timer.

Enums§

FreeRtosError
Basic error type for the library.
FreeRtosSchedulerState
FreeRtosTaskState
TaskNotification
Notification to be sent to a task.

Traits§

DurationTicks
FreeRtosTimeUnits
MutexInnerImpl

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_pvPortMallocâš 
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_uxTaskGetTaskNumberâš 
freertos_rs_vPortFreeâš 
freertos_rs_vTaskDelayâš 
freertos_rs_vTaskDelayUntilâš 
freertos_rs_vTaskSetTaskNumberâš 
freertos_rs_vTaskStartSchedulerâš 
freertos_rs_vTaskSuspendAllâš 
freertos_rs_xTaskGetTickCountâš 
freertos_rs_xTaskGetTickCountFromISRâš 
freertos_rs_xTaskResumeAllâš 
freertos_rt_xTaskGetSchedulerStateâš 
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
FreeRtosBaseType
FreeRtosBaseTypeMutPtr
FreeRtosChar
FreeRtosCharPtr
FreeRtosEventBitsType
FreeRtosEventGroupHandle
FreeRtosMutVoidPtr
FreeRtosQueueHandle
FreeRtosSemaphoreHandle
FreeRtosStackType
FreeRtosTaskFunction
FreeRtosTaskHandle
FreeRtosTickType
FreeRtosTimerCallback
FreeRtosTimerHandle
FreeRtosUBaseType
FreeRtosUnsignedLong
FreeRtosUnsignedShort
FreeRtosVoidPtr
Mutex
RecursiveMutex