新手上路
- 积分
- 31
- 金钱
- 31
- 注册时间
- 2021-3-12
- 在线时间
- 8 小时
|
1金钱
int main(void)
{
OS_ERR err;
/*关闭中断*/
//CPU_IntDis();
CPU_SR cpu_sr = 0;
CPU_INT_DIS();
/*配置SysTick 10ms中断一次*/
OS_CPU_SysTickInit(10);
/*初始化相关全局变量*/
OSInit(&err);
/*创建任务*/
OSTaskCreate((OS_TCB*) &Task1TCB, //任务控制块
(CPU_CHAR *)((void *)"Task1"),
(OS_TASK_PTR ) Task1,
(void *) 0,
(OS_PRIO )(3u),
(CPU_STK*) &Task1Stk[0],
(CPU_STK_SIZE)TASK1_STK_SIZE/10,
(CPU_STK_SIZE) TASK1_STK_SIZE,
(OS_MSG_QTY )0u,
(OS_TICK )0u,
(void *)0,
(OS_OPT )(OS_OPT_TASK_NONE),
(OS_ERR *) &err);
OSTaskCreate((OS_TCB*) &Task2TCB,
(CPU_CHAR *)((void *)"Task2"),
(OS_TASK_PTR ) Task2,
(void *) 0,
(OS_PRIO )(4u),
(CPU_STK*) &Task1Stk[0],
(CPU_STK_SIZE)TASK2_STK_SIZE/10,
(CPU_STK_SIZE) TASK2_STK_SIZE,
(OS_MSG_QTY )0u,
(OS_TICK )0u,
(void *)0,
(OS_OPT )(OS_OPT_TASK_STK_CHK|OS_OPT_TASK_STK_CLR),
(OS_ERR *) &err);
/*将任务加入到就绪列表*/
OSRdyList[0].HeadPtr = &Task1TCB;
OSRdyList[1].HeadPtr = &Task2TCB;
/*启动任务 不在返回*/
OSStart(&err);
}
|
|