小学生
最后登录1970-1-1
在线时间 小时
注册时间2022-6-10
|
楼主 |
发表于 2022-6-14 08:20:23
|
显示全部楼层
/*
*************************************************************************
* 任务控制块 & STACK
*************************************************************************
*/
TCB_t Task1TCB,Task2TCB;
#define TASK1_STACK_SIZE 20
StackType_t Task1Stack[TASK1_STACK_SIZE];
#define TASK2_STACK_SIZE 20
StackType_t Task2Stack[TASK2_STACK_SIZE];
//定义任务控制块
TCB_t Task1TCB;
TCB_t Task2TCB;
//定义任务句柄
TaskHandle_t Task1_Handle;
TaskHandle_t Task2_Handle;
/*
*************************************************************************
* 函数声明
*************************************************************************
*/
void delay (uint32_t count);
void Task1_Entry( void *p_arg );
void Task2_Entry( void *p_arg );
int main(void){
prvInitialiseTaskLists( ); //初始化就绪列表
Task1_Handle =xTaskCreateStatic(Task1_Entry,
"Task1_Entry",
TASK1_STACK_SIZE,
NULL,
2,
Task1Stack,
&Task1TCB
);
//vListInsert(&pxReadyTasksLists[1],&Task1TCB.xStateListItem);
Task2_Handle =xTaskCreateStatic(Task2_Entry,
"Task2_Entry",
TASK2_STACK_SIZE,
NULL,
1,
Task2Stack,
&Task2TCB
);
//vListInsert(&pxReadyTasksLists[2],&Task2TCB.xStateListItem);
/* 在启动调度器前,关闭中断 */
portDISABLE_INTERRUPTS();
vTaskStartScheduler();
while(1){
}
}
//定义一个任务函数
/* 软件延时 */
void delay (uint32_t count)
{
for(; count!=0; count--);
}
void Task1_Entry(void *p_arg)
{for(;;)
{ flag1 = 1;
vTaskDelay( 2 );
flag1 = 0;
vTaskDelay( 2);
//taskYIELD();
}
}
void Task2_Entry(void *p_arg)
{for(;;)
{flag2 = 1;
vTaskDelay( 2 );
flag2 = 0;
vTaskDelay( 2 );
}
}
StackType_t IdleTaskStack[configMINIMAL_STACK_SIZE];
TCB_t IdleTaskTCB;
void vApplicationGetIdleTaskMemory( TCB_t **ppxIdleTaskTCBBuffer,
StackType_t **ppxIdleTaskStackBuffer,
uint32_t *pulIdleTaskStackSize )
{
*ppxIdleTaskTCBBuffer=&IdleTaskTCB;
*ppxIdleTaskStackBuffer=IdleTaskStack;
*pulIdleTaskStackSize=configMINIMAL_STACK_SIZE;
} |
|