49 lines
1.7 KiB
C
49 lines
1.7 KiB
C
|
//
|
|||
|
// Created by KS00596 on 2022/7/13.
|
|||
|
//
|
|||
|
|
|||
|
#ifndef ORIGIN_USERTIMER_H
|
|||
|
#define ORIGIN_USERTIMER_H
|
|||
|
#include "type.h"
|
|||
|
#include "pt.h"
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
/**********************************************************
|
|||
|
行注释
|
|||
|
内容:基础定时服务
|
|||
|
**********************************************************/
|
|||
|
u32 time; //定时时间
|
|||
|
u32 tick; //目前时间
|
|||
|
void (*hdl)(void *,void *); //函数入口,填函数名即可
|
|||
|
void(*priv); //函数参数传递,也可直接定义全局变量,通过全局变量传递
|
|||
|
u8 use; //改定时器任务是否被创建
|
|||
|
u8 timeOut; //是否只执行一次 1:执行完成后直接删除改定时器
|
|||
|
/**********************************************************
|
|||
|
行注释
|
|||
|
内容:增加proto线程调度
|
|||
|
**********************************************************/
|
|||
|
u32 ptTickYead; //通过软件定时延迟程序执行
|
|||
|
u8 ptWake; // protothead是否已经启动过程序标志
|
|||
|
struct pt pt; //protothread句柄
|
|||
|
} USER_TIMER_HDL;
|
|||
|
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|||
|
模块注释
|
|||
|
内容:protoThead相关代码
|
|||
|
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
|
|||
|
#define US_BEGIN() PT_BEGIN(&tisTask->pt)
|
|||
|
#define US_DELAY(x) {tisTask->ptTickYead=x;PT_YIELD(&tisTask->pt);}
|
|||
|
#define US_END() PT_END(&tisTask->pt)
|
|||
|
#define TASK_CREAT_ERR 0xff
|
|||
|
#define TASK_NULL TASK_CREAT_ERR
|
|||
|
|
|||
|
|
|||
|
void UserTimerTask();
|
|||
|
void UserTimerOutDel(u8 id);
|
|||
|
u8 UserTimerOutAdd(void *hdl, void *priv, u16 time);
|
|||
|
void UserTimerResetTime(u8 id, u16 time);
|
|||
|
u8 UserTimerAdd(void *hdl, void *priv, u16 time);
|
|||
|
void UserTimerDel(u8 id);
|
|||
|
|
|||
|
|
|||
|
#endif //ORIGIN_USERTIMER_H
|