#ifndef __MY_TASK_H #define __MY_TASK_H #ifdef __cplusplus extern "C" { #endif #include "stm32f30x.h" /*任务id 数字越小优先级越高 TASK_NUM表示任务数量,务必放到末尾*/ enum { led_id = 0, ymod_id, TASK_NUM }; typedef void (*Task_Handler_t)(void); /*任务块*/ typedef struct { uint32_t RunTime; // 已运行时间 uint32_t On_Time; // 任务执行时间间隔 uint8_t TaskState; // 任务状态 1:可执行 0:空闲 Task_Handler_t Task_Handler; // 任务执行函数 } Task_Block_t, *p_Task_Block_t; /*任务控制块*/ typedef struct { void (*Update_State)(p_Task_Block_t Task_Block); // 更新任务状态函数 p_Task_Block_t Task; // 任务块指针 } Task_Ctrl_t, *p_Task_Ctrl_t; void TaskAdd(uint8_t task_id, Task_Handler_t task, uint32_t on_time); void TaskInit(void); void TaskStart(); extern Task_Ctrl_t Task_Ctrl; void ISR_CallBlack(p_Task_Ctrl_t Task_Ctrl); #ifdef __cplusplus } #endif #endif