Expand description
§esp-radio task scheduler interface.
esp-radio requires a task scheduler to operate. This crate allows the task scheduler to be
tailored to specific software platforms (such as ArielOS). Trying to use multiple scheduler
crates in a firmware project will not build.
If you want to use esp-radio without any OS, you can use the esp-rtos
crate as the task scheduler.
§Implementing a scheduler driver
This crate abstracts the capabilities of FreeRTOS. The implementor crate has two different
possible ways to implement the required capabilities. The SchedulerImplementation trait must
be implemented in both cases.
The implementation types must be registered using the respective register_x_implementation
macros.
§Without ipc-implementations
The implementor must implement the semaphore::SemaphoreImplementation,
queue::QueueImplementation, and timer::TimerImplementation traits.
use esp_radio_rtos_driver::{
SchedulerImplementation,
queue::QueueImplementation,
register_queue_implementation,
register_scheduler_implementation,
register_semaphore_implementation,
register_timer_implementation,
semaphore::SemaphoreImplementation,
timer::TimerImplementation,
};
struct MyScheduler {
// ...
}
impl SchedulerImplementation for MyScheduler {
// ...
}
struct MySemaphore {
// ...
}
impl SemaphoreImplementation for MySemaphore {
// ...
}
struct MyTimer {
// ...
}
impl TimerImplementation for MyTimer {
// ...
}
struct MyQueue {
// ...
}
impl QueueImplementation for MyQueue {
// ...
}
register_scheduler_implementation!(static SCHEDULER: MyScheduler = MyScheduler {});
register_semaphore_implementation!(MySemaphore);
register_timer_implementation!(MyTimer);
register_queue_implementation!(MyQueue);§Using ipc-implementations
The implementor must implement the [wait_queue::WaitQueueImplementation] trait, and can use
the various Compat types as the default implementations for the IPC types.
You still have the option to provide custom implementations for the IPC types.
use esp_radio_rtos_driver::{
SchedulerImplementation,
queue::CompatQueue,
register_queue_implementation,
register_scheduler_implementation,
register_semaphore_implementation,
register_timer_implementation,
register_wait_queue_implementation,
semaphore::CompatSemaphore,
timer::CompatTimer,
wait_queue::WaitQueueImplementation,
};Expand commentComment on lines R78 to R89ResolvedCode has comments. Press enter to view.
struct MyScheduler {
// ...
}
impl SchedulerImplementation for MyScheduler {
// ...
}
struct MyWaitQueue {
// ...
}
impl WaitQueueImplementation for MyWaitQueue {
// ...
}
register_scheduler_implementation!(static SCHEDULER: MyScheduler = MyScheduler {});
register_wait_queue_implementation!(MyWaitQueue);
register_semaphore_implementation!(CompatSemaphore);
register_timer_implementation!(CompatTimer);
register_queue_implementation!(CompatQueue);Modules§
Macros§
- register_
queue_ implementation - register_
scheduler_ implementation - Set the Scheduler implementation.
- register_
semaphore_ implementation - register_
timer_ implementation
Traits§
- Scheduler
Implementation - The scheduler interface.
Functions§
- current_
task - Returns a pointer to the current task.
- current_
task_ thread_ semaphore - Returns a pointer to the current thread’s semaphore.
- initialized
- Returns whether the task scheduler has been initialized.
- max_
task_ priority - Returns the maximum priority a task can have.
- now
- Returns the current timestamp, in microseconds.
- schedule_
task_ ⚠deletion - Schedules the given task for deletion.
- task_
create ⚠ - Creates a new task with the given initial parameter and stack size.
- usleep
- Puts the current task to sleep for the specified number of microseconds.
- usleep_
until - Puts the current task to sleep until the specified timestamp.
- yield_
task - Yields control to another task.
- yield_
task_ from_ isr - Yields control to another task for an interrupt.