libdragon
Data Structures | Macros | Typedefs | Functions
timer.h File Reference

Timer Subsystem. More...

Go to the source code of this file.

Data Structures

Macros

#define TF_ONE_SHOT   0
 Timer should fire only once.
 
#define TF_CONTINUOUS   1
 Timer should fire at a regular interval.
 
#define TF_DISABLED   2
 Timer is enabled or not. Can be used to get a new timer that's not started.
 
#define TIMER_TICKS(us)   ((int)TIMER_TICKS_LL(us))
 Calculate timer ticks based on microseconds. More...
 
#define TIMER_MICROS(tk)   ((int)TIMER_MICROS_LL(tk))
 Calculate microseconds based on timer ticks. More...
 
#define TIMER_TICKS_LL(us)   ((long long)(us) * TICKS_PER_SECOND / 1000000)
 Calculate timer ticks based on microseconds. More...
 
#define TIMER_MICROS_LL(tk)   ((long long)(tk) * 1000000 / TICKS_PER_SECOND)
 Calculate microseconds based on timer ticks. More...
 

Typedefs

typedef void(* timer_callback1_t) (int ovfl)
 Timer callback function without context.
 
typedef void(* timer_callback2_t) (int ovfl, void *ctx)
 Timer callback function with context.
 

Functions

void timer_init (void)
 Initialize the timer subsystem. More...
 
void timer_close (void)
 Free and close the timer subsystem. More...
 
long long timer_ticks (void)
 Return total ticks since timer was initialized, as a 64-bit counter. More...
 
timer_link_tnew_timer (int ticks, int flags, timer_callback1_t callback)
 Create a new timer and add to list. More...
 
timer_link_tnew_timer_context (int ticks, int flags, timer_callback2_t callback, void *ctx)
 Create a new timer with context and add to list. More...
 
void start_timer (timer_link_t *timer, int ticks, int flags, timer_callback1_t callback)
 Start a timer (not currently in the list) More...
 
void start_timer_context (timer_link_t *timer, int ticks, int flags, timer_callback2_t callback, void *ctx)
 Start a timer (not currently in the list) with context. More...
 
void restart_timer (timer_link_t *timer)
 Reset a timer and add to list. More...
 
void stop_timer (timer_link_t *timer)
 Stop a timer and remove it from the list. More...
 
void delete_timer (timer_link_t *timer)
 Remove a timer from the list and delete it. More...
 

Detailed Description

Timer Subsystem.