示例#1
0
文件: stick.c 项目: BuFran/canshark
// 1.5 ns step
uint64_t stick_get_us(void)
{
	CM_ATOMIC_CONTEXT();
	uint32_t rld = systick_get_reload() + 1;

	uint64_t ss = (rld-systick_get_value()) * 1000 / rld;

	if (nvic_get_pending_irq(NVIC_SYSTICK_IRQ) && (ss < 500)) {
		// overflow between atomic and get value?
		ss += 1000;
	}

	return ticks * 1000 + ss;
}
示例#2
0
uint32_t tick_delta_time_tick(uint32_t start, uint32_t end)
{

  uint32_t reload_val = systick_get_reload() - 1;
  uint32_t diff;

  if (end > start)
  {
    diff = end - start;
  }
  else
  {
    diff = reload_val - (start - end) + 1;
  }

  return diff;
}
示例#3
0
void sys_tick_handler(void)
{
    uint32_t next_timer = 0;
    volatile uint32_t reload = systick_get_reload();
    uint32_t this_timeslice;
    SysTick_Hook();
    jiffies+= clock_interval;
    _n_int++;
    next_timer = ktimers_check();

#ifdef CONFIG_LOWPOWER
    if (next_timer < 0 || next_timer > 1000){
        next_timer = 1000; /* Wake up every second if timer is too long, or if no timers */
    }

    /* Checking deep sleep */
    if (next_timer >= 1000 && scheduler_can_sleep()) {
        systick_interrupt_disable();
        cputimer_start(next_timer);
        return;
    }
#ifdef CONFIG_TICKLESS
    this_timeslice = task_timeslice();
    if (_sched_active && (this_timeslice == 0) && (!task_running())) {
        schedule();
    } else {
        systick_interrupt_disable();
        cputimer_start(this_timeslice);
    }
    return;
#endif
#endif

    if (_sched_active && ((task_timeslice() == 0) || (!task_running()))) {
        schedule();
        (void)next_timer;
    }
}