+
+//TODO: take care of slow timers so add convertions for seconds to ticks and viceversa.
+
+/*! Convert \a ms [ms] to ticks */
+INLINE ticks_t ms_to_ticks(mtime_t ms)
+{
+ return ms * TIMER_TICKS_PER_MSEC;
+}
+
+/*! Convert \a us [us] to ticks */
+INLINE ticks_t us_to_ticks(utime_t us)
+{
+#if TIMER_TICKS_PER_MSEC < 10000
+ return (us * TIMER_TICKS_PER_MSEC + 500) / 1000;
+#else
+ return (us * TIMER_TICKS_PER_USEC);
+#endif
+}
+
+/*! Convert \a ticks [ticks] to ms */
+INLINE mtime_t ticks_to_ms(ticks_t ticks)
+{
+ return (ticks + TIMER_TICKS_PER_MSEC / 2) / TIMER_TICKS_PER_MSEC;
+}
+
+/*! Convert \a ticks [ticks] to us */
+INLINE utime_t ticks_to_us(ticks_t ticks)
+{
+#if TIMER_TICKS_PER_USEC > 10
+ return (ticks / TIMER_TICKS_PER_USEC);
+#else
+ return (ticks * 1000 + TIMER_TICKS_PER_MSEC / 2) / TIMER_TICKS_PER_MSEC;
+#endif
+}
+
+/*! Convert \a us [us] to hpticks */
+INLINE hptime_t us_to_hptime(utime_t us)
+{
+ #if TIMER_HW_HPTICKS_PER_SEC > 10000000UL
+ return(us * ((TIMER_HW_HPTICKS_PER_SEC + 500000UL) / 1000000UL));
+ #else
+ return((us * TIMER_HW_HPTICKS_PER_SEC + 500000UL) / 1000000UL);
+ #endif /* TIMER_HW_HPTICKS_PER_SEC > 10000000UL */
+}
+
+/*! Convert \a hpticks [hptime] to usec */
+INLINE utime_t hptime_to_us(hptime_t hpticks)
+{
+ #if TIMER_HW_HPTICKS_PER_SEC < 100000UL
+ return(hpticks * (1000000UL / TIMER_HW_HPTICKS_PER_SEC));
+ #else
+ return((hpticks * 1000000UL) / TIMER_HW_HPTICKS_PER_SEC);
+ #endif /* TIMER_HW_HPTICKS_PER_SEC < 100000UL */
+}
+
+
+void timer_init(void);
+void timer_delayTicks(ticks_t delay);
+INLINE void timer_delay(mtime_t delay)
+{
+ timer_delayTicks(ms_to_ticks(delay));
+}
+
+#if !defined(CONFIG_TIMER_DISABLE_UDELAY)
+void timer_busyWait(hptime_t delay);
+void timer_delayHp(hptime_t delay);
+INLINE void timer_udelay(utime_t delay)
+{
+ timer_delayHp(us_to_hptime(delay));
+}
+#endif
+
+#if CONFIG_TEST
+void timer_test(void);
+#endif /* CONFIG_TEST */
+
+#ifndef CONFIG_TIMER_DISABLE_EVENTS
+
+#include <mware/event.h>
+