#ifndef TIMER_H #define TIMER_H /* * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): * wrote this file. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return. Joerg Wunsch * ---------------------------------------------------------------------------- * * Simple timer queue management * * $Id: timer.h,v 1.1.1.1 2002/04/14 20:01:36 j Exp $ */ /* argument to pass to an action function */ union timeoutarg { uint16_t i; void *p; }; /* the action function itself */ typedef void (*timeout_t)(union timeoutarg); /* we maintain a 32-bit clock */ typedef uint32_t time_t; /* * Insert one-shot timer `tm' ticks after now. Call `fun' * with `arg' when timer expires. * * Returns handle to timer queue entry that can be saved for * later deletion of the event. Returns 0 if fails (no more * memory for allocating a timer). */ void *timeout(time_t tm, timeout_t fun, union timeoutarg arg); /* * Delete the timer handle from the queue. Returns 0 for * success, -1 if event was not found in queue. */ int untimeout(void *handle); /* * Must be called per hardware timer tick from main(). Should * not be called directly from within an interrupt service, since * the callback functions for expired timers will be called within * the context of timertick(), and since the queue handling has no * precautions against being interrupted. */ void timertick(void); #endif /* TIMER_H */