/** * Native CPU hwtimer_arch.h implementation * * Copyright (C) 2013 Ludwig Ortmann * * This file subject to the terms and conditions of the GNU General Public * License. See the file LICENSE in the top level directory for more details. * * @ingroup arch * @{ * @file * @author Ludwig Ortmann * @} */ #include #include #include #include #include "hwtimer.h" #include "hwtimer_arch.h" #include "hwtimer_cpu.h" #include "cpu.h" #include "cpu-conf.h" #include "debug.h" #define HWTIMER_MINTICKS (1000) static unsigned long native_hwtimer_now; static int native_hwtimer_irq[ARCH_MAXTIMERS]; static timer_t native_hwtimer_timer[ARCH_MAXTIMERS]; static void (*int_handler)(int); void ticks2ts(unsigned long ticks, struct timespec *tp) { tp->tv_sec = ticks / HWTIMER_SPEED; tp->tv_nsec = (ticks % HWTIMER_SPEED)*1000 ; } unsigned long ts2ticks(struct timespec *tp) { /* TODO: check for overflow */ return((tp->tv_sec * HWTIMER_SPEED) + (tp->tv_nsec/1000)); } void hwtimer_isr_timer() { DEBUG("hwtimer_isr_timer()\n"); for (int i = 0; i