45 lines
949 B
C
45 lines
949 B
C
#include "has_platform.h"
|
|
|
|
static void timer_cb(void *arg)
|
|
{
|
|
(void)arg;
|
|
printf("hello timer\n");
|
|
has_timer_set(timer_cb, NULL, 1000);
|
|
}
|
|
|
|
static OS_THREAD_ID gui_tid;
|
|
static void gui_task(void *param)
|
|
{
|
|
(void)param;
|
|
uint8_t data[2];
|
|
data[0] = 0x5a;
|
|
data[1] = 0x5b;
|
|
has_timer_set(timer_cb, NULL, 1000);
|
|
while (1)
|
|
{
|
|
has_msg_publish(GUI, data, sizeof(data));
|
|
has_sleep_ms(10000);
|
|
}
|
|
}
|
|
|
|
int example_gui_init(void)
|
|
{
|
|
has_task_attr_t task_attr = {
|
|
.name = "gui",
|
|
.entry = gui_task,
|
|
.arg = NULL,
|
|
.stack_size_bytes = 1024U,
|
|
.priority = HAS_TASK_PRIORITY_NORMAL,
|
|
.linux_attr = { .sched_policy = -1 },
|
|
};
|
|
|
|
printf("module:GUI\n");
|
|
/* 创建线程 */
|
|
if (has_task_create(&task_attr, &gui_tid) != 0) {
|
|
printf("module:GUI create task failed\n");
|
|
return -1;
|
|
}
|
|
return 0;
|
|
}
|
|
HAS_DECLARE_MODULE(GUI, example_gui_init)
|