esp_wifi/
tasks.rs
1use crate::{
2 compat::timer_compat::TIMERS,
3 preempt::{task_create, yield_task},
4 time::systimer_count,
5};
6
7pub(crate) fn init_tasks() {
9 task_create(timer_task, core::ptr::null_mut(), 8192);
11}
12
13pub(crate) extern "C" fn timer_task(_param: *mut esp_wifi_sys::c_types::c_void) {
16 loop {
17 let current_timestamp = systimer_count();
18 let to_run = TIMERS.with(|timers| {
19 let to_run = unsafe { timers.find_next_due(current_timestamp) }?;
20
21 to_run.active = to_run.periodic;
22
23 if to_run.periodic {
24 to_run.started = current_timestamp;
25 }
26
27 Some(to_run.callback)
28 });
29
30 if let Some(to_run) = to_run {
32 trace!("trigger timer....");
33 to_run.call();
34 trace!("timer callback called");
35 } else {
36 yield_task();
37 }
38 }
39}