Skip to main content

Crate esp_radio_rtos_driver

Crate esp_radio_rtos_driver 

Source
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§

queue
Queues
semaphore
Semaphores
timer
Timers (callbacks scheduled to run in the future)

Macros§

register_queue_implementation
register_scheduler_implementation
Set the Scheduler implementation.
register_semaphore_implementation
register_timer_implementation

Traits§

SchedulerImplementation
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.

Type Aliases§

ThreadPtr