-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtick.h
55 lines (37 loc) · 900 Bytes
/
tick.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
47
48
49
50
51
52
53
54
/** @file tick.h
@author M. P. Hayes, UCECE
@date 3 June 2007
@brief
*/
#ifndef TICK_H
#define TICK_H
#ifdef __cplusplus
extern "C" {
#endif
#include "config.h"
#include "pit.h"
#define TICK_RATE_MIN (F_CPU / 16 / (1 << 20))
/* This macro is used to avoid run-time division. */
#define TICK_DIVISOR(FREQ) PIT_DIVISOR (FREQ)
#define TICK_READY_P() PIT_COMPARE_P ()
#define TICK_WAIT() while (!TICK_READY_P ()) continue
#define TICK_RESET() PIT_RESET()
#define TICK_INT_ENABLE() PIT_INT_ENABLE()
#define TICK_INT_DISABLE() PIT_INT_DISABLE()
//#define TICK_INTERRUPT SIG_OUTPUT_COMPARE2
#if 0
#define TICK_SLEEP() \
do {set_sleep_mode (SLEEP_MODE_IDLE); sleep_mode ();} while (0)
#endif
extern void
tick_init (uint32_t divisor);
static inline void
tick_wait (void)
{
/* Wait for next clock tick. */
TICK_WAIT ();
}
#ifdef __cplusplus
}
#endif
#endif