You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

54 lines
1.1 KiB

#include "ztask.h"
#define TAG "ztask"
/*
* @brief: uart回调任务状态转换,由任务时间表进行任务通知
*
*/
void Task_init(Task_t* task){
if(task->TaskNotify){
task->TaskNotify--;
if(task->m_tasktransition){
task->m_status = working;
//ZLOGI(TAG, "task_init");
if(task->m_taskfunc) task->m_taskfunc();
task->m_status = end;
}
else{
task->m_status = idle;
}
}
}
/*
* @brief 回调函数注册
*
*
*
*判断任务状态
*任务空闲:状态转换开
* 状态转换开:1.回调函数登记注册
* 2.任务通知
*
*任务非空闲:状态转换关
* 状态转换关:1.不注册
* 2.任务通知等待任务状态空闲
*/
void Task_start(taskfuction cb, Task_t* task){
if(task->m_status != idle){
task->m_tasktransition = false;//状态: 非空闲,状态转换关
task->TaskNotify++; //通知任务
}
else{
task->m_taskfunc = cb;
task->m_tasktransition = true;//状态: 空闲,状态转换开
task->TaskNotify++; //通知任务
}
//ZLOGI(TAG, "TaskNotify: %d", task->TaskNotify);
}