[][src]Crate freertos_rust

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;
}

Modules

patterns

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.

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:

FreeRtosHooks
FreeRtosSchedulerState
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. The items are owned by the queue and are copied.

Semaphore

A counting or binary semaphore

SemaphoreGuard

Holds the lock to the semaphore until we are dropped

Task

Handle for a FreeRTOS task

TaskBuilder

Helper for spawning a new task. Instantiate with Task::new().

TaskDelay

Delay the current task by the given duration, minus the time that was spent processing the last wakeup loop.

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

CVoid
FreeRtosError

Basic error type for the library.

FreeRtosTaskState
TaskNotification

Notification to be sent to a task.

Statics

FREERTOS_HOOKS

Traits

DurationTicks
FreeRtosTimeUnits
MutexInnerImpl

Functions

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_exit_critical
freertos_rs_get_current_task
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_mutex
freertos_rs_give_recursive_mutex
freertos_rs_invoke_configASSERT
freertos_rs_isr_yield
freertos_rs_max_wait
freertos_rs_pvPortMalloc
freertos_rs_queue_create
freertos_rs_queue_delete
freertos_rs_queue_receive
freertos_rs_queue_send
freertos_rs_queue_send_isr
freertos_rs_sizeof
freertos_rs_spawn_task
freertos_rs_take_mutex
freertos_rs_take_recursive_mutex
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_timer_change_period
freertos_rs_timer_create
freertos_rs_timer_delete
freertos_rs_timer_get_id
freertos_rs_timer_start
freertos_rs_timer_stop
freertos_rs_vPortFree
freertos_rs_vTaskDelay
freertos_rs_vTaskDelayUntil
freertos_rs_vTaskStartScheduler
freertos_rs_xTaskGetTickCount
shim_sanity_check

Perform checks whether the C FreeRTOS shim and Rust agree on the sizes of used types.

vAssertCalled

Type Definitions

Duration
FreeRtosBaseType
FreeRtosBaseTypeMutPtr
FreeRtosChar
FreeRtosCharPtr
FreeRtosMutTaskHandle
FreeRtosMutVoidPtr
FreeRtosQueueHandle
FreeRtosSemaphoreHandle
FreeRtosStackType
FreeRtosTaskFunction
FreeRtosTaskHandle
FreeRtosTickType
FreeRtosTimerCallback
FreeRtosTimerHandle
FreeRtosUBaseType
FreeRtosUnsignedLong
FreeRtosUnsignedShort
FreeRtosVoidPtr
Mutex
RecursiveMutex