-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimer.h
46 lines (34 loc) · 864 Bytes
/
timer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef TIMER_H
#define TIMER_H
#ifndef HZ
# define HZ 124 /* 0.117065556712 error after 1-hour running at 8Mhz */
#endif
#define TIMER_ID_MAX 8
enum timer_mode {
TIMER_MODE_NONE,
TIMER_MODE_ONESHOT,
TIMER_MODE_PERIODIC,
} ;
typedef unsigned short tick_t;
typedef unsigned char timer_id_t;
static inline
int tick_sub(tick_t a, tick_t b)
{
return (int) (a - b);
}
void timer_init();
unsigned char timer_read_events();
/**
* Read single event
*/
unsigned char timer_read_event(timer_id_t id);
int timer_start_periodic(timer_id_t id, tick_t ival);
int timer_start_oneshot(timer_id_t id, tick_t ival);
void timer_stop(timer_id_t id);
void timer_stop_all();
enum timer_mode timer_get_mode(timer_id_t id);
void timer_enable();
void timer_disable();
extern volatile tick_t ticks;
extern volatile unsigned short seconds;
#endif /* TIMER_H */