pub trait Scheduler:
Send
+ Sync
+ 'static {
// Required methods
fn initialized(&self) -> bool;
fn yield_task(&self);
fn yield_task_from_isr(&self);
fn current_task(&self) -> *mut c_void;
fn max_task_priority(&self) -> u32;
fn task_create(
&self,
name: &str,
task: extern "C" fn(*mut c_void),
param: *mut c_void,
priority: u32,
core_id: Option<u32>,
task_stack_size: usize,
) -> *mut c_void;
fn schedule_task_deletion(&self, task_handle: *mut c_void);
fn current_task_thread_semaphore(&self) -> SemaphorePtr;
fn usleep(&self, us: u32);
fn now(&self) -> u64;
}Expand description
The scheduler interface.
This trait needs to be implemented by a driver crate to integrate esp-radio with a software platform.
The following snippet demonstrates the boilerplate necessary to implement a scheduler using the
Scheduler trait:
struct MyScheduler {}
impl esp_radio_rtos_driver::Scheduler for MyScheduler {
fn initialized(&self) -> bool {
unimplemented!()
}
fn yield_task(&self) {
unimplemented!()
}
fn yield_task_from_isr(&self) {
unimplemented!()
}
fn max_task_priority(&self) -> u32 {
unimplemented!()
}
fn task_create(
&self,
name: &str,
task: extern "C" fn(*mut c_void),
param: *mut c_void,
priority: u32,
pin_to_core: Option<u32>,
task_stack_size: usize,
) -> *mut c_void {
unimplemented!()
}
fn current_task(&self) -> *mut c_void {
unimplemented!()
}
fn schedule_task_deletion(&self, task_handle: *mut c_void) {
unimplemented!()
}
fn current_task_thread_semaphore(&self) -> SemaphorePtr {
unimplemented!()
}
fn usleep(&self, us: u32) {
unimplemented!()
}
fn now(&self) -> u64 {
unimplemented!()
}
}
esp_radio_rtos_driver::scheduler_impl!(static SCHEDULER: MyScheduler = MyScheduler {});Required Methods§
Sourcefn initialized(&self) -> bool
fn initialized(&self) -> bool
This function is called by esp_radio::init to verify that the scheduler is properly set
up.
Sourcefn yield_task(&self)
fn yield_task(&self)
This function is called by esp_radio to yield control to another task.
Sourcefn yield_task_from_isr(&self)
fn yield_task_from_isr(&self)
This function is called by esp_radio to yield control to another task.
Sourcefn current_task(&self) -> *mut c_void
fn current_task(&self) -> *mut c_void
This function is called by esp_radio::init to retrieve a pointer to the current task.
Sourcefn max_task_priority(&self) -> u32
fn max_task_priority(&self) -> u32
This function returns the maximum task priority level. Higher number is considered to be higher priority.
Sourcefn task_create(
&self,
name: &str,
task: extern "C" fn(*mut c_void),
param: *mut c_void,
priority: u32,
core_id: Option<u32>,
task_stack_size: usize,
) -> *mut c_void
fn task_create( &self, name: &str, task: extern "C" fn(*mut c_void), param: *mut c_void, priority: u32, core_id: Option<u32>, task_stack_size: usize, ) -> *mut c_void
This function is used to create threads. It should allocate the stack.
Sourcefn schedule_task_deletion(&self, task_handle: *mut c_void)
fn schedule_task_deletion(&self, task_handle: *mut c_void)
This function is called to let the scheduler know this thread is not needed anymore and should be deleted. After this function is called, the thread should not be scheduled anymore. The thread stack can be free’ed.
Passing null as the task handle should delete the currently running task.
Sourcefn current_task_thread_semaphore(&self) -> SemaphorePtr
fn current_task_thread_semaphore(&self) -> SemaphorePtr
This function should return an opaque per-thread pointer to an usize-sized memory location, which will be used to store a pointer to a semaphore for this thread.