embedded system library for e-puck  1.0.1
A redesigned API library for the e-puck robot platform
 All Data Structures Files Functions Variables Enumerations Enumerator Modules Pages
el_timer.h
Go to the documentation of this file.
1 /*
2 
3 embedded system library for e-puck
4 
5 --------------------------------------------------------------------------------
6 
7 code distribution:
8 https://github.com/jianingchen/epucklib
9 
10 online documentation:
11 http://jianingchen.github.io/epucklib/html/
12 
13 --------------------------------------------------------------------------------
14 
15 This file is released under the terms of the MIT license (see "el.h").
16 
17 */
18 
28 #ifndef EL_TIMER_H
29 #define EL_TIMER_H
30 
31 #include "el_common.h"
32 #include "el_clock.h"
33 
34 typedef void (*el_timer_callback)(void*);
35 
47 el_handle el_create_timer(void);
48 
49 
55 void el_delete_timer(el_handle h);
56 
57 
64 void el_timer_set_periodic(el_handle h,el_bool b);
65 
66 
91 void el_timer_set_callback(el_handle h,el_timer_callback func,void*arg);
92 
93 
130 void el_timer_start(el_handle h,el_time t_ms);
131 
132 
142 void el_timer_start_fraction(el_handle h,int num,int den);// (num/den) second
143 
144 
150 void el_timer_pause(el_handle h);
151 
152 
160 void el_timer_resume(el_handle h);
161 
162 
170 el_handle el_timer_callback_get_handle();
171 
172 
186 el_uint32 el_timer_get_rounds(el_handle h);
187 
188 
198 void el_timer_set_rounds(el_handle h,el_uint32 n);
199 
200 
201 /*
202 --------------------------------------------------------------------------------
203 */
204 
205 
206 #ifdef EL_INCLUDE_LIB_INTERNAL_CONTEXT
207 
208 #define EL_TIMER_DIM 10
209 
210 typedef struct{
211  el_mct period;
212  el_mct count_down;
213  el_uint32 rounds;
214  void *append_data;
215  void (*callback)(void*);
216  uint8_t paused:1;
217  uint8_t repeat:1;
218  uint8_t remove:1;
219 } el_timer;
220 
221 extern el_mct el_timer_mck;
222 extern el_bool el_is_in_timer_callback;
223 extern el_uint16 el_timer_overwatch;
224 
225 void el_init_timers();
226 void el_routine_timers();
227 
228 #endif
229 
230 #endif
void el_timer_set_callback(el_handle h, el_timer_callback func, void *arg)
set the callback of a timer
void el_timer_pause(el_handle h)
pause the countdown of the timer
void el_timer_start_fraction(el_handle h, int num, int den)
specify the countdown time using a fraction and start the timer
void el_timer_resume(el_handle h)
resume the countdown of the timer
void el_timer_start(el_handle h, el_time t_ms)
specify the countdown time and start the timer
void el_delete_timer(el_handle h)
delete the timer
void el_timer_set_periodic(el_handle h, el_bool b)
set whether the timer repeat the countdown process once a countdown is finished
el_handle el_create_timer(void)
create a timer in the system
el_uint32 el_timer_get_rounds(el_handle h)
get the rounds of the timer
void el_timer_set_rounds(el_handle h, el_uint32 n)
set the rounds of the timer
el_handle el_timer_callback_get_handle()
get the handle of the timer in a timer callback