1 /* $Id: timers.h,v 1.1 2010/06/27 22:18:26 simimeie Exp $
2 * Functions for timing.
3 * This mainly allows you to get a timestamp value
9 /* timestamps are usually delivered in 'ticks'.
10 * At 8.0 MHz, there are ca. 122 ticks per second, and the 16 bit tick counter
11 * overflows about every 536 seconds.
12 * If you need exacter timing, you can also get a struct timestamp.
13 * That will contain the tick value and the current counter value as
14 * an uint16, giving you a precision of up to 1 cpu cycle. */
16 #define TICKSPERSECOND (CPUFREQ / 65536UL)
17 #define TICKSPERSECONDF ((float)CPUFREQ / 65536.0)
25 void timers_init(void);
28 * Warning: Will reenable interrupts if they were disabled. */
29 uint16_t getticks(void);
30 /* The same, but won't touch the global interrupt enable bit.
31 * MUST BE CALLED WITH INTERRUPTS DISABLED */
32 uint16_t getticks_noirq(void);
35 * Warning: Will reenable interrupts if they were disabled. */
36 struct timestamp gettimestamp(void);
37 /* The same, but won't touch the global interrupt enable bit.
38 * MUST BE CALLED WITH INTERRUPTS DISABLED */
39 struct timestamp gettimestamp_noirq(void);
41 #endif /* _TIMERS_H_ */