示例#1
0
文件: nrk.c 项目: prabalsharma/NanoRK
void nrk_start (void)
{
	int8_t task_ID;
	uint8_t i,j;
//	NRK_STK *x;
//	unsigned char *stkc;

	/*
		- Get highest priority task from rdy list
		- set cur prio and start the task 
	*/
    // Check to make sure all tasks unique
    for(i=0; i<NRK_MAX_TASKS; i++ )
    {
	task_ID = nrk_task_TCB[i].task_ID;
	// only check activated tasks
	if(task_ID!=-1)
	{
    		for(j=0; j<NRK_MAX_TASKS; j++ )
		{
			if(i!=j && task_ID==nrk_task_TCB[j].task_ID)
			{
			nrk_kernel_error_add(NRK_DUP_TASK_ID,task_ID);

			}
		}
	}

    }

    task_ID = nrk_get_high_ready_task_ID();	
    nrk_high_ready_prio = nrk_task_TCB[task_ID].task_prio;
    nrk_high_ready_TCB = nrk_cur_task_TCB = &nrk_task_TCB[task_ID];           
    nrk_cur_task_prio = nrk_high_ready_prio;
		
//    nrk_stack_pointer_restore();

    /*
    #ifdef KERNEL_STK_ARRAY
     	stkc = (uint16_t*)&nrk_kernel_stk[NRK_KERNEL_STACKSIZE-1];
    #else
    	stkc = NRK_KERNEL_STK_TOP;
    #endif
    *stkc++ = (uint16_t)((uint16_t)_nrk_timer_tick>>8);
    *stkc = (uint16_t)((uint16_t)_nrk_timer_tick&0xFF); 
    
    //TODO: this way on msp
    // *stkc++ = (uint16_t)((uint16_t)_nrk_timer_tick&0xFF);
    // *stkc = (uint16_t)((uint16_t)_nrk_timer_tick>>8); 
*/
    nrk_target_start();
    nrk_stack_pointer_init(); 
    nrk_start_high_ready_task();	

    // you should never get here    
    while(1);
}
示例#2
0
 void nrk_start (void)
{
 nrk_cur_task_TCB = nrk_get_high_ready_task_ID(); //taskTCB
    /////task_ID=taskTCB->task_ID;//////task_ID = nrk_get_high_ready_task_ID();	
    nrk_high_ready_prio = nrk_cur_task_TCB->task_prio;
    nrk_high_ready_TCB = nrk_cur_task_TCB;// = taskTCB;           
    nrk_cur_task_prio = nrk_high_ready_prio;
    nrk_target_start();
	nrk_stack_pointer_init(); 
	nrk_start_high_ready_task(nrk_high_ready_TCB);	

    // you should never get here    
    while(1);
}
示例#3
0
文件: nrk.cpp 项目: ESE519/EVM-2013
void nrk_start (void)
{
    int8_t task_ID;
    uint8_t i,j;
    //    NRK_STK *x;
    //    unsigned char *stkc;

    /*
       - Get highest priority task from rdy list
       - set cur prio and start the task 
     */
    // Check to make sure all tasks unique
    for(i=0; i<NRK_MAX_TASKS; i++ )
    {
        task_ID = nrk_task_TCB[i].task_ID;
        // only check activated tasks
        if(task_ID!=-1)
        {
            for(j=0; j<NRK_MAX_TASKS; j++ )
            {
                if(i!=j && task_ID==nrk_task_TCB[j].task_ID)
                {
                    nrk_kernel_error_add(NRK_DUP_TASK_ID,task_ID);
                    //pc.printf("in task error");
                }
            }
        }

    }
    
    task_ID = nrk_get_high_ready_task_ID();    
    nrk_high_ready_prio = nrk_task_TCB[task_ID].task_prio;
    nrk_high_ready_TCB = nrk_cur_task_TCB = &nrk_task_TCB[task_ID];           
    nrk_cur_task_prio = nrk_high_ready_prio;
    //    nrk_stack_pointer_restore();

    /*
#ifdef KERNEL_STK_ARRAY
stkc = (uint16_t*)&nrk_kernel_stk[NRK_KERNEL_STACKSIZE-1];
#else
stkc = NRK_KERNEL_STK_TOP;
#endif
     *stkc++ = (uint16_t)((uint16_t)_nrk_timer_tick>>8);
     *stkc = (uint16_t)((uint16_t)_nrk_timer_tick&0xFF); 

    //TODO: this way on msp
    // *stkc++ = (uint16_t)((uint16_t)_nrk_timer_tick&0xFF);
    // *stkc = (uint16_t)((uint16_t)_nrk_timer_tick>>8); 
     */
    nrk_target_start();
		//_nrk_setup_timer_test();
    //pc.printf("call nrk_foo()\r\n");
    //nrk_foo();  
    nrk_stack_pointer_init(); 
    //nrk_led_set(RED_LED);
		task_addr = (unsigned int) nrk_task_TCB[task_ID].task_addr; // Abhijeet's statement
		//pc1.printf("first tcb address:%x",nrk_high_ready_TCB);
		//NVIC_SetPriority(SVCall_IRQn, 2);
		//NVIC_SetPriority(TIMER0_IRQn, 1);
		//NVIC_SetPriority(PendSV_IRQn, 3);
    nrk_start_high_ready_task();    
		//_startos();
    // you should never get here    
    while(1);
}