Firmware SDK
twr_scheduler.h
1 #ifndef _TWR_SCHEDULER_H
2 #define _TWR_SCHEDULER_H
3 
4 #include <twr_tick.h>
5 
9 
11 
12 #ifndef TWR_SCHEDULER_MAX_TASKS
13 #define TWR_SCHEDULER_MAX_TASKS 32
14 #endif
15 
16 #ifndef TWR_SCHEDULER_INTERVAL_MS
17 #define TWR_SCHEDULER_INTERVAL_MS 10
18 #endif
19 
21 
22 typedef size_t twr_scheduler_task_id_t;
23 
25 
26 void twr_scheduler_init(void);
27 
29 
30 void twr_scheduler_run(void);
31 
37 
38 twr_scheduler_task_id_t twr_scheduler_register(void (*task)(void *), void *param, twr_tick_t tick);
39 
42 
44 
47 
49 
52 
54 
56 
58 
60 
62 
65 
67 
71 
73 
77 
79 
83 
85 
87 
89 
92 
94 
97 
99 
102 
104 
106 
107 #endif // _TWR_SCHEDULER_H
void twr_scheduler_plan_relative(twr_scheduler_task_id_t task_id, twr_tick_t tick)
Schedule specified task to tick relative from current spin.
void twr_scheduler_plan_current_relative(twr_tick_t tick)
Schedule current task to tick relative from current spin.
twr_scheduler_task_id_t twr_scheduler_register(void(*task)(void *), void *param, twr_tick_t tick)
Register task in scheduler.
Definition: twr_scheduler.c:53
void twr_scheduler_plan_current_absolute(twr_tick_t tick)
Schedule current task to absolute tick.
void twr_scheduler_enable_sleep(void)
Enable sleep mode, implemented as semaphore.
twr_tick_t twr_scheduler_get_spin_tick(void)
Get current tick of spin in which task has been run.
twr_scheduler_task_id_t twr_scheduler_get_current_task_id(void)
Get task ID of currently executing task.
Definition: twr_scheduler.c:96
void twr_scheduler_init(void)
Initialize task scheduler.
Definition: twr_scheduler.c:24
void twr_scheduler_plan_current_from_now(twr_tick_t tick)
Schedule current task to tick relative from now.
void twr_scheduler_plan_current_now(void)
Schedule current task for immediate execution.
size_t twr_scheduler_task_id_t
Task ID assigned by scheduler.
Definition: twr_scheduler.h:22
void twr_scheduler_disable_sleep(void)
Disable sleep mode, implemented as semaphore.
uint64_t twr_tick_t
Timestamp data type.
Definition: twr_tick.h:16
void twr_scheduler_plan_from_now(twr_scheduler_task_id_t task_id, twr_tick_t tick)
Schedule specified task to tick relative from now.
void twr_scheduler_unregister(twr_scheduler_task_id_t task_id)
Unregister specified task.
Definition: twr_scheduler.c:77
void twr_scheduler_run(void)
Run task scheduler (this call never ends)
Definition: twr_scheduler.c:29
void twr_scheduler_plan_absolute(twr_scheduler_task_id_t task_id, twr_tick_t tick)
Schedule specified task to absolute tick.
void twr_scheduler_plan_now(twr_scheduler_task_id_t task_id)
Schedule specified task for immediate execution.