1 #ifndef __LUNAIX_TIMER_H
2 #define __LUNAIX_TIMER_H
4 #include <lunaix/ds/llist.h>
7 #define SYS_TIMER_FREQUENCY_HZ 1024
9 #define TIMER_MODE_PERIODIC 0x1
11 typedef u32_t ticks_t;
13 struct lx_timer_context
15 struct lx_timer* active_timers;
17 * @brief APIC timer base frequency (ticks per seconds)
20 ticks_t base_frequency;
22 * @brief Desired system running frequency
25 u32_t running_frequency;
27 * @brief Ticks per hertz
35 struct llist_header link;
39 void (*callback)(void*);
44 * @brief Initialize the system timer that runs at specified frequency
46 * @param frequency The frequency that timer should run in Hz.
49 timer_init(u32_t frequency);
52 timer_run_second(u32_t second,
53 void (*callback)(void*),
58 timer_run_ms(u32_t millisecond,
59 void (*callback)(void*),
64 timer_run(ticks_t ticks, void (*callback)(void*), void* payload, uint8_t flags);
66 struct lx_timer_context*
69 #endif /* __LUNAIX_TIMER_H */