1 #ifndef __LUNAIX_TIMER_H
2 #define __LUNAIX_TIMER_H
4 #include <lunaix/ds/llist.h>
5 #include <lunaix/time.h>
6 #include <lunaix/pcontext.h>
8 #define SYS_TIMER_FREQUENCY_HZ 1000
10 #define TIMER_MODE_PERIODIC 0x1
12 struct lx_timer_context
14 struct lx_timer* active_timers;
16 * @brief timer hardware base frequency (ticks per seconds)
19 ticks_t base_frequency;
21 * @brief Desired system running frequency
24 ticks_t running_frequency;
26 * @brief Ticks per hertz
32 struct timer_init_param
34 struct lx_timer_context* context;
35 void* timer_update_isr;
40 struct llist_header link;
44 void (*callback)(void*);
49 * @brief Initialize the system timer that runs at specified frequency
51 * @param frequency The frequency that timer should run in Hz.
57 timer_run_second(u32_t second,
58 void (*callback)(void*),
63 timer_run_ms(u32_t millisecond,
64 void (*callback)(void*),
69 timer_run(ticks_t ticks, void (*callback)(void*), void* payload, u8_t flags);
71 struct lx_timer_context*
74 #endif /* __LUNAIX_TIMER_H */