System Timer API
Application Example
API Reference
Header File
Source: include/timer.h
#include <timer.h>
Functions
-
int timer_register(timercb_f callback, void *arg)
Register a task independent timer
- Parameters:
callback – [in] timer callback function of type timercb_f
arg – [in] User data pointer passed to callback function
- Returns:
On success, returns timer ID registered. On error a negative value is returned
-
int timer_config(int id, unsigned long ms, int cyclic)
Configure timer
- Parameters:
id – [in] Timer ID returned by
timer_register()ms – [in] Timeout value in miliseconds
cyclic – [in] TRUE if timer is cyclic, FALSE if single shot timer
- Returns:
0 on success, On error a negative value is returned
-
int timer_start(int id)
Start a timer
- Parameters:
id – [in] Timer ID returned by
timer_register()- Returns:
0 on success, On error a negative value is returned
-
int timer_stop(int id)
Stop a timer
- Parameters:
id – [in] Timer ID returned by
timer_register()- Returns:
0 on success, On error a negative value is returned
-
int timer_reset(int id)
Restart a timer
- Parameters:
id – [in] Timer ID returned by
timer_register()- Returns:
0 on success, On error a negative value is returned
-
int timer_free(int id)
Free a registered timer
- Parameters:
id – [in] Timer ID returned by
timer_register()- Returns:
0 on success, On error a negative value is returned
Type Definitions
-
typedef void (*timercb_f)(int id, void *arg)
Timer function callback
- Param id:
Timer ID
- Param arg:
User data argument supplied during registration
