libdragon
timer.h
Go to the documentation of this file.
00001 
00006 #ifndef __LIBDRAGON_TIMER_H
00007 #define __LIBDRAGON_TIMER_H
00008 
00017 typedef struct timer_link
00018 {
00020     int left;
00022     int set;
00024     int ovfl;
00026     int flags;
00028     void (*callback)(int ovfl);
00030     struct timer_link *next;
00031 } timer_link_t;
00032 
00034 #define TF_ONE_SHOT   0
00035 
00036 #define TF_CONTINUOUS 1
00037 
00046 #define TIMER_TICKS(us) ((int)((long long)(us) * 46875LL / 1000LL))
00047 
00055 #define TIMER_MICROS(tk) ((int)((long long)(tk) * 1000LL / 46875LL))
00056 
00065 #define TIMER_TICKS_LL(us) ((long long)(us) * 46875LL / 1000LL)
00066 
00074 #define TIMER_MICROS_LL(tk) ((long long)(tk) * 1000LL / 46875LL)
00075 
00078 #ifdef __cplusplus
00079 extern "C" {
00080 #endif
00081 
00082 /* initialize timer subsystem */
00083 void timer_init(void);
00084 /* create a new timer and add to list */
00085 timer_link_t *new_timer(int ticks, int flags, void (*callback)(int ovfl));
00086 /* start a timer not currently in the list */
00087 void start_timer(timer_link_t *timer, int ticks, int flags, void (*callback)(int ovfl));
00088 /* remove a timer from the list */
00089 void stop_timer(timer_link_t *timer);
00090 /* remove a timer from the list and delete it */
00091 void delete_timer(timer_link_t *timer);
00092 /* delete all timers in list */
00093 void timer_close(void);
00094 /* return total ticks since timer was initialized */
00095 long long timer_ticks(void);
00096 
00097 #ifdef __cplusplus
00098 }
00099 #endif
00100 
00101 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines