PixelKey
NeoPixel USB Key
Loading...
Searching...
No Matches
hal_tasks.h
1#ifndef HAL_TASKS_H
2#define HAL_TASKS_H
3
4#include <stdint.h>
5#include <stdbool.h>
6
17#define TASK_LIST \
18 XTASK(REBOOT, pixelkey_reboot, Triggers a software reset.) \
19 XTASK(FRAME_TX, npdata_frame_send, Transmits the last rendered frame.) \
20 XTASK(FRAME_RENDER, pixelkey_task_do_frame, Calculates the next frame.) \
21 XTASK(TERMINAL_CONNECTED, pixelkey_task_terminal_connected, Sends strings for newly connected terminals.) \
22 XTASK(CMD_RX, pixelkey_task_command_rx, Command string reception and parsing.) \
23 XTASK(CMD_HANDLER, pixelkey_commandproc_task, Command handling.) \
24 XTASK(CMD_PROMPT, pixelkey_task_command_prompt, Sends the command prompt string once command handling completes.) \
25
26
27#define XTASK(task,fn,doc) TASK_ ## task ,
29typedef enum e_task
30{
33 TASK_UNDEFINED = -1
35#undef XTASK
36
38typedef enum e_task_status
39{
45
46typedef void (*task_fn_t)(void);
47
48void tasks_run(task_fn_t idle_task);
49
50void tasks_queue(task_t task);
51
53
56#endif
task_t
Available tasks.
Definition: hal_tasks.h:30
void tasks_queue(task_t task)
Queue a task for execution.
Definition: hal_tasks.c:62
#define TASK_LIST
XMACRO(name,fn,docstring) for defining tasks.
Definition: hal_tasks.h:17
task_status_t tasks_status_get(task_t task)
Gets the status of a given task.
Definition: hal_tasks.c:73
task_status_t
Task status.
Definition: hal_tasks.h:39
void tasks_run(task_fn_t idle_task)
Main task runner loop.
Definition: hal_tasks.c:99
@ TASK_COUNT
Number of available tasks.
Definition: hal_tasks.h:32
@ TASK_UNDEFINED
Task is undefined.
Definition: hal_tasks.h:33
@ TASK_STATUS_QUEUED
The task has been queued to run.
Definition: hal_tasks.h:41
@ TASK_STATUS_RUNNING
The task is currently executing.
Definition: hal_tasks.h:43
@ TASK_STATUS_IDLE
The task is idle and not queued to run.
Definition: hal_tasks.h:40
@ TASK_STATUS_PENDING
The task is pending execution and is awaiting higher priority tasks.
Definition: hal_tasks.h:42