fix typos, some refinements
[lunaix-os.git] / lunaix-os / includes / hal / hwtimer.h
1 #ifndef __LUNAIX_HWTIMER_H
2 #define __LUNAIX_HWTIMER_H
3
4 #include <lunaix/device.h>
5 #include <lunaix/time.h>
6 #include <lunaix/types.h>
7
8 typedef void (*timer_tick_cb)();
9
10 #define HWTIMER_MIN_PRECEDENCE      0
11 #define HWTIMER_MAX_PRECEDENCE      15
12
13 struct hwtimer_pot;
14 struct hwtimer_pot_ops
15 {
16     void (*calibrate)(struct hwtimer_pot*, u32_t hertz);
17 };
18
19 struct hwtimer_pot
20 {
21     POTENS_META;
22     
23     struct llist_header timers;
24     
25     int precedence;
26     timer_tick_cb callback;
27     ticks_t base_freq;
28     ticks_t running_freq;
29     volatile ticks_t systick_raw;
30
31     struct hwtimer_pot_ops* ops;
32 };
33
34 void
35 hwtimer_init(u32_t hertz, void* tick_callback);
36
37 ticks_t
38 hwtimer_current_systicks();
39
40 ticks_t
41 hwtimer_to_ticks(u32_t value, int unit);
42
43 struct hwtimer_pot*
44 hwtimer_attach_potens(struct device* dev, int precedence, 
45                       struct hwtimer_pot_ops* ops);
46
47
48 #endif /* __LUNAIX_HWTIMER_H */