コード例 #1
0
ファイル: nrk_task.c プロジェクト: mlab-upenn/ecgpatch
int8_t nrk_wait (nrk_time_t t)
{
  uint8_t timer;
  uint16_t nw;

  nrk_stack_check ();

  nrk_int_disable ();
  nrk_cur_task_TCB->suspend_flag = 1;
  nrk_cur_task_TCB->num_periods = 1;
  timer = _nrk_os_timer_get ();

//printf( "t1 %lu %lu\n",t.secs, t.nano_secs/NANOS_PER_MS);
  nw = _nrk_time_to_ticks (t);
//printf( "t2 %u\n",nw );
  nrk_cur_task_TCB->next_wakeup = nw + timer;
//printf( "wu %u\n",nrk_cur_task_TCB->next_wakeup );
  if (timer < (MAX_SCHED_WAKEUP_TIME - TIME_PAD))
    if ((timer + TIME_PAD) <= _nrk_get_next_wakeup ()) {
      timer += TIME_PAD;
      _nrk_prev_timer_val = timer;
      _nrk_set_next_wakeup (timer);
    }
  nrk_int_enable ();

  _nrk_wait_for_scheduler ();
  return NRK_OK;
}
コード例 #2
0
ファイル: nrk_task.c プロジェクト: mlab-upenn/ecgpatch
int8_t nrk_wait_until_next_n_periods (uint16_t p)
{
  uint8_t timer;

  nrk_stack_check ();

  if (p == 0)
    p = 1;
// Next Period Wakeup Time is Set inside scheduler when a task becomes Runnable 
  nrk_int_disable ();
  nrk_cur_task_TCB->suspend_flag = 1;
  nrk_cur_task_TCB->num_periods = p;
  timer = _nrk_os_timer_get ();

//nrk_cur_task_TCB->cpu_remaining=_nrk_prev_timer_val+1;

// +2 allows for potential time conflict resolution
  if (timer < (MAX_SCHED_WAKEUP_TIME - TIME_PAD))       // 254 8bit overflow point - 2
    if ((timer + TIME_PAD) <= _nrk_get_next_wakeup ()) {
      timer += TIME_PAD;
      _nrk_prev_timer_val = timer;
      _nrk_set_next_wakeup (timer);
    }

  nrk_int_enable ();
  _nrk_wait_for_scheduler ();
  return NRK_OK;
}
コード例 #3
0
ファイル: nrk_task.c プロジェクト: prashar/nanork
int8_t nrk_wait_until_next_period() {
	uint8_t timer;

	nrk_stack_check();
	// Next Period Wakeup Time is Set inside scheduler when a task becomes Runnable
	nrk_int_disable();
	nrk_cur_task_TCB->num_periods = 1;
	nrk_cur_task_TCB->suspend_flag = 1;
	timer = _nrk_os_timer_get();

	//nrk_cur_task_TCB->cpu_remaining=_nrk_prev_timer_val+1;

	if (timer < (MAX_SCHED_WAKEUP_TIME - TIME_PAD))
		if ((timer + TIME_PAD) <= _nrk_get_next_wakeup()) {
			timer += TIME_PAD;
			_nrk_prev_timer_val = timer;
			_nrk_set_next_wakeup(timer);
		}

	printf("Task %u finished in %u. \r\n",nrk_cur_task_TCB->task_ID,timer);

	nrk_int_enable();
	_nrk_wait_for_scheduler();
	return NRK_OK;
}
コード例 #4
0
ファイル: nrk_task.c プロジェクト: vishnudh/RTOS
int8_t nrk_wait_until_next_period ()
{
  uint16_t timer;

  nrk_stack_check ();
// Next Period Wakeup Time is Set inside scheduler when a task becomes Runnable // EXCEPT THIS CAUSES A FIRST-TIME-THROUGH BUG
  nrk_int_disable ();
  nrk_cur_task_TCB->num_periods = 1;
  nrk_cur_task_TCB->suspend_flag = 1;
  nrk_cur_task_TCB->next_wakeup = nrk_cur_task_TCB->next_period;
  timer = _nrk_os_timer_get ();

//nrk_cur_task_TCB->cpu_remaining=_nrk_prev_timer_val+1;

  if (timer < (MAX_SCHED_WAKEUP_TIME - TIME_PAD))
    if ((timer + TIME_PAD) <= _nrk_get_next_wakeup ()) {
      timer += TIME_PAD;
      _nrk_prev_timer_val = timer;
      _nrk_set_next_wakeup (timer);
    }

  nrk_int_enable ();
  _nrk_wait_for_scheduler ();
  return NRK_OK;
}
コード例 #5
0
ファイル: nrk_task.c プロジェクト: alele89/18748-WSN
int8_t nrk_wait_until_next_period ()
{
    uint8_t timer;

    nrk_stack_check ();
// Next Period Wakeup Time is Set inside scheduler when a task becomes Runnable
    nrk_int_disable ();
    nrk_cur_task_TCB->num_periods = 1;
    nrk_cur_task_TCB->suspend_flag = 1;
    timer = _nrk_os_timer_get ();

//nrk_cur_task_TCB->cpu_remaining=_nrk_prev_timer_val+1;

    if (timer < (MAX_SCHED_WAKEUP_TIME - TIME_PAD))
        if ((timer + TIME_PAD) <= _nrk_get_next_wakeup ())
        {
            timer += TIME_PAD;
            _nrk_prev_timer_val = timer;                  // pdiener: why is this only set in this special case?
            _nrk_set_next_wakeup (timer);                 // pdiener: Set next wakeup to NOW
        }

    nrk_int_enable ();
    _nrk_wait_for_scheduler ();
    return NRK_OK;
}
コード例 #6
0
ファイル: nrk_idle_task.c プロジェクト: ESE519/ISA100.11a
void nrk_idle_task()
{
volatile unsigned char *stkc;
// unsigned int *stk ;  // 2 bytes
while(1)
{

  nrk_stack_check(); 
  
  if(_nrk_get_next_wakeup()<=NRK_SLEEP_WAKEUP_TIME) 
    {
	    _nrk_cpu_state=1;
	    nrk_idle();
    }
    else {
	#ifndef NRK_NO_POWER_DOWN
	    // Allow last UART byte to get out
    	    nrk_spin_wait_us(10);  
	    _nrk_cpu_state=2;
	    nrk_sleep();
	#else
	    nrk_idle();
	#endif
    }
 
#ifdef NRK_STACK_CHECK
   if(nrk_idle_task_stk[0]!=STK_CANARY_VAL) nrk_error_add(NRK_STACK_SMASH);
   #ifdef KERNEL_STK_ARRAY
   	if(nrk_kernel_stk[0]!=STK_CANARY_VAL) nrk_error_add(NRK_STACK_SMASH);
   #else
   	stkc=(unsigned char*)(NRK_KERNEL_STK_TOP-NRK_KERNEL_STACKSIZE);
   	if(*stkc!=STK_CANARY_VAL) nrk_error_add(NRK_STACK_SMASH);
   #endif
#endif



}


}