Scheduler

Trait Scheduler 

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

Source

fn initialized(&self) -> bool

This function is called by esp_radio::init to verify that the scheduler is properly set up.

Source

fn yield_task(&self)

This function is called by esp_radio to yield control to another task.

Source

fn yield_task_from_isr(&self)

This function is called by esp_radio to yield control to another task.

Source

fn current_task(&self) -> *mut c_void

This function is called by esp_radio::init to retrieve a pointer to the current task.

Source

fn max_task_priority(&self) -> u32

This function returns the maximum task priority level. Higher number is considered to be higher priority.

Source

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.

Source

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.

Source

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.

Source

fn usleep(&self, us: u32)

This function is called by a task to sleep for the specified number of microseconds.

Source

fn now(&self) -> u64

Returns the current timestamp in microseconds.

The underlying timer is expected not to overflow during the lifetime of the program.

The clock that generates this timestamp must be the same one used to trigger timer events.

Implementors§