Expand description
FreeRTOS task creation and management.
Any method of creating a task will return a TaskHandle
.
This handle can be used to control the task.
A handle to the current task can be obtained with current
.
Tasks can be created with the spawn
function or, for more control, with a task Builder
.
§Example
use pros::task::{spawn, TaskPriority};
spawn(|| {
println!("Hello from a task!");
});
Task locals can be created with the os_task_local!
macro.
See the local
module for more info on the custom task local implementation used.
Modules§
- A custom TLS implementation that allows for more than 5 entries in TLS.
Structs§
- An ergonomic builder for tasks. Alternatively you can use
spawn
. - An interval that can be used to repeatedly run code at a given rate.
- A guard that can be used to suspend the FreeRTOS scheduler. When dropped, the scheduler will be resumed.
- An owned permission to perform actions on a task.
Enums§
- Errors that can occur when spawning a task.
- Represents how much time the cpu should spend on this task. (Otherwise known as the priority)
- Represents how large of a stack the task should get. Tasks that don’t have any or many variables and/or don’t need floats can use the low stack depth option.
- Represents the current state of a task.
Functions§
- Returns the task the function was called from.
- Blocks the current FreeRTOS task for the given amount of time.
- Gets the first notification in the queue. If there is none, blocks until a notification is received. I am unsure what happens if the thread is unblocked while waiting. returns the value of the notification
- Creates a task to be run ‘asynchronously’ (More information at the FreeRTOS docs). Takes in a closure that can move variables if needed. If your task has a loop it is advised to use
delay
so that the task does not take up necessary system resources. Tasks should be long-living; starting many tasks can be slow and is usually not necessary. - Suspends the scheduler, preventing context switches. No other tasks will be run until the returned guard is dropped.