123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
-
- #ifndef _THREAD_TIMER__H_
- #define _THREAD_TIMER__H_
- #include <sys_clock.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #ifdef CONFIG_THREAD_TIMER
- struct thread_timer;
- typedef void (*thread_timer_expiry_t)(struct thread_timer *ttimer, void *expiry_fn_arg);
- struct thread_timer {
- sys_dlist_t node;
- int32_t duration;
- int32_t period;
- uint32_t expiry_time;
- thread_timer_expiry_t expiry_fn;
- void *expiry_fn_arg;
- };
- extern void thread_timer_init(struct thread_timer *ttimer,
- thread_timer_expiry_t expiry_fn,
- void *arg);
- extern void thread_timer_start(struct thread_timer *ttimer, int32_t duration, int32_t period);
- extern void thread_timer_stop(struct thread_timer *ttimer);
- static inline void thread_timer_restart(struct thread_timer *ttimer)
- {
- thread_timer_start(ttimer, ttimer->duration, ttimer->period);
- }
- extern bool thread_timer_is_running(struct thread_timer *ttimer);
- extern int thread_timer_next_timeout(void);
- extern void thread_timer_handle_expired(void);
- #else
- #define thread_timer_next_timeout() (-1)
- #define thread_timer_handle_expired() do { } while (0)
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
|