1 Star 0 Fork 0

eric.pyt/xOS

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
xos_demo.c 1.40 KB
一键复制 编辑 原始数据 按行查看 历史
eric 提交于 10个月前 . 规范API
#include <stdio.h>
#include "xos.h"
void led_init(void)
{
int a = 0;
printf("[%s] %d: a=%d\r\n", __func__, __LINE__, a);
}
device_initcall(led_init);
void led_task_cb(void* arg, uint32_t event)
{
int a = 0;
// printf("[%s] %d: a=%d\r\n", __func__, __LINE__, a);
}
void timer_task_cb(void* arg, uint32_t event)
{
int a = 0;
printf("[%s] %d: a=%d\r\n", __func__, __LINE__, a);
}
void key_task_cb(void* arg, uint32_t event)
{
int a = 0;
// printf("[%s] %d: a=%d\r\n", __func__, __LINE__, a);
}
void xos_demo(void)
{
// 普通任务创建
static task_t task_led = {
.func = led_task_cb,
.mode = TASK_LOOP,
};
xos_task_add(&task_led);
xos_task_start(&task_led);
printf("[%s] %d: task_led=%x\r\n", __func__, __LINE__, &task_led);
// 定时任务创建
static task_t task_timer = {
.func = timer_task_cb,
.mode = TASK_REPEAT,
.period = 500,
};
xos_task_add(&task_timer);
xos_task_start(&task_timer);
printf("[%s] %d: task_timer=%x\r\n", __func__, __LINE__, &task_timer);
// key定时任务创建
static task_t task_key = {
.func = key_task_cb,
.mode = TASK_REPEAT,
.period = 5,
};
xos_task_add(&task_key);
xos_task_start(&task_key);
printf("[%s] %d: task_key=%x\r\n", __func__, __LINE__, &task_key);
printf("[%s] %d: \r\n", __func__, __LINE__);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/eric_pyt/xOS.git
git@gitee.com:eric_pyt/xOS.git
eric_pyt
xOS
xOS
master

搜索帮助