RISC-V中断与异常详解
1. 调度器启动代码
以下代码展示了如何启动调度器:
unsigned int stackRegion [ NTASKS * TASK_STACK_SIZE ];
TCB_Type TCB[ NTASKS ];
void (* TaskFunctions [ NTASKS ]) ();
int current_task = -1;
void Task0 (){
while (1) {}
}
void Task1 (){
while (1) {}
}
void Task2 (){
while (1) {}
}
void Task3 (){
while (1) {}
}
int main ( void )
{
TaskFunctions [0] = Task0 ;
TaskFunctions [1] = Task1 ;
TaskFunctions [2] = Task2 ;
TaskFunctions [3] = Task3 ;
// Init scheduler :
InitSchedulerSVC ( stackRegion , TCB , TaskFunctions );
// Start SysTick timer :
HAL_InitTick (0);
// Switch to NOT PRIVILEDGED with PSP:
__set_CONTROL (0 x00000003 );
// Start the scheduler :
__asm volatile (" svc 0"
超级会员免费看
订阅专栏 解锁全文
1041

被折叠的 条评论
为什么被折叠?



