feat: device subsystem rework
[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 struct hwtimer
11 {
12     char* name;
13     void* data;
14
15     struct device* timer_dev;
16
17     int (*supported)(struct hwtimer*);
18     void (*init)(struct hwtimer*, u32_t hertz, timer_tick_cb);
19     ticks_t (*systicks)();
20     ticks_t base_freq;
21     ticks_t running_freq;
22 };
23
24 extern struct hwtimer* current_timer;
25
26 void
27 hwtimer_init(u32_t hertz, void* tick_callback);
28
29 struct hwtimer*
30 hwtimer_choose();
31
32 ticks_t
33 hwtimer_base_frequency();
34
35 ticks_t
36 hwtimer_current_systicks();
37
38 ticks_t
39 hwtimer_to_ticks(u32_t value, int unit);
40
41 #endif /* __LUNAIX_HWTIMER_H */