Working switch2led demonstration on tic55x
[firmerware] / include / 0cpm / timer.h
1 /*
2  * http://devel.0cpm.org/ -- Open source firmware for SIP phones.
3  *
4  * Timer drivers
5  */
6
7
8 #ifndef HEADER_TIMER
9 #define HEADER_TIMER
10
11 #include <0cpm/irq.h>
12
13
14 /* The bottom defines a few useful things:
15  *   typedef uint..._t timing_t;
16  *   #define TIME_MSEC(x) ...
17  *   #define TIME_SEC(x) ...
18  *   #define TIME_BEOFRE(x,y) ...
19  * The former can be used as a parameter without pointers;
20  * the TIME_xxx define such periods in terms of that time.
21  */
22
23
24 /* Timer drivers are split in a top half and a bottom half.  The top half is generic, the
25  * bottom half is device-specific.  The bottom half routines start with bottom_irqtimer_
26  * while the top half functions start with irqtimer_
27  *
28  * The bottom system is only aware of the time of the next hardware-raised interrupt.
29  * The top system maintains a timeout-ordered queue of interrupts to raise.
30  */
31
32 typedef struct irqtimer_type irqtimer_t;
33 struct irqtimer_type {
34         irq_t tmr_irq;
35         timing_t tmr_expiry;
36 };
37
38
39 /* Managing functions for kernel-defined timers */
40 void irqtimer_start   (irqtimer_t *tmr, timing_t delay, irq_handler_t hdl, priority_t prio);
41 void irqtimer_restart (irqtimer_t *tmr, timing_t intval);
42 void irqtimer_stop    (irqtimer_t *tmr);
43
44
45 /* Top-half operations to manipulate timers */
46 void top_timer_expiration (timing_t exptime);
47
48
49 /* Bottom-half operations to manipulate the next timer interrupt */
50 timing_t bottom_time (void);
51 timing_t bottom_timer_set (timing_t nextirq);
52
53
54 #endif