#include "stm32f10x.h"
#include "wkup.h"
#include "key.h"
#include "led.h"
#include "uart.h"
#include "time6.h"
#include "queue.h"
void task1()
{
printf("task1");
}
void task2()
{
printf("task2");
}
void task3()
{
printf("task3");
}
void task4()
{
printf("task4");
}
u16 task_delay[] = {100,200,300,400};//任务运行时间,也可作为首次执行时间
u16 task_reload_time[] = {100,200,300,400};//任务重装载时间
void (*task[])(void) = {task1,task2,task3,task4};//任务函数
void Task_Process()
{
u8 i = 0;
for(i = 0; i < sizeof(task) / sizeof(task[0]); i++)
{
if(task_delay[i] == 0)
{
task[i]();
task_delay[i] = task_reload_time[i];
break;
}
}
}
int main(void)
{
while(1)
{
Task_Process();
}
}
void timer_interrupt(void)
{
u8 i = 0;
for(i = 0; i < sizeof(task_delay) / sizeof(task_delay[0]); i++)
{
if(task_delay[i])
{
task_delay[i]--;
}
}
}
|