Пример #1
0
void rt_systick (void) {
  if(NVIC_Pending(SYS_TICK_IRQn)){
    rt_pop_req();
    NVIC_UnpendIRQ(SYS_TICK_IRQn);
    SYS_TICK_TIMER->IR = 0xF; // clear timer interrupt
    return;
  }
  /* Check for system clock update, suspend running task. */
  P_TCB next;

  os_tsk.run->state = READY;
  rt_put_rdy_first (os_tsk.run);

  /* Check Round Robin timeout. */
  rt_chk_robin ();

  /* Update delays. */
  os_time++;
  rt_dec_dly ();

  /* Check the user timers. */
#ifdef __CMSIS_RTOS
  sysTimerTick();
#else
  rt_tmr_tick ();
#endif

  /* Switch back to highest ready task */
  next = rt_get_first (&os_rdy);
  rt_switch_req (next);
  SYS_TICK_TIMER->IR = 0xF; // clear timer interrupt
}
Пример #2
0
void rt_systick (void) {
  /* Check for system clock update, suspend running task. */
  P_TCB next;

  os_tsk.run->state = READY;
  rt_put_rdy_first (os_tsk.run);

  /* Check Round Robin timeout. */
  rt_chk_robin ();

  /* Update delays. */
  os_time++;
  rt_dec_dly ();

  /* Check the user timers. */
#ifdef __CMSIS_RTOS
  sysTimerTick();
#else
  rt_tmr_tick ();
#endif

  /* Switch back to highest ready task */
  next = rt_get_first (&os_rdy);
  rt_switch_req (next);
}
Пример #3
0
void rt_resume (U32 sleep_time) {
  /* Resume OS scheduler after suspend */
  P_TCB next;
  U32   delta;

  os_tsk.run->state = READY;
  rt_put_rdy_first (os_tsk.run);

  os_robin.task = NULL;

  /* Update delays. */
  if (os_dly.p_dlnk) {
    delta = sleep_time;
    if (delta >= os_dly.delta_time) {
      delta   -= os_dly.delta_time;
      os_time += os_dly.delta_time;
      os_dly.delta_time = 1;
      while (os_dly.p_dlnk) {
        rt_dec_dly();
        if (delta == 0) break;
        delta--;
        os_time++;
      }
    } else {
      os_time           += delta;
      os_dly.delta_time -= delta;
    }
  } else {
    os_time += sleep_time;
  }

  /* Check the user timers. */
#ifdef __CMSIS_RTOS
  sysUserTimerUpdate(sleep_time);
#else
  if (os_tmr.next) {
    delta = sleep_time;
    if (delta >= os_tmr.tcnt) {
      delta   -= os_tmr.tcnt;
      os_tmr.tcnt = 1;
      while (os_tmr.next) {
        rt_tmr_tick();
        if (delta == 0) break;
        delta--;
      }
    } else {
      os_tmr.tcnt -= delta;
    }
  }
#endif

  /* Switch back to highest ready task */
  next = rt_get_first (&os_rdy);
  rt_switch_req (next);

  scheduler_suspended = 0;
  rt_tsk_unlock();
}