-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtimer.h
67 lines (60 loc) · 1.59 KB
/
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* @file timer.h
* @brief Defines functions that use the timer to call other functions at
* a given frequency.
* @author Stefan Bossbaly ([email protected])
* @date April, 2014
*
*/
#ifndef TIMER_H
#define TIMER_H
#include <avr/io.h>
#include <avr/interrupt.h>
#ifdef __cplusplus
extern "C"
{
#endif
/**
* @name Initialize Timer using Microseconds
* @brief Use the timer to call the function at the specified frequency in
* microseconds.
* @ingroup timer
*
* Calls the function at the specified frequency. This is accomplished
* using the timer compare interrupt.
*
* @param [in] frequency the time (in microseconds) between function calls
* @param [in] function the function that will be called at the given
* frequency
*
*/
void timer2_init_us(unsigned long frequency, void (*function)(void));
/**
* @name Initialize Timer using Milliseconds
* @brief Use the timer to call the function at the specified frequency in
* milliseconds.
* @ingroup timer
*
* Calls the function at the specified frequency. This is accomplished
* using the timer compare interrupt.
*
* @param [in] frequency the time (in milliseconds) between function calls
* @param [in] function the function that will be called at the given
* frequency
*
*/
void timer2_init_ms(unsigned long frequency, void (*function)(void));
/**
* @name Disable Timer
* @brief Stops the timer from counting.
* @ingroup timer
*
* Stops the timer from counting. The specified function will no longer be
* called at the given frequency.
*
*/
void timer2_stop();
#ifdef __cplusplus
}
#endif
#endif /* TIMER_H */