- 打卡等级:常住居民III
- 打卡总天数:103
- 最近打卡:2025-06-19 07:25:20
已绑定手机
中级会员
- 积分
- 282
|
发表于 2025-3-10 10:17:22
|
显示全部楼层
请教大佬们,定时器多任务 有点不明,static TASK_COMPONENTS Task_Comps[]=
{
//状态 计数 周期 函数
{0, 500, 500, Sample_LED0}, /* task 1 Period: 500ms */
{0, 1000, 1000, Sample_LED2}, /* task 2 Period: 1000ms */
{0, 2000, 2000, Sample_LED4}, /* task 3 Period: 2000ms */
// {0, 500, 500, Sample_RTC}, /* task 4 Period: 500ms */
/* Add new task here */
};
u8 Tasks_Max = sizeof(Task_Comps)/sizeof(Task_Comps[0]);
//========================================================================
// 函数: Task_Handler_Callback
// 描述: 任务标记回调函数.
// 参数: None.
// 返回: None.
// 版本: V1.0, 2012-10-22
//========================================================================
void Task_Marks_Handler_Callback(void)
{
u8 i;
for(i=0; i<Tasks_Max; i++)
{
if(Task_Comps[i].TIMCount) /* If the time is not 0 */
{
Task_Comps[i].TIMCount--; /* Time counter decrement */
if(Task_Comps[i].TIMCount == 0) /* If time arrives */
{
/*Resume the timer value and try again */
Task_Comps[i].TIMCount = Task_Comps[i].TRITime;
Task_Comps[i].Run = 1; /* The task can be run */
}
}
}
}
//========================================================================
// 函数: Task_Pro_Handler_Callback
// 描述: 任务处理回调函数.
// 参数: None.
// 返回: None.
// 版本: V1.0, 2012-10-22
//========================================================================
void Task_Pro_Handler_Callback(void)
{
u8 i;
for(i=0; i<Tasks_Max; i++)
{
if(Task_Comps[i].Run) /* If task can be run */
{
Task_Comps[i].Run = 0; /* Flag clear 0 */
Task_Comps[i].TaskHook(); /* Run task */
}
}
}
搞来搞不上在 40P的AI8051U -34K64 |
|