代码拉取完成,页面将自动刷新
#ifndef _XOS_H_
#define _XOS_H_
#include <stdint.h>
#include "dlist.h"
#include "xos_init.h"
#define XOS_VERSION 1
#define XOS_SUBVERSION 2
#define XOS_REVISION 0
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef ENTER_CRITICAL
#define ENTER_CRITICAL() \
do { \
} while (0);
#endif
#ifndef EXIT_CRITICAL
#define EXIT_CRITICAL() \
do { \
} while (0);
#endif
/**
* @brief 任务事件 举例
*
*
*
* enum EVENT_SIG
* {
* SIG_ALARM = 1 << 0,
* SIG_DATA = 1 << 1,
* SIG_NOTE = 1 << 2,
* SIG_UART = 1 << 3,
* SIG_RADIO = 1 << 4,
* SIG_GPRS = 1 << 5,
* SIG_USR1 = 1 << 8,
* SIG_USR2 = 1 << 9,
* SYS_EVENT_MSG = 1 << 15,
* };
*/
enum
{
TASK_LOOP = 0x00, // 循环任务
TASK_ONCE = 0x01, // 定时单次任务
TASK_REPEAT = 0x02,
};
enum
{
TASK_IDLE = 0x00,
TASK_BUSY = 0x01,
};
typedef void (*task_cb)(void* arg, uint32_t event);
typedef struct task_node
{
uint8_t is_start; // 启动任务
uint8_t is_run; // 任务运行标志
uint8_t is_busy; // 用于低功耗控制,TASK_IDLE 允许进入低功耗,TASK_BUSY:不进入低功耗
uint8_t mode; // 任务类型,TASK_LOOP,TASK_ONCE,TASK_REPEAT
uint32_t period; // 定时周期
uint32_t tick; // 定时计数
uint32_t event; // 驱动事件
task_cb func; // 回调函数
void* arg; // 用户接口
struct list_head list;
} task_t;
/**
* @brief 新建任务
*
* @param task 任务主体
* @return int TRUE or FALSE
*/
int xos_task_add(task_t* task);
/**
* @brief 删除任务
*
* @param task 任务主体
* @return int TRUE or FALSE
*/
int xos_task_delete(task_t* task);
/**
* @brief 任务循环
*
*/
void xos_task_loop(void);
/**
* @brief 任务启动,对于普通任务则直接运行,对于定时任务,则只触发start
*
* @param task 任务
* @return int TRUE or FALSE
*/
int xos_task_start(task_t* task);
/**
* @brief 任务停止
*
* @param task 任务
* @return int TRUE or FALSE
*/
int xos_task_stop(task_t* task);
/**
* @brief 任务基准时间,需放到1ms tick_handle中循环
*
*/
void xos_timer_ticker(void);
/**
* @brief 设置事件
*
* @param task 任务主体
* @param event 自定义事件
* @return int TRUE or FALSE
*/
int xos_event_set(task_t* task, uint32_t event);
/**
* @brief 重置事件
*
* @param task 任务主体
* @param event 自定义事件
* @return int TRUE or FALSE
*/
int xos_event_reset(task_t* task, uint32_t event);
/**
* @brief 1ms阻塞延时
*
* @param ms
*/
void xos_delay_ms(uint32_t ms);
/**
* @brief 设置sleep回调
*
* @param func 回调函数
* @return int TRUE
*/
int xos_set_sleep_handel(task_cb func);
#endif
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。