diff options
Diffstat (limited to 'core/timer.h')
-rw-r--r-- | core/timer.h | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/core/timer.h b/core/timer.h index 8844a1dd..15491326 100644 --- a/core/timer.h +++ b/core/timer.h | |||
@@ -44,7 +44,7 @@ typedef struct timer timer; | |||
44 | * You may call any of the timer functions within the callback: | 44 | * You may call any of the timer functions within the callback: |
45 | * For example, you may call timer_start to restart the timer from | 45 | * For example, you may call timer_start to restart the timer from |
46 | * within a callback. */ | 46 | * within a callback. */ |
47 | typedef int (*timer_callback)(timer* t, void* userarg); | 47 | typedef int (*timer_callback)(timer *t, void *userarg); |
48 | 48 | ||
49 | /* Initisalise timer subsystem */ | 49 | /* Initisalise timer subsystem */ |
50 | void timer_init(void); | 50 | void timer_init(void); |
@@ -53,52 +53,52 @@ void timer_init(void); | |||
53 | void timer_poll(void); | 53 | void timer_poll(void); |
54 | 54 | ||
55 | /* Creates a new timer. Does not enqueue/start it. */ | 55 | /* Creates a new timer. Does not enqueue/start it. */ |
56 | timer* new_timer(void); | 56 | timer *new_timer(void); |
57 | 57 | ||
58 | /* Destroys a timer instance. */ | 58 | /* Destroys a timer instance. */ |
59 | void delete_timer(timer* t); | 59 | void delete_timer(timer *t); |
60 | 60 | ||
61 | /* Sets up the timer callback. */ | 61 | /* Sets up the timer callback. */ |
62 | void timer_setup(timer* t, timer_callback cb, void* userarg); | 62 | void timer_setup(timer *t, timer_callback cb, void *userarg); |
63 | 63 | ||
64 | /* Accessor Function. */ | 64 | /* Accessor Function. */ |
65 | void* timer_get_userdata(timer* t); | 65 | void *timer_get_userdata(timer *t); |
66 | 66 | ||
67 | /* Starts the timer so that it's called in sec seconds in the future from now. | 67 | /* Starts the timer so that it's called in sec seconds in the future from now. |
68 | * A non-positive value of sec results in the callback being called immediately. | 68 | * A non-positive value of sec results in the callback being called immediately. |
69 | * This function may be called again after a timer has been started to adjust | 69 | * This function may be called again after a timer has been started to adjust |
70 | * the expiry time. */ | 70 | * the expiry time. */ |
71 | void timer_start(timer* t, int sec); | 71 | void timer_start(timer *t, int sec); |
72 | 72 | ||
73 | /* Stops the timer. Returns -1 if the timer was not active. */ | 73 | /* Stops the timer. Returns -1 if the timer was not active. */ |
74 | int timer_stop(timer* t); | 74 | int timer_stop(timer *t); |
75 | 75 | ||
76 | /* Adds additionalsec seconds to the timer. | 76 | /* Adds additionalsec seconds to the timer. |
77 | * Returns -1 and does nothing if the timer was not active. */ | 77 | * Returns -1 and does nothing if the timer was not active. */ |
78 | int timer_delay(timer* t, int additonalsec); | 78 | int timer_delay(timer *t, int additonalsec); |
79 | 79 | ||
80 | /* Returns the time remaining on a timer in seconds. | 80 | /* Returns the time remaining on a timer in seconds. |
81 | * Returns -1 if the timer is not active. | 81 | * Returns -1 if the timer is not active. |
82 | * Returns 0 if the timer has expired and the callback hasn't been called yet. */ | 82 | * Returns 0 if the timer has expired and the callback hasn't been called yet. */ |
83 | int timer_time_remaining(timer* t); | 83 | int timer_time_remaining(timer *t); |
84 | 84 | ||
85 | /* Determines if timer is active. Returns TRUE if it is active */ | 85 | /* Determines if timer is active. Returns TRUE if it is active */ |
86 | bool timer_is_active(timer* t); | 86 | bool timer_is_active(timer *t); |
87 | 87 | ||
88 | /* Single-use timer. | 88 | /* Single-use timer. |
89 | * Creates a new timer, preforms setup and starts it. | 89 | * Creates a new timer, preforms setup and starts it. |
90 | * Callback must return a non-zero value to prevent memory leak. */ | 90 | * Callback must return a non-zero value to prevent memory leak. */ |
91 | void timer_single(timer_callback cb, void* userarg, int sec); | 91 | void timer_single(timer_callback cb, void *userarg, int sec); |
92 | 92 | ||
93 | /* Single-use microsecond timer. | 93 | /* Single-use microsecond timer. |
94 | * Creates a new timer, preforms setup and starts it. | 94 | * Creates a new timer, preforms setup and starts it. |
95 | * Please do not use this when accuracy is not absolutely required. | 95 | * Please do not use this when accuracy is not absolutely required. |
96 | * Use when one needs to time a period < 1 s. | 96 | * Use when one needs to time a period < 1 s. |
97 | * Use the more coarse timers above for periods > 5 s. | 97 | * Use the more coarse timers above for periods > 5 s. |
98 | * WARNING: the callback will be called with NULL as the first argument */ | 98 | * WARNING: the callback will be called with NULL as the first argument */ |
99 | void timer_us(timer_callback cb, void* userarg, int us); | 99 | void timer_us(timer_callback cb, void *userarg, int us); |
100 | 100 | ||
101 | /* Internal Testing */ | 101 | /* Internal Testing */ |
102 | void timer_internal_tests(bool(*)(bool, char*)); | 102 | void timer_internal_tests(bool( *)(bool, char *)); |
103 | 103 | ||
104 | #endif | 104 | #endif |